diff --git a/benchmark/index.ts b/benchmark/index.ts index 6696642..e936fd3 100644 --- a/benchmark/index.ts +++ b/benchmark/index.ts @@ -55,6 +55,35 @@ import {aggCount, runs} from "./params"; runs, }); + // Verify multiple + + await runBenchmark<{pks: PublicKey[]; msgs: Uint8Array[]; sig: Signature}, boolean>({ + id: `${implementation} verifyMultiple (${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 sig = bls.Signature.aggregate(dataArr.map((data) => data.sig)); + + return { + input: {pks, msgs, sig}, + resultCheck: (valid) => valid === true, + }; + }, + testRunner: ({pks, msgs, sig}) => { + return sig.verifyMultiple(pks, msgs); + }, + runs, + }); + // Aggregate pubkeys await runBenchmark({ diff --git a/benchmark/noble.ts b/benchmark/noble.ts index 9980ae7..3d70d10 100644 --- a/benchmark/noble.ts +++ b/benchmark/noble.ts @@ -58,6 +58,37 @@ import {aggCount, runsNoble} from "./params"; runs: runsNoble, }); + // Verify multiple + + await runBenchmark<{pks: Uint8Array[]; msgs: Uint8Array[]; sig: Uint8Array}, boolean>({ + id: `noble verifyMultiple (${aggCount})`, + + prepareTest: async () => { + const dataArr = await Promise.all( + range(aggCount).map(async () => { + const sk = generateRandomSecretKey(); + const pk = noble.getPublicKey(sk); + const msg = randomMessage(); + const sig = await noble.sign(msg, sk); + return {pk, msg, sig}; + }) + ); + + const pks = dataArr.map((data) => data.pk); + const msgs = dataArr.map((data) => data.msg); + const sig = noble.aggregateSignatures(dataArr.map((data) => data.sig)); + + return { + input: {pks, msgs, sig}, + resultCheck: (valid: boolean) => valid === true, + }; + }, + testRunner: async ({pks, msgs, sig}) => { + return await noble.verifyBatch(msgs, pks, sig); + }, + runs: runsNoble, + }); + // Aggregate pubkeys await runBenchmark({