1
0

bip32: change hardened char "'"->"h" when encoding derivation paths

We accept either when decoding - this only changes what we use when encoding.
Single quotes are annoying to use in a shell, as they often need to be escaped.
This commit is contained in:
SomberNight
2023-02-13 05:51:53 +00:00
parent 2b0e624876
commit df2bd61de6
3 changed files with 15 additions and 13 deletions

View File

@@ -17,6 +17,8 @@ _logger = get_logger(__name__)
BIP32_PRIME = 0x80000000
UINT32_MAX = (1 << 32) - 1
BIP32_HARDENED_CHAR = "h" # default "hardened" char we put in str paths
def protect_against_invalid_ecpoint(func):
def func_wrapper(*args):
@@ -345,7 +347,7 @@ def convert_bip32_intpath_to_strpath(path: Sequence[int]) -> str:
raise ValueError(f"bip32 path child index out of range: {child_index}")
prime = ""
if child_index & BIP32_PRIME:
prime = "'"
prime = BIP32_HARDENED_CHAR
child_index = child_index ^ BIP32_PRIME
s += str(child_index) + prime + '/'
# cut trailing "/"