Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
README.MD
index.js
package-lock.json
package.json

README.MD

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