.phrase {
word-break: keep-all;
}
+.phraseSplitWarn {
+ text-align: right;
+ color: red;
+}
.generate-container .strength {
/* override mobile width from bootstrap */
width: auto!important;
<textarea id="phrase" class="phrase private-data form-control" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
</div>
</div>
+ <div class="form-group">
+ <label for="phrase" class="col-sm-2 control-label">BIP39 Split Mnemonic</label>
+ <div class="col-sm-10">
+ <textarea id="phraseSplit" class="phraseSplit private-data form-control" title="Only 2 of 3 cards needed to recover."></textarea>
+ </div>
+ <div id="phraseSplitWarn" class="phraseSplitWarn"></div>
+ </div>
<div class="form-group">
<label for="passphrase" class="col-sm-2 control-label">BIP39 Passphrase (optional)</label>
<div class="col-sm-10">
DOM.entropyWeakEntropyOverrideWarning = DOM.entropyContainer.find(".weak-entropy-override-warning");
DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning");
DOM.phrase = $(".phrase");
+ DOM.splitPhrase = $(".phraseSplit");
+ DOM.phraseSplitWarn = $(".phraseSplitWarn");
DOM.passphrase = $(".passphrase");
DOM.generateContainer = $(".generate-container");
DOM.generate = $(".generate");
if (phraseChangeTimeoutEvent != null) {
clearTimeout(phraseChangeTimeoutEvent);
}
- phraseChangeTimeoutEvent = setTimeout(phraseChanged, 400);
+ phraseChangeTimeoutEvent = setTimeout(function() {
+ phraseChanged();
+ var entropy = mnemonic.toRawEntropyHex(DOM.phrase.val());
+ if (entropy !== null) {
+ DOM.entropyMnemonicLength.val("raw");
+ DOM.entropy.val(entropy);
+ }
+ }, 400);
}
function phraseChanged() {
clearDisplay();
clearEntropyFeedback();
DOM.phrase.val("");
+ DOM.phraseSplit.val("");
showValidationError("Blank entropy");
return;
}
showPending();
// Clear existing mnemonic and passphrase
DOM.phrase.val("");
+ DOM.phraseSplit.val("");
DOM.passphrase.val("");
seed = null;
if (rootKeyChangedTimeoutEvent != null) {
if (DOM.phrase.val().length > 0) {
var newPhrase = convertPhraseToNewLanguage();
DOM.phrase.val(newPhrase);
+ writeSplitPhrase(newPhrase);
phraseChanged();
}
else {
// show the words
var words = mnemonic.toMnemonic(data);
DOM.phrase.val(words);
+ writeSplitPhrase(words);
// show the entropy
var entropyHex = uint8ArrayToHex(data);
DOM.entropy.val(entropyHex);
// Ethereum values are different
if ((networks[DOM.network.val()].name == "ETH - Ethereum")
|| (networks[DOM.network.val()].name == "ETC - Ethereum Classic")
+ || (networks[DOM.network.val()].name == "EWT - EnergyWeb")
|| (networks[DOM.network.val()].name == "PIRL - Pirl")
|| (networks[DOM.network.val()].name == "MIX - MIX")
|| (networks[DOM.network.val()].name == "MUSIC - Musicoin")
}
return phrase;
}
+
+ function writeSplitPhrase(phrase) {
+ var wordCount = phrase.split(/\s/g).length; //get number of words in phrase
+ var left=[]; //initialize array of indexs
+ for (var i=0;i<wordCount;i++) left.push(i); //add all indexs to array
+ var group=[[],[],[]], //make array for 3 groups
+ groupI=-1; //initialize group index
+ var seed = Math.abs(sjcl.hash.sha256.hash(phrase)[0])% 2147483647; //start seed at sudo random value based on hash of words
+ while (left.length>0) { //while indexs left
+ groupI=(groupI+1)%3; //get next group to insert index into
+ seed = seed * 16807 % 2147483647; //change random value.(simple predicatable random number generator works well for this use)
+ var selected=Math.floor(left.length*(seed - 1) / 2147483646); //get index in left we will use for this group
+ group[groupI].push(left[selected]); //add index to group
+ left.splice(selected,1); //remove selected index
+ }
+ var cards=[phrase.split(/\s/g),phrase.split(/\s/g),phrase.split(/\s/g)];//make array of cards
+ for (var i=0;i<3;i++) { //go through each card
+ for (var ii=0;ii<wordCount/3;ii++) cards[i][group[i][ii]]='XXXX'; //erase words listed in the group
+ cards[i]='Card '+(i+1)+': '+wordArrayToPhrase(cards[i]); //combine words on card back to string
+ }
+ DOM.splitPhrase.val(cards.join("\r\n")); //make words visible
+ var triesPerSecond=10000000000; //assumed number of tries per second
+ var hackTime=Math.pow(2,wordCount*10/3)/triesPerSecond; //get number of bits of unknown data per card
+ if (hackTime<1) {
+ hackTime="<1 second";
+ } else if (hackTime<86400) {
+ hackTime=Math.floor(hackTime)+" seconds";
+ } else if(hackTime<31557600) {
+ hackTime=Math.floor(hackTime/86400)+" days";
+ } else {
+ hackTime=Math.floor(hackTime/31557600)+" years";
+ }
+ DOM.phraseSplitWarn.html("Time to hack with only one card: "+hackTime);
+ }
function isUsingOwnEntropy() {
return DOM.useEntropy.prop("checked");
var phrase = mnemonic.toMnemonic(entropyArr);
// Set the mnemonic in the UI
DOM.phrase.val(phrase);
+ writeSplitPhrase(phrase);
// Show the word indexes
showWordIndexes();
// Show the checksum
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(60);
},
- },
+ },
+ {
+ name: "EWT - EnergyWeb",
+ onSelect: function() {
+ network = bitcoinjs.bitcoin.networks.bitcoin;
+ setHdCoin(246);
+ },
+ },
{
name: "EXCL - Exclusivecoin",
onSelect: function() {
}
self.check = function(mnemonic) {
- var mnemonic = self.splitWords(mnemonic);
- if (mnemonic.length == 0 || mnemonic.length % 3 > 0) {
- return false
- }
- // idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
- var idx = [];
- for (var i=0; i<mnemonic.length; i++) {
- var word = mnemonic[i];
- var wordIndex = wordlist.indexOf(word);
- if (wordIndex == -1) {
- return false;
- }
- var binaryIndex = zfill(wordIndex.toString(2), 11);
- idx.push(binaryIndex);
+ var b = mnemonicToBinaryString(mnemonic);
+ if (b === null) {
+ return false;
}
- var b = idx.join('');
var l = b.length;
//d = b[:l / 33 * 32]
//h = b[-l / 33:]
return h == nh;
}
+ self.toRawEntropyHex = function(mnemonic) {
+ var b = mnemonicToBinaryString(mnemonic);
+ if (b === null)
+ return null;
+ var d = b.substring(0, b.length / 33 * 32);
+ var nd = binaryStringToWordArray(d);
+
+ var h = "";
+ for (var i=0; i<nd.length; i++) {
+ h += ('0000000' + nd[i].toString(16)).slice(-8);
+ }
+ return h;
+ }
+
self.toSeed = function(mnemonic, passphrase) {
passphrase = passphrase || '';
mnemonic = self.joinWords(self.splitWords(mnemonic)); // removes duplicate blanks
return a;
}
+ function mnemonicToBinaryString(mnemonic) {
+ var mnemonic = self.splitWords(mnemonic);
+ if (mnemonic.length == 0 || mnemonic.length % 3 > 0) {
+ return null;
+ }
+ // idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
+ var idx = [];
+ for (var i=0; i<mnemonic.length; i++) {
+ var word = mnemonic[i];
+ var wordIndex = wordlist.indexOf(word);
+ if (wordIndex == -1) {
+ return null;
+ }
+ var binaryIndex = zfill(wordIndex.toString(2), 11);
+ idx.push(binaryIndex);
+ }
+ return idx.join('');
+ }
+
// Pad a numeric string on the left with zero digits until the given width
// is reached.
// Note this differs to the python implementation because it does not
wif: 0x80,
};
+bitcoinjs.bitcoin.networks.monkeyproject.p2wpkh = {
+ baseNetwork: "monkeyproject",
+ messagePrefix: 'Monkey Signed Message:\n',
+ bech32: 'monkey',
+ bip32: {
+ public: 0x0488b21e,
+ private: 0x0488dde4
+ },
+ pubKeyHash: 0x33,
+ scriptHash: 0x1c,
+ wif: 0x37
+};
+
+bitcoinjs.bitcoin.networks.monkeyproject.p2wpkhInP2sh = {
+ baseNetwork: "monkeyproject",
+ messagePrefix: 'Monkey Signed Message:\n',
+ bech32: 'monkey',
+ bip32: {
+ public: 0x0488b21e,
+ private: 0x0488dde4
+ },
+ pubKeyHash: 0x33,
+ scriptHash: 0x1c,
+ wif: 0x37
+};
+
+bitcoinjs.bitcoin.networks.atom.p2wpkh = {
+ baseNetwork: "atom",
+ messagePrefix: '\x18Bitcoin Atom Signed Message:\n',
+ bech32: 'atom',
+ bip32: {
+ public: 0x0488B21E,
+ private: 0x0488ADE4
+ },
+ pubKeyHash: 0x17,
+ scriptHash: 0x0a,
+ wif: 0x80
+};
+
+bitcoinjs.bitcoin.networks.atom.p2wpkhInP2sh = {
+ baseNetwork: "atom",
+ messagePrefix: '\x18Bitcoin Atom Signed Message:\n',
+ bech32: 'atom',
+ bip32: {
+ public: 0x0488B21E,
+ private: 0x0488ADE4
+ },
+ pubKeyHash: 0x17,
+ scriptHash: 0x0a,
+ wif: 0x80
+};
+
+bitcoinjs.bitcoin.networks.bitcore.p2wpkh = {
+ baseNetwork: "bitcore",
+ messagePrefix: '\x18BitCore Signed Message:\n',
+ bech32: 'bitcore',
+ bip32: {
+ public: 0x0488B21E,
+ private: 0x0488ADE4
+ },
+ pubKeyHash: 0x03,
+ scriptHash: 0x7D,
+ wif: 0x80
+};
+
+bitcoinjs.bitcoin.networks.bitcore.p2wpkhInP2sh = {
+ baseNetwork: "bitcore",
+ messagePrefix: '\x18BitCore Signed Message:\n',
+ bech32: 'bitcore',
+ bip32: {
+ public: 0x0488B21E,
+ private: 0x0488ADE4
+ },
+ pubKeyHash: 0x03,
+ scriptHash: 0x7D,
+ wif: 0x80
+};
+
+bitcoinjs.bitcoin.networks.monacoin.p2wpkh = {
+ baseNetwork: "monacoin",
+ messagePrefix: '\x18Monacoin Signed Message:\n',
+ bech32: 'monacoin',
+ bip32: {
+ public: 0x0488b21e,
+ private: 0x0488ade4
+ },
+ pubKeyHash: 0x32,
+ scriptHash: 0x37,
+ wif: 0xb0
+};
+
+bitcoinjs.bitcoin.networks.monacoin.p2wpkhInP2sh = {
+ baseNetwork: "monacoin",
+ messagePrefix: '\x18Monacoin Signed Message:\n',
+ bech32: 'monacoin',
+ bip32: {
+ public: 0x0488b21e,
+ private: 0x0488ade4
+ },
+ pubKeyHash: 0x32,
+ scriptHash: 0x37,
+ wif: 0xb0
+};
+
+bitcoinjs.bitcoin.networks.syscoin.p2wpkh = {
+ baseNetwork: "syscoin",
+ messagePrefix: '\x18Syscoin Signed Message:\n',
+ bech32: 'sys',
+ bip32: {
+ public: 0x04b24746,
+ private: 0x04b2430c
+ },
+ pubKeyHash: 0x3f,
+ scriptHash: 0x05,
+ wif: 0x80
+};
+
+bitcoinjs.bitcoin.networks.syscoin.p2wpkhInP2sh = {
+ baseNetwork: "syscoin",
+ messagePrefix: '\x18Syscoin Signed Message:\n',
+ bech32: 'sys',
+ bip32: {
+ public: 0x049d7cb2,
+ private: 0x049d7878
+ },
+ pubKeyHash: 0x3f,
+ scriptHash: 0x05,
+ wif: 0x80
+};
+
+bitcoinjs.bitcoin.networks.viacoin.p2wpkh = {
+ baseNetwork: "viacoin",
+ messagePrefix: '\x18Viacoin Signed Message:\n',
+ bech32: 'viacoin',
+ bip32: {
+ public: 0x0488b21e,
+ private: 0x0488ade4
+ },
+ pubKeyHash: 0x47,
+ scriptHash: 0x21,
+ wif: 0xc7
+};
+
+bitcoinjs.bitcoin.networks.viacoin.p2wpkhInP2sh = {
+ baseNetwork: "viacoin",
+ messagePrefix: '\x18Viacoin Signed Message:\n',
+ bech32: 'viacoin',
+ bip32: {
+ public: 0x0488b21e,
+ private: 0x0488ade4
+ },
+ pubKeyHash: 0x47,
+ scriptHash: 0x21,
+ wif: 0xc7
+};
+
+bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkh = {
+ baseNetwork: "dogecointestnet",
+ messagePrefix: '\x19Dogecoin Signed Message:\n',
+ bech32: 'dogecointestnet',
+ bip32: {
+ public: 0x043587cf,
+ private: 0x04358394
+ },
+ pubKeyHash: 0x71,
+ scriptHash: 0xc4,
+ wif: 0xf1
+};
+
+bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
+ baseNetwork: "dogecointestnet",
+ messagePrefix: '\x19Dogecoin Signed Message:\n',
+ bech32: 'dogecointestnet',
+ bip32: {
+ public: 0x043587cf,
+ private: 0x04358394
+ },
+ pubKeyHash: 0x71,
+ scriptHash: 0xc4,
+ wif: 0xf1
+};
+
+bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkh = {
+ baseNetwork: "dogecointestnet",
+ messagePrefix: '\x19Dogecoin Signed Message:\n',
+ bech32: 'dogecointestnet',
+ bip32: {
+ public: 0x043587cf,
+ private: 0x04358394
+ },
+ pubKeyHash: 0x71,
+ scriptHash: 0xc4,
+ wif: 0xf1
+};
+
+bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
+ baseNetwork: "dogecointestnet",
+ messagePrefix: '\x19Dogecoin Signed Message:\n',
+ bech32: 'dogecointestnet',
+ bip32: {
+ public: 0x043587cf,
+ private: 0x04358394
+ },
+ pubKeyHash: 0x71,
+ scriptHash: 0xc4,
+ wif: 0xf1
+};
+
+bitcoinjs.bitcoin.networks.litecointestnet.p2wpkh = {
+ baseNetwork: "litecointestnet",
+ messagePrefix: '\x18Litecoin Signed Message:\n',
+ bech32: 'litecointestnet',
+ bip32: {
+ public: 0x043587cf,
+ private: 0x04358394
+ },
+ pubKeyHash: 0x6f,
+ scriptHash: 0xc4,
+ wif: 0xef
+};
+
+bitcoinjs.bitcoin.networks.litecointestnet.p2wpkhInP2sh = {
+ baseNetwork: "litecointestnet",
+ messagePrefix: '\x18Litecoin Signed Message:\n',
+ bech32: 'litecointestnet',
+ bip32: {
+ public: 0x043587cf,
+ private: 0x04358394
+ },
+ pubKeyHash: 0x6f,
+ scriptHash: 0xc4,
+ wif: 0xef
+};
+
bitcoinjs.bitcoin.networks.groestlcoin.p2wpkh = {
baseNetwork: "groestlcoin",
messagePrefix: '\x19GroestlCoin Signed Message:\n',