diff --git a/src/privatekey.cpp b/src/privatekey.cpp index e8e51aa69..bfd296d7b 100644 --- a/src/privatekey.cpp +++ b/src/privatekey.cpp @@ -88,6 +88,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 5af5ea775..bb9c0edd5 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}") {