Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
everything now seemingly working with just buffer private and public …
Browse files Browse the repository at this point in the history
…keys
  • Loading branch information
campbell-codes committed Nov 15, 2017
1 parent 9e74f81 commit ec20526
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/asymmetric-encryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function encrypt(input, _privateKey, _remoteKey) {

// Derive secret.
const secret = ec.keyFromPrivate(privateKey)
.derive(ec.keyFromPublic(remoteKey).getPublic())
.derive(ec.keyFromPublic({x: remoteKey.slice(0,32), y: remoteKey.slice(32,remoteKey.length)}).getPublic())
.toArrayLike(Buffer);

const key = kdf(secret, 32);
Expand Down
4 changes: 2 additions & 2 deletions src/b-privacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ class BPrivacy {
// Encrypts `input` using `BPrivacy`'s private key and provided reader's
// remote `publicKey`.
encrypt(input, remoteKey) {
return BPrivacy.encrypt(input, this.privateKey, remoteKey);
return BPrivacy.encrypt(input, this.pvtKey, remoteKey);
}

// Decrypts `input` message using `BPrivacy`'s private key.
decrypt(input) {
return BPrivacy.decrypt(input, this.privateKey);
return BPrivacy.decrypt(input, this.pvtKey);
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports = {
isHex,
isHex0x,
toBuffer,
// toHex,
//toHex,
toHex0x,
areBuffersEqual,
kindOf,
Expand Down
2 changes: 1 addition & 1 deletion test/asymmetric-encryption.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('AsymmetricEncryption', function () {
const a = new B({ mnemonic: B.generateMnemonicPhrase() })
const b = new B({ mnemonic: B.generateMnemonicPhrase() })
const m = { foo: "bar" };
const a2b = a.encrypt(m, b.publicKey);
const a2b = a.encrypt(m, b.pubKey);
const m2 = b.decrypt(a2b);
t(m2, m);
});
Expand Down

0 comments on commit ec20526

Please sign in to comment.