rust/bitbox02/keystore: remove Bip39Wordlist
What changed, and why it matters
This commit is a routine code cleanup. It removes a thin Rust wrapper type called Bip39Wordlist and replaces it with direct use of a plain list of word indices. The behavior of the BIP39 wordlist used for entering recovery words on the device stays the same; no security vulnerability is introduced or fixed.
No security action needed; review as normal code-quality refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change deletes the Bip39Wordlist struct and get_bip39_wordlist() helper from src/rust/bitbox02/src/keystore.rs. Callers in mnemonic.rs now pass a Vec
Changed components
src/rust/bitbox02-rust/src/workflow/mnemonic.rssrc/rust/bitbox02/src/keystore.rssrc/rust/bitbox02/src/ui/types.rsInspect captured patch +4 / −28
diff --git a/src/rust/bitbox02-rust/src/workflow/mnemonic.rs b/src/rust/bitbox02-rust/src/workflow/mnemonic.rs
index 8997950..6ce340f 100644
--- a/src/rust/bitbox02-rust/src/workflow/mnemonic.rs
+++ b/src/rust/bitbox02-rust/src/workflow/mnemonic.rs
@@ -271,13 +271,12 @@ async fn get_12th_18th_word(
// these.
loop {
let choices = lastword_choices(entered_words);
- let candidates = bitbox02::keystore::get_bip39_wordlist(Some(&choices));
let word = hal
.ui()
.enter_string(
&trinary_input_string::Params {
title,
- wordlist: Some(&candidates),
+ wordlist: Some(&choices),
..Default::default()
},
trinary_input_string::CanCancel::Yes,
@@ -320,7 +319,7 @@ pub async fn get(
.await;
// Provide all bip39 words to restrict the keyboard entry.
- let bip39_wordlist = bitbox02::keystore::get_bip39_wordlist(None);
+ let bip39_wordlist: Vec<u16> = (0..bitbox02::keystore::BIP39_WORDLIST_LEN).collect();
let mut word_idx: usize = 0;
let mut entered_words = vec![zeroize::Zeroizing::new(String::new()); num_words];
diff --git a/src/rust/bitbox02/src/keystore.rs b/src/rust/bitbox02/src/keystore.rs
index 02d8281..434e002 100644
--- a/src/rust/bitbox02/src/keystore.rs
+++ b/src/rust/bitbox02/src/keystore.rs
@@ -168,29 +168,6 @@ pub fn get_bip39_word(idx: u16) -> Result<zeroize::Zeroizing<String>, ()> {
}
}
-/// An opaque C type which gives access to all BIP39 words.
-pub struct Bip39Wordlist(Vec<u16>);
-
-impl Bip39Wordlist {
- pub fn as_ptr(&self) -> *const u16 {
- self.0.as_ptr()
- }
-
- pub fn len(&self) -> usize {
- self.0.len()
- }
-}
-
-/// If indices is None, all BIP39 English words are returned, otherwise only the words of the given
-/// indices in the BIP39 English wordlist.
-pub fn get_bip39_wordlist(indices: Option<&[u16]>) -> Bip39Wordlist {
- let indices = match indices {
- Some(indices) => indices.to_vec(),
- None => (0..BIP39_WORDLIST_LEN).collect(),
- };
- Bip39Wordlist(indices)
-}
-
pub struct SignResult {
pub signature: [u8; 64],
pub recid: u8,
diff --git a/src/rust/bitbox02/src/ui/types.rs b/src/rust/bitbox02/src/ui/types.rs
index 5db7ff6..02a460e 100644
--- a/src/rust/bitbox02/src/ui/types.rs
+++ b/src/rust/bitbox02/src/ui/types.rs
@@ -100,8 +100,8 @@ impl<'a> ConfirmParams<'a> {
pub struct TrinaryInputStringParams<'a> {
/// The confirmation title of the screen. Max 200 chars, otherwise **panic**.
pub title: &'a str,
- /// Currently specialized to the BIP39 wordlist. Can be extended if needed.
- pub wordlist: Option<&'a crate::keystore::Bip39Wordlist>,
+ /// Currently specialized to the BIP39 wordlist: a list of BIP39 word indices. Can be extended if needed.
+ pub wordlist: Option<&'a [u16]>,
pub number_input: bool,
pub hide: bool,
pub special_chars: bool,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.