Benchmarks: update noble to use decompressed points.

Much faster now
This commit is contained in:
Paul Miller 2020-12-03 20:01:14 +04:00 committed by GitHub
parent e8d81fef96
commit 1ba1247978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 11 deletions

View File

@ -13,11 +13,11 @@ import {aggCount, runsNoble} from "./params";
prepareTest: async () => {
const priv = generateRandomSecretKey();
const msg = randomMessage();
const sig = await noble.sign(msg, priv);
const pk = noble.getPublicKey(priv);
const pk = noble.PointG1.fromPrivateKey(priv);
const sig = noble.PointG2.fromSignature(await noble.sign(msg, priv));
return {
input: {pk, msg, sig},
input: {pk, msg: await noble.PointG2.hashToCurve(msg), sig},
resultCheck: (valid: boolean) => valid === true,
};
},
@ -37,14 +37,14 @@ import {aggCount, runsNoble} from "./params";
const dataArr = await Promise.all(
range(aggCount).map(async () => {
const sk = generateRandomSecretKey();
const pk = noble.getPublicKey(sk);
const sig = await noble.sign(msg, sk);
const pk = noble.PointG1.fromPrivateKey(sk);
const sig = noble.PointG2.fromSignature(await noble.sign(msg, sk));
return {pk, sig};
})
);
const pks = dataArr.map((data) => data.pk);
const sig = noble.aggregateSignatures(dataArr.map((data) => data.sig));
const sig = noble.aggregateSignatures(dataArr.map((data) => data.sig)) as unknown as noble.PointG2[];
return {
input: {pks, msg, sig},
@ -58,7 +58,7 @@ import {aggCount, runsNoble} from "./params";
runs: runsNoble,
});
// Verify multiple
// // Verify multiple
await runBenchmark<{pks: Uint8Array[]; msgs: Uint8Array[]; sig: Uint8Array}, boolean>({
id: `noble verifyMultiple (${aggCount})`,
@ -67,10 +67,10 @@ import {aggCount, runsNoble} from "./params";
const dataArr = await Promise.all(
range(aggCount).map(async () => {
const sk = generateRandomSecretKey();
const pk = noble.getPublicKey(sk);
const pk = noble.PointG1.fromPrivateKey(sk);
const msg = randomMessage();
const sig = await noble.sign(msg, sk);
return {pk, msg, sig};
const sig = noble.PointG2.fromSignature(await noble.sign(msg, sk));
return {pk, msg: await noble.PointG2.hashToCurve(msg), sig};
})
);
@ -96,7 +96,21 @@ import {aggCount, runsNoble} from "./params";
prepareTest: () => {
return {
input: range(aggCount).map(() => noble.getPublicKey(generateRandomSecretKey())),
input: range(aggCount).map(() => noble.PointG1.fromPrivateKey(generateRandomSecretKey())),
};
},
testRunner: async (pks) => {
noble.aggregatePublicKeys(pks);
},
runs: runsNoble,
});
await runBenchmark<Uint8Array[], void>({
id: `noble aggregate sigs (${aggCount})`,
prepareTest: async () => {
return {
input: await Promise.all(range(aggCount).map(() => noble.PointG2.hashToCurve(generateRandomSecretKey()))),
};
},
testRunner: async (pks) => {