js-libp2p-crypto/benchmarks/ephemeral-keys.js
Alan Shaw ad7107233e feat: refactor to use async/await (#131)
BREAKING CHANGE: API refactored to use async/await

feat: WIP use async await
fix: passing tests
chore: update travis node.js versions
fix: skip ursa optional tests on windows
fix: benchmarks
docs: update docs
fix: remove broken and intested private key decrypt
chore: update deps
2019-07-10 17:15:26 +01:00

24 lines
606 B
JavaScript

/* eslint-disable no-console */
'use strict'
const Benchmark = require('benchmark')
const crypto = require('../src')
const suite = new Benchmark.Suite('ephemeral-keys')
const secrets = []
const curves = ['P-256', 'P-384', 'P-521']
curves.forEach((curve) => {
suite.add(`ephemeral key with secrect ${curve}`, async (d) => {
const res = await crypto.keys.generateEphemeralKeyPair('P-256')
const secret = await res.genSharedKey(res.key)
secrets.push(secret)
d.resolve()
}, { defer: true })
})
suite
.on('cycle', (event) => console.log(String(event.target)))
.run({ async: true })