Skip to content

Commit f243e18

Browse files
authored
Use _add_or_double instead of just _add and pin BLST to specific revision (#391)
* Use _add_or_double instead of just _add * Pin BLST library to a8cd361c9f671577aeab3f074098443af92a53fc
1 parent 29aabf9 commit f243e18

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ set(SODIUM_DISABLE_TESTS "on" CACHE STRING "")
4242
set(SODIUM_CHIA_MINIMAL "on" CACHE STRING "")
4343
FetchContent_MakeAvailable(Sodium)
4444

45-
set(BLST_GIT_TAG "origin/master")
45+
set(BLST_GIT_TAG "a8cd361c9f671577aeab3f074098443af92a53fc")
4646
set(BLST_REPOSITORY "https://github.com/supranational/blst")
4747

4848
message(STATUS "blst will be built from: ${BLST_GIT_TAG} and repository ${BLST_REPOSITORY}")

src/elements.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,14 @@ std::ostream& operator<<(std::ostream& os, const G1Element& ele)
193193

194194
G1Element& operator+=(G1Element& a, const G1Element& b)
195195
{
196-
blst_p1_add(&(a.p), &(a.p), &(b.p));
196+
blst_p1_add_or_double(&(a.p), &(a.p), &(b.p));
197197
return a;
198198
}
199199

200200
G1Element operator+(const G1Element& a, const G1Element& b)
201201
{
202202
G1Element ans;
203-
blst_p1_add(&(ans.p), &(a.p), &(b.p));
203+
blst_p1_add_or_double(&(ans.p), &(a.p), &(b.p));
204204
return ans;
205205
}
206206

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

361361
G2Element& operator+=(G2Element& a, const G2Element& b)
362362
{
363-
blst_p2_add(&(a.q), &(a.q), &(b.q));
363+
blst_p2_add_or_double(&(a.q), &(a.q), &(b.q));
364364
return a;
365365
}
366366

367367
G2Element operator+(const G2Element& a, const G2Element& b)
368368
{
369369
G2Element ans;
370-
blst_p2_add(&(ans.q), &(a.q), &(b.q));
370+
blst_p2_add_or_double(&(ans.q), &(a.q), &(b.q));
371371
return ans;
372372
}
373373

src/test.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,21 @@ TEST_CASE("Signature tests")
802802
PopSchemeMPL().FastAggregateVerify(
803803
pks_as_bytes, msg, aggSig.Serialize()) == false);
804804
}
805+
SECTION("Aggregate same sig element")
806+
{
807+
vector<uint8_t> message = {100, 2, 254, 88, 90, 45, 23};
808+
809+
vector<uint8_t> seed(32, 0x50);
810+
811+
PrivateKey sk1 = BasicSchemeMPL().KeyGen(seed);
812+
813+
G1Element pk1 = sk1.GetG1Element();
814+
815+
G2Element sig1Aug = AugSchemeMPL().Sign(sk1, message);
816+
G2Element aggSigAug = AugSchemeMPL().Aggregate({sig1Aug, sig1Aug});
817+
REQUIRE(AugSchemeMPL().AggregateVerify(
818+
{pk1, pk1}, vector<vector<uint8_t>>{message, message}, aggSigAug));
819+
}
805820
}
806821

807822
TEST_CASE("Agg sks")

0 commit comments

Comments
 (0)