From e3973e7771220f7e7030a35965198dad9f64ea59 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Wed, 26 Jul 2023 08:36:57 -0700 Subject: [PATCH 1/2] Add test for AugScheme aggregation and comment --- src/test.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/test.cpp b/src/test.cpp index 6376d9df8..420f9c850 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -892,6 +892,47 @@ TEST_CASE("Agg sks") vector>{message, message2}, aggSigFinal)); } + SECTION("Should create aggregates with agg sk (aug scheme)") + { + const vector message = {100, 2, 254, 88, 90, 45, 23}; + const vector seed(32, 0x07); + const vector 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") From 2dcfb24c24620f830d7e02af521699f086db4b00 Mon Sep 17 00:00:00 2001 From: Earle Lowe <30607889+emlowe@users.noreply.github.com> Date: Wed, 26 Jul 2023 11:06:52 -0700 Subject: [PATCH 2/2] Fixed some typos in the comment Fixed a couple types --- src/test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test.cpp b/src/test.cpp index 420f9c850..1c7a95640 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -913,10 +913,10 @@ TEST_CASE("Agg sks") // // Note, AugScheme will automatically prepend the public key of the - // provided private key to the message before singing. This creates + // 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 - // specific directly the same publie key (G1Element) for all messages. + // 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. //