mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-31 18:40:56 +00:00
core: return root_fingerprint in PublicKey
This commit is contained in:
parent
4d45a68fd0
commit
5728f54b78
@ -60,4 +60,8 @@ async def get_public_key(ctx: wire.Context, msg: GetPublicKey) -> PublicKey:
|
||||
if msg.show_display:
|
||||
await layout.show_xpub(ctx, node_xpub, "XPUB", "Cancel")
|
||||
|
||||
return PublicKey(node=node_type, xpub=node_xpub)
|
||||
return PublicKey(
|
||||
node=node_type,
|
||||
xpub=node_xpub,
|
||||
root_fingerprint=keychain.root_fingerprint(),
|
||||
)
|
||||
|
@ -98,6 +98,7 @@ class Keychain:
|
||||
self.slip21_namespaces = tuple(slip21_namespaces)
|
||||
|
||||
self._cache = LRUCache(10)
|
||||
self._root_fingerprint: Optional[int] = None
|
||||
|
||||
def __del__(self) -> None:
|
||||
self._cache.__del__()
|
||||
@ -136,6 +137,17 @@ class Keychain:
|
||||
node.derive_path(path[prefix_len:])
|
||||
return node
|
||||
|
||||
def root_fingerprint(self) -> int:
|
||||
if self._root_fingerprint is None:
|
||||
# derive m/0' to obtain root_fingerprint
|
||||
n = self._derive_with_cache(
|
||||
prefix_len=0,
|
||||
path=[0 | paths.HARDENED],
|
||||
new_root=lambda: bip32.from_seed(self.seed, self.curve),
|
||||
)
|
||||
self._root_fingerprint = n.fingerprint()
|
||||
return self._root_fingerprint
|
||||
|
||||
def derive(self, path: paths.Bip32Path) -> bip32.HDNode:
|
||||
self.verify_path(path)
|
||||
return self._derive_with_cache(
|
||||
|
Loading…
Reference in New Issue
Block a user