Add benchmark

This commit is contained in:
dapplion 2020-12-02 23:21:48 +00:00
parent 092165a5f4
commit fc868ffd27
1 changed files with 29 additions and 0 deletions

View File

@ -84,6 +84,35 @@ import {aggCount, runs} from "./params";
runs, 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 // Aggregate pubkeys
await runBenchmark<PublicKey[], void>({ await runBenchmark<PublicKey[], void>({