aboutsummaryrefslogtreecommitdiff
path: root/src/js/index.js
diff options
context:
space:
mode:
authorPavol Rusnak <stick@gk2.sk>2014-09-24 17:32:02 +0200
committerPavol Rusnak <stick@gk2.sk>2014-09-24 17:32:02 +0200
commit1abcc51168d22067d303a709eb45d2ec7774808d (patch)
tree6b2dba2c5d3de0af46efe05794e45eeaefc8cc6c /src/js/index.js
parentd922d6910987f9161870ca2225a0e49d91ffc8b7 (diff)
downloadBIP39-1abcc51168d22067d303a709eb45d2ec7774808d.tar.gz
BIP39-1abcc51168d22067d303a709eb45d2ec7774808d.tar.zst
BIP39-1abcc51168d22067d303a709eb45d2ec7774808d.zip
add support for BIP39 passphrase
Diffstat (limited to 'src/js/index.js')
-rw-r--r--src/js/index.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/js/index.js b/src/js/index.js
index 161f91f..cee8ffb 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -10,6 +10,7 @@
10 10
11 var DOM = {}; 11 var DOM = {};
12 DOM.phrase = $(".phrase"); 12 DOM.phrase = $(".phrase");
13 DOM.passphrase = $(".passphrase");
13 DOM.generate = $(".generate"); 14 DOM.generate = $(".generate");
14 DOM.rootKey = $(".root-key"); 15 DOM.rootKey = $(".root-key");
15 DOM.extendedPrivKey = $(".extended-priv-key"); 16 DOM.extendedPrivKey = $(".extended-priv-key");
@@ -35,6 +36,7 @@
35 function init() { 36 function init() {
36 // Events 37 // Events
37 DOM.phrase.on("keyup", delayedPhraseChanged); 38 DOM.phrase.on("keyup", delayedPhraseChanged);
39 DOM.passphrase.on("keyup", delayedPhraseChanged);
38 DOM.generate.on("click", generateClicked); 40 DOM.generate.on("click", generateClicked);
39 DOM.more.on("click", showMore); 41 DOM.more.on("click", showMore);
40 DOM.bip32path.on("keyup", bip32Changed); 42 DOM.bip32path.on("keyup", bip32Changed);
@@ -67,6 +69,7 @@
67 hideValidationError(); 69 hideValidationError();
68 // Get the mnemonic phrase 70 // Get the mnemonic phrase
69 var phrase = DOM.phrase.val(); 71 var phrase = DOM.phrase.val();
72 var passphrase = DOM.passphrase.val();
70 var errorText = findPhraseErrors(phrase); 73 var errorText = findPhraseErrors(phrase);
71 if (errorText) { 74 if (errorText) {
72 showValidationError(errorText); 75 showValidationError(errorText);
@@ -79,7 +82,7 @@
79 return; 82 return;
80 } 83 }
81 // Calculate and display 84 // Calculate and display
82 calcBip32Seed(phrase, derivationPath); 85 calcBip32Seed(phrase, passphrase, derivationPath);
83 displayBip32Info(); 86 displayBip32Info();
84 hidePending(); 87 hidePending();
85 } 88 }
@@ -159,8 +162,8 @@
159 return words; 162 return words;
160 } 163 }
161 164
162 function calcBip32Seed(phrase, path) { 165 function calcBip32Seed(phrase, passphrase, path) {
163 var seed = mnemonic.toSeed(phrase); 166 var seed = mnemonic.toSeed(phrase, passphrase);
164 var seedHash = Bitcoin.crypto.sha256(seed).toString("hex"); 167 var seedHash = Bitcoin.crypto.sha256(seed).toString("hex");
165 bip32RootKey = Bitcoin.HDNode.fromSeedHex(seedHash, network); 168 bip32RootKey = Bitcoin.HDNode.fromSeedHex(seedHash, network);
166 bip32ExtendedKey = bip32RootKey; 169 bip32ExtendedKey = bip32RootKey;