2023-04-10 22:04:16 +03:00
|
|
|
import { run, compare } from 'micro-bmark';
|
2023-02-16 14:32:18 +03:00
|
|
|
import { secp256k1 } from '../secp256k1.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 14:32:18 +03:00
|
|
|
import { x25519 } from '../ed25519.js';
|
|
|
|
import { x448 } from '../ed448.js';
|
|
|
|
|
|
|
|
run(async () => {
|
2023-04-10 22:04:16 +03:00
|
|
|
const curves = { x25519, secp256k1, p256, p384, p521, x448 };
|
2023-02-16 14:32:18 +03:00
|
|
|
const fns = {};
|
|
|
|
for (let [k, c] of Object.entries(curves)) {
|
|
|
|
const pubB = c.getPublicKey(c.utils.randomPrivateKey());
|
|
|
|
const privA = c.utils.randomPrivateKey();
|
|
|
|
fns[k] = () => c.getSharedSecret(privA, pubB);
|
|
|
|
}
|
|
|
|
await compare('ecdh', 1000, fns);
|
|
|
|
});
|