Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for AugScheme aggregation and comment #421

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 singing. 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
// specific directly the same publie 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
Loading