fix PublicKey.toObject
This commit is contained in:
parent
74b93e228c
commit
951a07c011
@ -343,8 +343,8 @@ PublicKey.isValid = function(data) {
|
|||||||
*/
|
*/
|
||||||
PublicKey.prototype.toObject = function toObject() {
|
PublicKey.prototype.toObject = function toObject() {
|
||||||
return {
|
return {
|
||||||
x: this.point.getX().toString('hex'),
|
x: this.point.getX().toString('hex', 2),
|
||||||
y: this.point.getY().toString('hex'),
|
y: this.point.getY().toString('hex', 2),
|
||||||
compressed: this.compressed
|
compressed: this.compressed
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -194,6 +194,12 @@ describe('PublicKey', function() {
|
|||||||
}).to.throw();
|
}).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() {
|
describe('#fromPrivateKey', function() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user