|
|
@ -40,6 +40,31 @@ describe('Pubkey', function() { |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
describe('#fromBuffer', function() { |
|
|
|
|
|
|
|
it('should parse this uncompressed public key', function() { |
|
|
|
var pk = new Pubkey(); |
|
|
|
pk.fromBuffer(new Buffer('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341', 'hex')); |
|
|
|
pk.point.getX().toString(16).should.equal('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a'); |
|
|
|
pk.point.getY().toString(16).should.equal('7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341'); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should parse this compressed public key', function() { |
|
|
|
var pk = new Pubkey(); |
|
|
|
pk.fromBuffer(new Buffer('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex')); |
|
|
|
pk.point.getX().toString(16).should.equal('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a'); |
|
|
|
pk.point.getY().toString(16).should.equal('7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341'); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should throw an error on this invalid public key', function() { |
|
|
|
var pk = new Pubkey(); |
|
|
|
(function() { |
|
|
|
pk.fromBuffer(new Buffer('091ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex')); |
|
|
|
}).should.throw(); |
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
describe('#fromDER', function() { |
|
|
|
|
|
|
|
it('should parse this uncompressed public key', function() { |
|
|
|