Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
fix(address): keys without leading zeros are now usable.
Browse files Browse the repository at this point in the history
  • Loading branch information
sha49 committed Feb 11, 2016
1 parent e6fead6 commit 7a8b19b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,8 @@ MyWallet.detectPrivateKeyFormat = function(key) {
};
// should be a helper
function buffertoByteArray(value) {
return BigInteger.fromBuffer(value).toByteArray();
return Array.prototype.map.call(value, function (b) { return b; })
// return BigInteger.fromBuffer(value).toByteArray();
}
// should be a helper
// used locally and wallet-spender.js
Expand Down Expand Up @@ -1292,7 +1293,8 @@ MyWallet.privateKeyStringToKey = function(value, format) {
throw 'Unsupported Key Format';
}

if (key_bytes.length != 32 && key_bytes.length != 33)
if (key_bytes.length !== 31 && key_bytes.length !== 32 && key_bytes.length !== 33)
// 31 is included as valid for the leading 0 problem
throw 'Result not 32 or 33 bytes in length';

return new ECKey(new BigInteger.fromByteArrayUnsigned(key_bytes), (format !== 'sipa'));
Expand Down

0 comments on commit 7a8b19b

Please sign in to comment.