diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2016-12-19 14:16:49 +1100 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2016-12-19 14:17:36 +1100 |
commit | 0a1f0259d1cfe5217ca9c08f7fbd371a03703594 (patch) | |
tree | 43a1ad7a58be69399aad6e3047191ec23c3c77fc /bip39-standalone.html | |
parent | ba3cb9ecae2667e98af71f5b38a862ba604e8e1c (diff) | |
download | BIP39-0a1f0259d1cfe5217ca9c08f7fbd371a03703594.tar.gz BIP39-0a1f0259d1cfe5217ca9c08f7fbd371a03703594.tar.zst BIP39-0a1f0259d1cfe5217ca9c08f7fbd371a03703594.zip |
Root key validity is checked before deriving
Diffstat (limited to 'bip39-standalone.html')
-rw-r--r-- | bip39-standalone.html | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bip39-standalone.html b/bip39-standalone.html index 367d9a2..ca18ea8 100644 --- a/bip39-standalone.html +++ b/bip39-standalone.html | |||
@@ -18964,6 +18964,10 @@ window.Entropy = new (function() { | |||
18964 | } | 18964 | } |
18965 | 18965 | ||
18966 | function calcBip32ExtendedKey(path) { | 18966 | function calcBip32ExtendedKey(path) { |
18967 | // Check there's a root key to derive from | ||
18968 | if (!bip32RootKey) { | ||
18969 | return bip32RootKey; | ||
18970 | } | ||
18967 | var extendedKey = bip32RootKey; | 18971 | var extendedKey = bip32RootKey; |
18968 | // Derive the key from the path | 18972 | // Derive the key from the path |
18969 | var pathBits = path.split("/"); | 18973 | var pathBits = path.split("/"); |
@@ -19098,6 +19102,10 @@ window.Entropy = new (function() { | |||
19098 | } | 19102 | } |
19099 | } | 19103 | } |
19100 | } | 19104 | } |
19105 | // Check root key exists or else derivation path is useless! | ||
19106 | if (!bip32RootKey) { | ||
19107 | return "No root key"; | ||
19108 | } | ||
19101 | // Check no hardened derivation path when using xpub keys | 19109 | // Check no hardened derivation path when using xpub keys |
19102 | var hardened = path.indexOf("'") > -1; | 19110 | var hardened = path.indexOf("'") > -1; |
19103 | var isXpubkey = !("privKey" in bip32RootKey); | 19111 | var isXpubkey = !("privKey" in bip32RootKey); |