From 2b5ca8a5f3c0202f9b905b0ef8746d57c66ce912 Mon Sep 17 00:00:00 2001 From: Jeff Weiss Date: Sat, 6 Apr 2013 23:07:30 -0400 Subject: [PATCH] Fixed hex/bytes conversion so that unit tests still pass. --- bitaddress.org.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bitaddress.org.html b/bitaddress.org.html index 3bbc19c..70ce57a 100644 --- a/bitaddress.org.html +++ b/bitaddress.org.html @@ -707,7 +707,7 @@ hex.push((bytes[i] >>> 4).toString(16)); hex.push((bytes[i] & 0xF).toString(16)); } - return hex.join("").split(/^0+/).slice(-1)[0]; //drop leading 0 + return hex.join(""); }, // Convert a hex string to a byte array @@ -7505,6 +7505,8 @@ }, + stripLeadZeros: function(hex) { return hex.split(/^0+/).slice(-1)[0]; }, + // Split a private key and update information in the HTML splitKey: function () { try { @@ -7547,7 +7549,8 @@ var shares = document.getElementById("combineinput").value.split(/\W+/); var combined = secrets.combine(shares.map(Bitcoin.Base58.decode). - map(Crypto.util.bytesToHex)); + map(Crypto.util.bytesToHex). + map(this.stripLeadZeros)); var privkeyBase58 = Bitcoin.Base58.encode(Crypto.util.hexToBytes(combined)); var output = document.createElement("div");