diff --git a/src/ecdsa.js b/src/ecdsa.js index 1aa15ed..e65b8e1 100644 --- a/src/ecdsa.js +++ b/src/ecdsa.js @@ -275,10 +275,12 @@ var ECDSA = { * This function simply tries all four cases and returns the value * that resulted in a successful pubkey recovery. */ - calcPubkeyRecoveryParam: function (address, r, s, hash) + calcPubkeyRecoveryParam: function (origPubkey, r, s, hash) { + var address = origPubkey.getBitcoinAddress().toString(); for (var i = 0; i < 4; i++) { var pubkey = ECDSA.recoverPubKey(r, s, hash, i); + pubkey.compressed = origPubkey.compressed; if (pubkey.getBitcoinAddress().toString() == address) { return i; } diff --git a/src/message.js b/src/message.js index abc2da5..ef29117 100644 --- a/src/message.js +++ b/src/message.js @@ -34,8 +34,7 @@ Message.signMessage = function (key, message, compressed) { var obj = ecdsa.parseSig(sig); - var address = key.getBitcoinAddress().toString(); - var i = ecdsa.calcPubkeyRecoveryParam(address, obj.r, obj.s, hash); + var i = ecdsa.calcPubkeyRecoveryParam(key, obj.r, obj.s, hash); i += 27; if (compressed) i += 4;