From ae80ca8678d467802a1e169b1c8c7f08935eea9d Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Thu, 4 Dec 2014 12:46:59 -0500 Subject: [PATCH 1/2] PublicKey: Add test to verify that both uncompressed an compressed keys validatate. Fixes #665 --- test/publickey.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/publickey.js b/test/publickey.js index 58a3d07ef..497550d4a 100644 --- a/test/publickey.js +++ b/test/publickey.js @@ -79,11 +79,16 @@ describe('PublicKey', function() { valid.should.equal(false); }); - it('should recieve a boolean as true', function() { + it('should recieve a boolean as true for uncompressed', function() { var valid = PublicKey.isValid('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341'); valid.should.equal(true); }); + it('should recieve a boolean as true for compressed', function() { + var valid = PublicKey.isValid('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a'); + valid.should.equal(true); + }); + }); describe('#fromPoint', function() { From 012466d41123864e0c304da7016b5a072d0bdfe8 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Thu, 4 Dec 2014 13:06:10 -0500 Subject: [PATCH 2/2] PublicKey: Remove compressed boolean from validation, not nessassary. --- lib/publickey.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/publickey.js b/lib/publickey.js index eb8fbf7d9..76c854f85 100644 --- a/lib/publickey.js +++ b/lib/publickey.js @@ -248,10 +248,10 @@ PublicKey.fromX = function(odd, x) { * @param {String} [compressed] - If the public key is compressed * @returns {null|Error} An error if exists */ -PublicKey.getValidationError = function(data, compressed) { +PublicKey.getValidationError = function(data) { var error; try { - new PublicKey(data, compressed); + new PublicKey(data); } catch (e) { error = e; } @@ -266,8 +266,8 @@ PublicKey.getValidationError = function(data, compressed) { * @param {String} [compressed] - If the public key is compressed * @returns {Boolean} If the public key would be valid */ -PublicKey.isValid = function(data, compressed) { - return !PublicKey.getValidationError(data, compressed); +PublicKey.isValid = function(data) { + return !PublicKey.getValidationError(data); }; /**