2021-03-23 12:29:25 +00:00
|
|
|
from micropython import const
|
2021-12-08 09:10:58 +00:00
|
|
|
from typing import TYPE_CHECKING
|
2021-03-23 12:29:25 +00:00
|
|
|
|
|
|
|
HARDENED = const(0x8000_0000)
|
2022-06-03 09:41:44 +00:00
|
|
|
SLIP25_PURPOSE = const(10025 | HARDENED)
|
2018-08-30 11:45:09 +00:00
|
|
|
|
2021-12-08 09:10:58 +00:00
|
|
|
if TYPE_CHECKING:
|
2020-07-14 10:15:18 +00:00
|
|
|
from typing import (
|
|
|
|
Any,
|
|
|
|
Callable,
|
|
|
|
Collection,
|
2020-11-13 14:53:21 +00:00
|
|
|
Container,
|
2020-07-14 10:15:18 +00:00
|
|
|
Iterable,
|
|
|
|
Sequence,
|
|
|
|
TypeVar,
|
|
|
|
)
|
|
|
|
from typing_extensions import Protocol
|
core: refactor keychain to only support one curve at a time
also make a cleaner distinction between keychain, seed, path
This enables using `unsafe_prompts`, because with the original code, if
there was no namespace match, we wouldn't know which curve to use.
For ease of implementation, we use a LRU cache for derived keys,
instead of the original design "one cache entry per namespace".
SLIP21 is now treated completely separately, via `slip21_namespaces` and
`derive_slip21` method.
If more slip21-like things come in the future, we can instead hang them
on the keychain: put a per-curve Keychain object accessible by
`keychain[curve_name].derive()`, and the majority usecase will just pass
around `keychain[curve_name]` instead of having to specify the curve in
every `derive()` call.
Or alternately we'll just specify the curve in every `derive()` call,
whichever seems more appropriate.
2020-07-14 10:15:05 +00:00
|
|
|
|
|
|
|
Bip32Path = Sequence[int]
|
|
|
|
Slip21Path = Sequence[bytes]
|
2021-12-08 09:10:58 +00:00
|
|
|
PathType = TypeVar("PathType", Bip32Path, Slip21Path, contravariant=True)
|
2018-08-30 11:45:09 +00:00
|
|
|
|
2020-07-14 10:15:18 +00:00
|
|
|
class PathSchemaType(Protocol):
|
|
|
|
def match(self, path: Bip32Path) -> bool:
|
|
|
|
...
|
|
|
|
|
2021-01-08 10:31:03 +00:00
|
|
|
class KeychainValidatorType(Protocol):
|
|
|
|
def is_in_keychain(self, path: Bip32Path) -> bool:
|
|
|
|
...
|
|
|
|
|
|
|
|
def verify_path(self, path: Bip32Path) -> None:
|
|
|
|
...
|
|
|
|
|
2020-07-14 10:15:18 +00:00
|
|
|
|
2020-11-13 14:53:21 +00:00
|
|
|
class Interval:
|
|
|
|
"""Helper for testing membership in an interval."""
|
2020-07-14 10:15:18 +00:00
|
|
|
|
|
|
|
def __init__(self, min: int, max: int) -> None:
|
2020-11-13 14:53:21 +00:00
|
|
|
self.min = min
|
|
|
|
self.max = max
|
2020-07-14 10:15:18 +00:00
|
|
|
|
|
|
|
def __contains__(self, x: object) -> bool:
|
|
|
|
if not isinstance(x, int):
|
|
|
|
return False
|
2020-11-13 14:53:21 +00:00
|
|
|
return self.min <= x <= self.max
|
2020-07-14 10:15:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
class PathSchema:
|
|
|
|
"""General BIP-32 path schema.
|
|
|
|
|
|
|
|
Loosely based on the BIP-32 path template proposal [1].
|
|
|
|
|
|
|
|
Each path component can be one of the following:
|
|
|
|
- constant, e.g., `7`
|
|
|
|
- list of constants, e.g., `[1,2,3]`
|
|
|
|
- range, e.g., `[0-19]`
|
|
|
|
|
|
|
|
Brackets are recommended but not enforced.
|
|
|
|
|
|
|
|
The following substitutions are available:
|
|
|
|
- `coin_type` is substituted with the coin's SLIP-44 identifier
|
|
|
|
- `account` is substituted with `[0-100]`, Trezor's default range of accounts
|
|
|
|
- `change` is substituted with `[0,1]`
|
|
|
|
- `address_index` is substituted with `[0-1000000]`, Trezor's default range of
|
|
|
|
addresses
|
|
|
|
|
|
|
|
Hardened flag is indicated by an apostrophe and applies to the whole path component.
|
|
|
|
It is impossible to specify both hardened and non-hardened values for the same
|
|
|
|
component.
|
|
|
|
|
|
|
|
See examples of valid path formats below and in `apps.bitcoin.keychain`.
|
|
|
|
|
|
|
|
E.g. the following are equivalent definitions of a BIP-84 schema:
|
|
|
|
|
|
|
|
m/84'/coin_type'/[0-100]'/[0,1]/[0-1000000]
|
|
|
|
m/84'/coin_type'/0-100'/0,1/0-1000000
|
|
|
|
m/84'/coin_type'/account'/change/address_index
|
|
|
|
|
|
|
|
Adding an asterisk at the end of the pattern acts as a wildcard for zero or more
|
|
|
|
path components:
|
|
|
|
- m/* can be followed by any number of _unhardened_ path components
|
|
|
|
- m/*' can be followed by any number of _hardened_ path components
|
|
|
|
- m/** can be followed by any number of _any_ path components
|
|
|
|
|
|
|
|
The following is a BIP-44 generic `GetPublicKey` schema:
|
|
|
|
|
|
|
|
m/44'/coin_type'/account'/*
|
|
|
|
|
|
|
|
The asterisk expression can only appear at end of pattern.
|
|
|
|
|
|
|
|
[1] https://github.com/dgpv/bip32_template_parse_tplaplus_spec/blob/master/bip-path-templates.mediawiki
|
|
|
|
"""
|
|
|
|
|
|
|
|
REPLACEMENTS = {
|
|
|
|
"account": "0-100",
|
|
|
|
"change": "0,1",
|
|
|
|
"address_index": "0-1000000",
|
|
|
|
}
|
|
|
|
|
|
|
|
WILDCARD_RANGES = {
|
2020-11-13 14:53:21 +00:00
|
|
|
"*": Interval(0, HARDENED - 1),
|
|
|
|
"*'": Interval(HARDENED, 0xFFFF_FFFF),
|
|
|
|
"**": Interval(0, 0xFFFF_FFFF),
|
2020-07-14 10:15:18 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 15:32:55 +00:00
|
|
|
_EMPTY_TUPLE = ()
|
|
|
|
|
|
|
|
@staticmethod
|
2021-12-08 09:10:58 +00:00
|
|
|
def _parse_hardened(s: str | int) -> int:
|
2021-03-19 15:32:55 +00:00
|
|
|
return int(s) | HARDENED
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _copy_container(container: Container[int]) -> Container[int]:
|
2021-05-05 10:27:21 +00:00
|
|
|
# On hardware, hardened indices do not fit into smallint.
|
|
|
|
# The n+0 operation ensures that a new instance of a longint is created.
|
2021-03-19 15:32:55 +00:00
|
|
|
if isinstance(container, Interval):
|
2021-05-05 10:27:21 +00:00
|
|
|
return Interval(container.min + 0, container.max + 0)
|
2021-03-19 15:32:55 +00:00
|
|
|
if isinstance(container, set):
|
2021-05-05 10:27:21 +00:00
|
|
|
return set(i + 0 for i in container)
|
2021-03-19 15:32:55 +00:00
|
|
|
if isinstance(container, tuple):
|
2021-05-05 10:27:21 +00:00
|
|
|
return tuple(i + 0 for i in container)
|
2021-03-19 15:32:55 +00:00
|
|
|
raise RuntimeError("Unsupported container for copy")
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
schema: list[Container[int]],
|
|
|
|
trailing_components: Container[int] = (),
|
|
|
|
compact: bool = False,
|
|
|
|
) -> None:
|
|
|
|
"""Create a new PathSchema from a list of containers and trailing components.
|
|
|
|
|
|
|
|
Mainly for internal use in `PathSchema.parse`, which is the method you should
|
|
|
|
be using.
|
|
|
|
|
|
|
|
Can be used to create a schema manually without parsing a path string:
|
|
|
|
|
|
|
|
>>> SCHEMA_MINE = PathSchema([
|
|
|
|
>>> (44 | HARDENED,),
|
|
|
|
>>> (0 | HARDENED,),
|
|
|
|
>>> Interval(0 | HARDENED, 10 | HARDENED),
|
|
|
|
>>> ],
|
|
|
|
>>> trailing_components=Interval(0, 0xFFFF_FFFF),
|
|
|
|
>>> )
|
|
|
|
|
|
|
|
Setting `compact=True` creates a compact copy of the provided components, so
|
|
|
|
as to prevent memory fragmentation.
|
|
|
|
"""
|
|
|
|
if compact:
|
|
|
|
self.schema: list[Container[int]] = [self._EMPTY_TUPLE] * len(schema)
|
|
|
|
for i in range(len(schema)):
|
|
|
|
self.schema[i] = self._copy_container(schema[i])
|
|
|
|
self.trailing_components = self._copy_container(trailing_components)
|
|
|
|
|
|
|
|
else:
|
|
|
|
self.schema = schema
|
|
|
|
self.trailing_components = trailing_components
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def parse(cls, pattern: str, slip44_id: int | Iterable[int]) -> "PathSchema":
|
|
|
|
"""Parse a path schema string into a PathSchema instance.
|
|
|
|
|
|
|
|
The parsing process trashes the memory layout, so at the end a compact-allocated
|
|
|
|
copy of the resulting structures is returned.
|
|
|
|
"""
|
2020-07-14 10:15:18 +00:00
|
|
|
if not pattern.startswith("m/"):
|
|
|
|
raise ValueError # unsupported path template
|
|
|
|
components = pattern[2:].split("/")
|
|
|
|
|
|
|
|
if isinstance(slip44_id, int):
|
|
|
|
slip44_id = (slip44_id,)
|
|
|
|
|
2021-03-19 15:32:55 +00:00
|
|
|
schema: list[Container[int]] = []
|
|
|
|
trailing_components: Container[int] = ()
|
2020-07-14 10:15:18 +00:00
|
|
|
|
|
|
|
for component in components:
|
2021-03-19 15:32:55 +00:00
|
|
|
if component in cls.WILDCARD_RANGES:
|
|
|
|
if len(schema) != len(components) - 1:
|
|
|
|
# every component should have resulted in extending schema
|
|
|
|
# so if schema does not have the appropriate length (yet),
|
2020-07-14 10:15:18 +00:00
|
|
|
# the asterisk is not the last item
|
|
|
|
raise ValueError # asterisk is not last item of pattern
|
|
|
|
|
2021-03-19 15:32:55 +00:00
|
|
|
trailing_components = cls.WILDCARD_RANGES[component]
|
2020-07-14 10:15:18 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
# figure out if the component is hardened
|
|
|
|
if component[-1] == "'":
|
|
|
|
component = component[:-1]
|
2021-03-19 15:32:55 +00:00
|
|
|
parse: Callable[[Any], int] = cls._parse_hardened
|
2020-07-14 10:15:18 +00:00
|
|
|
else:
|
|
|
|
parse = int
|
|
|
|
|
|
|
|
# strip brackets
|
|
|
|
if component[0] == "[" and component[-1] == "]":
|
|
|
|
component = component[1:-1]
|
|
|
|
|
|
|
|
# optionally replace a keyword
|
2021-03-19 15:32:55 +00:00
|
|
|
component = cls.REPLACEMENTS.get(component, component)
|
2022-09-19 09:17:36 +00:00
|
|
|
append = schema.append # local_cache_attribute
|
2020-07-14 10:15:18 +00:00
|
|
|
|
|
|
|
if "-" in component:
|
|
|
|
# parse as a range
|
|
|
|
a, b = [parse(s) for s in component.split("-", 1)]
|
2022-09-19 09:17:36 +00:00
|
|
|
append(Interval(a, b))
|
2020-07-14 10:15:18 +00:00
|
|
|
|
|
|
|
elif "," in component:
|
|
|
|
# parse as a list of values
|
2022-09-19 09:17:36 +00:00
|
|
|
append(set(parse(s) for s in component.split(",")))
|
2020-07-14 10:15:18 +00:00
|
|
|
|
|
|
|
elif component == "coin_type":
|
|
|
|
# substitute SLIP-44 ids
|
2022-09-19 09:17:36 +00:00
|
|
|
append(set(parse(s) for s in slip44_id))
|
2020-07-14 10:15:18 +00:00
|
|
|
|
|
|
|
else:
|
|
|
|
# plain constant
|
2022-09-19 09:17:36 +00:00
|
|
|
append((parse(component),))
|
2021-03-19 15:32:55 +00:00
|
|
|
|
|
|
|
return cls(schema, trailing_components, compact=True)
|
|
|
|
|
|
|
|
def copy(self) -> "PathSchema":
|
|
|
|
"""Create a compact copy of the schema.
|
|
|
|
|
|
|
|
Useful when creating multiple schemas in a row. The following code ensures
|
|
|
|
that the set of schemas is allocated in a contiguous block of memory:
|
|
|
|
|
|
|
|
>>> some_schemas = make_multiple_schemas()
|
|
|
|
>>> some_schemas = [s.copy() for s in some_schemas]
|
|
|
|
"""
|
|
|
|
return PathSchema(self.schema, self.trailing_components, compact=True)
|
2020-07-14 10:15:18 +00:00
|
|
|
|
|
|
|
def match(self, path: Bip32Path) -> bool:
|
|
|
|
# The path must not be _shorter_ than schema. It may be longer.
|
|
|
|
if len(path) < len(self.schema):
|
|
|
|
return False
|
|
|
|
|
|
|
|
path_iter = iter(path)
|
|
|
|
# iterate over length of schema, consuming path components
|
|
|
|
for expected in self.schema:
|
|
|
|
value = next(path_iter)
|
|
|
|
if value not in expected:
|
|
|
|
return False
|
|
|
|
|
|
|
|
# iterate over remaining path components
|
|
|
|
for value in path_iter:
|
|
|
|
if value not in self.trailing_components:
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
2022-06-03 09:41:44 +00:00
|
|
|
def set_never_matching(self) -> None:
|
|
|
|
"""Sets the schema to never match any paths."""
|
|
|
|
self.schema = []
|
|
|
|
self.trailing_components = self._EMPTY_TUPLE
|
|
|
|
|
|
|
|
def restrict(self, path: Bip32Path) -> bool:
|
|
|
|
"""
|
|
|
|
Restricts the schema to patterns that are prefixed by the specified
|
|
|
|
path. If the restriction results in a never-matching schema, then False
|
|
|
|
is returned.
|
|
|
|
"""
|
2022-09-19 09:17:36 +00:00
|
|
|
schema = self.schema # local_cache_attribute
|
2022-06-03 09:41:44 +00:00
|
|
|
|
|
|
|
for i, value in enumerate(path):
|
2022-09-19 09:17:36 +00:00
|
|
|
if i < len(schema):
|
2022-06-03 09:41:44 +00:00
|
|
|
# Ensure that the path is a prefix of the schema.
|
2022-09-19 09:17:36 +00:00
|
|
|
if value not in schema[i]:
|
2022-06-03 09:41:44 +00:00
|
|
|
self.set_never_matching()
|
|
|
|
return False
|
|
|
|
|
|
|
|
# Restrict the schema component if there are multiple choices.
|
2022-09-19 09:17:36 +00:00
|
|
|
component = schema[i]
|
2022-06-03 09:41:44 +00:00
|
|
|
if not isinstance(component, tuple) or len(component) != 1:
|
2022-09-19 09:17:36 +00:00
|
|
|
schema[i] = (value,)
|
2022-06-03 09:41:44 +00:00
|
|
|
else:
|
|
|
|
# The path is longer than the schema. We need to restrict the
|
|
|
|
# trailing components.
|
|
|
|
|
|
|
|
if value not in self.trailing_components:
|
|
|
|
self.set_never_matching()
|
|
|
|
return False
|
|
|
|
|
2022-09-19 09:17:36 +00:00
|
|
|
schema.append((value,))
|
2022-06-03 09:41:44 +00:00
|
|
|
|
|
|
|
return True
|
|
|
|
|
2020-07-14 10:15:18 +00:00
|
|
|
if __debug__:
|
|
|
|
|
|
|
|
def __repr__(self) -> str:
|
|
|
|
components = ["m"]
|
2022-09-19 09:17:36 +00:00
|
|
|
append = components.append # local_cache_attribute
|
2020-07-14 10:15:18 +00:00
|
|
|
|
|
|
|
for component in self.schema:
|
2020-11-13 14:53:21 +00:00
|
|
|
if isinstance(component, Interval):
|
|
|
|
a, b = component.min, component.max
|
2021-10-13 13:45:53 +00:00
|
|
|
prime = "'" if a & HARDENED else ""
|
2022-09-19 09:17:36 +00:00
|
|
|
append(f"[{unharden(a)}-{unharden(b)}]{prime}")
|
2020-07-14 10:15:18 +00:00
|
|
|
else:
|
2021-12-08 09:10:58 +00:00
|
|
|
# typechecker thinks component is a Contanier but we're using it
|
|
|
|
# as a Collection.
|
2020-11-13 14:53:21 +00:00
|
|
|
# Which in practice it is, the only non-Collection is Interval.
|
|
|
|
# But we're not going to introduce an additional type requirement
|
|
|
|
# for the sake of __repr__ that doesn't exist in production anyway
|
2022-03-01 12:55:58 +00:00
|
|
|
collection: Collection[int] = component # type: ignore [Expression of type "Container[int]" cannot be assigned to declared type "Collection[int]"]
|
2020-11-13 14:53:21 +00:00
|
|
|
component_str = ",".join(str(unharden(i)) for i in collection)
|
|
|
|
if len(collection) > 1:
|
2020-07-14 10:15:18 +00:00
|
|
|
component_str = "[" + component_str + "]"
|
2020-11-13 14:53:21 +00:00
|
|
|
if next(iter(collection)) & HARDENED:
|
2020-07-14 10:15:18 +00:00
|
|
|
component_str += "'"
|
2022-09-19 09:17:36 +00:00
|
|
|
append(component_str)
|
2020-07-14 10:15:18 +00:00
|
|
|
|
|
|
|
if self.trailing_components:
|
|
|
|
for key, val in self.WILDCARD_RANGES.items():
|
|
|
|
if self.trailing_components is val:
|
2022-09-19 09:17:36 +00:00
|
|
|
append(key)
|
2020-07-14 10:15:18 +00:00
|
|
|
break
|
|
|
|
else:
|
2022-09-19 09:17:36 +00:00
|
|
|
append("???")
|
2020-07-14 10:15:18 +00:00
|
|
|
|
|
|
|
return "<schema:" + "/".join(components) + ">"
|
|
|
|
|
|
|
|
|
2021-12-08 09:10:58 +00:00
|
|
|
class AlwaysMatchingSchema:
|
2020-07-14 10:15:18 +00:00
|
|
|
@staticmethod
|
|
|
|
def match(path: Bip32Path) -> bool:
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2020-11-04 10:49:38 +00:00
|
|
|
# BIP-44 for basic (legacy) Bitcoin accounts, and widely used for other currencies:
|
|
|
|
# https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
|
2020-07-14 10:15:18 +00:00
|
|
|
PATTERN_BIP44 = "m/44'/coin_type'/account'/change/address_index"
|
2020-11-04 10:49:38 +00:00
|
|
|
# BIP-44 public key export, starting at end of the hardened part
|
2020-07-14 10:15:18 +00:00
|
|
|
PATTERN_BIP44_PUBKEY = "m/44'/coin_type'/account'/*"
|
2020-11-04 10:49:38 +00:00
|
|
|
# SEP-0005 for non-UTXO-based currencies, defined by Stellar:
|
|
|
|
# https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md
|
2020-07-14 10:15:18 +00:00
|
|
|
PATTERN_SEP5 = "m/44'/coin_type'/account'"
|
2022-11-23 11:15:11 +00:00
|
|
|
# SEP-0005 Ledger Live legacy path
|
|
|
|
# https://github.com/trezor/trezor-firmware/issues/1749
|
|
|
|
PATTERN_SEP5_LEDGER_LIVE_LEGACY = "m/44'/coin_type'/0'/account"
|
2020-07-14 10:15:18 +00:00
|
|
|
|
2023-01-05 22:05:59 +00:00
|
|
|
PATTERN_CASA = "m/45'/coin_type/account/change/address_index"
|
|
|
|
|
2019-07-03 13:07:04 +00:00
|
|
|
|
|
|
|
async def validate_path(
|
2021-01-08 10:31:03 +00:00
|
|
|
keychain: KeychainValidatorType,
|
|
|
|
path: Bip32Path,
|
|
|
|
*additional_checks: bool,
|
2019-07-03 13:07:04 +00:00
|
|
|
) -> None:
|
core: refactor keychain to only support one curve at a time
also make a cleaner distinction between keychain, seed, path
This enables using `unsafe_prompts`, because with the original code, if
there was no namespace match, we wouldn't know which curve to use.
For ease of implementation, we use a LRU cache for derived keys,
instead of the original design "one cache entry per namespace".
SLIP21 is now treated completely separately, via `slip21_namespaces` and
`derive_slip21` method.
If more slip21-like things come in the future, we can instead hang them
on the keychain: put a per-curve Keychain object accessible by
`keychain[curve_name].derive()`, and the majority usecase will just pass
around `keychain[curve_name]` instead of having to specify the curve in
every `derive()` call.
Or alternately we'll just specify the curve in every `derive()` call,
whichever seems more appropriate.
2020-07-14 10:15:05 +00:00
|
|
|
keychain.verify_path(path)
|
2020-07-14 10:15:18 +00:00
|
|
|
if not keychain.is_in_keychain(path) or not all(additional_checks):
|
2023-06-26 11:42:10 +00:00
|
|
|
await show_path_warning(path)
|
2018-08-30 11:45:09 +00:00
|
|
|
|
|
|
|
|
2023-06-26 11:42:10 +00:00
|
|
|
async def show_path_warning(path: Bip32Path) -> None:
|
2021-04-16 11:01:09 +00:00
|
|
|
from trezor.ui.layouts import confirm_path_warning
|
|
|
|
|
2023-06-26 11:42:10 +00:00
|
|
|
await confirm_path_warning(address_n_to_str(path))
|
2018-08-30 11:45:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
def is_hardened(i: int) -> bool:
|
2020-04-20 09:37:09 +00:00
|
|
|
return bool(i & HARDENED)
|
2018-08-30 11:45:09 +00:00
|
|
|
|
|
|
|
|
core: refactor keychain to only support one curve at a time
also make a cleaner distinction between keychain, seed, path
This enables using `unsafe_prompts`, because with the original code, if
there was no namespace match, we wouldn't know which curve to use.
For ease of implementation, we use a LRU cache for derived keys,
instead of the original design "one cache entry per namespace".
SLIP21 is now treated completely separately, via `slip21_namespaces` and
`derive_slip21` method.
If more slip21-like things come in the future, we can instead hang them
on the keychain: put a per-curve Keychain object accessible by
`keychain[curve_name].derive()`, and the majority usecase will just pass
around `keychain[curve_name]` instead of having to specify the curve in
every `derive()` call.
Or alternately we'll just specify the curve in every `derive()` call,
whichever seems more appropriate.
2020-07-14 10:15:05 +00:00
|
|
|
def path_is_hardened(address_n: Bip32Path) -> bool:
|
|
|
|
return all(is_hardened(n) for n in address_n)
|
2021-03-23 12:29:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
def address_n_to_str(address_n: Iterable[int]) -> str:
|
2022-09-19 09:17:36 +00:00
|
|
|
def _path_item(i: int) -> str:
|
2021-03-23 12:29:25 +00:00
|
|
|
if i & HARDENED:
|
|
|
|
return str(i ^ HARDENED) + "'"
|
|
|
|
else:
|
|
|
|
return str(i)
|
|
|
|
|
|
|
|
if not address_n:
|
|
|
|
return "m"
|
|
|
|
|
2022-09-19 09:17:36 +00:00
|
|
|
return "m/" + "/".join(_path_item(i) for i in address_n)
|
2022-11-25 20:09:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
def unharden(item: int) -> int:
|
|
|
|
return item ^ (item & HARDENED)
|