What changed, and why it matters
This is a routine code cleanup: a small helper function for showing a word menu was moved and the old wrapper module was deleted. There is no security-relevant change visible in the diff.
No security action required. Review as normal refactoring if desired.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit inlines workflow::menu::pick() into the BitBox02Ui::menu() HAL implementation and removes the now-unused workflow::menu module. The function signature changes its error type alias from menu::CancelError to cancel::Error, but these are the same type (pub use super::cancel::Error as CancelError). Call sites in mnemonic.rs are updated accordingly. Behavior is unchanged: the same bitbox02::ui::menu C FFI call with identical parameters is made, and the same panic on unexpected ContinueOnLast and Cancel→Cancelled mapping is preserved.
Changed components
src/rust/bitbox02-rust/src/hal/bitbox02/ui.rssrc/rust/bitbox02-rust/src/hal/testing/ui.rssrc/rust/bitbox02-rust/src/hal/ui.rssrc/rust/bitbox02-rust/src/workflow.rssrc/rust/bitbox02-rust/src/workflow/menu.rssrc/rust/bitbox02-rust/src/workflow/mnemonic.rsInspect captured patch +22 / −33
diff --git a/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs b/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs
index 7a62208..02213d8 100644
--- a/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs
+++ b/src/rust/bitbox02-rust/src/hal/bitbox02/ui.rs
@@ -4,7 +4,7 @@ use alloc::string::String;
use crate::hal::Ui;
use crate::workflow::{
- cancel, confirm, menu, mnemonic, sdcard, transaction, trinary_choice, trinary_input_string,
+ cancel, confirm, mnemonic, sdcard, transaction, trinary_choice, trinary_input_string,
};
pub(crate) struct BitBox02Ui;
@@ -73,8 +73,20 @@ impl Ui for BitBox02Ui {
}
#[inline(always)]
- async fn menu(&mut self, words: &[&str], title: Option<&str>) -> Result<u8, menu::CancelError> {
- menu::pick(words, title).await
+ async fn menu(&mut self, words: &[&str], title: Option<&str>) -> Result<u8, cancel::Error> {
+ match bitbox02::ui::menu(bitbox02::ui::MenuParams {
+ words,
+ title,
+ select_word: true,
+ continue_on_last: false,
+ cancel_confirm_title: None,
+ })
+ .await
+ {
+ bitbox02::ui::MenuResponse::SelectWord(choice_idx) => Ok(choice_idx),
+ bitbox02::ui::MenuResponse::ContinueOnLast => panic!("unexpected continue-on-last"),
+ bitbox02::ui::MenuResponse::Cancel => Err(cancel::Error::Cancelled),
+ }
}
#[inline(always)]
diff --git a/src/rust/bitbox02-rust/src/hal/testing/ui.rs b/src/rust/bitbox02-rust/src/hal/testing/ui.rs
index 424aa1a..dbd0958 100644
--- a/src/rust/bitbox02-rust/src/hal/testing/ui.rs
+++ b/src/rust/bitbox02-rust/src/hal/testing/ui.rs
@@ -2,7 +2,7 @@
use crate::hal::Ui;
use crate::workflow::{
- cancel, confirm, menu, sdcard, transaction, trinary_choice, trinary_input_string,
+ cancel, confirm, sdcard, transaction, trinary_choice, trinary_input_string,
};
use alloc::boxed::Box;
@@ -136,7 +136,7 @@ impl Ui for TestingUi<'_> {
&mut self,
_words: &[&str],
_title: Option<&str>,
- ) -> Result<u8, menu::CancelError> {
+ ) -> Result<u8, cancel::Error> {
todo!("not used in unit tests yet");
}
diff --git a/src/rust/bitbox02-rust/src/hal/ui.rs b/src/rust/bitbox02-rust/src/hal/ui.rs
index ea0f7d3..12a9f97 100644
--- a/src/rust/bitbox02-rust/src/hal/ui.rs
+++ b/src/rust/bitbox02-rust/src/hal/ui.rs
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
-use crate::workflow::{
- cancel, confirm, menu, mnemonic, sdcard, transaction, trinary_choice, trinary_input_string,
-};
+use crate::workflow::{cancel, confirm, mnemonic, sdcard, transaction, trinary_choice, trinary_input_string};
use alloc::string::String;
@@ -38,7 +36,8 @@ pub trait Ui {
async fn insert_sdcard(&mut self) -> Result<(), sdcard::UserAbort>;
- async fn menu(&mut self, words: &[&str], title: Option<&str>) -> Result<u8, menu::CancelError>;
+ /// Returns the index of the word chosen by the user.
+ async fn menu(&mut self, words: &[&str], title: Option<&str>) -> Result<u8, cancel::Error>;
async fn trinary_choice(
&mut self,
diff --git a/src/rust/bitbox02-rust/src/workflow.rs b/src/rust/bitbox02-rust/src/workflow.rs
index bb81e7a..08edc24 100644
--- a/src/rust/bitbox02-rust/src/workflow.rs
+++ b/src/rust/bitbox02-rust/src/workflow.rs
@@ -2,7 +2,6 @@
pub mod cancel;
pub mod confirm;
-pub mod menu;
#[cfg_attr(
all(feature = "c-unit-testing", not(feature = "testing")),
path = "workflow/mnemonic_c_unit_tests.rs"
diff --git a/src/rust/bitbox02-rust/src/workflow/menu.rs b/src/rust/bitbox02-rust/src/workflow/menu.rs
deleted file mode 100644
index 25d21fd..0000000
--- a/src/rust/bitbox02-rust/src/workflow/menu.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-
-pub use super::cancel::Error as CancelError;
-
-/// Returns the index of the word chosen by the user.
-pub async fn pick(words: &[&str], title: Option<&str>) -> Result<u8, CancelError> {
- match bitbox02::ui::menu(bitbox02::ui::MenuParams {
- words,
- title,
- select_word: true,
- continue_on_last: false,
- cancel_confirm_title: None,
- })
- .await
- {
- bitbox02::ui::MenuResponse::SelectWord(choice_idx) => Ok(choice_idx),
- bitbox02::ui::MenuResponse::ContinueOnLast => panic!("unexpected continue-on-last"),
- bitbox02::ui::MenuResponse::Cancel => Err(CancelError::Cancelled),
- }
-}
diff --git a/src/rust/bitbox02-rust/src/workflow/mnemonic.rs b/src/rust/bitbox02-rust/src/workflow/mnemonic.rs
index 3615891..f5bfe5f 100644
--- a/src/rust/bitbox02-rust/src/workflow/mnemonic.rs
+++ b/src/rust/bitbox02-rust/src/workflow/mnemonic.rs
@@ -2,7 +2,6 @@
pub use super::cancel::Error as CancelError;
use super::confirm;
-use super::menu;
use super::trinary_choice::TrinaryChoice;
use super::trinary_input_string;
@@ -222,7 +221,7 @@ async fn get_24th_word(
};
loop {
match hal_ui.menu(&as_str_vec(&choices), Some(title)).await {
- Err(menu::CancelError::Cancelled) => return Err(CancelError::Cancelled),
+ Err(CancelError::Cancelled) => return Err(CancelError::Cancelled),
Ok(choice_idx) if choice_idx as usize == none_of_them_idx => {
let params = confirm::Params {
title: "",
@@ -373,7 +372,7 @@ pub async fn get(
.menu(&["Edit previous word", "Cancel restore"], Some("Choose"))
.await
{
- Err(menu::CancelError::Cancelled) => {
+ Err(CancelError::Cancelled) => {
// Cancel cancelled.
continue;
}
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.