refactor(core): deterministic share word confirmation
What changed, and why it matters
This is a tiny code cleanup that changes how a list of backup words is prepared before being shown to the user. It adds sorting so automated UI tests produce the same screen order regardless of internal hash randomness. The actual list is still shuffled with a secure random function afterward, so user-facing behavior is unchanged. There is no security issue here.
No security action needed. Treat as a normal refactor/test-stability change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch replaces list(set(share_words)) with sorted(set(share_words)) in core/src/apps/management/reset_device/layout.py. The purpose, per the comment, is to make UI tests deterministic across MicroPython hash-function variations. The resulting list is still passed to random.shuffle, so the final choices presented to the user remain randomized. The change affects only test reproducibility, not cryptographic or security behavior.
Changed components
core/src/apps/management/reset_device/layout.pyInspect captured patch +2 / −1
diff --git a/core/src/apps/management/reset_device/layout.py b/core/src/apps/management/reset_device/layout.py
index 802b3552..40a6a8df 100644
--- a/core/src/apps/management/reset_device/layout.py
+++ b/core/src/apps/management/reset_device/layout.py
@@ -28,7 +28,8 @@ async def _confirm_word(
from trezor.ui.layouts.reset import select_word
# remove duplicates
- non_duplicates = list(set(share_words))
+ # sort list to make UI tests independent on micropython hash function
+ non_duplicates = sorted(set(share_words))
# shuffle list
random.shuffle(non_duplicates)
# take top _NUM_OF_CHOICES words
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.