Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

uncompressed key enc/dec failed #88

@axet

Description

@axet

Hello!

Library fails to compress / uncompress when input key set to 'uncompressed' (any key created from Buffer)

Standart example, but with key pregenerated:

var alicePrivateKey = new bitcore.PrivateKey.fromObject(new Buffer('1fa76f9c799ca3a51e2c7c901d3ba8e24f6d870beccf8df56faf30120b38f360', 'hex'));
console.log("alice private", alicePrivateKey);
var alicePublicKey = new bitcore.PublicKey.fromPrivateKey(alicePrivateKey) // alicePrivateKey.publicKey
console.log("alice public", alicePublicKey);

var data = new Buffer('test');

var cypher1 = ECIES().privateKey(alicePrivateKey).publicKey(alicePublicKey);
var encrypted = cypher1.encrypt(data);
console.log("encrypted",encrypted, encrypted.length);

var cypher2 = ECIES().privateKey(alicePrivateKey).publicKey(alicePublicKey);
var decrypted = cypher2.decrypt(encrypted);
console.log("decrypted",decrypted, decrypted.length);
`

with exception:

/Users/axet/encfs/source/axet.github.io/android-sms-gate/node_modules/bitcore-lib/lib/publickey.js:159
throw new TypeError('Length of x and y must be 32 bytes');
^

TypeError: Length of x and y must be 32 bytes
at Function.PublicKey._transformDER (/Users/axet/encfs/source/axet.github.io/android-sms-gate/node_modules/bitcore-lib/lib/publickey.js:159:13)
at Function.PublicKey.fromDER.PublicKey.fromBuffer (/Users/axet/encfs/source/axet.github.io/android-sms-gate/node_modules/bitcore-lib/lib/publickey.js:235:24)
at ECIES.decrypt (/Users/axet/encfs/source/axet.github.io/android-sms-gate/node_modules/bitcore-ecies/lib/ecies.js:106:33)
at Object. (/Users/axet/encfs/source/axet.github.io/android-sms-gate/index.js:49:25)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
ax

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions