Run benchmarks for verifyMultiple
This commit is contained in:
parent
e356bd1b37
commit
324285c38a
|
@ -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>({
|
||||
|
|
|
@ -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>({
|
||||
|
|
Reference in New Issue