Run benchmarks for verifyMultiple

This commit is contained in:
dapplion 2020-12-02 20:54:46 +00:00
parent e356bd1b37
commit 324285c38a
2 changed files with 60 additions and 0 deletions

View File

@ -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<PublicKey[], void>({

View File

@ -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<Uint8Array[], void>({