Merge branch 'master' into patch-3

This commit is contained in:
Paul Miller 2020-12-03 20:23:21 +04:00 committed by GitHub
commit 94caa9bedd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 24 deletions

View File

@ -87,9 +87,9 @@ The API is identical for all implementations.
## Benchmarks ## Benchmarks
- `blst`: [src/blst](src/blst) - `blst`: [src/blst](src/blst) (node.js-only, bindings to C via node-gyp)
- `herumi`: [src/herumi](src/herumi) - `herumi`: [src/herumi](src/herumi) (node.js & browser, wasm)
- `noble`: [noble-bls12-381](https://github.com/paulmillr/noble-bls12-381) - `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`). Results are in `ops/sec (x times slower)`, where `x times slower` = times slower than fastest implementation (`blst`).

View File

@ -1,6 +1,6 @@
import {runBenchmark} from "./runner"; import {runBenchmark} from "./runner";
import {runForAllImplementations} from "../test/switch"; 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 {range, randomMessage} from "../test/util";
import {aggCount, runs} from "./params"; import {aggCount, runs} from "./params";
@ -120,5 +120,22 @@ import {aggCount, runs} from "./params";
}, },
runs, 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,
});
}); });
})(); })();

View File

@ -105,32 +105,18 @@ import {aggCount, runsNoble} from "./params";
runs: runsNoble, 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 (sigs) => {
noble.aggregateSignatures(sigs);
},
runs: runsNoble,
});
await runBenchmark<{sk: Uint8Array; msg: Uint8Array}, void>({ await runBenchmark<{sk: Uint8Array; msg: Uint8Array}, void>({
id: `noble sign`, id: `noble sign`,
prepareTest: async () => ({ prepareTest: async () => ({
input: { input: {
sk: generateRandomSecretKey(), sk: generateRandomSecretKey(),
msg: randomMessage(), msg: randomMessage(),
}, },
}), }),
testRunner: async ({sk, msg}) => { testRunner: async ({sk, msg}) => {
await noble.sign(msg, sk); await noble.sign(msg, sk);
}, },
runs: runsNoble, runs: runsNoble,
}); });
})(); })();