From 1abcc51168d22067d303a709eb45d2ec7774808d Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 24 Sep 2014 17:32:02 +0200 Subject: add support for BIP39 passphrase --- src/js/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/js/index.js') 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; -- cgit v1.2.3