Skip to content

Commit

Permalink
add sig aggregation bench
Browse files Browse the repository at this point in the history
  • Loading branch information
arnetheduck committed Aug 6, 2023
1 parent 81ed3ff commit b97eeb2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions benchmarks/bls_signature.nim
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,31 @@ proc keyGen(): tuple[pk: PublicKey, sk: SecretKey] =
b = byte benchRNG.rand(0xFF)
doAssert ikm.keyGen(result.pk, result.sk)

proc benchAggSigs*(numKeys, iters: int) =
## Verification of N pubkeys signing for 1 message
let msg = "Mr F was here"

var validators = newSeq[PublicKey](numKeys)
var sigs = newSeq[Signature](numKeys)


for i in 0 ..< numKeys:
let (pk, sk) = keyGen()
validators[i] = pk

sigs[i] = sk.sign(msg)

bench("BLS agg " & $numKeys & " sigs", iters):
var aggSig: AggregateSignature
for i in 0..<sigs.len:
if i == 0:
aggSig.init(sigs[i])
else:
aggSig.aggregate(sigs[i])

var finalSig: Signature
finalSig.finish(aggSig)

proc benchFastAggregateVerify*(numKeys, iters: int) =
## Verification of N pubkeys signing for 1 message
let msg = "Mr F was here"
Expand Down Expand Up @@ -237,6 +262,7 @@ when isMainModule:
benchDeserSig(1000)
benchSign(1000)
benchVerify(1000)
benchAggSigs(numKeys = 512, iters = 10)
benchFastAggregateVerify(numKeys = 128, iters = 10)

when BLS_BACKEND == BLST:
Expand Down

0 comments on commit b97eeb2

Please sign in to comment.