diff --git a/client/src/ledger_app_clients/ethereum/eip712/InputData.py b/client/src/ledger_app_clients/ethereum/eip712/InputData.py index 0227343..ee31b0a 100644 --- a/client/src/ledger_app_clients/ethereum/eip712/InputData.py +++ b/client/src/ledger_app_clients/ethereum/eip712/InputData.py @@ -332,7 +332,10 @@ def next_timeout(_signum: int, _frame): def enable_autonext(): - delay = 1/5 + if app_client._client.firmware.device in ("stax", "flex"): + delay = 1/3 + else: + delay = 1/4 signal.setitimer(signal.ITIMER_REAL, delay, delay) diff --git a/src_nbgl/ui_message_signing.c b/src_nbgl/ui_message_signing.c index 40544df..1e1e589 100644 --- a/src_nbgl/ui_message_signing.c +++ b/src_nbgl/ui_message_signing.c @@ -41,10 +41,18 @@ void ui_message_start(const char *title, ui_message_confirm_rejection); } -void ui_message_712_approved(void) { +static void ui_message_712_approved(void) { ui_712_approve(); } -void ui_message_712_rejected(void) { +static void ui_message_712_rejected(void) { ui_712_reject(); } + +void ui_typed_message_review_choice(bool confirm) { + if (confirm) { + nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_SIGNED, ui_message_712_approved); + } else { + nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_REJECTED, ui_message_712_rejected); + } +} diff --git a/src_nbgl/ui_message_signing.h b/src_nbgl/ui_message_signing.h index 008f574..0791851 100644 --- a/src_nbgl/ui_message_signing.h +++ b/src_nbgl/ui_message_signing.h @@ -2,6 +2,7 @@ #define UI_MESSAGE_SIGNING_H_ #include +#include "ui_signing.h" #define TEXT_MESSAGE "message" #define TEXT_TYPED_MESSAGE "typed " TEXT_MESSAGE @@ -13,8 +14,6 @@ void ui_message_start(const char *title, void (*start_func)(void), void (*approved_func)(void), void (*rejected_func)(void)); - -void ui_message_712_approved(void); -void ui_message_712_rejected(void); +void ui_typed_message_review_choice(bool confirm); #endif // UI_MESSAGE_SIGNING_H_ diff --git a/src_nbgl/ui_sign_712.c b/src_nbgl/ui_sign_712.c index de82582..ba148bb 100644 --- a/src_nbgl/ui_sign_712.c +++ b/src_nbgl/ui_sign_712.c @@ -1,80 +1,56 @@ #ifdef HAVE_EIP712_FULL_SUPPORT +#include // explicit_bzero #include "common_ui.h" #include "ui_nbgl.h" #include "ui_logic.h" #include "common_712.h" #include "nbgl_use_case.h" -#include "network.h" #include "ui_message_signing.h" -#include "ui_signing.h" static nbgl_contentTagValue_t pair; +static nbgl_contentTagValueList_t pairs_list; -static bool display_sign_page(uint8_t page, nbgl_pageContent_t *content) { - (void) page; - content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true); - content->infoLongPress.text = TEXT_SIGN_EIP712; - content->infoLongPress.longPressText = SIGN_BUTTON; - return true; -} - -static bool display_review_page(uint8_t page, nbgl_pageContent_t *content) { - bool ret; - uint16_t len; - - switch (page) { - case 0: - // limit the value to one page - nbgl_getTextMaxLenInNbLines(LARGE_MEDIUM_FONT, - strings.tmp.tmp, - SCREEN_WIDTH - (2 * BORDER_MARGIN), - NB_MAX_LINES_IN_REVIEW, - &len, - false); - strings.tmp.tmp[len] = '\0'; - - pair.item = strings.tmp.tmp2; - pair.value = strings.tmp.tmp; - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 1; - content->tagValueList.pairs = &pair; - content->tagValueList.wrapping = false; - ret = true; - break; - - case 1: - if (ui_712_next_field() == EIP712_NO_MORE_FIELD) { - ui_712_switch_to_sign(); - } - __attribute__((fallthrough)); - default: - ret = false; - break; +static void message_progress(bool confirm) { + if (confirm) { + if (ui_712_next_field() == EIP712_NO_MORE_FIELD) { + ui_712_switch_to_sign(); + } + } else { + ui_typed_message_review_choice(false); } - return ret; } -static void handle_display(nbgl_navCallback_t cb) { - nbgl_useCaseRegularReview(0, 0, REJECT_BUTTON, NULL, cb, ui_message_review_choice); +static void message_update(bool confirm) { + if (confirm) { + explicit_bzero(&pair, sizeof(pair)); + explicit_bzero(&pairs_list, sizeof(pairs_list)); + + pair.item = strings.tmp.tmp2; + pair.value = strings.tmp.tmp; + pairs_list.nbPairs = 1; + pairs_list.pairs = &pair; + pairs_list.wrapping = false; + nbgl_useCaseReviewStreamingContinue(&pairs_list, message_progress); + } else { + ui_typed_message_review_choice(false); + } } void ui_712_start(void) { - g_position = UI_SIGNING_POSITION_START; - ui_message_start(TEXT_REVIEW_EIP712, - &ui_712_switch_to_message, - &ui_message_712_approved, - &ui_message_712_rejected); + nbgl_useCaseReviewStreamingStart(TYPE_MESSAGE, + &C_Review_64px, + TEXT_REVIEW_EIP712, + NULL, + message_update); } void ui_712_switch_to_message(void) { - g_position = UI_SIGNING_POSITION_REVIEW; - handle_display(display_review_page); + message_update(true); } void ui_712_switch_to_sign(void) { - g_position = UI_SIGNING_POSITION_SIGN; - handle_display(display_sign_page); + nbgl_useCaseReviewStreamingFinish(TEXT_SIGN_EIP712, ui_typed_message_review_choice); } #endif // HAVE_EIP712_FULL_SUPPORT diff --git a/src_nbgl/ui_sign_712_v0.c b/src_nbgl/ui_sign_712_v0.c index f81f2f0..a3a39b7 100644 --- a/src_nbgl/ui_sign_712_v0.c +++ b/src_nbgl/ui_sign_712_v0.c @@ -4,18 +4,9 @@ #include "ui_nbgl.h" #include "common_712.h" #include "ui_message_signing.h" -#include "ui_signing.h" static nbgl_contentTagValue_t pairs[2]; -static nbgl_contentTagValueList_t pairsList; - -static void message_review_choice(bool confirm) { - if (confirm) { - nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_SIGNED, ui_message_712_approved); - } else { - nbgl_useCaseReviewStatus(STATUS_TYPE_MESSAGE_REJECTED, ui_message_712_rejected); - } -} +static nbgl_contentTagValueList_t pairs_list; static char *format_hash(const uint8_t *hash, char *buffer, size_t buffer_size, size_t offset) { array_bytes_string(buffer + offset, buffer_size - offset, hash, KECCAK256_HASH_BYTESIZE); @@ -24,7 +15,7 @@ static char *format_hash(const uint8_t *hash, char *buffer, size_t buffer_size, void ui_sign_712_v0(void) { explicit_bzero(pairs, sizeof(pairs)); - explicit_bzero(&pairsList, sizeof(pairsList)); + explicit_bzero(&pairs_list, sizeof(pairs_list)); pairs[0].item = "Domain hash"; pairs[0].value = format_hash(tmpCtx.messageSigningContext712.domainHash, @@ -37,15 +28,15 @@ void ui_sign_712_v0(void) { sizeof(strings.tmp.tmp), 70); - pairsList.nbPairs = ARRAYLEN(pairs); - pairsList.pairs = pairs; - pairsList.nbMaxLinesForValue = 0; + pairs_list.nbPairs = ARRAYLEN(pairs); + pairs_list.pairs = pairs; + pairs_list.nbMaxLinesForValue = 0; nbgl_useCaseReview(TYPE_MESSAGE, - &pairsList, + &pairs_list, &C_Review_64px, TEXT_REVIEW_EIP712, NULL, TEXT_SIGN_EIP712, - message_review_choice); + ui_typed_message_review_choice); } diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution/00000.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00000.png new file mode 100644 index 0000000..a1879da Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00000.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution/00001.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00001.png new file mode 100644 index 0000000..6bdc1e0 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00001.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution/00002.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00002.png new file mode 100644 index 0000000..8f98115 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00002.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution/00003.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00003.png new file mode 100644 index 0000000..3106ba8 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00003.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution/00004.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00004.png new file mode 100644 index 0000000..a8988ce Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00004.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution/00005.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00005.png new file mode 100644 index 0000000..cbaa889 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00005.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution/00006.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00006.png new file mode 100644 index 0000000..8b981d4 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution/00006.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00000.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00000.png new file mode 100644 index 0000000..a1879da Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00000.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00001.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00001.png new file mode 100644 index 0000000..96525be Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00001.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00002.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00002.png new file mode 100644 index 0000000..16ade57 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00002.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00003.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00003.png new file mode 100644 index 0000000..24e7097 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00003.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00004.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00004.png new file mode 100644 index 0000000..d7f125e Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00004.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00005.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00005.png new file mode 100644 index 0000000..39cd558 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00005.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00006.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00006.png new file mode 100644 index 0000000..5af63c1 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00006.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00007.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00007.png new file mode 100644 index 0000000..e96f427 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00007.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00008.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00008.png new file mode 100644 index 0000000..131edd1 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00008.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00009.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00009.png new file mode 100644 index 0000000..4127432 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00009.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00010.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00010.png new file mode 100644 index 0000000..64ae31d Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00010.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00011.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00011.png new file mode 100644 index 0000000..cbaa889 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00011.png differ diff --git a/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00012.png b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00012.png new file mode 100644 index 0000000..8b981d4 Binary files /dev/null and b/tests/ragger/snapshots/flex/test_eip712_address_substitution_verbose/00012.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00000.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00000.png index 7c64769..b47dc20 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00000.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00000.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00001.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00001.png index 7437b4f..77c86c8 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00001.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00001.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00002.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00002.png index 7d3100b..58f1657 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00002.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00002.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00003.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00003.png index 404c495..8a15d01 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00003.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00003.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00004.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00004.png index 987479c..c9dd0f2 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00004.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00004.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00005.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00005.png index 726c927..9c2fa5d 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00005.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00005.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00006.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00006.png index 1c2d6cd..54aba60 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution/00006.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution/00006.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00000.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00000.png index 7c64769..b47dc20 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00000.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00000.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00001.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00001.png index eb09cbf..40cc099 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00001.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00001.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00002.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00002.png index ebd8116..8eeaf8b 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00002.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00002.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00003.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00003.png index 539bd78..7339e25 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00003.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00003.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00004.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00004.png index 249ca4f..c367eb6 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00004.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00004.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00005.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00005.png index c9f59eb..43a6b68 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00005.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00005.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00006.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00006.png index 8da1fa8..06031a7 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00006.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00006.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00007.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00007.png index 26ca679..dcd3cfa 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00007.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00007.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00008.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00008.png index dee5c6c..4d7644b 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00008.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00008.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00009.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00009.png index fa8a88e..bc1ee08 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00009.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00009.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00010.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00010.png index 606a1ed..5415585 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00010.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00010.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00011.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00011.png index 726c927..9c2fa5d 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00011.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00011.png differ diff --git a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00012.png b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00012.png index 1c2d6cd..54aba60 100644 Binary files a/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00012.png and b/tests/ragger/snapshots/stax/test_eip712_address_substitution_verbose/00012.png differ diff --git a/tests/ragger/test_eip712.py b/tests/ragger/test_eip712.py index abedeb4..6059740 100644 --- a/tests/ragger/test_eip712.py +++ b/tests/ragger/test_eip712.py @@ -150,8 +150,6 @@ def test_eip712_new(firmware: Firmware, app_client = EthAppClient(backend) if firmware.device == "nanos": pytest.skip("Not supported on LNS") - if firmware.device == "flex": - pytest.skip("Not yet available on Flex (due to swipe)") test_path = f"{input_file.parent}/{'-'.join(input_file.stem.split('-')[:-1])}" @@ -193,8 +191,6 @@ def test_eip712_address_substitution(firmware: Firmware, app_client = EthAppClient(backend) if firmware.device == "nanos": pytest.skip("Not supported on LNS") - if firmware.device == "flex": - pytest.skip("Not yet available on Flex (due to swipe)") if verbose: test_name += "_verbose"