diff --git a/benchmark/noble.ts b/benchmark/noble.ts index 3d70d10..eb223d0 100644 --- a/benchmark/noble.ts +++ b/benchmark/noble.ts @@ -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({ + id: `noble aggregate sigs (${aggCount})`, + + prepareTest: async () => { + return { + input: await Promise.all(range(aggCount).map(() => noble.PointG2.hashToCurve(generateRandomSecretKey()))), }; }, testRunner: async (pks) => {