Browse Source

fix PublicKey.toObject

patch-2
Manuel Araoz 10 years ago
parent
commit
951a07c011
  1. 4
      lib/publickey.js
  2. 6
      test/publickey.js

4
lib/publickey.js

@ -343,8 +343,8 @@ PublicKey.isValid = function(data) {
*/
PublicKey.prototype.toObject = function toObject() {
return {
x: this.point.getX().toString('hex'),
y: this.point.getY().toString('hex'),
x: this.point.getX().toString('hex', 2),
y: this.point.getY().toString('hex', 2),
compressed: this.compressed
};
};

6
test/publickey.js

@ -194,6 +194,12 @@ describe('PublicKey', function() {
}).to.throw();
});
it('works for X starting with 0x00', function() {
var a = new PublicKey('030589ee559348bd6a7325994f9c8eff12bd5d73cc683142bd0dd1a17abc99b0dc');
var b = new PublicKey('03'+a.toObject().x);
b.toString().should.equal(a.toString());
});
});
describe('#fromPrivateKey', function() {

Loading…
Cancel
Save