Skip to content

Commit

Permalink
Use _add_or_double instead of just _add and pin BLST to specific revi…
Browse files Browse the repository at this point in the history
…sion (#391)

* Use _add_or_double instead of just _add

* Pin BLST library to a8cd361c9f671577aeab3f074098443af92a53fc
  • Loading branch information
emlowe committed Jun 13, 2023
1 parent 29aabf9 commit f243e18
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -42,7 +42,7 @@ set(SODIUM_DISABLE_TESTS "on" CACHE STRING "")
set(SODIUM_CHIA_MINIMAL "on" CACHE STRING "")
FetchContent_MakeAvailable(Sodium)

set(BLST_GIT_TAG "origin/master")
set(BLST_GIT_TAG "a8cd361c9f671577aeab3f074098443af92a53fc")
set(BLST_REPOSITORY "https://github.com/supranational/blst")

message(STATUS "blst will be built from: ${BLST_GIT_TAG} and repository ${BLST_REPOSITORY}")
Expand Down
8 changes: 4 additions & 4 deletions src/elements.cpp
Expand Up @@ -193,14 +193,14 @@ std::ostream& operator<<(std::ostream& os, const G1Element& ele)

G1Element& operator+=(G1Element& a, const G1Element& b)
{
blst_p1_add(&(a.p), &(a.p), &(b.p));
blst_p1_add_or_double(&(a.p), &(a.p), &(b.p));
return a;
}

G1Element operator+(const G1Element& a, const G1Element& b)
{
G1Element ans;
blst_p1_add(&(ans.p), &(a.p), &(b.p));
blst_p1_add_or_double(&(ans.p), &(a.p), &(b.p));
return ans;
}

Expand Down Expand Up @@ -360,14 +360,14 @@ std::ostream& operator<<(std::ostream& os, const G2Element& s)

G2Element& operator+=(G2Element& a, const G2Element& b)
{
blst_p2_add(&(a.q), &(a.q), &(b.q));
blst_p2_add_or_double(&(a.q), &(a.q), &(b.q));
return a;
}

G2Element operator+(const G2Element& a, const G2Element& b)
{
G2Element ans;
blst_p2_add(&(ans.q), &(a.q), &(b.q));
blst_p2_add_or_double(&(ans.q), &(a.q), &(b.q));
return ans;
}

Expand Down
15 changes: 15 additions & 0 deletions src/test.cpp
Expand Up @@ -802,6 +802,21 @@ TEST_CASE("Signature tests")
PopSchemeMPL().FastAggregateVerify(
pks_as_bytes, msg, aggSig.Serialize()) == false);
}
SECTION("Aggregate same sig element")
{
vector<uint8_t> message = {100, 2, 254, 88, 90, 45, 23};

vector<uint8_t> seed(32, 0x50);

PrivateKey sk1 = BasicSchemeMPL().KeyGen(seed);

G1Element pk1 = sk1.GetG1Element();

G2Element sig1Aug = AugSchemeMPL().Sign(sk1, message);
G2Element aggSigAug = AugSchemeMPL().Aggregate({sig1Aug, sig1Aug});
REQUIRE(AugSchemeMPL().AggregateVerify(
{pk1, pk1}, vector<vector<uint8_t>>{message, message}, aggSigAug));
}
}

TEST_CASE("Agg sks")
Expand Down

0 comments on commit f243e18

Please sign in to comment.