Skip to content

Commit

Permalink
komodo
Browse files Browse the repository at this point in the history
  • Loading branch information
pbca26 committed Aug 14, 2017
1 parent 4f6d383 commit b583324
Show file tree
Hide file tree
Showing 9 changed files with 398 additions and 1,386 deletions.
1,723 changes: 368 additions & 1,355 deletions index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/bitcoinjs-lib.address.js
Expand Up @@ -16,7 +16,7 @@ Bitcoin.Address.prototype.toString = function () {
var hash = this.hash.slice(0);

// Version
hash.unshift(janin.currency.networkVersion());
hash.unshift('0x3c');
var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });
var bytes = hash.concat(checksum.slice(0, 4));
return Bitcoin.Base58.encode(bytes);
Expand Down
12 changes: 6 additions & 6 deletions src/bitcoinjs-lib.eckey.js
Expand Up @@ -29,7 +29,7 @@ Bitcoin.ECKey = (function () {
} else if (ECKey.isBase64Format(input)) {
bytes = Crypto.util.base64ToBytes(input);
}

if (ECKey.isBase6Format(input)) {
this.priv = new BigInteger(input, 6);
} else if (bytes == null || bytes.length != 32) {
Expand Down Expand Up @@ -127,31 +127,31 @@ Bitcoin.ECKey = (function () {
return this;
};

// Sipa Private Key Wallet Import Format
// Sipa Private Key Wallet Import Format
ECKey.prototype.getBitcoinWalletImportFormat = function () {
var bytes = this.getBitcoinPrivateKeyByteArray();
bytes.unshift(janin.currency.privateKeyPrefix()); // prepend private key prefix
bytes.unshift('0xbc'); // prepend private key prefix
if (this.compressed) 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
// Private Key Hex Format
ECKey.prototype.getBitcoinHexFormat = function () {
return Crypto.util.bytesToHex(this.getBitcoinPrivateKeyByteArray()).toString().toUpperCase();
};

// Private Key Base64 Format
// Private Key Base64 Format
ECKey.prototype.getBitcoinBase64Format = function () {
return Crypto.util.bytesToBase64(this.getBitcoinPrivateKeyByteArray());
};

ECKey.prototype.getBitcoinPrivateKeyByteArray = 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
// zero pad if private key is less than 32 bytes
while (bytes.length < 32) bytes.unshift(0x00);
return bytes;
};
Expand Down
6 changes: 3 additions & 3 deletions src/main.css
Expand Up @@ -14,7 +14,7 @@ hr { margin: 20px 0; border-top: 1px dashed #008000; }
.keyarea .qrcode_private { display: inline-block; position: relative; top: 28px; float: right; }
.pubkeyhex { word-wrap: break-word; }
html { height: 100%; }
body { font-family: Arial; background-image: url('images/diamonds.png'); height: 100%; }
body { font-family: Arial; background-image: url('../images/diamonds.png'); height: 100%; }
.faqs ol { padding: 0 0 0 25px; }
.faqs li { padding: 3px 0; }
.question { padding: 10px 15px; text-align: left; cursor: pointer; }
Expand Down Expand Up @@ -146,7 +146,7 @@ h1 { margin: 0px; height: 91px; }
.greenText { color: green; }

#coinLogo { width: 55px; height: 55px; padding: 10px; position: absolute; top: 2px; left: 10px; }
#coinLogoImg { width: 100%; height: 100%; }
.coinLogoImg { width: 100%; height: 100%; }

.coinIcoin { width: 64px; height: 64px; padding: 10px; position: absolute; top: 272px; left: 48px; }
#coinImg { width: 100%; height: 100%; }
Expand Down Expand Up @@ -249,7 +249,7 @@ h1 { margin: 0px; height: 91px; }
.unittests { text-align: center; }
.unittests div { width: 894px; font-family: monospace; text-align: left; margin: auto; padding: 5px; border: 1px solid black; }
#testnet { display: none; background-color: Orange; color: #000000; border-radius: 5px; font-weight: bold; padding: 10px 0; margin: 0 auto 20px auto; }
#busyblock { position: fixed; display: none; background: url("./images/busy.gif") #ccc no-repeat center; opacity: 0.4; width: 100%; height: 100%; top: 0; left: 0; z-index: 5000; }
#busyblock { position: fixed; display: none; background: url("../images/busy.gif") #ccc no-repeat center; opacity: 0.4; width: 100%; height: 100%; top: 0; left: 0; z-index: 5000; }
#busyblock.busy { display: block; }
.hide { display: none; }
.show { display: block; }
Expand Down
2 changes: 1 addition & 1 deletion src/ninja.brainwallet.js
Expand Up @@ -9,7 +9,7 @@ ninja.wallets.brainwallet = {
document.getElementById("brainarea").style.display = "none";
},

minPassphraseLength: 15,
minPassphraseLength: 3,

view: function () {
document.getElementById("brainerror").innerHTML = "";
Expand Down
6 changes: 2 additions & 4 deletions src/ninja.key.js
@@ -1,5 +1,3 @@
var ninja = { wallets: {} };

ninja.privateKey = {
isPrivateKey: function (key) {
return (
Expand Down Expand Up @@ -53,7 +51,7 @@ ninja.privateKey = {
callback(new Error(ninja.translator.get("detailalertnotvalidprivatekey")));
return;
}
// first byte is always 0x01
// first byte is always 0x01
else if (hex[0] != 0x01) {
callback(new Error(ninja.translator.get("detailalertnotvalidprivatekey")));
return;
Expand Down Expand Up @@ -82,7 +80,7 @@ ninja.privateKey = {
return;
}
}
// second byte for EC-multiplied key
// second byte for EC-multiplied key
else if (hex[1] == 0x43) {
isECMult = true;
isCompPoint = (hex[2] & 0x20) != 0;
Expand Down
14 changes: 7 additions & 7 deletions src/ninja.misc.js
@@ -1,6 +1,6 @@
ninja.seeder = {
init: (function () {
document.getElementById("generatekeyinput").value = "";
//document.getElementById("generatekeyinput").value = "";
})(),

// number of mouse movements to wait for
Expand All @@ -16,7 +16,7 @@
isDone: function() {
return ninja.seeder.seedCount >= ninja.seeder.seedLimit;
},

// seed function exists to wait for mouse movement to add more entropy before generating an address
seed: function (evt) {
if (!evt) var evt = window.event;
Expand Down Expand Up @@ -76,7 +76,7 @@
div.setAttribute("class", "seedpoint");
div.style.top = y + "px";
div.style.left = x + "px";

// let's make the entropy 'points' grow and change color!
percentageComplete = ninja.seeder.seedCount / ninja.seeder.seedLimit;
document.getElementById("progress-bar-percentage").style.width=Math.ceil(percentageComplete*100)+"%";
Expand Down Expand Up @@ -145,7 +145,7 @@ ninja.qrCode = {
return canvas;
},

// generate a QRCode and return it's representation as an Html table
// generate a QRCode and return it's representation as an Html table
createTableHtml: function (text) {
var typeNumber = ninja.qrCode.getTypeNumber(text);
var qr = new QRCode(typeNumber, QRCode.ErrorCorrectLevel.H);
Expand All @@ -168,7 +168,7 @@ ninja.qrCode = {
},

// show QRCodes with canvas OR table (IE8)
// parameter: keyValuePair
// parameter: keyValuePair
// example: { "id1": "string1", "id2": "string2"}
// "id1" is the id of a div element where you want a QRCode inserted.
// "string1" is the string you want encoded into the QRCode.
Expand Down Expand Up @@ -212,7 +212,7 @@ ninja.envSecurityCheck = function() {
innerHTML = '<span style="color: #009900;">' + ninja.translator.get("securitychecklistofflineOK") + '</span>';
break;
default:
}
}
document.getElementById('envSecurityCheck').innerHTML = innerHTML;
};

Expand All @@ -222,7 +222,7 @@ ninja.browserSecurityCheck = function() {
innerHTML = '<span style="color: #009900;">' + ninja.translator.get("securitychecklistrandomOK") + '</span>';
} else {
innerHTML = '<span style="color: #990000;">' + ninja.translator.get("securitychecklistrandomNOK") + '</span>';
}
}
document.getElementById('browserSecurityCheck').innerHTML = innerHTML;
}

Expand Down
9 changes: 5 additions & 4 deletions src/ninja.paperwallet.js
Expand Up @@ -88,15 +88,16 @@ ninja.wallets.paperwallet = {
else {
var key = new Bitcoin.ECKey(false);
var bitcoinAddress = key.getBitcoinAddress();
key.setCompressed(true);
var privateKeyWif = key.getBitcoinWalletImportFormat();

ninja.wallets.paperwallet.showArtisticWallet(idPostFix, bitcoinAddress, privateKeyWif);
}
},

// Verify that a self-entered key is valid, and compute the corresponding
// public address, render the wallet.
testAndApplyVanityKey: function () {
testAndApplyVanityKey: function () {
var suppliedKey = document.getElementById('suppliedPrivateKey').value;
suppliedKey = suppliedKey.trim(); // in case any spaces or whitespace got pasted in
document.getElementById('suppliedPrivateKey').value = suppliedKey;
Expand Down Expand Up @@ -139,11 +140,11 @@ ninja.wallets.paperwallet = {
var keyValuePair = {};
keyValuePair["qrcode_public" + idPostFix] = bitcoinAddress;
ninja.qrCode.showQrCode(keyValuePair, 3.5);

var keyValuePair = {};
keyValuePair["qrcode_private" + idPostFix] = privateKey;
ninja.qrCode.showQrCode(keyValuePair, 2.8);

document.getElementById("btcaddress" + idPostFix).innerHTML = bitcoinAddress;
document.getElementById("btcprivwif" + idPostFix).innerHTML = privateKey;
},
Expand Down
10 changes: 5 additions & 5 deletions src/securerandom.js
@@ -1,10 +1,10 @@
/*!
* Random number generator with ArcFour PRNG
*
*
* NOTE: For best results, put code like
* <body onclick='SecureRandom.seedTime();' onkeypress='SecureRandom.seedTime();'>
* in your main HTML document.
*
*
* Copyright Tom Wu, bitaddress.org BSD License.
* http://www-cs-students.stanford.edu/~tjw/jsbn/LICENSE
*/
Expand Down Expand Up @@ -52,11 +52,11 @@
}

sr.getByte = function () {
if(!ninja.seeder.isDone()) {
/*if(!ninja.seeder.isDone()) {
alert("Premature initialisation of the random generator. Something is really wrong, do not generate wallets.");
return NaN;
}
}*/

if (sr.state == null) {
sr.seedTime();
sr.state = sr.ArcFour(); // Plug in your RNG constructor here
Expand Down

0 comments on commit b583324

Please sign in to comment.