mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-03-15 19:31:05 +00:00
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
35 lines
841 B
JavaScript
35 lines
841 B
JavaScript
/* eslint-disable no-console */
|
|
'use strict'
|
|
|
|
const Benchmark = require('benchmark')
|
|
|
|
const crypto = require('../src')
|
|
|
|
const suite = new Benchmark.Suite('key-stretcher')
|
|
|
|
const keys = []
|
|
|
|
const ciphers = ['AES-128', 'AES-256', 'Blowfish']
|
|
const hashes = ['SHA1', 'SHA256', 'SHA512']
|
|
|
|
;(async () => {
|
|
const res = await crypto.keys.generateEphemeralKeyPair('P-256')
|
|
const secret = await res.genSharedKey(res.key)
|
|
|
|
ciphers.forEach((cipher) => hashes.forEach((hash) => {
|
|
setup(cipher, hash, secret)
|
|
}))
|
|
|
|
suite
|
|
.on('cycle', (event) => console.log(String(event.target)))
|
|
.run({ async: true })
|
|
})()
|
|
|
|
function setup (cipher, hash, secret) {
|
|
suite.add(`keyStretcher ${cipher} ${hash}`, async (d) => {
|
|
const k = await crypto.keys.keyStretcher(cipher, hash, secret)
|
|
keys.push(k)
|
|
d.resolve()
|
|
}, { defer: true })
|
|
}
|