Skip to content

Commit

Permalink
Add test for AugScheme aggregation and comment (#421)
Browse files Browse the repository at this point in the history
Add test and some comments for AugScheme aggregation
  • Loading branch information
emlowe authored Jul 27, 2023
2 parents 3c8590d + 2dcfb24 commit f9b1d05
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,47 @@ TEST_CASE("Agg sks")
vector<vector<uint8_t>>{message, message2},
aggSigFinal));
}
SECTION("Should create aggregates with agg sk (aug scheme)")
{
const vector<uint8_t> message = {100, 2, 254, 88, 90, 45, 23};
const vector<uint8_t> seed(32, 0x07);
const vector<uint8_t> seed2(32, 0x08);

auto sk1 = AugSchemeMPL().KeyGen(seed);
auto pk1 = sk1.GetG1Element();

auto sk2 = AugSchemeMPL().KeyGen(seed2);
auto pk2 = sk2.GetG1Element();

auto aggSk = PrivateKey::Aggregate({sk1, sk2});
auto aggSkAlt = PrivateKey::Aggregate({sk2, sk1});
REQUIRE(aggSk == aggSkAlt);

auto aggPubKey = pk1 + pk2;
REQUIRE(aggPubKey == aggSk.GetG1Element());

//
// Note, AugScheme will automatically prepend the public key of the
// provided private key to the message before signing. This creates
// problems in aggregation here as then the messages are all technically
// different so the aggregation doesn't work as expected. So you must
// specify directly the same public key (G1Element) for all messages.
// Here we use the Aggregate Public Key, however, you can use any
// G1Element as long as there are all the same.
//
auto sig1 = AugSchemeMPL().Sign(sk1, message, aggPubKey);
auto sig2 = AugSchemeMPL().Sign(sk2, message, aggPubKey);

// Technically passing in aggPubKey is unneeded, but kept for clarity
auto aggSig2 = AugSchemeMPL().Sign(aggSk, message, aggPubKey);

auto aggSig = AugSchemeMPL().Aggregate({sig1, sig2});
REQUIRE(aggSig == aggSig2);

// Verify as a single G2Element
REQUIRE(AugSchemeMPL().Verify(aggPubKey, message, aggSig));
REQUIRE(AugSchemeMPL().Verify(aggPubKey, message, aggSig2));
}
}

TEST_CASE("Advanced")
Expand Down

0 comments on commit f9b1d05

Please sign in to comment.