mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-27 21:00:41 +00:00
Root key validity is checked before deriving
This commit is contained in:
@@ -324,6 +324,10 @@
|
||||
}
|
||||
|
||||
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("/");
|
||||
@@ -458,6 +462,10 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
|
||||
Reference in New Issue
Block a user