git ssb

0+

wanderer🌟 / bls-lib



Tree: cb3dd62c1388d6303184dad6bb39be120a958012

Files: cb3dd62c1388d6303184dad6bb39be120a958012 / benchmark / benchmark.js

885 bytesRaw
1const bls = require('../')
2const nacl = require('tweetnacl')
3
4bls.onModuleInit(() => {
5 bls.init()
6
7 const sec = bls.secretKey()
8 const pub = bls.publicKey()
9 const sig = bls.signature()
10
11 bls.secretKeySetByCSPRNG(sec)
12 bls.getPublicKey(pub, sec)
13
14 let start = new Date()
15 const msg = Buffer.from('hello world')
16 bls.sign(sig, sec, msg)
17
18 const v = bls.verify(sig, pub, msg)
19
20 let end = new Date()
21 let time = end.getTime() - start.getTime()
22 console.log('finished in', time, 'ms')
23 console.log(v)
24
25 bls.free(sec)
26 bls.free(sig)
27 bls.free(pub)
28
29 const keyPair = nacl.sign.keyPair()
30
31 start = new Date()
32 const signedMsg = nacl.sign(msg, keyPair.secretKey)
33 const rmsg = nacl.sign.open(signedMsg, keyPair.publicKey)
34
35 end = new Date()
36 time = end.getTime() - start.getTime()
37 console.log('finished in', time, 'ms')
38 console.log(Buffer.from(rmsg).toString())
39})
40

Built with git-ssb-web