2023-01-27 05:43:18 +03:00
|
|
|
import { run, mark, utils } from 'micro-bmark';
|
|
|
|
import { generateData } from './_shared.js';
|
2023-04-10 22:04:16 +03:00
|
|
|
import { p256 } from '../p256.js';
|
|
|
|
import { p384 } from '../p384.js';
|
|
|
|
import { p521 } from '../p521.js';
|
2023-02-16 00:50:32 +03:00
|
|
|
import { ed25519 } from '../ed25519.js';
|
|
|
|
import { ed448 } from '../ed448.js';
|
2023-01-27 05:43:18 +03:00
|
|
|
|
|
|
|
run(async () => {
|
|
|
|
const RAM = false
|
2023-05-19 10:58:30 +03:00
|
|
|
for (let kv of Object.entries({ ed25519, ed448, p256, p384, p521 })) {
|
2023-01-27 05:43:18 +03:00
|
|
|
const [name, curve] = kv;
|
|
|
|
console.log();
|
|
|
|
console.log(`\x1b[36m${name}\x1b[0m`);
|
|
|
|
if (RAM) utils.logMem();
|
|
|
|
await mark('init', 1, () => curve.utils.precompute(8));
|
|
|
|
const d = generateData(curve);
|
|
|
|
await mark('getPublicKey', 5000, () => curve.getPublicKey(d.priv));
|
|
|
|
await mark('sign', 5000, () => curve.sign(d.msg, d.priv));
|
|
|
|
await mark('verify', 500, () => curve.verify(d.sig, d.msg, d.pub));
|
|
|
|
if (RAM) utils.logMem();
|
|
|
|
}
|
|
|
|
});
|