From 61e5a37cff94a8668bd22fd0fcfaca33806d55e2 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Thu, 3 Dec 2020 13:12:22 +0400 Subject: [PATCH 1/3] Benchmarks: Clarify tech. It may be useful for folks to know that blst is node-only and noble is pure JS. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1230c22..9ec722f 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, bindings to C++ via 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`). From 9b6369c07aac8c6c578a167d08a6a7328109cfa5 Mon Sep 17 00:00:00 2001 From: dapplion Date: Thu, 3 Dec 2020 09:38:13 +0000 Subject: [PATCH 2/3] Benchmark sign() --- benchmark/index.ts | 19 ++++++++++++++++++- benchmark/noble.ts | 17 +++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) 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 3d70d10..4c7cbf1 100644 --- a/benchmark/noble.ts +++ b/benchmark/noble.ts @@ -104,4 +104,21 @@ import {aggCount, runsNoble} from "./params"; }, runs: runsNoble, }); + + // Sign + + await runBenchmark<{sk: Uint8Array; msg: Uint8Array}, void>({ + id: `noble sign`, + + prepareTest: async () => ({ + input: { + sk: generateRandomSecretKey(), + msg: randomMessage(), + }, + }), + testRunner: async ({sk, msg}) => { + await noble.sign(msg, sk); + }, + runs: runsNoble, + }); })(); From 8d6c4df745600060796a7a7d410e5d8f47b671f1 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Thu, 3 Dec 2020 18:53:00 +0400 Subject: [PATCH 3/3] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marin Petrunić --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ec722f..380f4c0 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ The API is identical for all implementations. ## Benchmarks - `blst`: [src/blst](src/blst) (node.js-only, bindings to C via node-gyp) -- `herumi`: [src/herumi](src/herumi) (node.js & browser, bindings to C++ via wasm) +- `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`).