trezor / python-mnemonic

:snake: Mnemonic code for generating deterministic keys, BIP39
https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
MIT License
843 stars 372 forks source link

Use the normalize_string function when reading mnemonic words #122

Closed nglsena0722 closed 10 months ago

nglsena0722 commented 10 months ago

I created a mnemonic word using the to_mnemonic function of the module you created. However, I entered the mnemonic word as a parameter of the to_entropy function to regenerate a private key again later, but got a ValueError: myword is not in list.

As it turns out, the environment in which I type the mnemonic words used NFC method, and the module you created used the word in the NFKD method. Therefore, when reading the word in the to_entropy function, I suggest that it is always normalized with the NFKD method through the normalize_string function.

Thanks for reading this.

prusnak commented 10 months ago

@matejcik what do you think? Should we do this or is it a caller's responsibility to provide a valid NFKD input?

matejcik commented 10 months ago

check() and to_seed() also do it so it seems consistent to do it here too