ecdh-sodium
v0.0.4
Published
ECDH usign libsodium
Downloads
4
Readme
ecdh-sodium
ecdh-sodium is a wrapper over libsodium ecdh. Browserify+
npm install ecdh-sodium
Using
const Ecdh = require('ecdh-sodium');
let alice = Ecdh.generate();
let bob = Ecdh.generate();
let aliceSecret = alice.computeSecret(bob.publicKey, 'buffer', 'base64');
let bobSecret = bob.computeSecret(alice.publicKey, 'buffer', 'base64');
true === (aliceSecret === bobSecret);
By private key
let bob = Ecdh.fromPrivateKey('8263086244a5ed93ae5b884258a7d2179ade9e04ba1582f9dadff6d9bc8c4023', 'hex');
let alice = Ecdh.fromPrivateKey('xo0bJpgcr9lf2DCFXpS2FTUmdlmvvw0cS1VvWkYKUqE=', 'base64');
let bobSecret = bob.computeSecret(alice.publicKey);
let aliceSecret = alice.computeSecret(bob.publicKey);
true === (bobSecret.base64 === aliceSecret.base64);
Tests
npm test