@@ -21,6 +21,8 @@ func TestBls(t *testing.T) {
2121 t .Run ("G2/Errors" , testErrors [bls .G2 ])
2222 t .Run ("G1/Aggregation" , testAggregation [bls .G1 ])
2323 t .Run ("G2/Aggregation" , testAggregation [bls .G2 ])
24+ t .Run ("G1/DuplicatedMsg" , testDuplicatedMsgs [bls .G1 ])
25+ t .Run ("G2/DuplicatedMsg" , testDuplicatedMsgs [bls .G2 ])
2426}
2527
2628func testBls [K bls.KeyGroup ](t * testing.T ) {
@@ -152,6 +154,34 @@ func testAggregation[K bls.KeyGroup](t *testing.T) {
152154 test .CheckOk (ok , "failed to verify aggregated signature" , t )
153155}
154156
157+ func testDuplicatedMsgs [K bls.KeyGroup ](t * testing.T ) {
158+ const N = 3
159+
160+ ikm := [32 ]byte {}
161+ _ , _ = rand .Reader .Read (ikm [:])
162+
163+ duplicated_msg := []byte ("signing the same messsage" )
164+ msgs := make ([][]byte , N )
165+ sigs := make ([]bls.Signature , N )
166+ pubKeys := make ([]* bls.PublicKey [K ], N )
167+
168+ for i := range sigs {
169+ priv , err := bls .KeyGen [K ](ikm [:], nil , nil )
170+ test .CheckNoErr (t , err , "failed to keygen" )
171+ pubKeys [i ] = priv .PublicKey ()
172+
173+ msgs [i ] = duplicated_msg
174+ sigs [i ] = bls .Sign (priv , msgs [i ])
175+ }
176+
177+ aggSig , err := bls .Aggregate (* new (K ), sigs )
178+ test .CheckNoErr (t , err , "failed to aggregate" )
179+
180+ test .CheckOk (
181+ bls .VerifyAggregate (pubKeys , msgs , aggSig ) == false ,
182+ "failed to reject aggregated signature with duplicated messages" , t )
183+ }
184+
155185func BenchmarkBls (b * testing.B ) {
156186 b .Run ("G1" , benchmarkBls [bls .G1 ])
157187 b .Run ("G2" , benchmarkBls [bls .G2 ])
0 commit comments