From 8e6a28162b24209678cb095f586c12c91f6fceca Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Fri, 22 Aug 2014 16:34:45 -0700 Subject: [PATCH] it is a "Compact" signature, not "Compressed" --- lib/message.js | 4 ++-- lib/signature.js | 4 ++-- test/test.signature.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/message.js b/lib/message.js index 544d177..a3b8018 100644 --- a/lib/message.js +++ b/lib/message.js @@ -46,7 +46,7 @@ Message.prototype.sign = function() { Message.sign = function(messagebuf, key) { var m = Message(messagebuf, key); m.sign(); - var sigbuf = m.sig.toCompressed(); + var sigbuf = m.sig.toCompact(); var sigstr = sigbuf.toString('base64'); return sigstr; }; @@ -79,7 +79,7 @@ Message.verify = function(messagebuf, sigstr, address) { var sigbuf = new Buffer(sigstr, 'base64'); var message = new Message(); message.messagebuf = messagebuf; - message.sig = Signature().fromCompressed(sigbuf); + message.sig = Signature().fromCompact(sigbuf); message.address = address; return message.verify().verified; diff --git a/lib/signature.js b/lib/signature.js index 31e88d4..965bcaa 100644 --- a/lib/signature.js +++ b/lib/signature.js @@ -11,7 +11,7 @@ var Signature = function Signature(r, s, i) { this.i = i; //public key recovery parameter in range [0, 3] }; -Signature.prototype.fromCompressed = function(buf) { +Signature.prototype.fromCompact = function(buf) { var i = buf.slice(0, 1)[0] - 27 - 4; //TODO: handle uncompressed pubkeys var b2 = buf.slice(1, 33); var b3 = buf.slice(33, 65); @@ -102,7 +102,7 @@ Signature.parseDER = function(buf) { return obj; }; -Signature.prototype.toCompressed = function(i) { +Signature.prototype.toCompact = function(i) { i = typeof i === 'number' ? i : this.i; if (!(i === 0 || i === 1 || i === 2 || i === 3)) throw new Error('i must be equal to 0, 1, 2, or 3'); diff --git a/test/test.signature.js b/test/test.signature.js index e74e802..d52bcd5 100644 --- a/test/test.signature.js +++ b/test/test.signature.js @@ -9,7 +9,7 @@ describe('Signature', function() { should.exist(sig); }); - describe('#fromCompressed', function() { + describe('#fromCompact', function() { it('should create a signature from a compressed signature', function() { var blank = new Buffer(32); @@ -20,7 +20,7 @@ describe('Signature', function() { blank ]); var sig = new Signature(); - sig.fromCompressed(compressed); + sig.fromCompact(compressed); sig.r.cmp(0).should.equal(0); sig.s.cmp(0).should.equal(0); });