]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - src/js/index.js
Root key validity is checked before deriving
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / src / js / index.js
index 45edea8477b835245c3a03b34183310f226ebbc3..13c61780931f03282c99d043e76d7231af7fbc0f 100644 (file)
     }
 
     function calcBip32ExtendedKey(path) {
+        // Check there's a root key to derive from
+        if (!bip32RootKey) {
+            return bip32RootKey;
+        }
         var extendedKey = bip32RootKey;
         // Derive the key from the path
         var pathBits = path.split("/");
                 }
             }
         }
+        // Check root key exists or else derivation path is useless!
+        if (!bip32RootKey) {
+            return "No root key";
+        }
         // Check no hardened derivation path when using xpub keys
         var hardened = path.indexOf("'") > -1;
         var isXpubkey = !("privKey" in bip32RootKey);