mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-03-15 10:41:03 +00:00
chore(benchmarks): lint happy
This commit is contained in:
parent
a7c2567ba2
commit
3cc26d167f
@ -33,5 +33,5 @@ suite
|
||||
console.log(String(event.target))
|
||||
})
|
||||
.run({
|
||||
'async': true
|
||||
async: true
|
||||
})
|
||||
|
@ -1,6 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
const Benchmark = require('benchmark')
|
||||
const async = require('async')
|
||||
|
||||
const crypto = require('../src')
|
||||
|
||||
const suite = new Benchmark.Suite('key-stretcher')
|
||||
@ -10,38 +12,38 @@ const keys = []
|
||||
const ciphers = ['AES-128', 'AES-256', 'Blowfish']
|
||||
const hashes = ['SHA1', 'SHA256', 'SHA512']
|
||||
|
||||
crypto.generateEphemeralKeyPair('P-256', (err, res) => {
|
||||
async.waterfall([
|
||||
(cb) => crypto.generateEphemeralKeyPair('P-256', cb),
|
||||
(res, cb) => res.genSharedKey(res.key, cb)
|
||||
], (err, secret) => {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
|
||||
res.genSharedKey(res.key, (err, secret) => {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
ciphers.forEach((cipher) => {
|
||||
hashes.forEach((hash) => {
|
||||
suite.add(`keyStretcher ${cipher} ${hash}`, (d) => {
|
||||
crypto.keyStretcher(cipher, hash, secret, (err, k) => {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
ciphers.forEach((cipher) => hashes.forEach((hash) => {
|
||||
setup(cipher, hash, secret)
|
||||
}))
|
||||
|
||||
keys.push(k)
|
||||
d.resolve()
|
||||
})
|
||||
}, {
|
||||
defer: true
|
||||
})
|
||||
})
|
||||
suite
|
||||
.on('cycle', (event) => {
|
||||
console.log(String(event.target))
|
||||
})
|
||||
.run({
|
||||
async: true
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
suite
|
||||
.on('cycle', (event) => {
|
||||
console.log(String(event.target))
|
||||
})
|
||||
.run({
|
||||
'async': true
|
||||
function setup (cipher, hash, secret) {
|
||||
suite.add(`keyStretcher ${cipher} ${hash}`, (d) => {
|
||||
crypto.keyStretcher(cipher, hash, secret, (err, k) => {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
|
||||
keys.push(k)
|
||||
d.resolve()
|
||||
})
|
||||
}, {
|
||||
defer: true
|
||||
})
|
||||
}
|
||||
|
@ -48,5 +48,5 @@ suite
|
||||
console.log(String(event.target))
|
||||
})
|
||||
.run({
|
||||
'async': true
|
||||
async: true
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user