aboutsummaryrefslogtreecommitdiff
path: root/src
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
parentd922d6910987f9161870ca2225a0e49d91ffc8b7 (diff)
downloadBIP39-1abcc51168d22067d303a709eb45d2ec7774808d.tar.gz
BIP39-1abcc51168d22067d303a709eb45d2ec7774808d.tar.zst
BIP39-1abcc51168d22067d303a709eb45d2ec7774808d.zip
add support for BIP39 passphrase
Diffstat (limited to 'src')
-rw-r--r--src/index.html8
-rw-r--r--src/js/index.js9
2 files changed, 13 insertions, 4 deletions
diff --git a/src/index.html b/src/index.html
index dbdc67c..4a9647e 100644
--- a/src/index.html
+++ b/src/index.html
@@ -49,7 +49,7 @@
49 <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki" target="_blank">BIP39 spec</a></p> 49 <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki" target="_blank">BIP39 spec</a></p>
50 </div> 50 </div>
51 <div class="form-group"> 51 <div class="form-group">
52 <label for="phrase" class="col-sm-2 control-label">BIP39 Phrase</label> 52 <label for="phrase" class="col-sm-2 control-label">BIP39 Mnemonic</label>
53 <div class="col-sm-10"> 53 <div class="col-sm-10">
54 <textarea id="phrase" class="phrase form-control"></textarea> 54 <textarea id="phrase" class="phrase form-control"></textarea>
55 </div> 55 </div>
@@ -66,6 +66,12 @@
66 </div> 66 </div>
67 </div> 67 </div>
68 <div class="form-group"> 68 <div class="form-group">
69 <label for="passphrase" class="col-sm-2 control-label">BIP39 Passphrase (optional)</label>
70 <div class="col-sm-10">
71 <textarea id="passphrase" class="passphrase form-control"></textarea>
72 </div>
73 </div>
74 <div class="form-group">
69 <label for="root-key" class="col-sm-2 control-label">BIP32 Root Key</label> 75 <label for="root-key" class="col-sm-2 control-label">BIP32 Root Key</label>
70 <div class="col-sm-10"> 76 <div class="col-sm-10">
71 <textarea id="root-key" class="root-key form-control" disabled="disabled"></textarea> 77 <textarea id="root-key" class="root-key form-control" disabled="disabled"></textarea>
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;