diff --git a/CHANGELOG.md b/CHANGELOG.md index e1656c4..9536817 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Blind signing: Implement the ability to sign transactions that cannot be decoded + ## [0.6.9] - 2024-01-23 ### Added diff --git a/Makefile b/Makefile index ee8f490..8d1fa49 100644 --- a/Makefile +++ b/Makefile @@ -47,8 +47,8 @@ APPNAME = "Aptos" # Application version APPVERSION_M = 0 -APPVERSION_N = 6 -APPVERSION_P = 9 +APPVERSION_N = 7 +APPVERSION_P = 0 APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)" # Application source files diff --git a/src/handler/sign_tx.c b/src/handler/sign_tx.c index 2850752..f3fb0bf 100644 --- a/src/handler/sign_tx.c +++ b/src/handler/sign_tx.c @@ -63,7 +63,8 @@ int handler_sign_tx(buffer_t *cdata, uint8_t chunk, bool more) { G_context.req_type = REQUEST_UNDEFINED; return io_send_sw(SW_BAD_STATE); } - if (G_context.state == STATE_PARSED || G_context.state == STATE_APPROVED) { + if (G_context.state == STATE_PARSED || G_context.state == STATE_APPROVED || + G_context.state == STATE_CONTINUE_UNPARSED) { // should not get here, double check, context should already be reset return io_send_sw(SW_BAD_STATE); } @@ -96,15 +97,16 @@ int handler_sign_tx(buffer_t *cdata, uint8_t chunk, bool more) { parser_status_e status = transaction_deserialize(&buf, &G_context.tx_info.transaction); PRINTF("Parsing status: %d.\n", status); - if (status != PARSING_OK) { - // reset the context to prevent sending the "last" chunk multiple times - G_context.req_type = REQUEST_UNDEFINED; - return io_send_sw(SW_TX_PARSING_FAIL); - } - G_context.state = STATE_PARSED; + int ui_status = 0; + if (status == PARSING_OK) { + G_context.state = STATE_PARSED; + ui_status = ui_display_transaction(); + } else { + G_context.state = STATE_CONTINUE_UNPARSED; + ui_status = ui_display_unparsed_transaction(); + } - int ui_status = ui_display_transaction(); G_context.req_type = REQUEST_UNDEFINED; // all the work is done, reset the context return ui_status; } diff --git a/src/types.h b/src/types.h index 5694e1d..21b5102 100644 --- a/src/types.h +++ b/src/types.h @@ -22,9 +22,10 @@ typedef enum { * Enumeration with parsing state. */ typedef enum { - STATE_NONE, /// No state - STATE_PARSED, /// Transaction data parsed - STATE_APPROVED /// Transaction data approved + STATE_NONE, /// No state + STATE_PARSED, /// Transaction data parsed + STATE_CONTINUE_UNPARSED, /// Transaction data parsed + STATE_APPROVED /// Transaction data approved } state_e; /** diff --git a/src/ui/action/validate.c b/src/ui/action/validate.c index e28c3bf..fb6f33c 100644 --- a/src/ui/action/validate.c +++ b/src/ui/action/validate.c @@ -48,3 +48,8 @@ void validate_transaction(bool choice) { io_send_sw(SW_DENY); } } + +void reject_unparsed_transaction(void) { + G_context.state = STATE_NONE; + io_send_sw(SW_TX_PARSING_FAIL); +} diff --git a/src/ui/action/validate.h b/src/ui/action/validate.h index 5b9e83c..e6763fc 100644 --- a/src/ui/action/validate.h +++ b/src/ui/action/validate.h @@ -19,3 +19,5 @@ void validate_pubkey(bool choice); * */ void validate_transaction(bool choice); + +void reject_unparsed_transaction(void); diff --git a/src/ui/bagl_display.c b/src/ui/bagl_display.c index c9484e7..003080a 100644 --- a/src/ui/bagl_display.c +++ b/src/ui/bagl_display.c @@ -79,6 +79,14 @@ UX_STEP_NOCB(ux_display_blind_sign_banner_step, "enabled in Settings", }); #endif +// Step with continue button +UX_STEP_CB(ux_display_continue_step, + pb, + (*g_validate_callback)(true), + { + &C_icon_validate_14, + "Continue", + }); // Step with approve button UX_STEP_CB(ux_display_approve_step, pb, @@ -170,6 +178,29 @@ int ui_display_address() { return ret; } +#ifdef TARGET_NANOS +UX_STEP_NOCB(ux_display_decode_fail_step, + bnnn_paging, + { + .title = "Info", + .text = "Unable to display transaction data", + }); +#else +UX_STEP_NOCB(ux_display_decode_fail_step, + pnn, + { + &C_icon_warning, + "Unable to display", + "transaction data", + }); +#endif +UX_STEP_NOCB(ux_display_details_step, + pnn, + { + &C_icon_eye, + "Details", + "Unavailable", + }); // Step with icon and text UX_STEP_NOCB(ux_display_blind_warn_step, pnn, @@ -258,6 +289,26 @@ UX_STEP_NOCB(ux_display_gas_fee_step, .text = g_gas_fee, }); +// FLOW to display uparsed transaction information: +// #1 screen : "Unable to display transaction data" +// #2 screen : continue button +// #3 screen : reject button +UX_FLOW(ux_display_warn_uparsed_tx_flow, + &ux_display_decode_fail_step, + &ux_display_continue_step, + &ux_display_reject_step); + +// FLOW to display message that transaction details are unavailable: +// #1 screen : warning icon + "Blind Signing" +// #2 screen : eye icon + "Details Unavailable" +// #3 screen : approve button +// #4 screen : reject button +UX_FLOW(ux_display_uparsed_tx_flow, + &ux_display_blind_warn_step, + &ux_display_details_step, + &ux_display_approve_step, + &ux_display_reject_step); + // FLOW to display default transaction information: // #1 screen : warning icon + "Blind Signing" // #2 screen : eye icon + "Review Transaction" @@ -366,6 +417,27 @@ UX_FLOW(ux_display_tx_coin_transfer_flow, &ux_display_approve_step, &ux_display_reject_step); +static void ui_action_continue_unparsed_transaction(bool choice) { + if (choice) { + g_validate_callback = &ui_action_validate_transaction; + ui_flow_verified_display(ux_display_uparsed_tx_flow); + } else { + reject_unparsed_transaction(); + ui_menu_main(); + } +} + +int ui_display_unparsed_transaction() { + const int ret = ui_prepare_unparsed_transaction(); + if (ret == UI_PREPARED) { + g_validate_callback = &ui_action_continue_unparsed_transaction; + ui_flow_display(ux_display_warn_uparsed_tx_flow); + return 0; + } + + return ret; +} + int ui_display_transaction() { g_validate_callback = &ui_action_validate_transaction; diff --git a/src/ui/common_display.c b/src/ui/common_display.c index eeb4487..2c2daf7 100644 --- a/src/ui/common_display.c +++ b/src/ui/common_display.c @@ -137,6 +137,15 @@ int ui_prepare_transaction() { return UI_PREPARED; } +int ui_prepare_unparsed_transaction() { + if (G_context.req_type != CONFIRM_TRANSACTION || G_context.state != STATE_CONTINUE_UNPARSED) { + G_context.state = STATE_NONE; + return io_send_sw(SW_BAD_STATE); + } + + return UI_PREPARED; +} + int ui_prepare_entry_function() { entry_function_payload_t *function = &G_context.tx_info.transaction.payload.entry_function; char function_module_id_address_hex[67] = {0}; diff --git a/src/ui/display.h b/src/ui/display.h index 05e4759..c3c0028 100644 --- a/src/ui/display.h +++ b/src/ui/display.h @@ -28,6 +28,9 @@ int ui_prepare_address(void); int ui_display_transaction(void); int ui_prepare_transaction(void); +int ui_display_unparsed_transaction(void); +int ui_prepare_unparsed_transaction(void); + int ui_display_message(void); int ui_display_raw_message(void); diff --git a/src/ui/nbgl_display.c b/src/ui/nbgl_display.c index f92e5f9..d0c71af 100644 --- a/src/ui/nbgl_display.c +++ b/src/ui/nbgl_display.c @@ -38,12 +38,29 @@ nbgl_layoutTagValueList_t pairList; nbgl_pageInfoLongPress_t infoLongPress; static void blind_sign_continue() { - nbgl_useCaseReviewStart(blind_sign_ctx.icon, - blind_sign_ctx.review_title, - blind_sign_ctx.review_sub_title, - blind_sign_ctx.reject_text, - blind_sign_ctx.continue_callback, - blind_sign_ctx.reject_callback); + if (blind_sign_ctx.continue_callback) { + nbgl_useCaseReviewStart(blind_sign_ctx.icon, + blind_sign_ctx.review_title, + blind_sign_ctx.review_sub_title, + blind_sign_ctx.reject_text, + blind_sign_ctx.continue_callback, + blind_sign_ctx.reject_callback); + } else if (blind_sign_ctx.choice_callback) { + pairList.nbMaxLinesForValue = 0; + pairList.nbPairs = 0; + pairList.pairs = pairs; + + infoLongPress.icon = &C_aptos_logo_64px; + infoLongPress.text = blind_sign_ctx.long_press_title; + infoLongPress.longPressText = blind_sign_ctx.long_press_button_text; + + nbgl_useCaseStaticReview(&pairList, + &infoLongPress, + blind_sign_ctx.reject_text, + blind_sign_ctx.choice_callback); + } else { + PRINTF("Invalid blind signing context\n"); + } } static void blind_sign_info() { @@ -65,6 +82,19 @@ static void blind_sign_choice(bool enable) { } } +static void blind_sign_init_choice() { + if (N_storage.settings.allow_blind_signing) { + blind_sign_info(); + } else { + nbgl_useCaseChoice(&C_round_warning_64px, + "Enable blind signing to\nauthorize this\noperation", + NULL, + "Enable blind signing", + blind_sign_ctx.reject_text, + blind_sign_choice); + } +} + void nbgl_useCaseReviewVerify(const nbgl_icon_details_t *icon, const char *review_title, const char *review_sub_title, @@ -77,16 +107,26 @@ void nbgl_useCaseReviewVerify(const nbgl_icon_details_t *icon, blind_sign_ctx.reject_text = reject_text; blind_sign_ctx.continue_callback = continue_callback; blind_sign_ctx.reject_callback = reject_callback; - if (N_storage.settings.allow_blind_signing) { - blind_sign_info(); - } else { - nbgl_useCaseChoice(&C_round_warning_64px, - "Enable blind signing to\nauthorize this\noperation", - NULL, - "Enable blind signing", - reject_text, - blind_sign_choice); - } + blind_sign_ctx.choice_callback = NULL; + + blind_sign_init_choice(); +} + +void nbgl_useCaseStaticReviewVerify(const nbgl_icon_details_t *icon, + const char *long_press_title, + const char *long_press_button_text, + const char *reject_text, + nbgl_choiceCallback_t choice_callback, + nbgl_callback_t reject_callback) { + blind_sign_ctx.icon = icon; + blind_sign_ctx.long_press_title = long_press_title; + blind_sign_ctx.long_press_button_text = long_press_button_text; + blind_sign_ctx.reject_text = reject_text; + blind_sign_ctx.continue_callback = NULL; + blind_sign_ctx.reject_callback = reject_callback; + blind_sign_ctx.choice_callback = choice_callback; + + blind_sign_init_choice(); } #endif diff --git a/src/ui/nbgl_display.h b/src/ui/nbgl_display.h index 3f20010..2a08783 100644 --- a/src/ui/nbgl_display.h +++ b/src/ui/nbgl_display.h @@ -8,11 +8,18 @@ extern nbgl_pageInfoLongPress_t infoLongPress; typedef struct use_case_review_ctx_s { const nbgl_icon_details_t *icon; - const char *review_title; - const char *review_sub_title; + union { + const char *review_title; + const char *long_press_title; + }; + union { + const char *review_sub_title; + const char *long_press_button_text; + }; const char *reject_text; nbgl_callback_t continue_callback; nbgl_callback_t reject_callback; + nbgl_choiceCallback_t choice_callback; } use_case_review_ctx_t; void nbgl_useCaseReviewVerify(const nbgl_icon_details_t *icon, @@ -21,3 +28,10 @@ void nbgl_useCaseReviewVerify(const nbgl_icon_details_t *icon, const char *reject_text, nbgl_callback_t continue_callback, nbgl_callback_t reject_callback); + +void nbgl_useCaseStaticReviewVerify(const nbgl_icon_details_t *icon, + const char *long_press_title, + const char *long_press_button_text, + const char *reject_text, + nbgl_choiceCallback_t choice_callback, + nbgl_callback_t reject_callback); \ No newline at end of file diff --git a/src/ui/nbgl_display_transaction.c b/src/ui/nbgl_display_transaction.c index 8fd0478..584ca2f 100755 --- a/src/ui/nbgl_display_transaction.c +++ b/src/ui/nbgl_display_transaction.c @@ -36,12 +36,25 @@ static void confirm_transaction_rejection(void) { nbgl_useCaseStatus("Transaction rejected", false, ui_menu_main); } -static void ask_transaction_rejection_confirmation(void) { +static void confirm_unparsed_transaction_rejection(void) { + reject_unparsed_transaction(); + nbgl_useCaseStatus("Transaction rejected", false, ui_menu_main); +} + +static void ask_transaction_rejection(nbgl_callback_t callback) { nbgl_useCaseConfirm("Reject transaction?", NULL, "Yes, Reject", "Go back to transaction", - confirm_transaction_rejection); + callback); +} + +static void ask_transaction_rejection_confirmation(void) { + ask_transaction_rejection(confirm_transaction_rejection); +} + +static void ask_unparsed_transaction_rejection_confirmation(void) { + ask_transaction_rejection(confirm_unparsed_transaction_rejection); } static void review_choice(bool confirm) { @@ -53,6 +66,19 @@ static void review_choice(bool confirm) { } } +static void review_unparsed_choice(bool confirm) { + if (confirm) { + nbgl_useCaseStaticReviewVerify(&C_aptos_logo_64px, + "Sign transaction", + "Hold to sign", + "Reject transaction", + review_choice, + ask_transaction_rejection_confirmation); + } else { + ask_unparsed_transaction_rejection_confirmation(); + } +} + static void review_default_continue(void) { pairs[0].item = "Transaction Type"; pairs[0].value = g_tx_type; @@ -197,4 +223,19 @@ int ui_display_tx_coin_transfer() { return ret; } +int ui_display_unparsed_transaction() { + const int ret = ui_prepare_unparsed_transaction(); + if (ret == UI_PREPARED) { + nbgl_useCaseChoice(&C_warning64px, + "Transaction\ndetails unavailable", + "Acknowledge the risks\nand proceed with caution.", + "Continue", + "Reject transaction", + review_unparsed_choice); + return 0; + } + + return ret; +} + #endif diff --git a/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part0/00000.png b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part0/00000.png new file mode 100644 index 0000000..94056af Binary files /dev/null and b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part0/00000.png differ diff --git a/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part0/00001.png b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part0/00001.png new file mode 100644 index 0000000..25ec084 Binary files /dev/null and b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part0/00001.png differ diff --git a/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part0/00002.png b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part0/00002.png new file mode 100644 index 0000000..12b06a7 Binary files /dev/null and b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part0/00002.png differ diff --git a/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part1/00000.png b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part1/00000.png new file mode 100644 index 0000000..c2420af Binary files /dev/null and b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part1/00000.png differ diff --git a/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part1/00001.png b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part1/00001.png new file mode 100644 index 0000000..71fb65e Binary files /dev/null and b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part1/00001.png differ diff --git a/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part1/00002.png b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part1/00002.png new file mode 100644 index 0000000..2d1b940 Binary files /dev/null and b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part1/00002.png differ diff --git a/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part2/00000.png b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part2/00000.png new file mode 100644 index 0000000..28f5547 Binary files /dev/null and b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part2/00000.png differ diff --git a/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part2/00001.png b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part2/00001.png new file mode 100644 index 0000000..66c411c Binary files /dev/null and b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part2/00001.png differ diff --git a/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part2/00002.png b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part2/00002.png new file mode 100644 index 0000000..02d922b Binary files /dev/null and b/tests/snapshots/nanos/test_blind_sign_tx_unparsed_tx/part2/00002.png differ diff --git a/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part0/00000.png b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part0/00000.png new file mode 100644 index 0000000..a6b7370 Binary files /dev/null and b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part0/00000.png differ diff --git a/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part0/00001.png b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part0/00001.png new file mode 100644 index 0000000..adea514 Binary files /dev/null and b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part0/00001.png differ diff --git a/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part1/00000.png b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part1/00000.png new file mode 100644 index 0000000..2d20155 Binary files /dev/null and b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part1/00000.png differ diff --git a/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part1/00001.png b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part1/00001.png new file mode 100644 index 0000000..c4bbf90 Binary files /dev/null and b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part1/00001.png differ diff --git a/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part2/00000.png b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part2/00000.png new file mode 100644 index 0000000..ddc516b Binary files /dev/null and b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part2/00000.png differ diff --git a/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part2/00001.png b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part2/00001.png new file mode 100644 index 0000000..53ae651 Binary files /dev/null and b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part2/00001.png differ diff --git a/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part2/00002.png b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part2/00002.png new file mode 100644 index 0000000..79857a0 Binary files /dev/null and b/tests/snapshots/nanosp/test_blind_sign_tx_unparsed_tx/part2/00002.png differ diff --git a/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part0/00000.png b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part0/00000.png new file mode 100644 index 0000000..a6b7370 Binary files /dev/null and b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part0/00000.png differ diff --git a/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part0/00001.png b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part0/00001.png new file mode 100644 index 0000000..adea514 Binary files /dev/null and b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part0/00001.png differ diff --git a/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part1/00000.png b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part1/00000.png new file mode 100644 index 0000000..2d20155 Binary files /dev/null and b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part1/00000.png differ diff --git a/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part1/00001.png b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part1/00001.png new file mode 100644 index 0000000..c4bbf90 Binary files /dev/null and b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part1/00001.png differ diff --git a/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part2/00000.png b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part2/00000.png new file mode 100644 index 0000000..ddc516b Binary files /dev/null and b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part2/00000.png differ diff --git a/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part2/00001.png b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part2/00001.png new file mode 100644 index 0000000..53ae651 Binary files /dev/null and b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part2/00001.png differ diff --git a/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part2/00002.png b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part2/00002.png new file mode 100644 index 0000000..79857a0 Binary files /dev/null and b/tests/snapshots/nanox/test_blind_sign_tx_unparsed_tx/part2/00002.png differ diff --git a/tests/snapshots/stax/test_app_mainmenu/00001.png b/tests/snapshots/stax/test_app_mainmenu/00001.png index 33e5cf9..7c979cd 100644 Binary files a/tests/snapshots/stax/test_app_mainmenu/00001.png and b/tests/snapshots/stax/test_app_mainmenu/00001.png differ diff --git a/tests/snapshots/stax/test_app_mainmenu/00002.png b/tests/snapshots/stax/test_app_mainmenu/00002.png index bdf16f2..fa69e35 100644 Binary files a/tests/snapshots/stax/test_app_mainmenu/00002.png and b/tests/snapshots/stax/test_app_mainmenu/00002.png differ diff --git a/tests/snapshots/stax/test_app_mainmenu/00003.png b/tests/snapshots/stax/test_app_mainmenu/00003.png index 3845f3a..a032e6a 100644 Binary files a/tests/snapshots/stax/test_app_mainmenu/00003.png and b/tests/snapshots/stax/test_app_mainmenu/00003.png differ diff --git a/tests/snapshots/stax/test_app_mainmenu/00004.png b/tests/snapshots/stax/test_app_mainmenu/00004.png index bdf16f2..fa69e35 100644 Binary files a/tests/snapshots/stax/test_app_mainmenu/00004.png and b/tests/snapshots/stax/test_app_mainmenu/00004.png differ diff --git a/tests/snapshots/stax/test_app_mainmenu/00005.png b/tests/snapshots/stax/test_app_mainmenu/00005.png index 33e5cf9..733caca 100644 Binary files a/tests/snapshots/stax/test_app_mainmenu/00005.png and b/tests/snapshots/stax/test_app_mainmenu/00005.png differ diff --git a/tests/snapshots/stax/test_blind_sign_tx_long_tx/part0/00001.png b/tests/snapshots/stax/test_blind_sign_tx_long_tx/part0/00001.png index 279acd5..9d9cdb4 100644 Binary files a/tests/snapshots/stax/test_blind_sign_tx_long_tx/part0/00001.png and b/tests/snapshots/stax/test_blind_sign_tx_long_tx/part0/00001.png differ diff --git a/tests/snapshots/stax/test_blind_sign_tx_long_tx/part1/00005.png b/tests/snapshots/stax/test_blind_sign_tx_long_tx/part1/00005.png index cd2f527..a21279c 100644 Binary files a/tests/snapshots/stax/test_blind_sign_tx_long_tx/part1/00005.png and b/tests/snapshots/stax/test_blind_sign_tx_long_tx/part1/00005.png differ diff --git a/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part0/00000.png b/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part0/00000.png new file mode 100644 index 0000000..311f96b Binary files /dev/null and b/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part0/00000.png differ diff --git a/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part0/00001.png b/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part0/00001.png new file mode 100644 index 0000000..2519750 Binary files /dev/null and b/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part0/00001.png differ diff --git a/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part0/00002.png b/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part0/00002.png new file mode 100644 index 0000000..9d9cdb4 Binary files /dev/null and b/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part0/00002.png differ diff --git a/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part1/00000.png b/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part1/00000.png new file mode 100644 index 0000000..0155f62 Binary files /dev/null and b/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part1/00000.png differ diff --git a/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part1/00001.png b/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part1/00001.png new file mode 100644 index 0000000..b3146bf Binary files /dev/null and b/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part1/00001.png differ diff --git a/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part1/00002.png b/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part1/00002.png new file mode 100644 index 0000000..a21279c Binary files /dev/null and b/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part1/00002.png differ diff --git a/tests/snapshots/stax/test_app_mainmenu/00006.png b/tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part1/00003.png similarity index 100% rename from tests/snapshots/stax/test_app_mainmenu/00006.png rename to tests/snapshots/stax/test_blind_sign_tx_unparsed_tx/part1/00003.png diff --git a/tests/snapshots/stax/test_get_public_key_confirm_accepted/00002.png b/tests/snapshots/stax/test_get_public_key_confirm_accepted/00002.png index 1d83684..c203b13 100644 Binary files a/tests/snapshots/stax/test_get_public_key_confirm_accepted/00002.png and b/tests/snapshots/stax/test_get_public_key_confirm_accepted/00002.png differ diff --git a/tests/snapshots/stax/test_get_public_key_confirm_accepted/00005.png b/tests/snapshots/stax/test_get_public_key_confirm_accepted/00005.png index f59899e..13499fc 100644 Binary files a/tests/snapshots/stax/test_get_public_key_confirm_accepted/00005.png and b/tests/snapshots/stax/test_get_public_key_confirm_accepted/00005.png differ diff --git a/tests/snapshots/stax/test_sign_long_raw_msg/part0/00001.png b/tests/snapshots/stax/test_sign_long_raw_msg/part0/00001.png index 279acd5..9d9cdb4 100644 Binary files a/tests/snapshots/stax/test_sign_long_raw_msg/part0/00001.png and b/tests/snapshots/stax/test_sign_long_raw_msg/part0/00001.png differ diff --git a/tests/snapshots/stax/test_sign_long_raw_msg/part1/00004.png b/tests/snapshots/stax/test_sign_long_raw_msg/part1/00004.png index c1a8fd4..1c2d6cd 100644 Binary files a/tests/snapshots/stax/test_sign_long_raw_msg/part1/00004.png and b/tests/snapshots/stax/test_sign_long_raw_msg/part1/00004.png differ diff --git a/tests/snapshots/stax/test_sign_short_raw_msg/00003.png b/tests/snapshots/stax/test_sign_short_raw_msg/00003.png index c1a8fd4..1c2d6cd 100644 Binary files a/tests/snapshots/stax/test_sign_short_raw_msg/00003.png and b/tests/snapshots/stax/test_sign_short_raw_msg/00003.png differ diff --git a/tests/snapshots/stax/test_sign_tx_short_msg/00003.png b/tests/snapshots/stax/test_sign_tx_short_msg/00003.png index c1a8fd4..1c2d6cd 100644 Binary files a/tests/snapshots/stax/test_sign_tx_short_msg/00003.png and b/tests/snapshots/stax/test_sign_tx_short_msg/00003.png differ diff --git a/tests/snapshots/stax/test_sign_tx_short_tx/00004.png b/tests/snapshots/stax/test_sign_tx_short_tx/00004.png index cd2f527..a21279c 100644 Binary files a/tests/snapshots/stax/test_sign_tx_short_tx/00004.png and b/tests/snapshots/stax/test_sign_tx_short_tx/00004.png differ diff --git a/tests/test_app_mainmenu.py b/tests/test_app_mainmenu.py index 4ef565d..6d2d95f 100644 --- a/tests/test_app_mainmenu.py +++ b/tests/test_app_mainmenu.py @@ -18,7 +18,6 @@ def test_app_mainmenu(firmware, navigator, test_name): NavInsID.USE_CASE_SETTINGS_NEXT, NavIns(NavInsID.TOUCH, (200, 113)), NavIns(NavInsID.TOUCH, (200, 113)), - NavInsID.USE_CASE_CHOICE_REJECT, NavInsID.USE_CASE_SETTINGS_MULTI_PAGE_EXIT ] navigator.navigate_and_compare(ROOT_SCREENSHOT_PATH, test_name, instructions, diff --git a/tests/test_name_version.py b/tests/test_name_version.py index a7d6d24..f8ccbe7 100644 --- a/tests/test_name_version.py +++ b/tests/test_name_version.py @@ -12,4 +12,4 @@ def test_get_app_and_version(backend, backend_name): app_name, version = unpack_get_app_and_version_response(response.data) assert app_name == "Aptos" - assert version == "0.6.9" + assert version == "0.7.0" diff --git a/tests/test_sign_cmd.py b/tests/test_sign_cmd.py index 7c9b663..f003b88 100644 --- a/tests/test_sign_cmd.py +++ b/tests/test_sign_cmd.py @@ -27,7 +27,6 @@ def disable_blind_signing(firmware, backend, navigator): NavInsID.USE_CASE_HOME_SETTINGS, NavInsID.USE_CASE_SETTINGS_NEXT, NavIns(NavInsID.TOUCH, (200, 113)), - NavInsID.USE_CASE_CHOICE_REJECT, NavInsID.USE_CASE_SETTINGS_MULTI_PAGE_EXIT ] navigator.navigate(instructions, screen_change_before_first_instruction=False) @@ -118,6 +117,56 @@ def test_blind_sign_tx_long_tx(firmware, backend, navigator, test_name, disable_ _, sig, _ = unpack_sign_tx_response(response) assert check_signature_validity(public_key, sig, transaction) +# In this test we send to the device a transaction to sign and validate it on screen +# The transaction will be sent in multiple chunks +# Also, this transaction cannot be parsed by the device +def test_blind_sign_tx_unparsed_tx(firmware, backend, navigator, test_name, disable_blind_signing): + # Use the app interface instead of raw interface + client = AptosCommandSender(backend) + path: str = "m/44'/637'/1'/0'/0'" + + rapdu = client.get_public_key(path=path) + _, public_key, _, _ = unpack_get_public_key_response(rapdu.data) + + transaction = bytes.fromhex("b5e97db07fa0bd0e5598aa3643a9bc6f6693bddc1a9fec9e674a461eaa00b193783135e8b00430253a22ba041d860c373d7a1501ccf7ac2d1ad37a8ed2775aee4b000000000000000200000000000000000000000000000000000000000000000000000000000000010d6170746f735f6163636f756e740e7472616e736665725f636f696e73010761d2c22a6cb7831bee0f48363b0eec92369357aece0d1142062f7d5d85c7bef8076c705f636f696e024c50030773eb84966be67e4697fc5ae75173ca6c35089e802650f75422ab49a8729704ec04636f696e06446f6f446f6f000700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00070163df34fccbf003ce219d3f1d9e70d140b60622cb9dd47599c25fb2f797ba6e066375727665730c556e636f7272656c61746564000220fdf3824962d2f803e009ac61cca29c822338da6c5f541a4e58898468152b11c60800e1f50500000000204e0000000000006400000000000000549927660000000002") + + with client.sign_tx(path=path, transaction=transaction): + if firmware.device.startswith("nano"): + navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, + [NavInsID.BOTH_CLICK], + "Continue", + ROOT_SCREENSHOT_PATH, + test_name + "/part0", + screen_change_after_last_instruction=False) + navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, + [NavInsID.BOTH_CLICK], + "Allow", + ROOT_SCREENSHOT_PATH, + test_name + "/part1", + screen_change_after_last_instruction=False) + navigator.navigate_until_text_and_compare(NavInsID.RIGHT_CLICK, + [NavInsID.BOTH_CLICK], + "Approve", + ROOT_SCREENSHOT_PATH, + test_name + "/part2") + else: + navigator.navigate_until_text_and_compare(NavInsID.USE_CASE_CHOICE_CONFIRM, + [NavInsID.USE_CASE_CHOICE_CONFIRM, + NavInsID.USE_CASE_STATUS_DISMISS], + "Enable blind signing", + ROOT_SCREENSHOT_PATH, + test_name + "/part0", + screen_change_after_last_instruction=False) + navigator.navigate_until_text_and_compare(NavInsID.USE_CASE_REVIEW_TAP, + [NavInsID.USE_CASE_REVIEW_CONFIRM, + NavInsID.USE_CASE_STATUS_DISMISS], + "Hold to sign", + ROOT_SCREENSHOT_PATH, + test_name + "/part1") + response = client.get_async_response().data + _, sig, _ = unpack_sign_tx_response(response) + assert check_signature_validity(public_key, sig, transaction) + # Transaction signature refused test # The test will ask for a transaction signature that will be refused on screen diff --git a/tests/test_version_cmd.py b/tests/test_version_cmd.py index 535d3d1..719c273 100644 --- a/tests/test_version_cmd.py +++ b/tests/test_version_cmd.py @@ -3,8 +3,8 @@ # Taken from the Makefile, to update every time the Makefile version is bumped MAJOR = 0 -MINOR = 6 -PATCH = 9 +MINOR = 7 +PATCH = 0 # In this test we check the behavior of the device when asked to provide the app version def test_version(backend):