refactor(core): simplify passphrase eye hint code
What changed, and why it matters
This is a small user-interface cleanup in the Trezor hardware wallet firmware. It simplifies how the 'eye' hint icon is drawn when the user is typing a passphrase, and removes an extra safety margin that reserved space for a wide last character. There is no indication this change affects security, cryptography, or how secrets are handled.
No security action required. Treat as a normal UI refactor during routine review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors passphrase input rendering in two UI layouts (Bolt and Eckhart). In Bolt, it drops a special-case width reserve for the widest possible last character (‘MW@%’) and instead uses a simpler asterisk-based fit calculation. In Eckhart, it removes local constants for the eye icon and references the theme icon directly. The change is purely cosmetic/layout and reduces code complexity; it does not alter input handling, storage, or cryptographic operations.
Changed components
core/embed/rust/src/ui/layout_bolt/component/keyboard/passphrase.rscore/embed/rust/src/ui/layout_eckhart/firmware/keyboard/passphrase.rsInspect captured patch +4 / −12
### core/embed/rust/src/ui/layout_bolt/component/keyboard/passphrase.rs
@@ -474,16 +474,10 @@ impl Input {
// Compute how many characters fit in the available width. The characters
// are centered, so the eye icon margin is kept free on both sides. Account
// for the pending marker, which draws itself one pixel longer than the last
- // char, for the overflow twitch, and for a last char wider than an asterisk.
+ // char, and for the overflow twitch.
let available_width = self.area.width() - 2 * Self::TEXT_MARGIN - Self::TWITCH - 1;
let asterisk_width = style.text_font.char_width('*').max(1);
- let last_char_width = "MW@%"
- .chars()
- .map(|c| style.text_font.char_width(c))
- .max()
- .unwrap_or(asterisk_width);
- let max_visible =
- ((available_width - last_char_width) / asterisk_width + 1).max(1) as usize;
+ let max_visible = (available_width / asterisk_width).max(1) as usize;
let visible_count = pp_len.min(max_visible);
let asterisk_count = visible_count.saturating_sub(last_char_visible.into());
### core/embed/rust/src/ui/layout_eckhart/firmware/keyboard/passphrase.rs
@@ -39,8 +39,6 @@ impl PassphraseInput {
const ICON: Icon = theme::ICON_DASH_VERTICAL;
const ICON_WIDTH: i16 = Self::ICON.toif.width();
const ICON_SPACE: i16 = 12;
- const EYE_ICON: Icon = theme::ICON_EYE;
- const EYE_ICON_WIDTH: i16 = Self::EYE_ICON.toif.width();
const EYE_ICON_SPACE: i16 = 24;
/// Distance the eye icon travels when sliding in, starting off the screen
const EYE_ICON_SLIDE: i16 = 48;
@@ -135,14 +133,14 @@ impl PassphraseInput {
EyeHintAnimation::offset(self.eye_hint.icon_progress(), Self::EYE_ICON_SLIDE);
ToifImage::new(
hidden_area.left_center().ofs(Offset::x(eye_offset)),
- Self::EYE_ICON.toif,
+ theme::ICON_EYE.toif,
)
.with_align(Alignment2D::CENTER_LEFT)
.with_fg(theme::GREY_LIGHT)
.render(target);
}
- let dashes_offset = Self::EYE_ICON_WIDTH
+ let dashes_offset = theme::ICON_EYE.toif.width()
+ Self::EYE_ICON_SPACE
+ EyeHintAnimation::offset(self.eye_hint.content_progress(), Self::DASHES_SLIDE);
let mut cursor = hidden_area.left_center().ofs(Offset::x(dashes_offset));Why this scored 14/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.