From 1abcc51168d22067d303a709eb45d2ec7774808d Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 24 Sep 2014 17:32:02 +0200 Subject: [PATCH] add support for BIP39 passphrase --- src/index.html | 8 +++++++- src/js/index.js | 9 ++++++--- 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 @@

For more info see the BIP39 spec

- +
@@ -65,6 +65,12 @@
+
+ +
+ +
+
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 @@ var DOM = {}; DOM.phrase = $(".phrase"); + DOM.passphrase = $(".passphrase"); DOM.generate = $(".generate"); DOM.rootKey = $(".root-key"); DOM.extendedPrivKey = $(".extended-priv-key"); @@ -35,6 +36,7 @@ function init() { // Events DOM.phrase.on("keyup", delayedPhraseChanged); + DOM.passphrase.on("keyup", delayedPhraseChanged); DOM.generate.on("click", generateClicked); DOM.more.on("click", showMore); DOM.bip32path.on("keyup", bip32Changed); @@ -67,6 +69,7 @@ hideValidationError(); // Get the mnemonic phrase var phrase = DOM.phrase.val(); + var passphrase = DOM.passphrase.val(); var errorText = findPhraseErrors(phrase); if (errorText) { showValidationError(errorText); @@ -79,7 +82,7 @@ return; } // Calculate and display - calcBip32Seed(phrase, derivationPath); + calcBip32Seed(phrase, passphrase, derivationPath); displayBip32Info(); hidePending(); } @@ -159,8 +162,8 @@ return words; } - function calcBip32Seed(phrase, path) { - var seed = mnemonic.toSeed(phrase); + function calcBip32Seed(phrase, passphrase, path) { + var seed = mnemonic.toSeed(phrase, passphrase); var seedHash = Bitcoin.crypto.sha256(seed).toString("hex"); bip32RootKey = Bitcoin.HDNode.fromSeedHex(seedHash, network); bip32ExtendedKey = bip32RootKey; -- 2.41.0