Add support for abbreviated bip39 mnemonic elements#91
Add support for abbreviated bip39 mnemonic elements#91mword wants to merge 1 commit intoElementsProject:masterfrom
Conversation
20f77ef to
3e0a46b
Compare
|
Rather than changing the current code, I think it would be best if all we did was adding a new function that, provided a 4 characters words, returns the matching full word - then users of wally can easily convert from the short form to the full form. |
|
@greenaddress I can see a were a tool to convert short-form to full-form mnemonic strings might be useful but the two step process of 1. converting short-form to full-form string and then 2. doing full word string compares on the full words seems unnecessarily inefficient (as opposed to just 1. doing 4 character compares on any-form mnemonic. Maybe I'm missing something? Also, with the changes I made, to get a full-form mnemonic string from a short-form string one need only do a Your call. |
3e0a46b to
3d3c092
Compare
|
@greenaddress I have a counterproposal -- can we add a "unique_prefix" flag to wordlist_lookup_word, default false, which enables the following behavior: if there is exactly one word in the wordlist with "word" as a prefix, return that word, otherwise fail. (Alternatively this could be a new wordlist_lookup_word_unique_prefix function.) Then add the same flag to mnemonic_to_bytes and pass it through. This doesn't require any special handling for unicode, doesn't require hardcoding the four-character prefix rule for bip39 wordlists (but works with any correct use of four-letter truncated mnemonics), and generally does exactly what we want with minimal changes. |
Fix for utf8 multibyte characters
3d3c092 to
58b4f9a
Compare
Here's a simple set of changes that allow for the support of 4 (and greater) character bip39 mnemonic elements. It does this by implementing a uft8_strncmp() function that tries to account for utf8 multibyte characters (counting characters encoded in multiple bytes as a single character). Some characters are actually composed of two characters - for example in Hiragana (Japanese) sounds mark characters can be added to a preceding character - in which case only a single character should be counted. In any case, the utf8_strncmp() function should work on the character sets supported by libwally-core as of this PR but might need to be updated of other character sets are added.
One caveat with these changes is that it assumes that wordlist is only intended to handle 4 significant character words. If it's intended to be more general then the number of significant characters should be parameterized.
May resolve #89