From fc868ffd277025408e2a2cd26654b52e48041f91 Mon Sep 17 00:00:00 2001 From: dapplion Date: Wed, 2 Dec 2020 23:21:48 +0000 Subject: [PATCH] Add benchmark --- benchmark/index.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/benchmark/index.ts b/benchmark/index.ts index e936fd3..f1998fe 100644 --- a/benchmark/index.ts +++ b/benchmark/index.ts @@ -84,6 +84,35 @@ import {aggCount, runs} from "./params"; runs, }); + // Verify multiple signatures + + await runBenchmark<{pks: PublicKey[]; msgs: Uint8Array[]; sigs: Signature[]}, boolean>({ + id: `${implementation} verifyMultipleSignatures (${aggCount})`, + + prepareTest: () => { + const dataArr = range(aggCount).map(() => { + const sk = bls.SecretKey.fromKeygen(); + const pk = sk.toPublicKey(); + const msg = randomMessage(); + const sig = sk.sign(msg); + return {pk, msg, sig}; + }); + + const pks = dataArr.map((data) => data.pk); + const msgs = dataArr.map((data) => data.msg); + const sigs = dataArr.map((data) => data.sig); + + return { + input: {pks, msgs, sigs}, + resultCheck: (valid) => valid === true, + }; + }, + testRunner: ({pks, msgs, sigs}) => { + return bls.Signature.verifyMultipleSignatures(pks, msgs, sigs); + }, + runs, + }); + // Aggregate pubkeys await runBenchmark({