diff --git a/src/privatekey.cpp b/src/privatekey.cpp index 89f8ab6c9..ab685425c 100644 --- a/src/privatekey.cpp +++ b/src/privatekey.cpp @@ -87,6 +87,7 @@ PrivateKey& PrivateKey::operator=(const PrivateKey& other) { CheckKeyData(); other.CheckKeyData(); + InvalidateCaches(); bn_copy(keydata, other.keydata); return *this; } diff --git a/src/test.cpp b/src/test.cpp index 9ebb82c46..8a7770a38 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -65,8 +65,12 @@ TEST_CASE("class PrivateKey") { REQUIRE(!pk3.IsZero()); REQUIRE(pk1 != pk2); REQUIRE(pk3 == pk2); + REQUIRE(pk2.GetG1Element().IsValid()); // cache previous g1 + REQUIRE(pk2.GetG2Element().IsValid()); // cache previous g2 pk2 = pk1; REQUIRE(pk1 == pk2); + REQUIRE(pk1.GetG1Element() == pk2.GetG1Element()); + REQUIRE(pk1.GetG2Element() == pk2.GetG2Element()); REQUIRE(pk3 != pk2); } SECTION("Move {constructor|assignment operator}") {