Skip to content
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

workflow/mnemonic: generalize lastword_choices to 12/18/24 words #1068

Merged
merged 5 commits into from
Nov 3, 2023

Conversation

benma
Copy link
Collaborator

@benma benma commented May 18, 2023

The function computed all 8 possible 24th candidate words to make up a valid bip39 mnemonic given the first 23 words.

The function is extended to also work with 12 and 18 word mnemonics, returning 128 (resp. 32) possible candidates for the final word.

This function can then be used to make the entry of the final word easier for the 12th/18th word by restricting the keyboard to only allow entering from these candidates. This also allows easily importing seeds that were made without computers by rolling dices or similar, helping with the checksum issue, like we do now for 24 word mnemonics.

@benma benma force-pushed the select-12th branch 2 times, most recently from 82a34bf to 37c844c Compare May 18, 2023 10:58
@charlespax
Copy link

I'm must here to show my support for this feature.

@benma benma force-pushed the select-12th branch 6 times, most recently from 727216e to 22c2dd1 Compare November 1, 2023 14:35
@benma benma marked this pull request as ready for review November 1, 2023 14:38
Copy link
Collaborator

@asi345 asi345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a problem with the implementation, but there are a few suggestions about the comments and messages.
tACK 👍

src/rust/bitbox02-rust/src/workflow/mnemonic.rs Outdated Show resolved Hide resolved
Ok(choice_idx) if choice_idx as usize == none_of_them_idx => {
let params = confirm::Params {
title: "",
body: "Recovery words\ninvalid.\nRestart?",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more explanatory warning here could be preferable. One recommendation we discussed with Jad was Invalid. Check\recovery words.\nRestart?

benma added 5 commits November 3, 2023 06:50
Was quite hard to read as it was such a big function.
The function computed all 8 possible 24th candidate words to make up a
valid bip39 mnemonic given the first 23 words.

The function is extended to also work with 12 and 18 word mnemonics,
returning 128 (resp. 32) possible candidates for the final word.

This function can then be used to make the entry of the final word
easier for the 12th/18th word by restricting the keyboard to only
allow entering from these candidates. This also allows easily
importing seeds that were made without computers by rolling dices or
similar, helping with the checksum issue, like we do now for 24 word
mnemonics.
This will allow to set the autocomplete keyboard to a subset of the
BIP39 wordlist to allow entering the last word of a 12/18 word
mnemonic using the keyboard, similar to how the 24th word can be
entered using a menu.

The keyboard is needed for 12/18 words as there are too many
candidates to show in a simple menu.
So far we've only been doing this for 24 words, where there are 8 list
of valid candidate, so they could be shown in a menu.

We do the same for 12/18 words, but since there are many more
candidates (128 for 12 words, 32 for 18 words), we restrict the
trinary keyboard entry to this list instead of showing them all in a
menu.

This allows easily importing seeds that were made without computers by
rolling dices or similar, helping with the checksum issue, like we do
now for 24 word mnemonics.

One downside is that if the user has a typo in the previous words,
they will be unable to enter the last word as it will be missing from
the candidates, which could be confusing. With 24 words, there is an
explicit "None of them" entry to tell the user that their words are
invalid, but that only works in the menu. With the 12th/18th word
still using the keyboard, there is no good way of doing this.
@benma benma merged commit b64ba9a into BitBoxSwiss:master Nov 3, 2023
1 check passed
@benma benma deleted the select-12th branch November 3, 2023 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants