Skip to content

Commit

Permalink
Add a benchmark for aggregate verification (BDN BLS12381)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Aug 27, 2024
1 parent 8fd7d55 commit c96a0e4
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions sign/bdn/bdn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,46 @@ func Benchmark_BDN_AggregateSigs(b *testing.B) {
}
}

func Benchmark_BDN_BLS12381_AggregateVerify(b *testing.B) {
suite := bls12381.NewBLS12381Suite()
schemeOnG2 := NewSchemeOnG2(suite)

rng := random.New()
pubKeys := make([]kyber.Point, 3000)
privKeys := make([]kyber.Scalar, 3000)
for i := range pubKeys {
privKeys[i], pubKeys[i] = schemeOnG2.NewKeyPair(rng)
}

baseMask, err := sign.NewMask(suite, pubKeys, nil)
require.NoError(b, err)
mask, err := NewCachedMask(baseMask)
require.NoError(b, err)
for i := range pubKeys {
require.NoError(b, mask.SetBit(i, true))
}

msg := []byte("Hello many times Boneh-Lynn-Shacham")
sigs := make([][]byte, len(privKeys))
for i, k := range privKeys {
s, err := schemeOnG2.Sign(k, msg)
require.NoError(b, err)
sigs[i] = s
}

sig, err := schemeOnG2.AggregateSignatures(sigs, mask)
require.NoError(b, err)
sigb, err := sig.MarshalBinary()
require.NoError(b, err)

b.ResetTimer()
for i := 0; i < b.N; i++ {
pk, err := schemeOnG2.AggregatePublicKeys(mask)
require.NoError(b, err)
require.NoError(b, schemeOnG2.Verify(pk, msg, sigb))
}
}

func unmarshalHex[T encoding.BinaryUnmarshaler](t *testing.T, into T, s string) T {
t.Helper()
b, err := hex.DecodeString(s)
Expand Down

0 comments on commit c96a0e4

Please sign in to comment.