Merge branch 'master' into patch-3
This commit is contained in:
commit
94caa9bedd
|
@ -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`).
|
||||
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -105,32 +105,18 @@ import {aggCount, runsNoble} from "./params";
|
|||
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>({
|
||||
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,
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
Reference in New Issue