This commit is contained in:
Vitalik Buterin 2014-01-04 13:28:27 -05:00
commit 6edea532ba
4 changed files with 104 additions and 5 deletions

View file

@ -285,10 +285,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;
}