diff --git a/src/monero_types.h b/src/monero_types.h index 7119fb6..9c1b5a7 100644 --- a/src/monero_types.h +++ b/src/monero_types.h @@ -96,6 +96,9 @@ enum device_mode { NONE, TRANSACTION_CREATE_REAL, TRANSACTION_CREATE_FAKE, TRANS #define DISP_SUB 0x52 #define DISP_INTEGRATED 0x53 +#define MAX_AMOUNT_LENGTH 23 +#define MAX_ADDR_LENGTH 160 + struct monero_v_state_s { unsigned char state; unsigned char protocol; @@ -187,9 +190,9 @@ struct monero_v_state_s { /* menu */ char ux_menu[16]; // address to display: 95/106-chars + null - char ux_address[160]; + char ux_address[MAX_ADDR_LENGTH]; // xmr to display: max pow(2,64) unit, aka 20-chars + '0' + dot + null - char ux_amount[23]; + char ux_amount[MAX_AMOUNT_LENGTH]; // addr mode unsigned char disp_addr_mode; // M.m address diff --git a/src/monero_ux_nbgl.c b/src/monero_ux_nbgl.c index de0dfd8..84d9a13 100644 --- a/src/monero_ux_nbgl.c +++ b/src/monero_ux_nbgl.c @@ -34,39 +34,38 @@ /* ----------------------------------------------------------------------- */ /* --- Stax UI layout --- */ /* ----------------------------------------------------------------------- */ +#define MAX_TAGVALUE_NUMBER 9 +#define MAX_AMOUNT_NUMBER 6 +#define MAX_ADDR_NUMBER 3 // MAX_AMOUNT_NUMBER - timelock - fee - change typedef struct { - nbgl_layoutTagValue_t tagValuePair[6]; - nbgl_layoutTagValueList_t tagValueList; + nbgl_contentTagValue_t tagValuePair[MAX_TAGVALUE_NUMBER]; + nbgl_contentTagValueList_t tagValueList; nbgl_pageInfoLongPress_t infoLongPress; - char timelockBuffer[23]; - char feeBuffer[23]; - char changeBuffer[23]; + char amountBuffer[MAX_AMOUNT_NUMBER][MAX_AMOUNT_LENGTH]; + uint32_t amountNum; + char dstBuffer[MAX_ADDR_NUMBER][MAX_ADDR_LENGTH]; + uint32_t addrNum; nbgl_pageContent_t content; nbgl_pageNavigationInfo_t nav; } TransactionContext_t; static TransactionContext_t transactionContext; -static nbgl_page_t* pageContext; -static void release_context(void) { - if (pageContext != NULL) { - nbgl_pageRelease(pageContext); - pageContext = NULL; - } -} - -/* -------------------------------- INFO UX --------------------------------- */ +/* -------------------------------- TITLES ---------------------------------- */ +const char feeTitle[] = "Fee"; +const char changeTitle[] = "Change"; +const char amountTitle[] = "Amount"; +const char dstTitle[] = "Destination"; +const char timelockTitle[] = "Timelock"; -void ui_menu_show_tx_aborted(void) { - nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_REJECTED, ui_menu_main_display); -} - -void ui_menu_show_security_error(void) { - nbgl_useCaseStatus("Security Error", false, ui_menu_main_display); +/* ------------------------------ STATIC HELPERS ---------------------------- */ +static void reset_context(void) { + transactionContext.tagValueList.nbPairs = 0; + transactionContext.amountNum = 0; + transactionContext.addrNum = 0; } -/* -------------------------------- OPEN TX UX --------------------------------- */ static void ui_menu_validation_action_cancel(void) { monero_abort_tx(); monero_io_insert_u16(SW_DENY); @@ -80,236 +79,130 @@ static void ui_menu_validation_action_confirm(void) { nbgl_useCaseSpinner("Processing TX"); } -static void ui_menu_validation_action_cancel_prompt(void) { - nbgl_useCaseConfirm("Reject transaction?", "", "Yes, Reject", "Go back to transaction", - ui_menu_validation_action_cancel); -} - static void ui_menu_validation_action(bool value) { if (value) { - transactionContext.tagValueList.nbPairs = 0; + reset_context(); ui_menu_validation_action_confirm(); } else { - ui_menu_validation_action_cancel_prompt(); + ui_menu_validation_action_cancel(); } } -unsigned int ui_menu_transaction_start(void) { - transactionContext.tagValueList.nbPairs = 0; - nbgl_useCaseReviewStart(&C_Monero_64px, "Review Transaction\nto send Monero", "", - "Reject transaction", ui_menu_validation_action_confirm, - ui_menu_validation_action_cancel_prompt); - return 0; -} - -unsigned int ui_menu_transaction_signed(void) { - nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_SIGNED, ui_menu_main_display); - return 0; -} - -void ui_menu_opentx_display(unsigned int value __attribute__((unused))) { - if (G_monero_vstate.tx_sig_mode == TRANSACTION_CREATE_REAL) { - nbgl_useCaseSpinner("Processing TX"); - } else { - nbgl_useCaseSpinner("Preparing TX"); - } -} - -/* ----------------- FEE/CHANGE/TIMELOCK VALIDATION ----------------- */ - -void ui_menu_fee_validation_display(unsigned int value __attribute__((unused))) { +static void add_amount(const char* title, bool forcePageStart) { uint8_t nbPairs = transactionContext.tagValueList.nbPairs; + if ((transactionContext.amountNum >= MAX_AMOUNT_NUMBER) || (nbPairs >= MAX_TAGVALUE_NUMBER)) { + ui_menu_validation_action_cancel(); + return; + } - strncpy(transactionContext.feeBuffer, G_monero_vstate.ux_amount, - sizeof(transactionContext.feeBuffer)); + strncpy(transactionContext.amountBuffer[transactionContext.amountNum], + G_monero_vstate.ux_amount, MAX_AMOUNT_LENGTH); - transactionContext.tagValuePair[nbPairs].item = "Fee"; - transactionContext.tagValuePair[nbPairs].value = transactionContext.feeBuffer; + transactionContext.tagValuePair[nbPairs].item = title; + transactionContext.tagValuePair[nbPairs].value = + transactionContext.amountBuffer[transactionContext.amountNum]; + if (forcePageStart) transactionContext.tagValuePair[nbPairs].forcePageStart = 1; transactionContext.tagValueList.pairs = transactionContext.tagValuePair; - transactionContext.tagValueList.nbPairs++; - - ui_menu_validation_action_confirm(); -} - -void ui_menu_change_validation_display(unsigned int value __attribute__((unused))) { - uint8_t nbPairs = transactionContext.tagValueList.nbPairs; - strncpy(transactionContext.changeBuffer, G_monero_vstate.ux_amount, - sizeof(transactionContext.changeBuffer)); - - transactionContext.tagValuePair[nbPairs].item = "Change"; - transactionContext.tagValuePair[nbPairs].value = transactionContext.changeBuffer; - - transactionContext.tagValueList.pairs = transactionContext.tagValuePair; transactionContext.tagValueList.nbPairs++; - - ui_menu_validation_action_confirm(); + transactionContext.amountNum++; } -void ui_menu_change_validation_display_last(unsigned int value __attribute__((unused))) { +static void add_address(void) { uint8_t nbPairs = transactionContext.tagValueList.nbPairs; - strncpy(transactionContext.changeBuffer, G_monero_vstate.ux_amount, - sizeof(transactionContext.changeBuffer)); - - transactionContext.tagValuePair[nbPairs].item = "Change"; - transactionContext.tagValuePair[nbPairs].value = transactionContext.changeBuffer; - - transactionContext.tagValueList.pairs = transactionContext.tagValuePair; - transactionContext.tagValueList.nbPairs++; - - transactionContext.infoLongPress.icon = &C_Monero_64px; - transactionContext.infoLongPress.longPressText = "Hold to sign"; - transactionContext.infoLongPress.longPressToken = 0; - transactionContext.infoLongPress.tuneId = TUNE_TAP_CASUAL; - transactionContext.infoLongPress.text = "Sign transaction"; - - nbgl_useCaseStaticReview(&transactionContext.tagValueList, &transactionContext.infoLongPress, - "Reject transaction", ui_menu_validation_action); -} - -static void timelock_callback(void) { - uint8_t nbPairs = transactionContext.tagValueList.nbPairs; + if ((transactionContext.addrNum >= MAX_ADDR_NUMBER) || (nbPairs >= MAX_TAGVALUE_NUMBER)) { + ui_menu_validation_action_cancel(); + return; + } - strncpy(transactionContext.timelockBuffer, G_monero_vstate.ux_amount, - sizeof(transactionContext.timelockBuffer)); + strncpy(transactionContext.dstBuffer[transactionContext.addrNum], G_monero_vstate.ux_address, + MAX_ADDR_LENGTH); - transactionContext.tagValuePair[nbPairs].item = "Timelock"; - transactionContext.tagValuePair[nbPairs].value = transactionContext.timelockBuffer; + transactionContext.tagValuePair[nbPairs].item = dstTitle; + transactionContext.tagValuePair[nbPairs].value = + transactionContext.dstBuffer[transactionContext.addrNum]; transactionContext.tagValueList.pairs = transactionContext.tagValuePair; - transactionContext.tagValueList.nbPairs++; - ui_menu_validation_action_confirm(); + transactionContext.tagValueList.nbPairs++; + transactionContext.addrNum++; } -void ui_menu_timelock_validation_display(unsigned int value __attribute__((unused))) { - transactionContext.tagValueList.nbPairs = 0; +/* ------------------------------- OPEN TX UX ------------------------------- */ - nbgl_useCaseReviewStart(&C_Monero_64px, "Review Transaction\nto send Monero", NULL, - "Reject transaction", timelock_callback, - ui_menu_validation_action_cancel_prompt); +unsigned int ui_menu_transaction_start(void) { + reset_context(); + return SW_OK; } -/* ----------------------------- USER DEST/AMOUNT VALIDATION ----------------------------- */ - -#ifdef TARGET_FLEX -#define NEXT_PAGE_TEXT ("Swipe to continue") -#else -#define NEXT_PAGE_TEXT ("Tap to continue") -#endif - -static void fill_amount_and_destination(void) { - transactionContext.tagValuePair[0].item = "Amount"; - transactionContext.tagValuePair[0].value = G_monero_vstate.ux_amount; - - transactionContext.tagValuePair[1].item = "Destination"; - transactionContext.tagValuePair[1].value = G_monero_vstate.ux_address; +unsigned int ui_menu_transaction_signed(void) { + nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_SIGNED, ui_menu_main_display); + return 0; +} - transactionContext.tagValueList.nbPairs = 2; - transactionContext.tagValueList.pairs = transactionContext.tagValuePair; +void ui_menu_opentx_display(unsigned int value __attribute__((unused))) { + if (G_monero_vstate.tx_sig_mode == TRANSACTION_CREATE_REAL) { + nbgl_useCaseSpinner("Processing TX"); + } else { + nbgl_useCaseSpinner("Preparing TX"); + } } -static void page_callback(int token, unsigned char index) { - (void)index; - release_context(); +/* -------------------------------- INFO UX --------------------------------- */ - ui_menu_validation_action(token); +void ui_menu_show_tx_aborted(void) { + nbgl_useCaseReviewStatus(STATUS_TYPE_TRANSACTION_REJECTED, ui_menu_main_display); } -static void continue_display(int token, unsigned char index) { - (void)index; - - if (token == QUIT_TOKEN) { - ui_menu_validation_action_cancel_prompt(); - } +/* --------------------- FEE/CHANGE/TIMELOCK VALIDATION --------------------- */ - fill_amount_and_destination(); - - nbgl_pageNavigationInfo_t info = {.activePage = 0, - .nbPages = 0, - .navType = NAV_WITH_TAP, - .progressIndicator = true, - .navWithTap.backButton = false, - .navWithTap.nextPageText = NEXT_PAGE_TEXT, - .navWithTap.nextPageToken = CONTINUE_TOKEN, - .navWithTap.quitText = "Reject transaction", - .quitToken = QUIT_TOKEN, - .tuneId = TUNE_TAP_CASUAL}; - - nbgl_pageContent_t content = { - .type = TAG_VALUE_LIST, - .tagValueList.nbPairs = transactionContext.tagValueList.nbPairs, - .tagValueList.pairs = (nbgl_layoutTagValue_t*)transactionContext.tagValueList.pairs}; - - pageContext = nbgl_pageDrawGenericContent(page_callback, &info, &content); +static void start_signature(void) { + nbgl_useCaseReview(TYPE_TRANSACTION, &transactionContext.tagValueList, &C_Monero_64px, + "Review Transaction\nto send Monero", NULL, "Sign transaction", + ui_menu_validation_action); } -static void continue_display_last(int token, unsigned char index) { - (void)index; - - if (token == QUIT_TOKEN) { - ui_menu_validation_action_cancel_prompt(); - } +void ui_menu_fee_validation_display(unsigned int value __attribute__((unused))) { + add_amount(feeTitle, false); + ui_menu_validation_action_confirm(); +} - fill_amount_and_destination(); - transactionContext.infoLongPress.icon = &C_Monero_64px; - transactionContext.infoLongPress.longPressText = "Hold to sign"; - transactionContext.infoLongPress.longPressToken = 0; - transactionContext.infoLongPress.tuneId = TUNE_TAP_CASUAL; - transactionContext.infoLongPress.text = "Sign transaction"; +void ui_menu_change_validation_display(unsigned int value __attribute__((unused))) { + add_amount(changeTitle, false); + ui_menu_validation_action_confirm(); +} - nbgl_useCaseStaticReview(&transactionContext.tagValueList, &transactionContext.infoLongPress, - "Reject transaction", ui_menu_validation_action); +void ui_menu_change_validation_display_last(unsigned int value __attribute__((unused))) { + add_amount(changeTitle, true); + start_signature(); } -static void display_previous_infos(bool last) { - release_context(); - - nbgl_pageNavigationInfo_t info = {.activePage = 0, - .nbPages = 0, - .navType = NAV_WITH_TAP, - .progressIndicator = true, - .navWithTap.backButton = false, - .navWithTap.nextPageText = NEXT_PAGE_TEXT, - .navWithTap.nextPageToken = CONTINUE_TOKEN, - .navWithTap.quitText = "Reject transaction", - .quitToken = QUIT_TOKEN, - .tuneId = TUNE_TAP_CASUAL}; - - nbgl_pageContent_t content = { - .type = TAG_VALUE_LIST, - .tagValueList.nbPairs = transactionContext.tagValueList.nbPairs, - .tagValueList.pairs = (nbgl_layoutTagValue_t*)transactionContext.tagValueList.pairs}; - - if (last) { - pageContext = nbgl_pageDrawGenericContent(continue_display_last, &info, &content); +void ui_menu_timelock_validation_display(unsigned int value __attribute__((unused))) { + reset_context(); + if (transactionContext.addrNum == 0) { + /* If no yet receivers addresses let us add the change on the same page */ + add_amount(timelockTitle, false); } else { - pageContext = nbgl_pageDrawGenericContent(continue_display, &info, &content); + /* In the other case let us for new page */ + add_amount(timelockTitle, true); } + ui_menu_validation_action_confirm(); } -void ui_menu_validation_display(unsigned int value __attribute__((unused))) { - const bool last = 0; - uint8_t nbPairs = transactionContext.tagValueList.nbPairs; +/* ---------------------- USER DEST/AMOUNT VALIDATION ----------------------- */ - if (nbPairs > 0) { - display_previous_infos(last); - } else { - continue_display(CONTINUE_TOKEN, 0); - } +void ui_menu_validation_display(unsigned int value __attribute__((unused))) { + add_amount(amountTitle, true); + add_address(); + ui_menu_validation_action_confirm(); } void ui_menu_validation_display_last(unsigned int value __attribute__((unused))) { - const bool last = 1; - uint8_t nbPairs = transactionContext.tagValueList.nbPairs; - - if (nbPairs > 0) { - display_previous_infos(last); - } else { - continue_display_last(CONTINUE_TOKEN, 0); - } + add_amount(amountTitle, true); + add_address(); + start_signature(); } /* ---------------------------- PUBLIC ADDRESS UX ---------------------------- */ #define ADDR_MAJOR G_monero_vstate.ux_address + 124 @@ -401,7 +294,7 @@ int ui_menu_any_pubaddr_display(unsigned int value __attribute__((unused)), unsi return 0; } -/* -------------------------------- EXPORT VIEW KEY UX --------------------------------- */ +/* -------------------------- EXPORT VIEW KEY UX ---------------------------- */ static void ui_menu_export_viewkey_action(bool value) { unsigned int sw; diff --git a/tests/monero_client/monero_cmd.py b/tests/monero_client/monero_cmd.py index 0510a5e..ab1f2e9 100644 --- a/tests/monero_client/monero_cmd.py +++ b/tests/monero_client/monero_cmd.py @@ -28,7 +28,7 @@ from .utils.utils import get_nano_review_instructions from pathlib import Path from ragger.firmware import Firmware -from ragger.navigator import NavInsID, NavIns +from ragger.navigator import NavInsID PROTOCOL_VERSION: int = 3 TESTS_ROOT_DIR = Path(__file__).parent.parent @@ -224,23 +224,22 @@ def prefix_hash_init(self, backend, test_name, firmware, navigator, version: int encode_varint(timelock) ]) - if firmware == Firmware.NANOS: - instructions = get_nano_review_instructions(1) - elif firmware.is_nano: + instructions = None + if firmware.is_nano: instructions = get_nano_review_instructions(1) - else: - instructions = [ - NavInsID.SWIPE_CENTER_TO_LEFT - ] + with self.device.send_async(cla=PROTOCOL_VERSION, ins=ins, p1=1, p2=0, option=0, payload=payload): - navigator.navigate_and_compare(TESTS_ROOT_DIR, - test_name + "_hash_init", - instructions) + if firmware.is_nano: + navigator.navigate_and_compare(TESTS_ROOT_DIR, + test_name + "_hash_init", + instructions) + else: + pass sw, response = self.device.async_response() # type: int, bytes @@ -387,14 +386,9 @@ def validate_prehash_init(self, # txntype is skipped in the app payload: bytes = struct.pack("B", txntype) + encode_varint(txnfee) - if firmware == Firmware.NANOS: - instructions = get_nano_review_instructions(1) - elif firmware.is_nano: + instructions = None + if firmware.is_nano: instructions = get_nano_review_instructions(1) - else: - instructions = [ - NavInsID.USE_CASE_REVIEW_TAP - ] with self.device.send_async(cla=PROTOCOL_VERSION, ins=ins, @@ -451,6 +445,7 @@ def validate_prehash_update(self, blinded_amount )) + instructions = None if firmware == Firmware.NANOS: if is_last: instructions = get_nano_review_instructions(1) @@ -463,15 +458,13 @@ def validate_prehash_update(self, instructions = get_nano_review_instructions(3) else: if is_last: - instructions = [ - NavInsID.USE_CASE_REVIEW_TAP, - NavInsID.USE_CASE_REVIEW_CONFIRM - ] - - else: instructions = [ NavInsID.SWIPE_CENTER_TO_LEFT, NavInsID.SWIPE_CENTER_TO_LEFT, + NavInsID.SWIPE_CENTER_TO_LEFT, + NavInsID.SWIPE_CENTER_TO_LEFT, + NavInsID.USE_CASE_REVIEW_TAP, + NavInsID.USE_CASE_REVIEW_CONFIRM ] backend.wait_for_text_on_screen("Processing") @@ -488,9 +481,12 @@ def validate_prehash_update(self, instructions, screen_change_after_last_instruction=False, timeout=10000) else: - navigator.navigate_and_compare(TESTS_ROOT_DIR, - test_name + "_prehash_update_first", - instructions) + if firmware.is_nano: + navigator.navigate_and_compare(TESTS_ROOT_DIR, + test_name + "_prehash_update_" + str(index), + instructions) + else: + pass sw, response = self.device.async_response() # type: int, bytes diff --git a/tests/snapshots/flex/test_prefix_hash_hash_init/00000.png b/tests/snapshots/flex/test_prefix_hash_hash_init/00000.png deleted file mode 100644 index 4bb060d..0000000 Binary files a/tests/snapshots/flex/test_prefix_hash_hash_init/00000.png and /dev/null differ diff --git a/tests/snapshots/flex/test_prefix_hash_hash_init/00001.png b/tests/snapshots/flex/test_prefix_hash_hash_init/00001.png deleted file mode 100644 index 92bcce3..0000000 Binary files a/tests/snapshots/flex/test_prefix_hash_hash_init/00001.png and /dev/null differ diff --git a/tests/snapshots/flex/test_validate_prehash_update_first/00000.png b/tests/snapshots/flex/test_validate_prehash_update_first/00000.png deleted file mode 100644 index fa42052..0000000 Binary files a/tests/snapshots/flex/test_validate_prehash_update_first/00000.png and /dev/null differ diff --git a/tests/snapshots/flex/test_validate_prehash_update_first/00001.png b/tests/snapshots/flex/test_validate_prehash_update_first/00001.png deleted file mode 100644 index 80e695c..0000000 Binary files a/tests/snapshots/flex/test_validate_prehash_update_first/00001.png and /dev/null differ diff --git a/tests/snapshots/flex/test_validate_prehash_update_first/00002.png b/tests/snapshots/flex/test_validate_prehash_update_first/00002.png deleted file mode 100644 index 92bcce3..0000000 Binary files a/tests/snapshots/flex/test_validate_prehash_update_first/00002.png and /dev/null differ diff --git a/tests/snapshots/flex/test_validate_prehash_update_last/00000.png b/tests/snapshots/flex/test_validate_prehash_update_last/00000.png index ed0ded3..399dcdd 100644 Binary files a/tests/snapshots/flex/test_validate_prehash_update_last/00000.png and b/tests/snapshots/flex/test_validate_prehash_update_last/00000.png differ diff --git a/tests/snapshots/flex/test_validate_prehash_update_last/00001.png b/tests/snapshots/flex/test_validate_prehash_update_last/00001.png index 8d0f73a..ce21edb 100644 Binary files a/tests/snapshots/flex/test_validate_prehash_update_last/00001.png and b/tests/snapshots/flex/test_validate_prehash_update_last/00001.png differ diff --git a/tests/snapshots/flex/test_validate_prehash_update_last/00002.png b/tests/snapshots/flex/test_validate_prehash_update_last/00002.png new file mode 100644 index 0000000..fbdeb43 Binary files /dev/null and b/tests/snapshots/flex/test_validate_prehash_update_last/00002.png differ diff --git a/tests/snapshots/flex/test_validate_prehash_update_last/00003.png b/tests/snapshots/flex/test_validate_prehash_update_last/00003.png new file mode 100644 index 0000000..6ebc490 Binary files /dev/null and b/tests/snapshots/flex/test_validate_prehash_update_last/00003.png differ diff --git a/tests/snapshots/flex/test_validate_prehash_update_last/00004.png b/tests/snapshots/flex/test_validate_prehash_update_last/00004.png new file mode 100644 index 0000000..63aea46 Binary files /dev/null and b/tests/snapshots/flex/test_validate_prehash_update_last/00004.png differ diff --git a/tests/snapshots/flex/test_validate_prehash_update_last/00005.png b/tests/snapshots/flex/test_validate_prehash_update_last/00005.png new file mode 100644 index 0000000..cb0b84d Binary files /dev/null and b/tests/snapshots/flex/test_validate_prehash_update_last/00005.png differ diff --git a/tests/snapshots/nanos/test_validate_prehash_update_first/00000.png b/tests/snapshots/nanos/test_validate_prehash_update_1/00000.png similarity index 100% rename from tests/snapshots/nanos/test_validate_prehash_update_first/00000.png rename to tests/snapshots/nanos/test_validate_prehash_update_1/00000.png diff --git a/tests/snapshots/nanos/test_validate_prehash_update_first/00001.png b/tests/snapshots/nanos/test_validate_prehash_update_1/00001.png similarity index 100% rename from tests/snapshots/nanos/test_validate_prehash_update_first/00001.png rename to tests/snapshots/nanos/test_validate_prehash_update_1/00001.png diff --git a/tests/snapshots/nanos/test_validate_prehash_update_first/00002.png b/tests/snapshots/nanos/test_validate_prehash_update_1/00002.png similarity index 100% rename from tests/snapshots/nanos/test_validate_prehash_update_first/00002.png rename to tests/snapshots/nanos/test_validate_prehash_update_1/00002.png diff --git a/tests/snapshots/nanos/test_validate_prehash_update_first/00003.png b/tests/snapshots/nanos/test_validate_prehash_update_1/00003.png similarity index 100% rename from tests/snapshots/nanos/test_validate_prehash_update_first/00003.png rename to tests/snapshots/nanos/test_validate_prehash_update_1/00003.png diff --git a/tests/snapshots/nanos/test_validate_prehash_update_first/00004.png b/tests/snapshots/nanos/test_validate_prehash_update_1/00004.png similarity index 100% rename from tests/snapshots/nanos/test_validate_prehash_update_first/00004.png rename to tests/snapshots/nanos/test_validate_prehash_update_1/00004.png diff --git a/tests/snapshots/nanos/test_validate_prehash_update_first/00005.png b/tests/snapshots/nanos/test_validate_prehash_update_1/00005.png similarity index 100% rename from tests/snapshots/nanos/test_validate_prehash_update_first/00005.png rename to tests/snapshots/nanos/test_validate_prehash_update_1/00005.png diff --git a/tests/snapshots/nanos/test_validate_prehash_update_first/00006.png b/tests/snapshots/nanos/test_validate_prehash_update_1/00006.png similarity index 100% rename from tests/snapshots/nanos/test_validate_prehash_update_first/00006.png rename to tests/snapshots/nanos/test_validate_prehash_update_1/00006.png diff --git a/tests/snapshots/nanos/test_validate_prehash_update_first/00007.png b/tests/snapshots/nanos/test_validate_prehash_update_1/00007.png similarity index 100% rename from tests/snapshots/nanos/test_validate_prehash_update_first/00007.png rename to tests/snapshots/nanos/test_validate_prehash_update_1/00007.png diff --git a/tests/snapshots/nanos/test_validate_prehash_update_first/00008.png b/tests/snapshots/nanos/test_validate_prehash_update_1/00008.png similarity index 100% rename from tests/snapshots/nanos/test_validate_prehash_update_first/00008.png rename to tests/snapshots/nanos/test_validate_prehash_update_1/00008.png diff --git a/tests/snapshots/nanos/test_validate_prehash_update_2/00000.png b/tests/snapshots/nanos/test_validate_prehash_update_2/00000.png new file mode 100644 index 0000000..a689f82 Binary files /dev/null and b/tests/snapshots/nanos/test_validate_prehash_update_2/00000.png differ diff --git a/tests/snapshots/nanos/test_validate_prehash_update_2/00001.png b/tests/snapshots/nanos/test_validate_prehash_update_2/00001.png new file mode 100644 index 0000000..00e02d7 Binary files /dev/null and b/tests/snapshots/nanos/test_validate_prehash_update_2/00001.png differ diff --git a/tests/snapshots/nanos/test_validate_prehash_update_2/00002.png b/tests/snapshots/nanos/test_validate_prehash_update_2/00002.png new file mode 100644 index 0000000..a79df73 Binary files /dev/null and b/tests/snapshots/nanos/test_validate_prehash_update_2/00002.png differ diff --git a/tests/snapshots/nanos/test_validate_prehash_update_2/00003.png b/tests/snapshots/nanos/test_validate_prehash_update_2/00003.png new file mode 100644 index 0000000..5207c17 Binary files /dev/null and b/tests/snapshots/nanos/test_validate_prehash_update_2/00003.png differ diff --git a/tests/snapshots/nanos/test_validate_prehash_update_2/00004.png b/tests/snapshots/nanos/test_validate_prehash_update_2/00004.png new file mode 100644 index 0000000..fa90ac8 Binary files /dev/null and b/tests/snapshots/nanos/test_validate_prehash_update_2/00004.png differ diff --git a/tests/snapshots/nanos/test_validate_prehash_update_2/00005.png b/tests/snapshots/nanos/test_validate_prehash_update_2/00005.png new file mode 100644 index 0000000..dc69d01 Binary files /dev/null and b/tests/snapshots/nanos/test_validate_prehash_update_2/00005.png differ diff --git a/tests/snapshots/nanos/test_validate_prehash_update_2/00006.png b/tests/snapshots/nanos/test_validate_prehash_update_2/00006.png new file mode 100644 index 0000000..c27242a Binary files /dev/null and b/tests/snapshots/nanos/test_validate_prehash_update_2/00006.png differ diff --git a/tests/snapshots/nanos/test_validate_prehash_update_2/00007.png b/tests/snapshots/nanos/test_validate_prehash_update_2/00007.png new file mode 100644 index 0000000..e66f662 Binary files /dev/null and b/tests/snapshots/nanos/test_validate_prehash_update_2/00007.png differ diff --git a/tests/snapshots/nanos/test_validate_prehash_update_2/00008.png b/tests/snapshots/nanos/test_validate_prehash_update_2/00008.png new file mode 100644 index 0000000..2360dfb Binary files /dev/null and b/tests/snapshots/nanos/test_validate_prehash_update_2/00008.png differ diff --git a/tests/snapshots/nanosp/test_validate_prehash_update_first/00000.png b/tests/snapshots/nanosp/test_validate_prehash_update_1/00000.png similarity index 100% rename from tests/snapshots/nanosp/test_validate_prehash_update_first/00000.png rename to tests/snapshots/nanosp/test_validate_prehash_update_1/00000.png diff --git a/tests/snapshots/nanosp/test_validate_prehash_update_first/00001.png b/tests/snapshots/nanosp/test_validate_prehash_update_1/00001.png similarity index 100% rename from tests/snapshots/nanosp/test_validate_prehash_update_first/00001.png rename to tests/snapshots/nanosp/test_validate_prehash_update_1/00001.png diff --git a/tests/snapshots/nanosp/test_validate_prehash_update_first/00002.png b/tests/snapshots/nanosp/test_validate_prehash_update_1/00002.png similarity index 100% rename from tests/snapshots/nanosp/test_validate_prehash_update_first/00002.png rename to tests/snapshots/nanosp/test_validate_prehash_update_1/00002.png diff --git a/tests/snapshots/nanosp/test_validate_prehash_update_first/00003.png b/tests/snapshots/nanosp/test_validate_prehash_update_1/00003.png similarity index 100% rename from tests/snapshots/nanosp/test_validate_prehash_update_first/00003.png rename to tests/snapshots/nanosp/test_validate_prehash_update_1/00003.png diff --git a/tests/snapshots/nanosp/test_validate_prehash_update_first/00004.png b/tests/snapshots/nanosp/test_validate_prehash_update_1/00004.png similarity index 100% rename from tests/snapshots/nanosp/test_validate_prehash_update_first/00004.png rename to tests/snapshots/nanosp/test_validate_prehash_update_1/00004.png diff --git a/tests/snapshots/nanosp/test_validate_prehash_update_2/00000.png b/tests/snapshots/nanosp/test_validate_prehash_update_2/00000.png new file mode 100644 index 0000000..c10a641 Binary files /dev/null and b/tests/snapshots/nanosp/test_validate_prehash_update_2/00000.png differ diff --git a/tests/snapshots/nanosp/test_validate_prehash_update_2/00001.png b/tests/snapshots/nanosp/test_validate_prehash_update_2/00001.png new file mode 100644 index 0000000..3dfe1bc Binary files /dev/null and b/tests/snapshots/nanosp/test_validate_prehash_update_2/00001.png differ diff --git a/tests/snapshots/nanosp/test_validate_prehash_update_2/00002.png b/tests/snapshots/nanosp/test_validate_prehash_update_2/00002.png new file mode 100644 index 0000000..395d1fc Binary files /dev/null and b/tests/snapshots/nanosp/test_validate_prehash_update_2/00002.png differ diff --git a/tests/snapshots/nanox/test_validate_prehash_update_first/00003.png b/tests/snapshots/nanosp/test_validate_prehash_update_2/00003.png similarity index 100% rename from tests/snapshots/nanox/test_validate_prehash_update_first/00003.png rename to tests/snapshots/nanosp/test_validate_prehash_update_2/00003.png diff --git a/tests/snapshots/nanox/test_validate_prehash_update_first/00004.png b/tests/snapshots/nanosp/test_validate_prehash_update_2/00004.png similarity index 100% rename from tests/snapshots/nanox/test_validate_prehash_update_first/00004.png rename to tests/snapshots/nanosp/test_validate_prehash_update_2/00004.png diff --git a/tests/snapshots/nanox/test_validate_prehash_update_first/00000.png b/tests/snapshots/nanox/test_validate_prehash_update_1/00000.png similarity index 100% rename from tests/snapshots/nanox/test_validate_prehash_update_first/00000.png rename to tests/snapshots/nanox/test_validate_prehash_update_1/00000.png diff --git a/tests/snapshots/nanox/test_validate_prehash_update_first/00001.png b/tests/snapshots/nanox/test_validate_prehash_update_1/00001.png similarity index 100% rename from tests/snapshots/nanox/test_validate_prehash_update_first/00001.png rename to tests/snapshots/nanox/test_validate_prehash_update_1/00001.png diff --git a/tests/snapshots/nanox/test_validate_prehash_update_first/00002.png b/tests/snapshots/nanox/test_validate_prehash_update_1/00002.png similarity index 100% rename from tests/snapshots/nanox/test_validate_prehash_update_first/00002.png rename to tests/snapshots/nanox/test_validate_prehash_update_1/00002.png diff --git a/tests/snapshots/nanox/test_validate_prehash_update_1/00003.png b/tests/snapshots/nanox/test_validate_prehash_update_1/00003.png new file mode 100644 index 0000000..63db764 Binary files /dev/null and b/tests/snapshots/nanox/test_validate_prehash_update_1/00003.png differ diff --git a/tests/snapshots/nanox/test_validate_prehash_update_1/00004.png b/tests/snapshots/nanox/test_validate_prehash_update_1/00004.png new file mode 100644 index 0000000..e1237d4 Binary files /dev/null and b/tests/snapshots/nanox/test_validate_prehash_update_1/00004.png differ diff --git a/tests/snapshots/nanox/test_validate_prehash_update_2/00000.png b/tests/snapshots/nanox/test_validate_prehash_update_2/00000.png new file mode 100644 index 0000000..c10a641 Binary files /dev/null and b/tests/snapshots/nanox/test_validate_prehash_update_2/00000.png differ diff --git a/tests/snapshots/nanox/test_validate_prehash_update_2/00001.png b/tests/snapshots/nanox/test_validate_prehash_update_2/00001.png new file mode 100644 index 0000000..3dfe1bc Binary files /dev/null and b/tests/snapshots/nanox/test_validate_prehash_update_2/00001.png differ diff --git a/tests/snapshots/nanox/test_validate_prehash_update_2/00002.png b/tests/snapshots/nanox/test_validate_prehash_update_2/00002.png new file mode 100644 index 0000000..395d1fc Binary files /dev/null and b/tests/snapshots/nanox/test_validate_prehash_update_2/00002.png differ diff --git a/tests/snapshots/nanox/test_validate_prehash_update_2/00003.png b/tests/snapshots/nanox/test_validate_prehash_update_2/00003.png new file mode 100644 index 0000000..63db764 Binary files /dev/null and b/tests/snapshots/nanox/test_validate_prehash_update_2/00003.png differ diff --git a/tests/snapshots/nanox/test_validate_prehash_update_2/00004.png b/tests/snapshots/nanox/test_validate_prehash_update_2/00004.png new file mode 100644 index 0000000..e1237d4 Binary files /dev/null and b/tests/snapshots/nanox/test_validate_prehash_update_2/00004.png differ diff --git a/tests/snapshots/stax/test_prefix_hash_hash_init/00000.png b/tests/snapshots/stax/test_prefix_hash_hash_init/00000.png deleted file mode 100644 index 6216e52..0000000 Binary files a/tests/snapshots/stax/test_prefix_hash_hash_init/00000.png and /dev/null differ diff --git a/tests/snapshots/stax/test_prefix_hash_hash_init/00001.png b/tests/snapshots/stax/test_prefix_hash_hash_init/00001.png deleted file mode 100644 index 7409353..0000000 Binary files a/tests/snapshots/stax/test_prefix_hash_hash_init/00001.png and /dev/null differ diff --git a/tests/snapshots/stax/test_validate_prehash_update_first/00000.png b/tests/snapshots/stax/test_validate_prehash_update_first/00000.png deleted file mode 100644 index 3623167..0000000 Binary files a/tests/snapshots/stax/test_validate_prehash_update_first/00000.png and /dev/null differ diff --git a/tests/snapshots/stax/test_validate_prehash_update_first/00001.png b/tests/snapshots/stax/test_validate_prehash_update_first/00001.png deleted file mode 100644 index c9b9d96..0000000 Binary files a/tests/snapshots/stax/test_validate_prehash_update_first/00001.png and /dev/null differ diff --git a/tests/snapshots/stax/test_validate_prehash_update_first/00002.png b/tests/snapshots/stax/test_validate_prehash_update_first/00002.png deleted file mode 100644 index 7409353..0000000 Binary files a/tests/snapshots/stax/test_validate_prehash_update_first/00002.png and /dev/null differ diff --git a/tests/snapshots/stax/test_validate_prehash_update_last/00000.png b/tests/snapshots/stax/test_validate_prehash_update_last/00000.png index 6771739..4baabc0 100644 Binary files a/tests/snapshots/stax/test_validate_prehash_update_last/00000.png and b/tests/snapshots/stax/test_validate_prehash_update_last/00000.png differ diff --git a/tests/snapshots/stax/test_validate_prehash_update_last/00001.png b/tests/snapshots/stax/test_validate_prehash_update_last/00001.png index 0e94064..90d0bf2 100644 Binary files a/tests/snapshots/stax/test_validate_prehash_update_last/00001.png and b/tests/snapshots/stax/test_validate_prehash_update_last/00001.png differ diff --git a/tests/snapshots/stax/test_validate_prehash_update_last/00002.png b/tests/snapshots/stax/test_validate_prehash_update_last/00002.png new file mode 100644 index 0000000..8f4e185 Binary files /dev/null and b/tests/snapshots/stax/test_validate_prehash_update_last/00002.png differ diff --git a/tests/snapshots/stax/test_validate_prehash_update_last/00003.png b/tests/snapshots/stax/test_validate_prehash_update_last/00003.png new file mode 100644 index 0000000..279d4af Binary files /dev/null and b/tests/snapshots/stax/test_validate_prehash_update_last/00003.png differ diff --git a/tests/snapshots/stax/test_validate_prehash_update_last/00004.png b/tests/snapshots/stax/test_validate_prehash_update_last/00004.png new file mode 100644 index 0000000..1d6e090 Binary files /dev/null and b/tests/snapshots/stax/test_validate_prehash_update_last/00004.png differ diff --git a/tests/snapshots/stax/test_validate_prehash_update_last/00005.png b/tests/snapshots/stax/test_validate_prehash_update_last/00005.png new file mode 100644 index 0000000..abefe7c Binary files /dev/null and b/tests/snapshots/stax/test_validate_prehash_update_last/00005.png differ diff --git a/tests/test_sig.py b/tests/test_sig.py index 3f70e0c..529b2c8 100644 --- a/tests/test_sig.py +++ b/tests/test_sig.py @@ -1,8 +1,6 @@ import pytest from monero_client.monero_types import SigType, Keys -from monero_client.exception import ClientNotSupported - @pytest.mark.incremental class TestSignature: @@ -36,17 +34,28 @@ def state(): "a9FiYNpEjBoHZ9iTww3vL96P1hcmTQXvpFAo" ) + receiver2 = Keys( + public_view_key=bytes.fromhex("1fe0cf63fc16b40b5397c47a5227e4eb4d" + "9bc735dbd8d062340c11d35966f904"), + public_spend_key=bytes.fromhex("a22faef2684feb1583f69a3d2bd87e09b3" + "9f70276b69b8512876b7adc8ddfac8"), + secret_view_key=bytes.fromhex("b9209a473237f601d66246de732680cb62" + "d344fbf0d2bc23e195087d53a06f37"), + secret_spend_key=None, + addr="5R32BpY7seiTednbP9I7mzS7L9tyN0VmxSp1lSfkasRlgoO98XjU6gnHpwqtX9Md0e7SBj9IaWLZR2AZeEzz6NsXhLMdRi9" + ) + return {"sender": sender, - "receiver_number": 2, - "receiver": [receiver, sender], - "is_change_addr": [False, True], - "amount": [int(69.36*1000000000000), int(0.55*1000000000000)], + "receiver_number": 3, + "receiver": [receiver, receiver2, sender], + "is_change_addr": [False, False, True], + "amount": [int(69.36*1000000000000), int(0.37*1000000000000), int(0.55*1000000000000)], "tx_pub_key": None, "_tx_priv_key": None, - "_ak_amount": [[], []], - "blinded_amount": [[], []], - "blinded_mask": [[], []], - "y": [[], []]} + "_ak_amount": [[], [], []], + "blinded_amount": [[], [], []], + "blinded_mask": [[], [], []], + "y": [[], [], []]} @staticmethod def test_set_sig(monero):