fix: never offer the correct seed word twice when verifying - #62
Open
munzzyy wants to merge 1 commit into
Open
Conversation
The pick-the-correct-word screen built its options by taking 5 words off the top of a shuffled wordlist and then appending the answer, so whenever the answer was already among those 5 it was listed twice. The toSet() call meant to catch that threw its result away. The shuffle also ran on the caller's list rather than a copy, which permanently reordered Bip39.english for the rest of the session.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
VerifySeedViewModel.randomWordsbuilds the options for the pick-the-correct-word screen by taking 5 words off the top of a shuffled wordlist and then appending the answer. When the answer is already one of those 5 it ends up on the screen twice. Theelms.toSet()line that was meant to catch that throws its result away, so it never removed anything.The same closure shuffles
wordListin place instead of a copy.info_page.dartpassesBip39.englishstraight in, and that is a static list, so every seed verification permanently reorders the wordlist for the rest of the session.Repro
test/scratch_verify_seed_test.darton current main:Before:
After:
The 5-word list in the first test is what makes the duplicate deterministic. In the app it needs the answer to land in the five decoys, which is rare but not rare enough to leave alone.
With
Bip39.englishthe option count is unchanged. Three runs ofVerifySeedViewModel(seedWords: ['abandon', 'zoo', 'ability'], wordList: Bip39.english)after the fix:Notes
Ran on Flutter 3.32.0 per
.fvmrc, Dart 3.8.0, afterflutter pub getanddart run build_runner build.flutter analyzereports the same single pre-existinguse_build_context_synchronouslyinfo inunconfirmed_transaction.dartbefore and after, nothing new.One caveat on running the repro yourself: the view model imports reach
lib/coins/litecoin/wallet.dart, which importscw_mweb, so a hostflutter testwill not compile untilcw_mweb/lib/generated_bindings.g.dartexists. I stubbed the three symbolsmweb_ffi.dartreferences rather than build mwebd. Nothing on the path under test calls into them.The scratch test is not part of this PR since the repo has no
test/directory. Happy to add it if you want one.