diff --git a/doc/ins_encrypted_amount_transfer.md b/doc/ins_encrypted_amount_transfer.md deleted file mode 100644 index 908faea2..00000000 --- a/doc/ins_encrypted_amount_transfer.md +++ /dev/null @@ -1,31 +0,0 @@ -# Encrypted amount transfer - -A transaction for transferring an encrypted amount to another account. - -## Protocol description - -- Multiple commands. - -| INS | P1 | P2 | CDATA | Comment | -| ------ | ------ | ------ | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | -| `0x11` | `0x00` | `0x00` | `path_length path[uint32]x[8] account_transaction_header[60 bytes] transaction_kind[uint8] to_address[32 bytes]` | | -| `0x11` | `0x01` | `0x00` | `remaining_amount` | | -| `0x11` | `0x02` | `0x00` | `transfer_amount index encrypted_amount_agg_index proofs_size[uint16]` | | -| `0x11` | `0x03` | `0x00` | `proofs[1..255 bytes]` | In batches of up to 255 bytes, repeated until all proofs have been sent. | - -# Encrypted amount transfer with memo - -A transaction for transferring an encrypted amount to another account, with a memo attached. -Uses the same INS number, but a different P1 for the initial call, and has a different transaction kind (23); - -## Protocol description - -- Multiple commands - -| INS | P1 | P2 | CDATA | Comment | -| ------ | ------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------ | -| `0x11` | `0x04` | `0x00` | `path_length path[uint32]x[8] account_transaction_header[60 bytes] transaction_kind[uint8] to_address[32 bytes] memo_length[uint16]` | | -| `0x11` | `0x05` | `0x00` | `memo[1...255 bytes]` | The memo is assumed to be CBOR encoded. | -| `0x11` | `0x01` | `0x00` | `remaining_amount` | | -| `0x11` | `0x02` | `0x00` | `transfer_amount index encrypted_amount_agg_index proofs_size[uint16]` | | -| `0x11` | `0x03` | `0x00` | `proofs[1..255 bytes]` | In batches of up to 255 bytes, repeated until all proofs have been sent. | diff --git a/doc/ins_transfer_to_encrypted.md b/doc/ins_transfer_to_encrypted.md deleted file mode 100644 index 2334e8e9..00000000 --- a/doc/ins_transfer_to_encrypted.md +++ /dev/null @@ -1,11 +0,0 @@ -# Transfer to encrypted - -A transaction for transferring an amount to the encrypted balance of the account. - -## Protocol description - -- Single command - -| INS | P1 | P2 | CDATA | Comment | -| ------ | ------ | ------ | ----------------------------------------------------------------------------------------------------------------------- | ------- | -| `0x11` | `0x00` | `0x00` | `path_length path[uint32]x[8] account_transaction_header[60 bytes] transaction_kind[uint8] amount_to_encrypted[uint64]` | | diff --git a/src/common/handler.c b/src/common/handler.c index 8324253b..2e2bf7fb 100644 --- a/src/common/handler.c +++ b/src/common/handler.c @@ -33,15 +33,6 @@ int handler(uint8_t INS, case INS_EXPORT_PRIVATE_KEY: handleExportPrivateKey(cdata, p1, p2, flags); break; - case INS_TRANSFER_TO_ENCRYPTED: - handleSignTransferToEncrypted(cdata, flags); - break; - case INS_ENCRYPTED_AMOUNT_TRANSFER: - handleSignEncryptedAmountTransfer(cdata, p1, lc, flags, isInitialCall); - break; - case INS_ENCRYPTED_AMOUNT_TRANSFER_WITH_MEMO: - handleSignEncryptedAmountTransferWithMemo(cdata, p1, lc, flags, isInitialCall); - break; case INS_TRANSFER_TO_PUBLIC: handleSignTransferToPublic(cdata, p1, lc, flags, isInitialCall); break; diff --git a/src/common/handler.h b/src/common/handler.h index 94efcb96..57fe3d11 100644 --- a/src/common/handler.h +++ b/src/common/handler.h @@ -22,11 +22,8 @@ #define INS_INIT_CONTRACT 0x07 -#define INS_UPDATE_CONTRACT 0x08 - -#define INS_ENCRYPTED_AMOUNT_TRANSFER 0x10 -#define INS_TRANSFER_TO_ENCRYPTED 0x11 -#define INS_TRANSFER_TO_PUBLIC 0x12 +#define INS_UPDATE_CONTRACT 0x08 +#define INS_TRANSFER_TO_PUBLIC 0x12 #define INS_CONFIGURE_DELEGATION 0x17 #define INS_CONFIGURE_BAKER 0x18 @@ -36,7 +33,6 @@ #define INS_SIGN_UPDATE_CREDENTIAL 0x31 #define INS_SIGN_TRANSFER_WITH_MEMO 0x32 -#define INS_ENCRYPTED_AMOUNT_TRANSFER_WITH_MEMO 0x33 #define INS_SIGN_TRANSFER_WITH_SCHEDULE_AND_MEMO 0x34 #define INS_REGISTER_DATA 0x35 diff --git a/src/common/ui/display.h b/src/common/ui/display.h index 473bcfc7..b4bb7c4c 100644 --- a/src/common/ui/display.h +++ b/src/common/ui/display.h @@ -36,14 +36,6 @@ void uiSignCredentialDeploymentNewDisplay(void); void uiSignCredentialDeploymentExistingIntroDisplay(void); void uiSignCredentialDeploymentExistingDisplay(void); -// Encrypted amount transfer - -#ifdef HAVE_BAGL -extern const ux_flow_step_t *ux_sign_encrypted_amount_transfer[8]; -#endif - -void startEncryptedTransferDisplay(bool displayMemo); - // Public information for IP void uiReviewPublicInformationForIpDisplay(void); void uiSignPublicInformationForIpPublicKeyDisplay(void); @@ -62,8 +54,6 @@ extern const ux_flow_step_t *ux_sign_amount_transfer[8]; void startTransferDisplay(bool displayMemo, volatile unsigned int *flags); -// Sign Transfer to Encrypted -void uiSignTransferToEncryptedDisplay(volatile unsigned int *flags); // Sign Transfer to Public void uiSignTransferToPublicDisplay(volatile unsigned int *flags); diff --git a/src/common/ui/display_bagl.c b/src/common/ui/display_bagl.c index 6dfdcc95..e1f88fa5 100644 --- a/src/common/ui/display_bagl.c +++ b/src/common/ui/display_bagl.c @@ -516,37 +516,6 @@ void uiSignCredentialDeploymentExistingDisplay(void) { ux_flow_init(0, ux_sign_credential_deployment_existing, NULL); } -// Encrypted amount transfer - -const ux_flow_step_t *ux_sign_encrypted_amount_transfer[8]; - -// UI for displaying encrypted transfer transaction. It only shows the user the recipient address -// as the amounts are encrypted and can't be validated by the user. -UX_STEP_NOCB(ux_sign_encrypted_amount_transfer_1_step, nn, {"Shielded", "transfer"}); -UX_STEP_NOCB(ux_sign_encrypted_amount_transfer_2_step, - bnnn_paging, - {.title = "Recipient", - .text = (char *)global.withDataBlob.signEncryptedAmountToTransfer.to}); - -void startEncryptedTransferDisplay(bool displayMemo) { - uint8_t index = 0; - - ux_sign_encrypted_amount_transfer[index++] = &ux_sign_flow_shared_review; - ux_sign_encrypted_amount_transfer[index++] = &ux_sign_encrypted_amount_transfer_1_step; - ux_sign_encrypted_amount_transfer[index++] = &ux_sign_flow_account_sender_view; - ux_sign_encrypted_amount_transfer[index++] = &ux_sign_encrypted_amount_transfer_2_step; - - if (displayMemo) { - ux_sign_encrypted_amount_transfer[index++] = &ux_display_memo_step_nocb; - } - - ux_sign_encrypted_amount_transfer[index++] = &ux_sign_flow_shared_sign; - ux_sign_encrypted_amount_transfer[index++] = &ux_sign_flow_shared_decline; - - ux_sign_encrypted_amount_transfer[index++] = FLOW_END_STEP; - ux_flow_init(0, ux_sign_encrypted_amount_transfer, NULL); -} - // Public information for IP UX_STEP_NOCB(ux_sign_public_info_for_ip_display_public_key, @@ -679,23 +648,6 @@ void startTransferDisplay(bool displayMemo, volatile unsigned int *flags) { *flags |= IO_ASYNCH_REPLY; } -// Sign Transfer to Encrypted - -UX_STEP_NOCB(ux_sign_transfer_to_encrypted_1_step, - bnnn_paging, - {.title = "Shield amount", .text = (char *)global.signTransferToEncrypted.amount}); -UX_FLOW(ux_sign_transfer_to_encrypted, - &ux_sign_flow_shared_review, - &ux_sign_flow_account_sender_view, - &ux_sign_transfer_to_encrypted_1_step, - &ux_sign_flow_shared_sign, - &ux_sign_flow_shared_decline); - -void uiSignTransferToEncryptedDisplay(volatile unsigned int *flags) { - ux_flow_init(0, ux_sign_transfer_to_encrypted, NULL); - *flags |= IO_ASYNCH_REPLY; -} - // Sign Transfer to Public UX_STEP_NOCB(ux_sign_transfer_to_public_1_step, diff --git a/src/common/ui/display_nbgl.c b/src/common/ui/display_nbgl.c index 60611fd8..1aaf38b0 100644 --- a/src/common/ui/display_nbgl.c +++ b/src/common/ui/display_nbgl.c @@ -577,12 +577,6 @@ void uiSignCredentialDeploymentVerificationKeyFlowDisplay(volatile unsigned int *flags |= IO_ASYNCH_REPLY; } -void startEncryptedTransferDisplay(bool displayMemo) { - if (displayMemo) { - return; - } -} - void uiSignPublicInformationForIpCompleteDisplay(void) { // Setup data to display uint8_t pairIndex = 0; @@ -782,12 +776,6 @@ void startTransferDisplay(bool displayMemo, volatile unsigned int *flags) { *flags |= IO_ASYNCH_REPLY; } -void uiSignTransferToEncryptedDisplay(volatile unsigned int *flags) { - return; - *flags |= IO_ASYNCH_REPLY; - // TODO: Implement this -} - void uiSignTransferToPublicDisplay(volatile unsigned int *flags) { // Setup data to display uint8_t pairIndex = 0; diff --git a/src/globals.h b/src/globals.h index e45d340b..91185a6e 100644 --- a/src/globals.h +++ b/src/globals.h @@ -39,10 +39,8 @@ #include "signConfigureBaker.h" #include "signConfigureDelegation.h" #include "signCredentialDeployment.h" -#include "signEncryptedAmountTransfer.h" #include "signPublicInformationForIp.h" #include "signTransfer.h" -#include "signTransferToEncrypted.h" #include "signTransferToPublic.h" #include "signTransferWithSchedule.h" #include "signRegisterData.h" @@ -94,14 +92,11 @@ typedef enum { UPDATE_CONTRACT = 2, TRANSFER = 3, UPDATE_CREDENTIAL_KEYS = 13, - ENCRYPTED_AMOUNT_TRANSFER = 16, - TRANSFER_TO_ENCRYPTED = 17, TRANSFER_TO_PUBLIC = 18, TRANSFER_WITH_SCHEDULE = 19, UPDATE_CREDENTIALS = 20, REGISTER_DATA = 21, TRANSFER_WITH_MEMO = 22, - ENCRYPTED_AMOUNT_TRANSFER_WITH_MEMO = 23, TRANSFER_WITH_SCHEDULE_WITH_MEMO = 24, CONFIGURE_BAKER = 25, CONFIGURE_DELEGATION = 26 @@ -146,7 +141,6 @@ typedef struct { typedef struct { union { signTransferContext_t signTransferContext; - signEncryptedAmountToTransfer_t signEncryptedAmountToTransfer; signTransferWithScheduleContext_t signTransferWithScheduleContext; signRegisterData_t signRegisterData; }; @@ -167,7 +161,6 @@ typedef union { signPublicInformationForIp_t signPublicInformationForIp; signCredentialDeploymentContext_t signCredentialDeploymentContext; - signTransferToEncrypted_t signTransferToEncrypted; signTransferToPublic_t signTransferToPublic; signConfigureBaker_t signConfigureBaker; signConfigureDelegationContext_t signConfigureDelegation; diff --git a/src/signEncryptedAmountTransfer.c b/src/signEncryptedAmountTransfer.c deleted file mode 100644 index e2734ce9..00000000 --- a/src/signEncryptedAmountTransfer.c +++ /dev/null @@ -1,146 +0,0 @@ -#include "globals.h" - -static signEncryptedAmountToTransfer_t *ctx = &global.withDataBlob.signEncryptedAmountToTransfer; -static cborContext_t *memo_ctx = &global.withDataBlob.cborContext; -static tx_state_t *tx_state = &global_tx_state; - -#define P1_INITIAL 0x00 -#define P1_REMAINING_AMOUNT 0x01 -#define P1_TRANSFER_AMOUNT_AGG_INDEX_PROOF_SIZE 0x02 -#define P1_PROOF 0x03 -#define P1_INITIAL_WITH_MEMO 0x04 -#define P1_MEMO 0x05 - -void handleRemainingAmount(uint8_t *cdata) { - // Hash remaining amount. Remaining amount is encrypted, and so we cannot display it. - updateHash((cx_hash_t *)&tx_state->hash, cdata, 192); - ctx->state = TX_ENCRYPTED_AMOUNT_TRANSFER_TRANSFER_AMOUNT; - sendSuccessNoIdle(); -} - -void handleTransferAmountAggIndexProofSize(uint8_t *cdata) { - // Hash transfer amount and agg index. Transfer amount is encrypted, and so we cannot display - // it. - updateHash((cx_hash_t *)&tx_state->hash, cdata, 200); - cdata += 200; - - // Save proof size so that we know when we are done processing the - // proof bytes that we are going to receive. - ctx->proofSize = U2BE(cdata, 0); - - ctx->state = TX_ENCRYPTED_AMOUNT_TRANSFER_PROOFS; - sendSuccessNoIdle(); -} - -void handleProofs(uint8_t *cdata, - uint8_t dataLength, - volatile unsigned int *flags, - bool displayMemo) { - updateHash((cx_hash_t *)&tx_state->hash, cdata, dataLength); - ctx->proofSize -= dataLength; - - if (ctx->proofSize == 0) { - // We have received all proof bytes, continue to signing flow. - startEncryptedTransferDisplay(displayMemo); - *flags |= IO_ASYNCH_REPLY; - } else if (ctx->proofSize < 0) { - // We received more proof bytes than expected. - THROW(ERROR_INVALID_STATE); - } else { - // There are more bytes to be received. Ask the computer for more. - sendSuccessNoIdle(); - } -} - -void finishMemoEncrypted() { - ctx->state = TX_ENCRYPTED_AMOUNT_TRANSFER_REMAINING_AMOUNT; - sendSuccessNoIdle(); -} - -void handleSignEncryptedAmountTransferWithMemo(uint8_t *cdata, - uint8_t p1, - uint8_t dataLength, - volatile unsigned int *flags, - bool isInitialCall) { - if (isInitialCall) { - ctx->state = TX_ENCRYPTED_AMOUNT_TRANSFER_INITIAL; - } - - if (p1 == P1_INITIAL_WITH_MEMO && ctx->state == TX_ENCRYPTED_AMOUNT_TRANSFER_INITIAL) { - cdata += handleHeaderAndToAddress(cdata, - ENCRYPTED_AMOUNT_TRANSFER_WITH_MEMO, - ctx->to, - sizeof(ctx->to)); - - // Hash memo length - memo_ctx->cborLength = U2BE(cdata, 0); - if (memo_ctx->cborLength > MAX_MEMO_SIZE) { - THROW(ERROR_INVALID_PARAM); - } - - updateHash((cx_hash_t *)&tx_state->hash, cdata, 2); - - ctx->state = TX_ENCRYPTED_AMOUNT_TRANSFER_MEMO_START; - sendSuccessNoIdle(); - } else if (p1 == P1_MEMO && ctx->state == TX_ENCRYPTED_AMOUNT_TRANSFER_MEMO_START) { - updateHash((cx_hash_t *)&tx_state->hash, cdata, dataLength); - - // Read initial part of memo and then display it: - readCborInitial(cdata, dataLength); - - if (memo_ctx->cborLength == 0) { - finishMemoEncrypted(); - } else { - ctx->state = TX_ENCRYPTED_AMOUNT_TRANSFER_MEMO; - sendSuccessNoIdle(); - } - } else if (p1 == P1_MEMO && ctx->state == TX_ENCRYPTED_AMOUNT_TRANSFER_MEMO) { - updateHash((cx_hash_t *)&tx_state->hash, cdata, dataLength); - - // Read current part of memo and then display it: - readCborContent(cdata, dataLength); - - if (memo_ctx->cborLength != 0) { - // The memo size is <=256 bytes, so we should always have received the complete memo by - // this point; - THROW(ERROR_INVALID_STATE); - } - - finishMemoEncrypted(); - } else if (p1 == P1_REMAINING_AMOUNT && - ctx->state == TX_ENCRYPTED_AMOUNT_TRANSFER_REMAINING_AMOUNT) { - handleRemainingAmount(cdata); - } else if (p1 == P1_TRANSFER_AMOUNT_AGG_INDEX_PROOF_SIZE && - ctx->state == TX_ENCRYPTED_AMOUNT_TRANSFER_TRANSFER_AMOUNT) { - handleTransferAmountAggIndexProofSize(cdata); - } else if (p1 == P1_PROOF && ctx->state == TX_ENCRYPTED_AMOUNT_TRANSFER_PROOFS) { - handleProofs(cdata, dataLength, flags, true); - } else { - THROW(ERROR_INVALID_STATE); - } -} - -void handleSignEncryptedAmountTransfer(uint8_t *cdata, - uint8_t p1, - uint8_t dataLength, - volatile unsigned int *flags, - bool isInitialCall) { - if (isInitialCall) { - ctx->state = TX_ENCRYPTED_AMOUNT_TRANSFER_INITIAL; - } - if (p1 == P1_INITIAL && ctx->state == TX_ENCRYPTED_AMOUNT_TRANSFER_INITIAL) { - handleHeaderAndToAddress(cdata, ENCRYPTED_AMOUNT_TRANSFER, ctx->to, sizeof(ctx->to)); - ctx->state = TX_ENCRYPTED_AMOUNT_TRANSFER_REMAINING_AMOUNT; - sendSuccessNoIdle(); - } else if (p1 == P1_REMAINING_AMOUNT && - ctx->state == TX_ENCRYPTED_AMOUNT_TRANSFER_REMAINING_AMOUNT) { - handleRemainingAmount(cdata); - } else if (p1 == P1_TRANSFER_AMOUNT_AGG_INDEX_PROOF_SIZE && - ctx->state == TX_ENCRYPTED_AMOUNT_TRANSFER_TRANSFER_AMOUNT) { - handleTransferAmountAggIndexProofSize(cdata); - } else if (p1 == P1_PROOF && ctx->state == TX_ENCRYPTED_AMOUNT_TRANSFER_PROOFS) { - handleProofs(cdata, dataLength, flags, false); - } else { - THROW(ERROR_INVALID_STATE); - } -} diff --git a/src/signEncryptedAmountTransfer.h b/src/signEncryptedAmountTransfer.h deleted file mode 100644 index a63ead0a..00000000 --- a/src/signEncryptedAmountTransfer.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -/** - * Handles the signing flow, including updating the display, for the 'encrypted amount transfer' - * account transaction. - * @param cdata please see /doc/ins_encrypted_amount_transfer.md - */ -void handleSignEncryptedAmountTransfer(uint8_t *cdata, - uint8_t p1, - uint8_t dataLength, - volatile unsigned int *flags, - bool isInitialCall); -void handleSignEncryptedAmountTransferWithMemo(uint8_t *cdata, - uint8_t p1, - uint8_t dataLength, - volatile unsigned int *flags, - bool isInitialCall); - -typedef enum { - TX_ENCRYPTED_AMOUNT_TRANSFER_INITIAL = 15, - TX_ENCRYPTED_AMOUNT_TRANSFER_REMAINING_AMOUNT = 16, - TX_ENCRYPTED_AMOUNT_TRANSFER_TRANSFER_AMOUNT = 17, - TX_ENCRYPTED_AMOUNT_TRANSFER_PROOFS = 18, - TX_ENCRYPTED_AMOUNT_TRANSFER_MEMO_START = 53, - TX_ENCRYPTED_AMOUNT_TRANSFER_MEMO = 54 -} encryptedAmountTransferState_t; - -typedef struct { - uint8_t transactionType; - uint8_t to[57]; - uint16_t proofSize; - encryptedAmountTransferState_t state; -} signEncryptedAmountToTransfer_t; diff --git a/src/signTransferToEncrypted.c b/src/signTransferToEncrypted.c deleted file mode 100644 index bceae7f8..00000000 --- a/src/signTransferToEncrypted.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "globals.h" - -static signTransferToEncrypted_t *ctx = &global.signTransferToEncrypted; -static tx_state_t *tx_state = &global_tx_state; - -void handleSignTransferToEncrypted(uint8_t *cdata, volatile unsigned int *flags) { - cdata += parseKeyDerivationPath(cdata); - cx_sha256_init(&tx_state->hash); - cdata += hashAccountTransactionHeaderAndKind(cdata, TRANSFER_TO_ENCRYPTED); - - // Parse transaction amount so it can be displayed. - uint64_t amountToEncrypted = U8BE(cdata, 0); - amountToGtuDisplay(ctx->amount, sizeof(ctx->amount), amountToEncrypted); - updateHash((cx_hash_t *)&tx_state->hash, cdata, 8); - - uiSignTransferToEncryptedDisplay(flags); -} diff --git a/src/signTransferToEncrypted.h b/src/signTransferToEncrypted.h deleted file mode 100644 index 295728b4..00000000 --- a/src/signTransferToEncrypted.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -/** - * Handles the signing flow, including updating the display, for the 'transfer to encrypted' - * account transaction. - * @param cdata please see /doc/ins_transfer_to_encrypted.md - */ -void handleSignTransferToEncrypted(uint8_t *cdata, volatile unsigned int *flags); - -typedef struct { - uint8_t amount[30]; -} signTransferToEncrypted_t; diff --git a/tests/application_client/boilerplate_command_sender.py b/tests/application_client/boilerplate_command_sender.py index fa657c7e..e30c70f4 100644 --- a/tests/application_client/boilerplate_command_sender.py +++ b/tests/application_client/boilerplate_command_sender.py @@ -96,15 +96,12 @@ class InsType(IntEnum): DEPLOY_MODULE = 0x06 INIT_CONTRACT = 0x07 UPDATE_CONTRACT = 0x08 - ENCRYPTED_AMOUNT_TRANSFER = 0x10 - TRANSFER_TO_ENCRYPTED = 0x11 TRANSFER_TO_PUBLIC = 0x12 CONFIGURE_DELEGATION = 0x17 CONFIGURE_BAKER = 0x18 PUBLIC_INFO_FOR_IP = 0x20 SIGN_UPDATE_CREDENTIAL = 0x31 SIGN_TRANSFER_WITH_MEMO = 0x32 - ENCRYPTED_AMOUNT_TRANSFER_WITH_MEMO = 0x33 SIGN_TRANSFER_WITH_SCHEDULE_AND_MEMO = 0x34 REGISTER_DATA = 0x35 diff --git a/tests/snapshots/flex/test_verify_address_confirm_refused/00000.png b/tests/snapshots/flex/test_verify_address_confirm_refused/00000.png new file mode 100644 index 00000000..209010e0 Binary files /dev/null and b/tests/snapshots/flex/test_verify_address_confirm_refused/00000.png differ diff --git a/tests/snapshots/flex/test_verify_address_confirm_refused/00001.png b/tests/snapshots/flex/test_verify_address_confirm_refused/00001.png new file mode 100644 index 00000000..e4e65081 Binary files /dev/null and b/tests/snapshots/flex/test_verify_address_confirm_refused/00001.png differ diff --git a/tests/snapshots/flex/test_verify_address_confirm_refused/00002.png b/tests/snapshots/flex/test_verify_address_confirm_refused/00002.png new file mode 100644 index 00000000..4972bd7d Binary files /dev/null and b/tests/snapshots/flex/test_verify_address_confirm_refused/00002.png differ diff --git a/tests/snapshots/flex/test_verify_address_confirm_refused/00003.png b/tests/snapshots/flex/test_verify_address_confirm_refused/00003.png new file mode 100644 index 00000000..f8feb4ce Binary files /dev/null and b/tests/snapshots/flex/test_verify_address_confirm_refused/00003.png differ diff --git a/tests/snapshots/flex/test_verify_address_confirm_refused/00004.png b/tests/snapshots/flex/test_verify_address_confirm_refused/00004.png new file mode 100644 index 00000000..ea645d60 Binary files /dev/null and b/tests/snapshots/flex/test_verify_address_confirm_refused/00004.png differ diff --git a/tests/snapshots/nanosp/test_verify_address_confirm_refused/00000.png b/tests/snapshots/nanosp/test_verify_address_confirm_refused/00000.png new file mode 100644 index 00000000..13ea5563 Binary files /dev/null and b/tests/snapshots/nanosp/test_verify_address_confirm_refused/00000.png differ diff --git a/tests/snapshots/nanosp/test_verify_address_confirm_refused/00001.png b/tests/snapshots/nanosp/test_verify_address_confirm_refused/00001.png new file mode 100644 index 00000000..77e90dd9 Binary files /dev/null and b/tests/snapshots/nanosp/test_verify_address_confirm_refused/00001.png differ diff --git a/tests/snapshots/nanosp/test_verify_address_confirm_refused/00002.png b/tests/snapshots/nanosp/test_verify_address_confirm_refused/00002.png new file mode 100644 index 00000000..53ae6519 Binary files /dev/null and b/tests/snapshots/nanosp/test_verify_address_confirm_refused/00002.png differ diff --git a/tests/snapshots/nanosp/test_verify_address_confirm_refused/00003.png b/tests/snapshots/nanosp/test_verify_address_confirm_refused/00003.png new file mode 100644 index 00000000..c4c84cf4 Binary files /dev/null and b/tests/snapshots/nanosp/test_verify_address_confirm_refused/00003.png differ diff --git a/tests/snapshots/nanosp/test_verify_address_confirm_refused/00004.png b/tests/snapshots/nanosp/test_verify_address_confirm_refused/00004.png new file mode 100644 index 00000000..dbd0b137 Binary files /dev/null and b/tests/snapshots/nanosp/test_verify_address_confirm_refused/00004.png differ diff --git a/tests/snapshots/nanox/test_verify_address_confirm_refused/00000.png b/tests/snapshots/nanox/test_verify_address_confirm_refused/00000.png new file mode 100644 index 00000000..13ea5563 Binary files /dev/null and b/tests/snapshots/nanox/test_verify_address_confirm_refused/00000.png differ diff --git a/tests/snapshots/nanox/test_verify_address_confirm_refused/00001.png b/tests/snapshots/nanox/test_verify_address_confirm_refused/00001.png new file mode 100644 index 00000000..77e90dd9 Binary files /dev/null and b/tests/snapshots/nanox/test_verify_address_confirm_refused/00001.png differ diff --git a/tests/snapshots/nanox/test_verify_address_confirm_refused/00002.png b/tests/snapshots/nanox/test_verify_address_confirm_refused/00002.png new file mode 100644 index 00000000..53ae6519 Binary files /dev/null and b/tests/snapshots/nanox/test_verify_address_confirm_refused/00002.png differ diff --git a/tests/snapshots/nanox/test_verify_address_confirm_refused/00003.png b/tests/snapshots/nanox/test_verify_address_confirm_refused/00003.png new file mode 100644 index 00000000..c4c84cf4 Binary files /dev/null and b/tests/snapshots/nanox/test_verify_address_confirm_refused/00003.png differ diff --git a/tests/snapshots/nanox/test_verify_address_confirm_refused/00004.png b/tests/snapshots/nanox/test_verify_address_confirm_refused/00004.png new file mode 100644 index 00000000..dbd0b137 Binary files /dev/null and b/tests/snapshots/nanox/test_verify_address_confirm_refused/00004.png differ diff --git a/tests/snapshots/stax/test_verify_address_confirm_refused/00000.png b/tests/snapshots/stax/test_verify_address_confirm_refused/00000.png new file mode 100644 index 00000000..867f805e Binary files /dev/null and b/tests/snapshots/stax/test_verify_address_confirm_refused/00000.png differ diff --git a/tests/snapshots/stax/test_verify_address_confirm_refused/00001.png b/tests/snapshots/stax/test_verify_address_confirm_refused/00001.png new file mode 100644 index 00000000..7fa755e0 Binary files /dev/null and b/tests/snapshots/stax/test_verify_address_confirm_refused/00001.png differ diff --git a/tests/snapshots/stax/test_verify_address_confirm_refused/00002.png b/tests/snapshots/stax/test_verify_address_confirm_refused/00002.png new file mode 100644 index 00000000..42a4618a Binary files /dev/null and b/tests/snapshots/stax/test_verify_address_confirm_refused/00002.png differ diff --git a/tests/snapshots/stax/test_verify_address_confirm_refused/00003.png b/tests/snapshots/stax/test_verify_address_confirm_refused/00003.png new file mode 100644 index 00000000..3fd64e51 Binary files /dev/null and b/tests/snapshots/stax/test_verify_address_confirm_refused/00003.png differ diff --git a/tests/snapshots/stax/test_verify_address_confirm_refused/00004.png b/tests/snapshots/stax/test_verify_address_confirm_refused/00004.png new file mode 100644 index 00000000..f0407603 Binary files /dev/null and b/tests/snapshots/stax/test_verify_address_confirm_refused/00004.png differ diff --git a/tests/test_error_cmd.py b/tests/test_error_cmd.py deleted file mode 100644 index 99cd04b5..00000000 --- a/tests/test_error_cmd.py +++ /dev/null @@ -1,57 +0,0 @@ -import pytest - -from ragger.error import ExceptionRAPDU -from application_client.boilerplate_command_sender import CLA, InsType, P1, P2, Errors - - -# Ensure the app returns an error when a bad CLA is used -def test_bad_cla(backend): - with pytest.raises(ExceptionRAPDU) as e: - backend.exchange(cla=CLA + 1, ins=InsType.GET_VERSION) - assert e.value.status == Errors.SW_CLA_NOT_SUPPORTED - - -# Ensure the app returns an error when a bad INS is used -def test_bad_ins(backend): - with pytest.raises(ExceptionRAPDU) as e: - backend.exchange(cla=CLA, ins=0xff) - assert e.value.status == Errors.SW_INS_NOT_SUPPORTED - - -# Ensure the app returns an error when a bad P1 or P2 is used -def test_wrong_p1p2(backend): - with pytest.raises(ExceptionRAPDU) as e: - backend.exchange(cla=CLA, ins=InsType.GET_VERSION, p1=P1.P1_START + 1, p2=P2.P2_LAST) - assert e.value.status == Errors.SW_WRONG_P1P2 - with pytest.raises(ExceptionRAPDU) as e: - backend.exchange(cla=CLA, ins=InsType.GET_VERSION, p1=P1.P1_START, p2=P2.P2_MORE) - assert e.value.status == Errors.SW_WRONG_P1P2 - with pytest.raises(ExceptionRAPDU) as e: - backend.exchange(cla=CLA, ins=InsType.GET_APP_NAME, p1=P1.P1_START + 1, p2=P2.P2_LAST) - assert e.value.status == Errors.SW_WRONG_P1P2 - with pytest.raises(ExceptionRAPDU) as e: - backend.exchange(cla=CLA, ins=InsType.GET_APP_NAME, p1=P1.P1_START, p2=P2.P2_MORE) - assert e.value.status == Errors.SW_WRONG_P1P2 - - -# Ensure the app returns an error when a bad data length is used -def test_wrong_data_length(backend): - # APDUs must be at least 4 bytes: CLA, INS, P1, P2. - with pytest.raises(ExceptionRAPDU) as e: - backend.exchange_raw(bytes.fromhex("E00300")) - assert e.value.status == Errors.SW_WRONG_DATA_LENGTH - # APDUs advertises a too long length - with pytest.raises(ExceptionRAPDU) as e: - backend.exchange_raw(bytes.fromhex("E003000005")) - assert e.value.status == Errors.SW_WRONG_DATA_LENGTH - - -# Ensure there is no state confusion when trying wrong APDU sequences -def test_invalid_state(backend): - with pytest.raises(ExceptionRAPDU) as e: - backend.exchange(cla=CLA, - ins=InsType.SIGN_SIMPLE_TRANSFER, - p1=P1.P1_START + 1, # Try to continue a flow instead of start a new one - p2=P2.P2_MORE, - data=b"abcde") # data is not parsed in this case - assert e.value.status == Errors.SW_BAD_STATE diff --git a/tests/test_name_version.py b/tests/test_name_version.py deleted file mode 100644 index 51e9d1d9..00000000 --- a/tests/test_name_version.py +++ /dev/null @@ -1,15 +0,0 @@ -from application_client.boilerplate_command_sender import BoilerplateCommandSender -from application_client.boilerplate_response_unpacker import unpack_get_app_and_version_response - - -# Test a specific APDU asking BOLOS (and not the app) the name and version of the current app -def test_get_app_and_version(backend, backend_name): - # Use the app interface instead of raw interface - client = BoilerplateCommandSender(backend) - # Send the special instruction to BOLOS - response = client.get_app_and_version() - # Use an helper to parse the response, assert the values - app_name, version = unpack_get_app_and_version_response(response.data) - - assert app_name == "Concordium" - assert version == "5.0.0" diff --git a/tests/test_verify_address.py b/tests/test_verify_address.py index b7602cc9..3156ff30 100644 --- a/tests/test_verify_address.py +++ b/tests/test_verify_address.py @@ -25,6 +25,7 @@ NavInsID.SWIPE_CENTER_TO_LEFT, NavInsID.SWIPE_CENTER_TO_LEFT, NavInsID.USE_CASE_CHOICE_REJECT, + NavInsID.USE_CASE_CHOICE_CONFIRM, ] bagl_instructions_address_confirmation = [ NavInsID.RIGHT_CLICK, @@ -37,7 +38,6 @@ NavInsID.RIGHT_CLICK, NavInsID.RIGHT_CLICK, NavInsID.RIGHT_CLICK, - NavInsID.RIGHT_CLICK, NavInsID.BOTH_CLICK, ] @@ -90,6 +90,7 @@ def test_verify_address_confirm_new_path_accepted( # In this test we check that the VERIFY ADDRESS in confirmation mode replies an error if the user refuses +@pytest.mark.active_test_scope def test_verify_address_confirm_refused( backend, scenario_navigator, test_name, default_screenshot_path ): diff --git a/tests/test_version_cmd.py b/tests/test_version_cmd.py deleted file mode 100644 index 079a0c82..00000000 --- a/tests/test_version_cmd.py +++ /dev/null @@ -1,16 +0,0 @@ -from application_client.boilerplate_command_sender import BoilerplateCommandSender -from application_client.boilerplate_response_unpacker import unpack_get_version_response - -# Taken from the Makefile, to update every time the Makefile version is bumped -MAJOR = 5 -MINOR = 0 -PATCH = 0 - -# In this test we check the behavior of the device when asked to provide the app version -def test_version(backend): - # Use the app interface instead of raw interface - client = BoilerplateCommandSender(backend) - # Send the GET_VERSION instruction - rapdu = client.get_version() - # Use an helper to parse the response, assert the values - assert unpack_get_version_response(rapdu.data) == (MAJOR, MINOR, PATCH)