Limit bip39 mnemonic#63
Conversation
|
For an absurd example at the limit of what would currently be "valid": a 768 word mnemonic would have checksum as the last 24 words and would be encoding 8192 bits of entropy. Beyond that, current implementation would have problems w/ checksum, would not encode/decode and would not be valid. from embit import bip39
bits8192 = b"\x00" * 1024
assert len(bits8192) == 1024
words768 = bip39.mnemonic_from_bytes(bits8192)
assert len(words768.split()) == 768
assert bip39.mnemonic_is_valid(words768)
assert bip39.mnemonic_to_bytes(words768) == bits8192 |
|
ACK, I think this should target develop and be merged. |
|
Can you do a duplicated PR with same commit to |
|
About duplicated PR, it's no needed, as I was able to cherry-pick the 2 commits from this PR directly on develop. |
|
The commits from this pull request have now been merged into Embit's develop branch. |
|
|
|
Hey @jdlcdl we are maintaining the PRs opened to master to know the features/additions that now exists on develop |
|
I was attempting to review and test this PR to help get it merged. However I am unable to get the new test added in this PR to pass. |
Are you sure you are not testing against master branch? I just checked with this branch both in micropython and pytest - tests pass. |
ACK - Here pytests passed ⬆️ , could not test micropython yet |
|
Merged to main |
Purpose
To limit embit.bip39's mnemonic length to 24 words, entropy length to 128 - 256 bits, as defined in:
https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#generating-the-mnemonic
Changes
This pull-request changes:
Note: while this could break 3rd party apps that previously exploited this "feature", calling
mnemonic_to_seed()withwordlist=Nonewould still allow recovery of bip32 wallets from non-standard bip39 mnemonics. Only encoding/decoding and their internal validation of input length has changed.Example of non-standard embit.bip39 mis-use
Not that anyone should actually use embit.bip39 in the following manner, but so that they cannot --
unless it is intended that the following code snippet succeed: