aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Coleman <coleman.ian@gmail.com>2016-12-19 14:16:49 +1100
committerIan Coleman <coleman.ian@gmail.com>2016-12-19 14:17:36 +1100
commit0a1f0259d1cfe5217ca9c08f7fbd371a03703594 (patch)
tree43a1ad7a58be69399aad6e3047191ec23c3c77fc /src
parentba3cb9ecae2667e98af71f5b38a862ba604e8e1c (diff)
downloadBIP39-0a1f0259d1cfe5217ca9c08f7fbd371a03703594.tar.gz
BIP39-0a1f0259d1cfe5217ca9c08f7fbd371a03703594.tar.zst
BIP39-0a1f0259d1cfe5217ca9c08f7fbd371a03703594.zip
Root key validity is checked before deriving
Diffstat (limited to 'src')
-rw-r--r--src/js/index.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/js/index.js b/src/js/index.js
index 45edea8..13c6178 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -324,6 +324,10 @@
324 } 324 }
325 325
326 function calcBip32ExtendedKey(path) { 326 function calcBip32ExtendedKey(path) {
327 // Check there's a root key to derive from
328 if (!bip32RootKey) {
329 return bip32RootKey;
330 }
327 var extendedKey = bip32RootKey; 331 var extendedKey = bip32RootKey;
328 // Derive the key from the path 332 // Derive the key from the path
329 var pathBits = path.split("/"); 333 var pathBits = path.split("/");
@@ -458,6 +462,10 @@
458 } 462 }
459 } 463 }
460 } 464 }
465 // Check root key exists or else derivation path is useless!
466 if (!bip32RootKey) {
467 return "No root key";
468 }
461 // Check no hardened derivation path when using xpub keys 469 // Check no hardened derivation path when using xpub keys
462 var hardened = path.indexOf("'") > -1; 470 var hardened = path.indexOf("'") > -1;
463 var isXpubkey = !("privKey" in bip32RootKey); 471 var isXpubkey = !("privKey" in bip32RootKey);