diff --git a/README.md b/README.md index 1230c22..380f4c0 100644 --- a/README.md +++ b/README.md @@ -87,9 +87,9 @@ The API is identical for all implementations. ## Benchmarks -- `blst`: [src/blst](src/blst) -- `herumi`: [src/herumi](src/herumi) -- `noble`: [noble-bls12-381](https://github.com/paulmillr/noble-bls12-381) +- `blst`: [src/blst](src/blst) (node.js-only, bindings to C via node-gyp) +- `herumi`: [src/herumi](src/herumi) (node.js & browser, wasm) +- `noble`: [noble-bls12-381](https://github.com/paulmillr/noble-bls12-381) (node.js & browser, pure JS) Results are in `ops/sec (x times slower)`, where `x times slower` = times slower than fastest implementation (`blst`). diff --git a/benchmark/index.ts b/benchmark/index.ts index e936fd3..6cd1855 100644 --- a/benchmark/index.ts +++ b/benchmark/index.ts @@ -1,6 +1,6 @@ import {runBenchmark} from "./runner"; import {runForAllImplementations} from "../test/switch"; -import {PublicKey, Signature} from "../src/interface"; +import {PublicKey, Signature, SecretKey} from "../src/interface"; import {range, randomMessage} from "../test/util"; import {aggCount, runs} from "./params"; @@ -120,5 +120,22 @@ import {aggCount, runs} from "./params"; }, runs, }); + + // Sign + + await runBenchmark<{sk: SecretKey; msg: Uint8Array}, void>({ + id: `${implementation} sign`, + + prepareTest: () => ({ + input: { + sk: bls.SecretKey.fromKeygen(), + msg: randomMessage(), + }, + }), + testRunner: ({sk, msg}) => { + sk.sign(msg); + }, + runs, + }); }); })(); diff --git a/benchmark/noble.ts b/benchmark/noble.ts index 3ae821a..b33ff22 100644 --- a/benchmark/noble.ts +++ b/benchmark/noble.ts @@ -105,32 +105,18 @@ import {aggCount, runsNoble} from "./params"; 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 (sigs) => { - noble.aggregateSignatures(sigs); - }, - runs: runsNoble, - }); - await runBenchmark<{sk: Uint8Array; msg: Uint8Array}, void>({ id: `noble sign`, prepareTest: async () => ({ - input: { - sk: generateRandomSecretKey(), - msg: randomMessage(), - }, + input: { + sk: generateRandomSecretKey(), + msg: randomMessage(), + }, }), testRunner: async ({sk, msg}) => { - await noble.sign(msg, sk); + await noble.sign(msg, sk); }, runs: runsNoble, - }); + }); })();