Skip to content

Commit

Permalink
Squashed 'src/chiabls/' changes from bc64f128f0..eaf7d2d1a4
Browse files Browse the repository at this point in the history
eaf7d2d1a4 Merge PIVX-Project/bls-signatures#11: Bug: invalid G1 and G2 cached in PrivateKey
183be2750c BugFix: Invalidate caches in PrivateKey copy assignment operator
427246653c QA: test cache invalidation for PrivateKey copy assignment operator

git-subtree-dir: src/chiabls
git-subtree-split: eaf7d2d1a49115c8d098f96f80b5db9aa487b1d5
  • Loading branch information
furszy committed Nov 26, 2021
1 parent ad308f2 commit 9daeb29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/privatekey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ PrivateKey& PrivateKey::operator=(const PrivateKey& other)
{
CheckKeyData();
other.CheckKeyData();
InvalidateCaches();
bn_copy(keydata, other.keydata);
return *this;
}
Expand Down
4 changes: 4 additions & 0 deletions src/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,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}") {
Expand Down

0 comments on commit 9daeb29

Please sign in to comment.