ElementsProject / libwally-core

Useful primitives for wallets
Other
282 stars 135 forks source link

Support use of abbreviated 4-letter BIP39 words #89

Open gwillen opened 5 years ago

gwillen commented 5 years ago

The BIP39 wordlists are selected so that the first 4 letters of each word are unique. The functions for working with mnemonics should accept them in that form, and expand them to the full words.

This is important because tools like the CryptoSteel / BillFodl metal key storage devices only accept the first four letters of each word, and making the user hand-expand that back to the whole word is painful and unnecessary.

Screwing around with the input in this way playing guess-what-I-mean is fine because of the checksum. As long as the checksum passes, we know we performed the correct expansion. (In light of this I think we should also offer user-friendly things like automatic casefolding to the same case as the dictionary. All of this should only be triggered after trying the entered string as-is and failing the checksum in that form.)

greenaddress commented 5 years ago

@gwillen what are the pros/cons handling this at the GUI/app layer rather than at the wally layer?

Our mobile apps already suggest the right word at 4 characters or less depending on the word and i think you still need to keep the full dictionary to show it to the user to generate mnemonic etc

I am not against adding it though

gwillen commented 5 years ago

We are using the wally layer to create python commandline tools. So we don't have any way to take advantage of autocomplete and such happening at higher layers. If there's another good approach for commandline tools I'm all ears!

gwillen commented 5 years ago

(If the answer is that we should implement this in the tool, I don't disagree although it would be nice to get the benefit of all Wally's existing support for wordlists and such. Realistically this tool will probably never be used with anything other than the fixed BIP39 English wordlist, but I though more general support seemed likely to be useful.)

greenaddress commented 5 years ago

makes sense - if it's done in wally then it can be reused in all lib/apps/cli/gui so happy to review PRs or anyhow add it to the features wishlist

mword commented 5 years ago

Just add a PR regarding this issue for your perusal.