Files: 22bf66e454af3c3430bd9354d73620173cf52426 / examples / diffieHellman.js
581 bytesRaw
1 | const bls = require('../') |
2 | |
3 | // Diffie–Hellman key exchange |
4 | bls.onModuleInit(() => { |
5 | bls.init() |
6 | |
7 | const sk1 = bls.secretKey() |
8 | const sk2 = bls.secretKey() |
9 | |
10 | const pk1 = bls.publicKey() |
11 | const pk2 = bls.publicKey() |
12 | |
13 | bls.getPublicKey(pk1, sk1) |
14 | bls.getPublicKey(pk2, sk2) |
15 | |
16 | const sharedSec1 = bls.publicKey() |
17 | const sharedSec2 = bls.publicKey() |
18 | |
19 | bls.dhKeyExchange(sharedSec1, sk1, pk2) |
20 | bls.dhKeyExchange(sharedSec2, sk2, pk1) |
21 | |
22 | const r = bls.publicKeyIsEqual(sharedSec1, sharedSec2) |
23 | console.log(r) |
24 | |
25 | bls.freeArray([sk1, sk2, pk1, pk2, sharedSec2, sharedSec1]) |
26 | }) |
27 |
Built with git-ssb-web