From 099201cc62d6259f4f849f2598602e8cdd2181d8 Mon Sep 17 00:00:00 2001 From: coretechs Date: Thu, 8 Mar 2012 03:07:53 -0500 Subject: [PATCH 1/6] WIF privkey for compressed wallet format v0.6 --- bitaddress.org.html | 48 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/bitaddress.org.html b/bitaddress.org.html index 8e5ecf7..9fbee11 100644 --- a/bitaddress.org.html +++ b/bitaddress.org.html @@ -3763,6 +3763,23 @@ return privWif; }; + // Compressed Sipa Private Key Wallet Import Format (added by coretechs) + ECKey.prototype.getBitcoinWalletImportFormatComp = function () { + // Get a copy of private key as a byte array + var bytes = this.priv.toByteArrayUnsigned(); + + // zero pad if private key is less than 32 bytes (thanks Casascius) + while (bytes.length < 32) bytes.unshift(0x00); + + bytes.unshift(0x80); // prepend 0x80 byte + bytes.push(0x01); // append 0x01 byte for compressed format + var checksum = Crypto.SHA256(Crypto.SHA256(bytes, { asBytes: true }), { asBytes: true }); + bytes = bytes.concat(checksum.slice(0, 4)); + + var privWif = Bitcoin.Base58.encode(bytes); + return privWif; + }; + // Private Key Hex Format (added by bitaddress.org) ECKey.prototype.getBitcoinHexFormat = function () { // Get a copy of private key as a byte array @@ -3787,6 +3804,9 @@ else if (format.toString().toLowerCase() == "wif") { return this.getBitcoinWalletImportFormat(); } + else if (format.toString().toLowerCase() == "wifcomp") { + return this.getBitcoinWalletImportFormatComp(); + } else { return this.getBitcoinHexFormat(); } @@ -4070,11 +4090,15 @@ Public Key (130 characters [0-9A-F]): -
+
- Private Key Sipa Wallet Import Format (51 characters base58, starts with a '5'): + Private Key WIF (51 characters base58, starts with a '5'):
+
+ Private Key WIF (52 characters base58, compressed wallet format, bitcoin v0.6+): + +


Private Key Hexadecimal Format (64 characters [0-9A-F]): @@ -4525,6 +4549,11 @@ key = key.toString(); return (/^5[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{50}$/.test(key)); }, + // 52 characters base58 + isCompSipaWalletImportFormat: function (key) { + key = key.toString(); + return (/^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{52}$/.test(key)); + }, // 64 characters [0-9A-F] isHexFormat: function (key) { key = key.toString(); @@ -4566,6 +4595,19 @@ var btcKey = new Bitcoin.ECKey(bytes); } } + else if (keyFormat.isCompSipaWalletImportFormat(key)) { + var bytes = Bitcoin.Base58.decode(key); + bytes.shift(); + bytes.pop(); + bytes = bytes.slice(0, bytes.length - 4); + if (bytes.length != 32) { + alert("The text you entered is not a valid Private Key"); + ninja.wallets.detailwallet.clear(); + } + else { + var btcKey = new Bitcoin.ECKey(bytes); + } + } else if (keyFormat.isHexFormat(key)) { var bytes = Crypto.util.hexToBytes(key); var btcKey = new Bitcoin.ECKey(bytes); @@ -4617,6 +4659,7 @@ document.getElementById("detailpubkey").innerHTML = pubKeyFirstHalf + "
" + pubKeySecondHalf; document.getElementById("detailaddress").innerHTML = btcKey.getBitcoinAddress(); document.getElementById("detailprivwif").innerHTML = btcKey.getBitcoinWalletImportFormat(); + document.getElementById("detailprivwifcomp").innerHTML = btcKey.getBitcoinWalletImportFormatComp(); document.getElementById("detailprivhex").innerHTML = btcKey.toString().toUpperCase(); document.getElementById("detailprivb64").innerHTML = btcKey.toString("base64"); document.getElementById("detailqrcodepublic").innerHTML = ""; @@ -4639,6 +4682,7 @@ document.getElementById("detailpubkey").innerHTML = ""; document.getElementById("detailaddress").innerHTML = ""; document.getElementById("detailprivwif").innerHTML = ""; + document.getElementById("detailprivwifcomp").innerHTML = ""; document.getElementById("detailprivhex").innerHTML = ""; document.getElementById("detailprivb64").innerHTML = ""; document.getElementById("detailprivmini").innerHTML = ""; From bdaa695478e3f176ba546f1a3b4b0f66299a7c1e Mon Sep 17 00:00:00 2001 From: coretechs Date: Thu, 8 Mar 2012 23:39:49 -0500 Subject: [PATCH 2/6] added comp wif to csv --- bitaddress.org.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitaddress.org.html b/bitaddress.org.html index 9fbee11..e4e841b 100644 --- a/bitaddress.org.html +++ b/bitaddress.org.html @@ -3763,7 +3763,7 @@ return privWif; }; - // Compressed Sipa Private Key Wallet Import Format (added by coretechs) + // Compressed Sipa Private Key Wallet Import Format ECKey.prototype.getBitcoinWalletImportFormatComp = function () { // Get a copy of private key as a byte array var bytes = this.priv.toByteArrayUnsigned(); @@ -4417,7 +4417,7 @@ var key = new Bitcoin.ECKey(false); bulkWallet.csv.push((bulkWallet.csvRowLimit - bulkWallet.csvRowsRemaining + bulkWallet.csvStartIndex) - + ",\"" + key.getBitcoinAddress() + "\",\"" + key.getBitcoinWalletImportFormat() + + ",\"" + key.getBitcoinAddress() + "\",\"" + key.toString("wif") + "\",\"" + key.toString("wifcomp") //+ "\",\"" + key.getBitcoinHexFormat() + "\",\"" + key.toString("base64") // uncomment this line to add different private key formats to the CSV + "\""); From 77f7d7bafc3140f5cd5177492acd4fd87ffe9032 Mon Sep 17 00:00:00 2001 From: coretechs Date: Fri, 9 Mar 2012 21:46:46 -0500 Subject: [PATCH 3/6] added compressed pubkey (disp only) +fixes --- bitaddress.org.html | 56 ++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/bitaddress.org.html b/bitaddress.org.html index e4e841b..be111c8 100644 --- a/bitaddress.org.html +++ b/bitaddress.org.html @@ -948,13 +948,25 @@ }; // patched by bitaddress.org and Casascius for use with Bitcoin.ECKey - ec.PointFp.prototype.getEncoded = function () { + ec.PointFp.prototype.getEncoded = function (compressed) { var x = this.getX().toBigInteger(); var y = this.getY().toBigInteger(); var len = 32; // integerToBytes will zero pad if integer is less than 32 bytes. 32 bytes length is required by the Bitcoin protocol. var enc = ec.integerToBytes(x, len); - enc.unshift(0x04); - enc = enc.concat(ec.integerToBytes(y, len)); + + // modded from old code from forum post + if (compressed) { + if (y.isEven()) { + enc.unshift(0x02); + } + else { + enc.unshift(0x03); + } + } + else { + enc.unshift(0x04); + enc = enc.concat(ec.integerToBytes(y, len)); + } return enc; }; @@ -3730,19 +3742,19 @@ } }; - ECKey.prototype.getPub = function () { - if (this.pub) return this.pub; - this.pub = ecparams.getG().multiply(this.priv).getEncoded(); + ECKey.prototype.getPub = function (compressed) { + //if (this.pub) return this.pub; + this.pub = ecparams.getG().multiply(this.priv).getEncoded(compressed); return this.pub; }; - ECKey.prototype.getPubKeyHash = function () { - if (this.pubKeyHash) return this.pubKeyHash; - return this.pubKeyHash = Bitcoin.Util.sha256ripe160(this.getPub()); + ECKey.prototype.getPubKeyHash = function (compressed) { + //if (this.pubKeyHash) return this.pubKeyHash; + return this.pubKeyHash = Bitcoin.Util.sha256ripe160(this.getPub(compressed)); }; - ECKey.prototype.getBitcoinAddress = function () { - var hash = this.getPubKeyHash(); + ECKey.prototype.getBitcoinAddress = function (compressed) { + var hash = this.getPubKeyHash(compressed); var addr = new Bitcoin.Address(hash); return addr.toString(); }; @@ -3817,7 +3829,7 @@ }; ECKey.prototype.verify = function (hash, sig) { - return ECDSA.verify(hash, sig, this.getPub()); + return ECDSA.verify(hash, sig, this.getPub(0)); }; return ECKey; @@ -4070,7 +4082,7 @@
- Comma Separated Values: Index,Bitcoin Address,Private Key (Wallet Import Format) + Comma Separated Values: Index,Address,Private Key (WIF),Private Key (WIF compressed)
@@ -4085,6 +4097,10 @@ Bitcoin Address (33 or 34 characters, starts with a '1'):
+
+ Bitcoin Address (compressed 0.6+, 33 or 34 characters, starts with a '1'): + +

Public Key (130 characters [0-9A-F]): @@ -4193,7 +4209,7 @@ idPostFix = idPostFix || ""; try { var key = new Bitcoin.ECKey(false); - var bitcoinAddress = key.getBitcoinAddress(); + var bitcoinAddress = key.getBitcoinAddress(0); var privateKeyWif = key.getBitcoinWalletImportFormat(); } catch (e) { @@ -4417,7 +4433,7 @@ var key = new Bitcoin.ECKey(false); bulkWallet.csv.push((bulkWallet.csvRowLimit - bulkWallet.csvRowsRemaining + bulkWallet.csvStartIndex) - + ",\"" + key.getBitcoinAddress() + "\",\"" + key.toString("wif") + "\",\"" + key.toString("wifcomp") + + ",\"" + key.getBitcoinAddress(0) + "\",\"" + key.toString("wif") + "\",\"" + key.toString("wifcomp") //+ "\",\"" + key.getBitcoinHexFormat() + "\",\"" + key.toString("base64") // uncomment this line to add different private key formats to the CSV + "\""); @@ -4652,12 +4668,13 @@ } if (btcKey != undefined) { - var pubKey = Crypto.util.bytesToHex(btcKey.getPub()).toUpperCase(); + var pubKey = Crypto.util.bytesToHex(btcKey.getPub(0)).toUpperCase(); var halfWayIndex = Math.floor(pubKey.length / 2); var pubKeyFirstHalf = pubKey.substr(0, halfWayIndex); var pubKeySecondHalf = pubKey.substr(halfWayIndex, pubKey.length - halfWayIndex); document.getElementById("detailpubkey").innerHTML = pubKeyFirstHalf + "
" + pubKeySecondHalf; - document.getElementById("detailaddress").innerHTML = btcKey.getBitcoinAddress(); + document.getElementById("detailaddress").innerHTML = btcKey.getBitcoinAddress(0); + document.getElementById("detailaddresscomp").innerHTML = btcKey.getBitcoinAddress(1); document.getElementById("detailprivwif").innerHTML = btcKey.getBitcoinWalletImportFormat(); document.getElementById("detailprivwifcomp").innerHTML = btcKey.getBitcoinWalletImportFormatComp(); document.getElementById("detailprivhex").innerHTML = btcKey.toString().toUpperCase(); @@ -4666,12 +4683,12 @@ document.getElementById("detailqrcodeprivate").innerHTML = ""; // show QR codes try { - document.getElementById("detailqrcodepublic").appendChild(ninja.qrCode.createCanvas(btcKey.getBitcoinAddress())); + document.getElementById("detailqrcodepublic").appendChild(ninja.qrCode.createCanvas(btcKey.getBitcoinAddress(0))); document.getElementById("detailqrcodeprivate").appendChild(ninja.qrCode.createCanvas(btcKey.getBitcoinWalletImportFormat())); } catch (e) { // for browsers that do not support canvas (IE8) - document.getElementById("detailqrcodepublic").innerHTML = ninja.qrCode.createTableHtml(btcKey.getBitcoinAddress()); + document.getElementById("detailqrcodepublic").innerHTML = ninja.qrCode.createTableHtml(btcKey.getBitcoinAddress(0)); document.getElementById("detailqrcodeprivate").innerHTML = ninja.qrCode.createTableHtml(btcKey.getBitcoinWalletImportFormat()); } @@ -4681,6 +4698,7 @@ clear: function () { document.getElementById("detailpubkey").innerHTML = ""; document.getElementById("detailaddress").innerHTML = ""; + document.getElementById("detailaddresscomp").innerHTML = ""; document.getElementById("detailprivwif").innerHTML = ""; document.getElementById("detailprivwifcomp").innerHTML = ""; document.getElementById("detailprivhex").innerHTML = ""; From 4b6b08706c5532a5a956fdb0c4dbccedce56dc6f Mon Sep 17 00:00:00 2001 From: coretechs Date: Sat, 10 Mar 2012 21:22:32 -0500 Subject: [PATCH 4/6] cleaned up implementation, import format check fix --- bitaddress.org.html | 54 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/bitaddress.org.html b/bitaddress.org.html index be111c8..ca8a9e9 100644 --- a/bitaddress.org.html +++ b/bitaddress.org.html @@ -3760,7 +3760,7 @@ }; // Sipa Private Key Wallet Import Format (added by bitaddress.org) - ECKey.prototype.getBitcoinWalletImportFormat = function () { + ECKey.prototype.getBitcoinWalletImportFormat = function (compressed) { // Get a copy of private key as a byte array var bytes = this.priv.toByteArrayUnsigned(); @@ -3768,23 +3768,11 @@ while (bytes.length < 32) bytes.unshift(0x00); bytes.unshift(0x80); // prepend 0x80 byte - var checksum = Crypto.SHA256(Crypto.SHA256(bytes, { asBytes: true }), { asBytes: true }); - bytes = bytes.concat(checksum.slice(0, 4)); + + if (compressed) { + bytes.push(0x01); // append 0x01 byte for compressed format + } - var privWif = Bitcoin.Base58.encode(bytes); - return privWif; - }; - - // Compressed Sipa Private Key Wallet Import Format - ECKey.prototype.getBitcoinWalletImportFormatComp = function () { - // Get a copy of private key as a byte array - var bytes = this.priv.toByteArrayUnsigned(); - - // zero pad if private key is less than 32 bytes (thanks Casascius) - while (bytes.length < 32) bytes.unshift(0x00); - - bytes.unshift(0x80); // prepend 0x80 byte - bytes.push(0x01); // append 0x01 byte for compressed format var checksum = Crypto.SHA256(Crypto.SHA256(bytes, { asBytes: true }), { asBytes: true }); bytes = bytes.concat(checksum.slice(0, 4)); @@ -3814,10 +3802,10 @@ } // Wallet Import Format else if (format.toString().toLowerCase() == "wif") { - return this.getBitcoinWalletImportFormat(); + return this.getBitcoinWalletImportFormat(0); } else if (format.toString().toLowerCase() == "wifcomp") { - return this.getBitcoinWalletImportFormatComp(); + return this.getBitcoinWalletImportFormat(1); } else { return this.getBitcoinHexFormat(); @@ -4090,15 +4078,18 @@
Your Bitcoin Private Key is a unique secret number that only you know. It can be be encoded in a number of different formats. Below we show the Bitcoin Address and Public Key that corresponds to your Private Key as well as your Private Key in the most popular encoding formats (WIF, HEX, B64, MINI). + + Bitcoin v0.6+ stores public keys in compressed format. The client now also supports import and export of private keys with importprivkey/dumpprivkey. The format of the exported + private key is determined by whether the address was generated in an old or new wallet.
- Bitcoin Address (33 or 34 characters, starts with a '1'): + Bitcoin Address:
- Bitcoin Address (compressed 0.6+, 33 or 34 characters, starts with a '1'): + Bitcoin Address (compressed format):

@@ -4106,13 +4097,17 @@ Public Key (130 characters [0-9A-F]):
+
+ Public Key (compressed format, 65 characters [0-9A-F]): + +
Private Key WIF (51 characters base58, starts with a '5'):
- Private Key WIF (52 characters base58, compressed wallet format, bitcoin v0.6+): + Private Key WIF (compressed format, 52 characters base58, starts with a 'K' or 'L'):


@@ -4210,7 +4205,7 @@ try { var key = new Bitcoin.ECKey(false); var bitcoinAddress = key.getBitcoinAddress(0); - var privateKeyWif = key.getBitcoinWalletImportFormat(); + var privateKeyWif = key.getBitcoinWalletImportFormat(0); } catch (e) { alert(e); @@ -4568,7 +4563,7 @@ // 52 characters base58 isCompSipaWalletImportFormat: function (key) { key = key.toString(); - return (/^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{52}$/.test(key)); + return (/^[LK][123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$/.test(key)); }, // 64 characters [0-9A-F] isHexFormat: function (key) { @@ -4669,14 +4664,16 @@ if (btcKey != undefined) { var pubKey = Crypto.util.bytesToHex(btcKey.getPub(0)).toUpperCase(); + var pubKeyComp = Crypto.util.bytesToHex(btcKey.getPub(1)).toUpperCase(); var halfWayIndex = Math.floor(pubKey.length / 2); var pubKeyFirstHalf = pubKey.substr(0, halfWayIndex); var pubKeySecondHalf = pubKey.substr(halfWayIndex, pubKey.length - halfWayIndex); document.getElementById("detailpubkey").innerHTML = pubKeyFirstHalf + "
" + pubKeySecondHalf; + document.getElementById("detailpubkeycomp").innerHTML = pubKeyComp; document.getElementById("detailaddress").innerHTML = btcKey.getBitcoinAddress(0); document.getElementById("detailaddresscomp").innerHTML = btcKey.getBitcoinAddress(1); - document.getElementById("detailprivwif").innerHTML = btcKey.getBitcoinWalletImportFormat(); - document.getElementById("detailprivwifcomp").innerHTML = btcKey.getBitcoinWalletImportFormatComp(); + document.getElementById("detailprivwif").innerHTML = btcKey.getBitcoinWalletImportFormat(0); + document.getElementById("detailprivwifcomp").innerHTML = btcKey.getBitcoinWalletImportFormat(1); document.getElementById("detailprivhex").innerHTML = btcKey.toString().toUpperCase(); document.getElementById("detailprivb64").innerHTML = btcKey.toString("base64"); document.getElementById("detailqrcodepublic").innerHTML = ""; @@ -4684,12 +4681,12 @@ // show QR codes try { document.getElementById("detailqrcodepublic").appendChild(ninja.qrCode.createCanvas(btcKey.getBitcoinAddress(0))); - document.getElementById("detailqrcodeprivate").appendChild(ninja.qrCode.createCanvas(btcKey.getBitcoinWalletImportFormat())); + document.getElementById("detailqrcodeprivate").appendChild(ninja.qrCode.createCanvas(btcKey.getBitcoinWalletImportFormat(0))); } catch (e) { // for browsers that do not support canvas (IE8) document.getElementById("detailqrcodepublic").innerHTML = ninja.qrCode.createTableHtml(btcKey.getBitcoinAddress(0)); - document.getElementById("detailqrcodeprivate").innerHTML = ninja.qrCode.createTableHtml(btcKey.getBitcoinWalletImportFormat()); + document.getElementById("detailqrcodeprivate").innerHTML = ninja.qrCode.createTableHtml(btcKey.getBitcoinWalletImportFormat(0)); } } @@ -4697,6 +4694,7 @@ clear: function () { document.getElementById("detailpubkey").innerHTML = ""; + document.getElementById("detailpubkeycomp").innerHTML = ""; document.getElementById("detailaddress").innerHTML = ""; document.getElementById("detailaddresscomp").innerHTML = ""; document.getElementById("detailprivwif").innerHTML = ""; From d2ba280388be57e1f295c4aac80dab85447147ed Mon Sep 17 00:00:00 2001 From: coretechs Date: Sat, 10 Mar 2012 22:01:05 -0500 Subject: [PATCH 5/6] added QR codes, cleaned up a few things --- bitaddress.org.html | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/bitaddress.org.html b/bitaddress.org.html index ca8a9e9..a6e6993 100644 --- a/bitaddress.org.html +++ b/bitaddress.org.html @@ -3920,7 +3920,9 @@ #detailarea .label { display: block; text-decoration: underline; } #detailarea .output { display: block; min-height: 20px; } #detailarea #detailqrcodepublic { position: relative; float: left; margin: 0 10px 0 0; } - #detailarea #detailqrcodeprivate { position: relative; float: right; margin: 0 0 0 10px; } + #detailarea #detailqrcodepubliccomp { position: relative; float: right; margin: 0 0 0 10px; } + #detailarea #detailqrcodeprivate { position: relative; float: left; margin: 0 10px 0 0; } + #detailarea #detailqrcodeprivatecomp { position: relative; float: right; margin: 0 0 0 10px; } .right { text-align: right; } #bulkfaqs { display: none; } @@ -4070,7 +4072,7 @@
- Comma Separated Values: Index,Address,Private Key (WIF),Private Key (WIF compressed) + Comma Separated Values: Index,Address,Private Key (WIF)
@@ -4078,7 +4080,8 @@
Your Bitcoin Private Key is a unique secret number that only you know. It can be be encoded in a number of different formats. Below we show the Bitcoin Address and Public Key that corresponds to your Private Key as well as your Private Key in the most popular encoding formats (WIF, HEX, B64, MINI). - +
+
Bitcoin v0.6+ stores public keys in compressed format. The client now also supports import and export of private keys with importprivkey/dumpprivkey. The format of the exported private key is determined by whether the address was generated in an old or new wallet.
@@ -4088,8 +4091,10 @@ Bitcoin Address:
-
- Bitcoin Address (compressed format): +
+
+
+ Bitcoin Address (compressed):

@@ -4098,19 +4103,24 @@
- Public Key (compressed format, 65 characters [0-9A-F]): + Public Key (compressed, 65 characters [0-9A-F]):
-
+
+
Private Key WIF (51 characters base58, starts with a '5'):
-
- Private Key WIF (compressed format, 52 characters base58, starts with a 'K' or 'L'): +
+
+
+
+ Private Key WIF (compressed, 52 characters base58, starts with a 'K' or 'L'):
-

+
+
Private Key Hexadecimal Format (64 characters [0-9A-F]): @@ -4428,8 +4438,10 @@ var key = new Bitcoin.ECKey(false); bulkWallet.csv.push((bulkWallet.csvRowLimit - bulkWallet.csvRowsRemaining + bulkWallet.csvStartIndex) - + ",\"" + key.getBitcoinAddress(0) + "\",\"" + key.toString("wif") + "\",\"" + key.toString("wifcomp") - //+ "\",\"" + key.getBitcoinHexFormat() + "\",\"" + key.toString("base64") // uncomment this line to add different private key formats to the CSV + + ",\"" + key.getBitcoinAddress(0) + "\",\"" + key.toString("wif") + //+ "\",\"" + key.toString("wifcomp") // uncomment these lines to add different private key formats to the CSV + //+ "\",\"" + key.getBitcoinHexFormat() + //+ "\",\"" + key.toString("base64") + "\""); document.getElementById("bulktextarea").value = "Generating addresses... " + bulkWallet.csvRowsRemaining; @@ -4677,16 +4689,22 @@ document.getElementById("detailprivhex").innerHTML = btcKey.toString().toUpperCase(); document.getElementById("detailprivb64").innerHTML = btcKey.toString("base64"); document.getElementById("detailqrcodepublic").innerHTML = ""; + document.getElementById("detailqrcodepubliccomp").innerHTML = ""; document.getElementById("detailqrcodeprivate").innerHTML = ""; + document.getElementById("detailqrcodeprivatecomp").innerHTML = ""; // show QR codes try { document.getElementById("detailqrcodepublic").appendChild(ninja.qrCode.createCanvas(btcKey.getBitcoinAddress(0))); + document.getElementById("detailqrcodepubliccomp").appendChild(ninja.qrCode.createCanvas(btcKey.getBitcoinAddress(1))); document.getElementById("detailqrcodeprivate").appendChild(ninja.qrCode.createCanvas(btcKey.getBitcoinWalletImportFormat(0))); + document.getElementById("detailqrcodeprivatecomp").appendChild(ninja.qrCode.createCanvas(btcKey.getBitcoinWalletImportFormat(1))); } catch (e) { // for browsers that do not support canvas (IE8) document.getElementById("detailqrcodepublic").innerHTML = ninja.qrCode.createTableHtml(btcKey.getBitcoinAddress(0)); + document.getElementById("detailqrcodepubliccomp").innerHTML = ninja.qrCode.createTableHtml(btcKey.getBitcoinAddress(1)); document.getElementById("detailqrcodeprivate").innerHTML = ninja.qrCode.createTableHtml(btcKey.getBitcoinWalletImportFormat(0)); + document.getElementById("detailqrcodeprivatecomp").innerHTML = ninja.qrCode.createTableHtml(btcKey.getBitcoinWalletImportFormat(1)); } } @@ -4703,7 +4721,9 @@ document.getElementById("detailprivb64").innerHTML = ""; document.getElementById("detailprivmini").innerHTML = ""; document.getElementById("detailqrcodepublic").innerHTML = ""; + document.getElementById("detailqrcodepubliccomp").innerHTML = ""; document.getElementById("detailqrcodeprivate").innerHTML = ""; + document.getElementById("detailqrcodeprivatecomp").innerHTML = ""; } } }, From 0ebfba0b37d84ec5b9401df7e8f1be5c9ea4ad4b Mon Sep 17 00:00:00 2001 From: coretechs Date: Sun, 11 Mar 2012 01:47:01 -0500 Subject: [PATCH 6/6] fix base64 display bug ECKey.toString missing pad --- bitaddress.org.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bitaddress.org.html b/bitaddress.org.html index a6e6993..cf4bee4 100644 --- a/bitaddress.org.html +++ b/bitaddress.org.html @@ -3797,8 +3797,13 @@ ECKey.prototype.toString = function (format) { format = format || ""; + // Get a copy of private key as a byte array + var bytes = this.priv.toByteArrayUnsigned(); + // zero pad if private key is less than 32 bytes + while (bytes.length < 32) bytes.unshift(0x00); + if (format === "base64" || format === "b64") { - return Crypto.util.bytesToBase64(this.priv.toByteArrayUnsigned()); + return Crypto.util.bytesToBase64(bytes); } // Wallet Import Format else if (format.toString().toLowerCase() == "wif") {