Skip to content

Commit

Permalink
v3.0.0 add session log of keypairs
Browse files Browse the repository at this point in the history
  • Loading branch information
pointbiz committed Oct 25, 2015
1 parent 3cd0ae0 commit c26f106
Show file tree
Hide file tree
Showing 17 changed files with 686 additions and 238 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ END USER NOTES:

Here is a signed list of file names and version history.

2015-10-25: status ACTIVE
bitaddress.org-v3.0.0-SHA256-4781574ca09c07f65d1966619f37a762aac6decd8732cacc85b2f2f972f82751.html
- add session log icon that shows all the key pairs generated during the current session.

2015-08-16: status ACTIVE
bitaddress.org-v2.9.11-SHA256-40376eddc790a63d9afcfb72c0a45002827da965f3bfe6ba8c330e697bf188b2.html
- add status icons for checking the URI protocol used, support for window.crypto.getRandomValues
Expand Down
18 changes: 11 additions & 7 deletions CHANGELOG.txt.asc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ END USER NOTES:

Here is a signed list of file names and version history.

2015-10-25: status ACTIVE
bitaddress.org-v3.0.0-SHA256-4781574ca09c07f65d1966619f37a762aac6decd8732cacc85b2f2f972f82751.html
- add session log icon that shows all the key pairs generated during the current session.

2015-08-16: status ACTIVE
bitaddress.org-v2.9.11-SHA256-40376eddc790a63d9afcfb72c0a45002827da965f3bfe6ba8c330e697bf188b2.html
- add status icons for checking the URI protocol used, support for window.crypto.getRandomValues
Expand Down Expand Up @@ -298,11 +302,11 @@ bitaddress.org-v0.1-SHA1-f40e706490f3eb2be56c31ddbf4c8646cd51ef40.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (MingW32)

iQEcBAEBAgAGBQJV0Pu2AAoJEIdJe5Fjl09avHcH/31ABkos0xmXJ6E1PC2P7SUN
SiX6ehnKVTnMzbu1APhyJ2hlUrpSOBS0bbRhlHc9M6X2z8aqBT5izRba6V3LnxJ7
dxtPPv++ieJR/5s6EIrbn1I1f+eoCxKCtuFabmqq/Pmc+ChMbjsWbTz/Nx1lwjSq
F/a1k5RqEL3qMPHTc2eCwT4UdlcNr5YKm/8bJTbRKFygWGfj7U0ryX87h+xI3D2s
jO69dtU6hiQ490574Hl1w9cDMbAdNkhXP5TXZ9Tl7Lqs1SMgHZ9Shi+8xjiOyUSM
7hnRbGyK+r2DbpyLzFnayvez1Zu3oELa5qKNgIq1rS3XLZzxPXId+0li/MRSn1c=
=5DkH
iQEcBAEBAgAGBQJWLSSBAAoJEIdJe5Fjl09ajBMIAJobpBphyjpCmkt8CIzILevd
YZ4M9wCXq0rDj8oRmHzwHDU/UEqTQtmw0NK4juogBiBdfQ6SKon2woISYw1jg6g7
EaL3n14dykaXxCvRCo8uTqLr3zsK0w9bxBa0GQ9uh+xG61vM9B14bFkVn90zXLsw
njn+wyibt4b4NmymKdklU4Ds1jTfquAB/9+dbi7DT5p6hcCGTcvWqekLyVYzVmzO
fiAmbQyWgGC1GvvRsIhi5vgzhLttXaC/K6s4Ypb74Qd5Uw7DO3qje3pmdZF1V/gQ
HOsL43jhqFSeGz2SbdJZLQOi1l9GA04cODJsa18tyiZ5ItbXfp9XKL/EcIG1mV4=
=8hP9
-----END PGP SIGNATURE-----
444 changes: 332 additions & 112 deletions bitaddress.org.html

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions bitaddress.org.html.sig
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (MingW32)

iQEcBAABAgAGBQJV0PvPAAoJEIdJe5Fjl09aUz8IAIen68xsU8MnU56fHx+/KDbx
fiYz88OU7I6PnB+0hlVc5TW5VH4RD8Tzfpc1+31+RyPJ+Va/PUdh68FptcthBsuL
byv3+rrwxRDy/00stIQh1HBd0JJ+mX0DBCqnJ79NdGJJqEHW8D5VgfSnxaqvconi
U5Q1RvzdArb/HcbQ5BvNTXRgHP+TzQBJ3hHyoCxtwOpa3Qd/w5FzkB2TN52mvEiw
U1X0KrT4ntyLYAy4eJb+ecLYHi1dn92BTq8fqkj0mN+inBWb5J0zuZd/aBcqqvRM
qBBPMHBjbXETOunM0PmQ/ENiOugIuN/3JqL0yqVHP1cZxqtLPK5Iw7AVUchPe+E=
=O+Y0
iQEcBAABAgAGBQJWLSSUAAoJEIdJe5Fjl09aOCEIAI4GIeb3WpHoEFzGs0hEaJ/k
UHBlr716hqOyl0bmeTIABYMncJBxXsVtSphtGJChAAw4tdklRmCpXnauSrEnBqMO
bTkjrLXcif5Xot4bJ1+mKJZtDtDj57bpICA/Am7tSchlK/tJNlW5WhV8egd6IF1M
nkcWRz5Jx5VV+sDP0O/WgEYwL3dHZ+M4Q2Be+UCjj8G3GYbFOjocpowtab/2QXRF
Q+3e7XHflMdY04wYc/V/0ZYPx7kUZ456OjNbEIOTkKb0Rb968ERTVGkm0XuDWUuk
4Bay+IaRN6fSsHRtM1Qj6Z6ATSX4ofVh/qBTwjFJESrDz+4tBpbTTNfhvD7av1I=
=HQw+
-----END PGP SIGNATURE-----
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "bitaddress.org",
"version": "2.9.11",
"sha1sum": "7232900c98e3af634a46374cd7178ce5e33cb96f",
"sha256sum": "40376eddc790a63d9afcfb72c0a45002827da965f3bfe6ba8c330e697bf188b2",
"version": "3.0.0",
"sha1sum": "c3838fd668edd5e51aa262916ac7c286db0ddc51",
"sha256sum": "4781574ca09c07f65d1966619f37a762aac6decd8732cacc85b2f2f972f82751",
"description": "Open Source JavaScript Client-Side Bitcoin Wallet Generator",
"main": "Gruntfile.js",
"dependencies": {
Expand Down
66 changes: 39 additions & 27 deletions src/bitaddress-ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,35 +163,37 @@
<span class="print"><input type="button" name="print" value="Print" id="singleprint" onclick="window.print();" /></span>
</div>
</div>
<div id="keyarea" class="keyarea">
<div class="public">
<div class="pubaddress">
<span class="label" id="singlelabelbitcoinaddress">Bitcoin Address</span>
<div class="body">
<div id="keyarea" class="keyarea">
<div class="public">
<div class="pubaddress">
<span class="label" id="singlelabelbitcoinaddress">Bitcoin Address</span>
</div>
<div id="qrcode_public" class="qrcode_public"></div>
<div class="pubaddress">
<span class="output" id="btcaddress"></span>
</div>
<div id="singleshare">SHARE</div>
</div>
<div id="qrcode_public" class="qrcode_public"></div>
<div class="pubaddress">
<span class="output" id="btcaddress"></span>
<div class="private">
<div class="privwif">
<span class="label" id="singlelabelprivatekey">Private Key (Wallet Import Format)</span>
</div>
<div id="qrcode_private" class="qrcode_private"></div>
<div class="privwif">
<span class="output" id="btcprivwif"></span>
</div>
<div id="singlesecret">SECRET</div>
</div>
<div id="singleshare">SHARE</div>
</div>
<div class="private">
<div class="privwif">
<span class="label" id="singlelabelprivatekey">Private Key (Wallet Import Format)</span>
</div>
<div id="qrcode_private" class="qrcode_private"></div>
<div class="privwif">
<span class="output" id="btcprivwif"></span>
</div>
<div id="singlesecret">SECRET</div>
</div>
</div>

<div id="singlesafety">
<p id="singletip1"><b>A Bitcoin wallet</b> is as simple as a single pairing of a Bitcoin address with its corresponding Bitcoin private key. Such a wallet has been generated for you in your web browser and is displayed above.</p>
<p id="singletip2"><b>To safeguard this wallet</b> you must print or otherwise record the Bitcoin address and private key. It is important to make a backup copy of the private key and store it in a safe location. This site does not have knowledge of your private key. If you are familiar with PGP you can download this all-in-one HTML page and check that you have an authentic version from the author of this site by matching the SHA256 hash of this HTML with the SHA256 hash available in the signed version history document linked on the footer of this site. If you leave/refresh the site or press the "Generate New Address" button then a new private key will be generated and the previously displayed private key will not be retrievable. Your Bitcoin private key should be kept a secret. Whomever you share the private key with has access to spend all the bitcoins associated with that address. If you print your wallet then store it in a zip lock bag to keep it safe from water. Treat a paper wallet like cash.</p>
<p id="singletip3"><b>Add funds</b> to this wallet by instructing others to send bitcoins to your Bitcoin address.</p>
<p id="singletip4"><b>Check your balance</b> by going to blockchain.info or blockexplorer.com and entering your Bitcoin address.</p>
<p id="singletip5"><b>Spend your bitcoins</b> by going to blockchain.info and sweep the full balance of your private key into your account at their website. You can also spend your funds by downloading one of the popular bitcoin p2p clients and importing your private key to the p2p client wallet. Keep in mind when you import your single key to a bitcoin p2p client and spend funds your key will be bundled with other private keys in the p2p client wallet. When you perform a transaction your change will be sent to another bitcoin address within the p2p client wallet. You must then backup the p2p client wallet and keep it safe as your remaining bitcoins will be stored there. Satoshi advised that one should never delete a wallet.</p>

<div id="singlesafety">
<p id="singletip1"><b>A Bitcoin wallet</b> is as simple as a single pairing of a Bitcoin address with its corresponding Bitcoin private key. Such a wallet has been generated for you in your web browser and is displayed above.</p>
<p id="singletip2"><b>To safeguard this wallet</b> you must print or otherwise record the Bitcoin address and private key. It is important to make a backup copy of the private key and store it in a safe location. This site does not have knowledge of your private key. If you are familiar with PGP you can download this all-in-one HTML page and check that you have an authentic version from the author of this site by matching the SHA256 hash of this HTML with the SHA256 hash available in the signed version history document linked on the footer of this site. If you leave/refresh the site or press the "Generate New Address" button then a new private key will be generated and the previously displayed private key will not be retrievable. Your Bitcoin private key should be kept a secret. Whomever you share the private key with has access to spend all the bitcoins associated with that address. If you print your wallet then store it in a zip lock bag to keep it safe from water. Treat a paper wallet like cash.</p>
<p id="singletip3"><b>Add funds</b> to this wallet by instructing others to send bitcoins to your Bitcoin address.</p>
<p id="singletip4"><b>Check your balance</b> by going to blockchain.info or blockexplorer.com and entering your Bitcoin address.</p>
<p id="singletip5"><b>Spend your bitcoins</b> by going to blockchain.info and sweep the full balance of your private key into your account at their website. You can also spend your funds by downloading one of the popular bitcoin p2p clients and importing your private key to the p2p client wallet. Keep in mind when you import your single key to a bitcoin p2p client and spend funds your key will be bundled with other private keys in the p2p client wallet. When you perform a transaction your change will be sent to another bitcoin address within the p2p client wallet. You must then backup the p2p client wallet and keep it safe as your remaining bitcoins will be stored there. Satoshi advised that one should never delete a wallet.</p>
</div>
</div>
</div>

Expand Down Expand Up @@ -497,6 +499,14 @@
<span id="statuslabelprotocolbad3">the zip file from GitHub and run this generator offline as a local html file.</span>
<br /><br /><input type="button" value="OK" class="button" id="statusokprotocolbad" onclick="document.getElementById('statusprotocolbad').style.display = 'none';" />
</div>
<div class="tooltip" id="statuskeypoolgood">
<span id="statuslabelkeypool1">This is a log of all the Bitcoin Addresses and Private Keys you generated during your current session. Reloading the page will create a new session.</span>
<textarea rows="20" cols="102" id="keypooltextarea"></textarea>

<br /><br />
<input type="button" value="Refresh" class="button" id="statuskeypoolrefresh" onclick="ninja.status.showKeyPool();" />
<input type="button" value="OK" class="button" id="statusokkeypool" onclick="document.getElementById('statuskeypoolgood').style.display = 'none';" />
</div>
</div>

<div class="authorbtc">
Expand All @@ -505,6 +515,7 @@
<span class="statusicon" id="statusprotocol" onclick="ninja.status.showProtocol();">...</span>
<span class="statusicon" id="statuscrypto" onclick="ninja.status.showCrypto();">...</span>
<span class="statusicon" id="statusunittests" onclick="ninja.status.showUnitTests();">...</span>
<span class="statusicon" id="statuskeypool" onclick="ninja.status.showKeyPool();"></span>
</span>
<span class="item"><span id="footerlabeldonations">Donations:</span> <b>1NiNja</b>1bUmhSoTXozBRBEtR8LeF9TGbZBN</span>
<span class="item" id="footerlabeltranslatedby"></span>
Expand All @@ -519,8 +530,9 @@
</span>
<span class="item">527B 5C82 B1F6 B2DB 72A0<br />ECBF 8749 7B91 6397 4F5A</span>
<span class="item">
(<a href="ninja_bitaddress.org.txt" target="_blank" id="footerlabelpgp">PGP</a>)
(<a href="pointbiz_bitaddress.org.asc" target="_blank" id="footerlabelpgp">PGP</a>)
(<a href="javascript:window.location=window.location.pathname+'.sig';" target="_blank" id="footerlabelsig">sig</a>)
</span>
</div>
<div class="copyright">
<span id="footerlabelcopyright1">Copyright bitaddress.org.</span>
Expand Down
77 changes: 76 additions & 1 deletion src/bitcoinjs-lib.eckey.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,80 @@
Bitcoin.KeyPool = (function () {
var KeyPool = function () {
this.keyArray = [];

this.push = function (item) {
if (item == null || item.priv == null) return;
var doAdd = true;
// prevent duplicates from being added to the array
for (var index in this.keyArray) {
var currentItem = this.keyArray[index];
if (currentItem != null && currentItem.priv != null && item.getBitcoinAddress() == currentItem.getBitcoinAddress()) {
doAdd = false;
break;
}
}
if (doAdd) this.keyArray.push(item);
};

this.reset = function () {
this.keyArray = [];
};

this.getArray = function () {
return this.keyArray;
};

this.setArray = function (ka) {
this.keyArray = ka;
};

this.length = function () {
return this.keyArray.length;
};

this.toString = function () {
var keyPoolString = "# = " + this.length() + "\n";
var pool = this.getArray();
for (var index in pool) {
var item = pool[index];
if (Bitcoin.Util.hasMethods(item, 'getBitcoinAddress', 'toString')) {
if (item != null) {
keyPoolString += "\"" + item.getBitcoinAddress() + "\"" + ", \"" + item.toString("wif") + "\"\n";
}
}
}

return keyPoolString;
};

return this;
};

return new KeyPool();
})();

Bitcoin.Bip38Key = (function () {
var Bip38 = function (address, encryptedKey) {
this.address = address;
this.priv = encryptedKey;
};

Bip38.prototype.getBitcoinAddress = function () {
return this.address;
};

Bip38.prototype.toString = function () {
return this.priv;
};

return Bip38;
})();

//https://raw.github.com/pointbiz/bitcoinjs-lib/9b2f94a028a7bc9bed94e0722563e9ff1d8e8db8/src/eckey.js
Bitcoin.ECKey = (function () {
var ECDSA = Bitcoin.ECDSA;
var KeyPool = Bitcoin.KeyPool;
var ecparams = EllipticCurve.getSECCurveByName("secp256k1");
var rng = new SecureRandom();

var ECKey = function (input) {
if (!input) {
Expand Down Expand Up @@ -41,6 +113,7 @@ Bitcoin.ECKey = (function () {
}

this.compressed = (this.compressed == undefined) ? !!ECKey.compressByDefault : this.compressed;
KeyPool.push(this);
};

ECKey.privateKeyPrefix = 0x80; // mainnet 0x80 testnet 0xEF
Expand Down Expand Up @@ -132,6 +205,7 @@ Bitcoin.ECKey = (function () {
// Sipa Private Key Wallet Import Format
ECKey.prototype.getBitcoinWalletImportFormat = function () {
var bytes = this.getBitcoinPrivateKeyByteArray();
if (bytes == null) return "";
bytes.unshift(ECKey.privateKeyPrefix); // prepend 0x80 byte
if (this.compressed) bytes.push(0x01); // append 0x01 byte for compressed format
var checksum = Crypto.SHA256(Crypto.SHA256(bytes, { asBytes: true }), { asBytes: true });
Expand All @@ -151,6 +225,7 @@ Bitcoin.ECKey = (function () {
};

ECKey.prototype.getBitcoinPrivateKeyByteArray = function () {
if (this.priv == null) return null;
// 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
Expand Down
10 changes: 10 additions & 0 deletions src/bitcoinjs-lib.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,15 @@ Bitcoin.Util = {
// double sha256
dsha256: function (data) {
return Crypto.SHA256(Crypto.SHA256(data, { asBytes: true }), { asBytes: true });
},
// duck typing method
hasMethods: function(obj /*, method list as strings */){
var i = 1, methodName;
while((methodName = arguments[i++])){
if(typeof obj[methodName] != 'function') {
return false;
}
}
return true;
}
};
4 changes: 2 additions & 2 deletions src/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/ninja.detailwallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ ninja.wallets.detailwallet = {
},

populateKeyDetails: function (btcKey) {

if (btcKey.priv != null) {
// get the original compression value and set it back later in this function
var originalCompression = btcKey.compressed;
btcKey.setCompressed(false);
document.getElementById("detailprivhex").innerHTML = btcKey.toString().toUpperCase();
document.getElementById("detailprivb64").innerHTML = btcKey.toString("base64");
Expand All @@ -106,10 +109,13 @@ ninja.wallets.detailwallet = {
document.getElementById("detailprivwif").innerHTML = wif;
btcKey.setCompressed(true);
var bitcoinAddressComp = btcKey.getBitcoinAddress();
var wifComp = btcKey.getBitcoinWalletImportFormat();
var wifComp = btcKey.getBitcoinWalletImportFormat();
document.getElementById("detailpubkeycomp").innerHTML = btcKey.getPubKeyHex();
document.getElementById("detailaddresscomp").innerHTML = bitcoinAddressComp;
document.getElementById("detailprivwifcomp").innerHTML = wifComp;
btcKey.setCompressed(originalCompression); // to satisfy the key pool
var pool1 = new Bitcoin.ECKey(wif); // to satisfy the key pool
var pool2 = new Bitcoin.ECKey(wifComp); // to satisfy the key pool

ninja.qrCode.showQrCode({
"detailqrcodepublic": bitcoinAddress,
Expand Down
5 changes: 4 additions & 1 deletion src/ninja.key.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,12 @@ ninja.privateKey = {
var prefactorB = prefactorA.concat(ownerentropy); // ownerentropy using closure
passfactor = Bitcoin.Util.dsha256(prefactorB);
}
// remove this ECKey from the pool (because user does not see it)
var userKeyPool = Bitcoin.KeyPool.getArray();
Bitcoin.KeyPool.reset();
var kp = new Bitcoin.ECKey(passfactor);
var passpoint = kp.setCompressed(true).getPub();

Bitcoin.KeyPool.setArray(userKeyPool);
var encryptedpart2 = hex.slice(23, 23 + 16);

var addresshashplusownerentropy = hex.slice(3, 3 + 12);
Expand Down
12 changes: 11 additions & 1 deletion src/ninja.misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
document.getElementById("statusunittests").innerHTML = "&times;"; //×
unitTestsCase = "bad";
}
// show session log icon
document.getElementById("statuskeypool").innerHTML = "&#8803;"; //≣
};

var showCrypto = function () {
Expand All @@ -49,7 +51,15 @@
if(unitTestsCase != "") document.getElementById('statusunittests' + unitTestsCase).style.display = 'block';
};

return { unitTests: unitTests, showCrypto: showCrypto, showProtocol: showProtocol, showUnitTests: showUnitTests };
var showKeyPool = function () {
document.getElementById('statuskeypoolgood').style.display = 'block';
document.getElementById("keypooltextarea").value = Bitcoin.KeyPool.toString();
};

return {
unitTests: unitTests, showCrypto: showCrypto, showProtocol: showProtocol,
showUnitTests: showUnitTests, showKeyPool: showKeyPool
};
}();
})(ninja);

Expand Down
2 changes: 1 addition & 1 deletion src/ninja.onload.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ninja.getQueryString()["unittests"] == "true" || ninja.getQueryString()["uni
}
// run async unit tests
if (ninja.getQueryString()["asyncunittests"] == "true" || ninja.getQueryString()["asyncunittests"] == "1") {
ninja.unitTests.runAsynchronousTests();
ninja.unitTests.runAsynchronousTests(true);
}
// change language
if (ninja.getQueryString()["culture"] != undefined) {
Expand Down
1 change: 1 addition & 0 deletions src/ninja.paperwallet.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c26f106

Please sign in to comment.