Add tests that reveals incorrect public key calculation

This commit is contained in:
Braydon Fuller 2015-01-03 13:20:51 -05:00
parent 5ae97a7146
commit 3de6acc176
1 changed files with 13 additions and 0 deletions

View File

@ -44,6 +44,7 @@ describe('PublicKey', function() {
});
describe('instantiation', function() {
it('from a private key', function() {
var privhex = '906977a061af29276e40bf377042ffbde414e496ae2260bbf1fa9d085637bfff';
var pubhex = '02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc';
@ -52,6 +53,18 @@ describe('PublicKey', function() {
pk.toString().should.equal(pubhex);
});
it('from a known private key', function() {
var privwif = 'KzsjKq2FVqVuQv2ueHVFuB65A9uEZ6S1L6F8NuokCrE3V3kE3Ack';
var pubhex = '03d6106302d2698d6a41e9c9a114269e7be7c6a0081317de444bb2980bf9265a01';
var pubxhex = 'd6106302d2698d6a41e9c9a114269e7be7c6a0081317de444bb2980bf9265a01';
var pubyhex = 'e05fb262e64b108991a29979809fcef9d3e70cafceb3248c922c17d83d66bc9d';
var privkey = new PrivateKey(privwif);
var pubkey = privkey.toPublicKey();
pubkey.point.x.toString('hex').should.equal(pubxhex);
pubkey.point.y.toString('hex').should.equal(pubyhex);
pubkey.toString().should.equal(pubhex);
});
it('from a compressed public key', function() {
var publicKeyHex = '031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a';
var publicKey = new PublicKey(publicKeyHex);