mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-28 02:42:34 +00:00
seed: simplify Keychain.validate_path
This commit is contained in:
parent
7cadefcdd0
commit
d1a01bebc5
@ -26,19 +26,9 @@ class Keychain:
|
|||||||
del self.seed
|
del self.seed
|
||||||
|
|
||||||
def validate_path(self, checked_path: list):
|
def validate_path(self, checked_path: list):
|
||||||
empty = True
|
for curve, *path in self.namespaces:
|
||||||
for _, *namespace_path in self.namespaces:
|
if path == checked_path[: len(path)]: # TODO: check curve_name
|
||||||
if empty and len(namespace_path):
|
|
||||||
empty = False
|
|
||||||
for i, p in enumerate(namespace_path):
|
|
||||||
if p != checked_path[i]:
|
|
||||||
# item did not match, move on to the next allowed path in namespace
|
|
||||||
break
|
|
||||||
if i == len(namespace_path) - 1:
|
|
||||||
# all items match in some namespace path -> success
|
|
||||||
return
|
return
|
||||||
if not empty:
|
|
||||||
# checked_path was not among the allowed ones
|
|
||||||
raise wire.DataError("Forbidden key path")
|
raise wire.DataError("Forbidden key path")
|
||||||
|
|
||||||
def derive(self, node_path: list, curve_name: str = "secp256k1") -> bip32.HDNode:
|
def derive(self, node_path: list, curve_name: str = "secp256k1") -> bip32.HDNode:
|
||||||
|
Loading…
Reference in New Issue
Block a user