-
Couldn't load subscription status.
- Fork 165
Add SLIP-39 mnemonic and seed support #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
4518382 to
1a2261d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved.
c352070 to
a567114
Compare
|
Sorry, @axiom90! I pushed another enhancement to the SLIP39Mnemonic.decode and .decode, to support human-readable SLIP-39 Mnemonics via tabulate. It's difficult for humans to reliably parse these huge sets of Mnemonics, so this gives output in a readable Human form, that also parses reliably for recovery. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, Re-approved.
|
OK, thanks! There are still issues with the way Mnemonics are handled; BIP-39 mnemonics with accents (such as 'déclarer') are not handled correctly. Also, determining language from a set of mnemonics is not deterministic. I'm working through these issues right now, so don't merge this yet... |
o Re-order languages in rough probability for increased speed o Support wordlist_path with filename or mnemonic word list
0bd1c51 to
109dc2e
Compare
|
OK, @meherett @axiom90 -- this is ready to take a look at. The fundamental problem, is that Mnemonic languages are not deterministic, especially when accents and other letter UTF-8 "Marks" are ignored; generally required by all Mnemonic parsers. And, when abbreviations are allowed, it's even worse. Thus, it is quite easy to come up with entropy that decodes to a Mnemonic phrase that is valid in english AND french; if you then decode that Mnemonic to try to recover the entropy (you originally asked for the french Mnemonic), you can end up with the wrong seed (decoded as English)! So, I've improved the mnemonic APIs to support a preferred language for decoding the Mnemonic. This leaked into many parts of the code, unfortunately. As part of this fix -- I've also implemented hdwallet.imnemonic.WordIndices; a Trie-based Mnemonic decoder that supports abbreviations and optional accents. It looks a lot like a simple {'word': } dictionary, but also supports the reverse mapping {: 'word'}, and supports indexing by unambiguous abbreviations. This allowed me to implement IMnemonic.collect -- you give it a list of languages, and it produces a Generator that computes the remaining language(s) that are possible, and all of the "Next" characters that are valid for the mnemonic word in those languages. See tests/test_bip39_cross_language.py, test_bip39_collection. Anyway, take a look. This pull might need some more documentation updates before acceptance. |
109dc2e to
2a3adb4
Compare
|
Well, I found another pretty much intractable issue with the current implementation of Mnemonic language deduction and decoding. You just cannot separate langage deduction from decoding.
So, this now implements full multi-language IMnemonic.decode across all of the implemented mnemonic types. If multiple languages might look valid, the .decode will attempt them all, and ensure that exactly one language correctly decodes the Mnemonic, failing if none do, or if multiple languages correctly decode it -- unless a preferred language is specified. |
Adds SLIP-39 (Shamir's Secret Sharing) mnemonic and seed support to python-hdwallet:
Benefits
Test Plan