Skip to content

Commit

Permalink
UI: do not redisplay home screens at sign
Browse files Browse the repository at this point in the history
So the HWM will not be dynamically update
  • Loading branch information
spalmer25 committed Apr 3, 2024
1 parent fe96e7a commit 8711a1b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 45 deletions.
4 changes: 3 additions & 1 deletion src/apdu_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ int handle_setup(buffer_t *cdata, derivation_type_t derivation_type) {
int handle_deauthorize(void) {
UPDATE_NVRAM(ram, { memset(&ram->baking_key, 0, sizeof(ram->baking_key)); });
#ifdef HAVE_BAGL
update_baking_idle_screens();
// Ignore display error
calculate_baking_idle_screens_data();
refresh_screens();
#endif // HAVE_BAGL

return io_send_sw(SW_OK);
Expand Down
3 changes: 2 additions & 1 deletion src/apdu_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ static int baking_sign_complete(bool const send_hash) {
TZ_CHECK(guard_baking_authorized(&G.parsed_baking_data, &global.path_with_curve));
result = perform_signature(send_hash);
#ifdef HAVE_BAGL
update_baking_idle_screens();
// Ignore display error
calculate_baking_idle_screens_data();
#endif
break;

Expand Down
11 changes: 9 additions & 2 deletions src/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ void exit_app(void);
#ifdef HAVE_BAGL

/**
* @brief Updates the baking screens
* @brief Calculates baking values for the idle screens
*
* @return bool: whether the values have been calculated successfully or not
*/
void update_baking_idle_screens(void);
bool calculate_baking_idle_screens_data(void);

/**
* @brief Prepare confirmation screens callbacks
Expand Down Expand Up @@ -75,4 +76,10 @@ extern const ux_flow_step_t ux_prompt_flow_accept_step;
&ux_prompt_flow_reject_step, \
&ux_prompt_flow_accept_step)

/**
* @brief Refreshes all screens of the current flow
*
*/
void refresh_screens(void);

#endif // HAVE_BAGL
18 changes: 5 additions & 13 deletions src/ui_bagl.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,7 @@ UX_FLOW(ux_idle_flow,
&ux_idle_quit_step,
FLOW_LOOP);

/**
* @brief Calculates baking values for the idle screens
*
* @return bool: whether the values have been calculated successfully or not
*/
static bool calculate_baking_idle_screens_data(void) {
bool calculate_baking_idle_screens_data(void) {
tz_exc exc = SW_OK;

memset(&home_context, 0, sizeof(home_context));
Expand Down Expand Up @@ -125,13 +120,6 @@ void ui_initial_screen(void) {
}
}

void update_baking_idle_screens(void) {
if (calculate_baking_idle_screens_data()) {
/// refresh
ux_stack_redisplay();
}
}

void ux_prepare_confirm_callbacks(ui_callback_t ok_c, ui_callback_t cxl_c) {
if (ok_c) {
G_display.ok_callback = ok_c;
Expand Down Expand Up @@ -159,4 +147,8 @@ UX_STEP_CB(ux_prompt_flow_reject_step, pb, prompt_response(false), {&C_icon_cros
UX_STEP_CB(ux_prompt_flow_accept_step, pb, prompt_response(true), {&C_icon_validate_14, "Accept"});
UX_STEP_NOCB(ux_eye_step, nn, {"Review", "Request"});

void refresh_screens(void) {
ux_stack_redisplay();
}

#endif // HAVE_BAGL
32 changes: 4 additions & 28 deletions test/test_instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,7 @@ def test_sign_preattestation(
f"Expected hash {preattestation.hash.hex()} but got {preattestation_hash.hex()}"
account.check_signature(signature, bytes(preattestation))

if firmware.is_nano:
# No update for Stax
backend.wait_for_screen_change()
if firmware.device == "nanos":
# Wait blink
time.sleep(0.5)
tezos_navigator.assert_screen("hwm_after_sign", snap_path=snap_path)
tezos_navigator.assert_screen("hwm_before_sign", snap_path=snap_path)


tezos_navigator.check_app_context(
Expand Down Expand Up @@ -578,13 +572,7 @@ def test_sign_attestation(
f"Expected hash {attestation.hash.hex()} but got {attestation_hash.hex()}"
account.check_signature(signature, bytes(attestation))

if firmware.is_nano:
# No update for Stax
backend.wait_for_screen_change()
if firmware.device == "nanos":
# Wait blink
time.sleep(0.5)
tezos_navigator.assert_screen("hwm_after_sign", snap_path=snap_path)
tezos_navigator.assert_screen("hwm_before_sign", snap_path=snap_path)

tezos_navigator.check_app_context(
account,
Expand Down Expand Up @@ -635,13 +623,7 @@ def test_sign_attestation_dal(
f"Expected hash {attestation.hash.hex()} but got {attestation_hash.hex()}"
account.check_signature(signature, bytes(attestation))

if firmware.is_nano:
# No update for Stax
backend.wait_for_screen_change()
if firmware.device == "nanos":
# Wait blink
time.sleep(0.5)
tezos_navigator.assert_screen("hwm_after_sign", snap_path=snap_path)
tezos_navigator.assert_screen("hwm_before_sign", snap_path=snap_path)

tezos_navigator.check_app_context(
account,
Expand Down Expand Up @@ -692,13 +674,7 @@ def test_sign_block(
f"Expected hash {block.hash.hex()} but got {block_hash.hex()}"
account.check_signature(signature, bytes(block))

if firmware.is_nano:
# No update for Stax
backend.wait_for_screen_change()
if firmware.device == "nanos":
# Wait blink
time.sleep(0.5)
tezos_navigator.assert_screen("hwm_after_sign", snap_path=snap_path)
tezos_navigator.assert_screen("hwm_before_sign", snap_path=snap_path)

tezos_navigator.check_app_context(
account,
Expand Down

0 comments on commit 8711a1b

Please sign in to comment.