Allow 4-character abbreviations for mnemonic when using the existing-mnemonic workflow#242
Allow 4-character abbreviations for mnemonic when using the existing-mnemonic workflow#242CarlBeek merged 7 commits intoethereum:devfrom yorickdowne:abbreviations
Conversation
|
Thanks for the PR @yorickdowne, very cool! 🦏 This will be especially useful to have implemented as people need to generate their withdrawal keys when withdrawals become possible soon (tm). Some things:
|
Of all these, I like b'') best. It addresses the issue narrowly while keeping the existing UX intact for the vast majority of cases - possibly even all cases. |
|
|
I opened another PR (https://github.com/yorickdowne/eth2.0-deposit-cli/pull/2) against this branch to address the last few things I'd like to get done before merging this PR.
|
CarlBeek
left a comment
There was a problem hiding this comment.
Thanks for all the work & changes @yorickdowne!
For those wondering, the last force-push was a rebase onto dev
Allow 4-character abbreviations for mnemonic when using the existing-mnemonic workflow
This addresses #167
Rationale: Users may store their mnemonic in steel to protect against loss. Steel tablets record the first four characters of each word, not the full words. To recover keys, it is desirable that deposit-cli allow the use of 4-character abbreviations.
Previously submitted as #168 and now re-submitted to a) have a better git workflow and not use the
masterbranch directly and b) have a clean history of the PR.All tests run by
python3 -m pytest .pass.The core of this change is in
staking_deposit/key_handling/key_derivation/mnemonic.py.Choices made:
To get abbreviations from the word list, I normalize to 'NFKC' and slice to 4 characters or less. This specific normalization was chosen so that combining Unicode characters work and the string doesn't get sliced to 3 visible characters.
I am using a nested
forlist comprehension that compares the full word language map against abbreviations, then flatten the resulting 2D list again. If there's a more elegant way of doing this, please share!Because abbreviations can match several languages, and then merely fail the checksum, I am continuing the search through the languages when a checksum fails.
The
new-mnemonicworkflow has not been touched and still does a straight compare. Allowing abbreviations during the verification step in that workflow would be a different PR.