From ea1709b0ea658e512643c791b4cd9aacb5281410 Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Tue, 13 Feb 2024 10:40:01 +0100 Subject: [PATCH 1/3] Completely remove old Starkware internal "plugin" --- makefile_conf/chain/ethereum.mk | 4 - makefile_conf/chain/goerli.mk | 6 - makefile_conf/chain/ropsten.mk | 6 - src/apdu_constants.h | 51 - src/common_ui.h | 4 - src/eth_plugin_internal.c | 75 +- src/eth_plugin_internal.h | 7 - src/main.c | 56 -- src/poorstream.c | 43 - src/poorstream.h | 21 - src/shared_context.h | 56 -- src/starkDisplayUtils.c | 17 - src/starkDisplayUtils.h | 6 - src/stark_crypto.c | 91 -- src/stark_crypto.h | 21 - src/stark_utils.c | 245 ----- src/stark_utils.h | 35 - src/ui_callbacks.h | 3 - src_bagl/common_ui.c | 26 - src_bagl/ui_flow.h | 30 - src_bagl/ui_flow_stark_getPublicKey.c | 46 - src_bagl/ui_flow_stark_sign.c | 234 ----- src_bagl/ui_flow_stark_unsafe_sign.c | 70 -- .../cmd_getAppConfiguration.c | 4 - src_features/signTx/logic_signTx.c | 3 - .../cmd_stark_getPublicKey.c | 66 -- .../feature_stark_getPublicKey.h | 8 - .../logic_stark_getPublicKey.c | 14 - .../ui_common_stark_getPublicKey.c | 19 - .../cmd_stark_provideQuantum.c | 64 -- src_features/stark_sign/cmd_stark_sign.c | 259 ----- .../stark_sign/ui_common_stark_sign.c | 36 - .../stark_unsafe_sign/cmd_stark_unsafe_sign.c | 55 - .../ui_common_stark_unsafe_sign.c | 42 - src_nbgl/ui_get_stark_public_key.c | 29 - src_nbgl/ui_stark_limit_order.c | 68 -- src_nbgl/ui_stark_transfer.c | 134 --- src_nbgl/ui_stark_unsafe_sign.c | 70 -- src_plugins/erc20/erc20_plugin.c | 17 - src_plugins/starkware/starkware_plugin.c | 944 ------------------ 40 files changed, 1 insertion(+), 2984 deletions(-) delete mode 100644 src/poorstream.c delete mode 100644 src/poorstream.h delete mode 100644 src/starkDisplayUtils.c delete mode 100644 src/starkDisplayUtils.h delete mode 100644 src/stark_crypto.c delete mode 100644 src/stark_crypto.h delete mode 100644 src/stark_utils.c delete mode 100644 src/stark_utils.h delete mode 100644 src_bagl/ui_flow_stark_getPublicKey.c delete mode 100644 src_bagl/ui_flow_stark_sign.c delete mode 100644 src_bagl/ui_flow_stark_unsafe_sign.c delete mode 100644 src_features/stark_getPublicKey/cmd_stark_getPublicKey.c delete mode 100644 src_features/stark_getPublicKey/feature_stark_getPublicKey.h delete mode 100644 src_features/stark_getPublicKey/logic_stark_getPublicKey.c delete mode 100644 src_features/stark_getPublicKey/ui_common_stark_getPublicKey.c delete mode 100644 src_features/stark_provideQuantum/cmd_stark_provideQuantum.c delete mode 100644 src_features/stark_sign/cmd_stark_sign.c delete mode 100644 src_features/stark_sign/ui_common_stark_sign.c delete mode 100644 src_features/stark_unsafe_sign/cmd_stark_unsafe_sign.c delete mode 100644 src_features/stark_unsafe_sign/ui_common_stark_unsafe_sign.c delete mode 100644 src_nbgl/ui_get_stark_public_key.c delete mode 100644 src_nbgl/ui_stark_limit_order.c delete mode 100644 src_nbgl/ui_stark_transfer.c delete mode 100644 src_nbgl/ui_stark_unsafe_sign.c delete mode 100644 src_plugins/starkware/starkware_plugin.c diff --git a/makefile_conf/chain/ethereum.mk b/makefile_conf/chain/ethereum.mk index 16e4b8cae..993c9306d 100644 --- a/makefile_conf/chain/ethereum.mk +++ b/makefile_conf/chain/ethereum.mk @@ -2,10 +2,6 @@ APP_LOAD_PARAMS += --path "44'/60'" TICKER = "ETH" CHAIN_ID = 1 -# Starkware integration -APP_LOAD_PARAMS += --path "2645'/579218131'" -DEFINES += HAVE_STARKWARE -DEFINES += STARK_BIP32_PATH_0=0x80000A55 STARK_BIP32_PATH_1=0xA2862AD3 # Allow to derive ETH 2 public keys APP_LOAD_PARAMS += --path "12381/3600" --curve bls12381g1 DEFINES += HAVE_ETH2 diff --git a/makefile_conf/chain/goerli.mk b/makefile_conf/chain/goerli.mk index 1f8e37d53..c01e6c9b8 100644 --- a/makefile_conf/chain/goerli.mk +++ b/makefile_conf/chain/goerli.mk @@ -1,12 +1,6 @@ APP_LOAD_PARAMS += --path "44'/60'" TICKER = "ETH" CHAIN_ID = 5 -# Starkware integration -APP_LOAD_PARAMS += --path "2645'/579218131'" -DEFINES += HAVE_STARKWARE -# Keep for Starkware Goerli tests -DEFINES += HAVE_TOKENS_EXTRA_LIST -DEFINES += STARK_BIP32_PATH_0=0x80000A55 STARK_BIP32_PATH_1=0xA2862AD3 # Allow to derive ETH 2 public keys APP_LOAD_PARAMS += --path "12381/3600" --curve bls12381g1 DEFINES += HAVE_ETH2 diff --git a/makefile_conf/chain/ropsten.mk b/makefile_conf/chain/ropsten.mk index 793a31417..d709186f8 100644 --- a/makefile_conf/chain/ropsten.mk +++ b/makefile_conf/chain/ropsten.mk @@ -1,12 +1,6 @@ APP_LOAD_PARAMS += --path "44'/60'" TICKER = "ETH" CHAIN_ID = 3 -# Starkware integration -APP_LOAD_PARAMS += --path "2645'/579218131'" -DEFINES += HAVE_STARKWARE -# Keep for Starkware Ropsten tests -DEFINES += HAVE_TOKENS_EXTRA_LIST -DEFINES += STARK_BIP32_PATH_0=0x80000A55 STARK_BIP32_PATH_1=0xA2862AD3 # Allow to derive ETH 2 public keys APP_LOAD_PARAMS += --path "12381/3600" --curve bls12381g1 DEFINES += HAVE_ETH2 diff --git a/src/apdu_constants.h b/src/apdu_constants.h index 7911d6b5b..07e41a300 100644 --- a/src/apdu_constants.h +++ b/src/apdu_constants.h @@ -5,8 +5,6 @@ #define APP_FLAG_DATA_ALLOWED 0x01 #define APP_FLAG_EXTERNAL_TOKEN_NEEDED 0x02 -#define APP_FLAG_STARKWARE 0x04 -#define APP_FLAG_STARKWARE_V2 0x08 #define CLA 0xE0 #define INS_GET_PUBLIC_KEY 0x02 @@ -47,26 +45,6 @@ #define APDU_RESPONSE_CONDITION_NOT_SATISFIED 0x6985 #define APDU_RESPONSE_REF_DATA_NOT_FOUND 0x6a88 -#ifdef HAVE_STARKWARE - -#define STARKWARE_CLA 0xF0 -#define STARKWARE_INS_GET_PUBLIC_KEY 0x02 -#define STARKWARE_INS_SIGN_MESSAGE 0x04 -#define STARKWARE_INS_PROVIDE_QUANTUM 0x08 -#define STARKWARE_INS_UNSAFE_SIGN 0x0A - -#define P1_STARK_ORDER 0x01 -#define P1_STARK_TRANSFER 0x02 -#define P1_STARK_ORDER_V2 0x03 -#define P1_STARK_TRANSFER_V2 0x04 -#define P1_STARK_CONDITIONAL_TRANSFER 0x05 - -#define STARK_ORDER_TYPE 0 -#define STARK_TRANSFER_TYPE 1 -#define STARK_CONDITIONAL_TRANSFER_TYPE 2 - -#endif - enum { OFFSET_CLA = 0, OFFSET_INS, OFFSET_P1, OFFSET_P2, OFFSET_LC, OFFSET_CDATA }; #define ERR_APDU_EMPTY 0x6982 @@ -151,35 +129,6 @@ void handleSetEth2WinthdrawalIndex(uint8_t p1, #endif -#ifdef HAVE_STARKWARE - -void handleStarkwareGetPublicKey(uint8_t p1, - uint8_t p2, - const uint8_t *dataBuffer, - uint8_t dataLength, - unsigned int *flags, - unsigned int *tx); -void handleStarkwareSignMessage(uint8_t p1, - uint8_t p2, - uint8_t *dataBuffer, - uint8_t dataLength, - unsigned int *flags, - unsigned int *tx); -void handleStarkwareProvideQuantum(uint8_t p1, - uint8_t p2, - const uint8_t *dataBuffer, - uint8_t dataLength, - unsigned int *flags, - unsigned int *tx); -void handleStarkwareUnsafeSign(uint8_t p1, - uint8_t p2, - const uint8_t *dataBuffer, - uint8_t dataLength, - unsigned int *flags, - unsigned int *tx); - -#endif - extern uint16_t apdu_response_code; #endif // _APDU_CONSTANTS_H_ diff --git a/src/common_ui.h b/src/common_ui.h index d4505972e..97dabad7a 100644 --- a/src/common_ui.h +++ b/src/common_ui.h @@ -11,12 +11,8 @@ void ui_display_privacy_public_key(void); void ui_display_privacy_shared_secret(void); void ui_display_public_key(const uint64_t *chain_id); void ui_sign_712_v0(void); -void ui_display_stark_public(void); void ui_confirm_selector(void); void ui_confirm_parameter(void); -void ui_stark_limit_order(void); -void ui_stark_unsafe_sign(void); -void ui_stark_transfer(bool selfTransfer, bool conditional); // EIP-191 void ui_191_start(void); diff --git a/src/eth_plugin_internal.c b/src/eth_plugin_internal.c index ddf61bbcc..2cfe351eb 100644 --- a/src/eth_plugin_internal.c +++ b/src/eth_plugin_internal.c @@ -2,13 +2,8 @@ #include "eth_plugin_internal.h" #include "plugin_utils.h" -bool erc20_plugin_available_check(void); - void erc20_plugin_call(int message, void* parameters); -#ifdef HAVE_STARKWARE -void starkware_plugin_call(int message, void* parameters); -#endif #ifdef HAVE_ETH2 void eth2_plugin_call(int message, void* parameters); #endif @@ -27,83 +22,15 @@ const uint8_t* const ETH2_SELECTORS[NUM_ETH2_SELECTORS] = {ETH2_DEPOSIT_SELECTOR #endif -#ifdef HAVE_STARKWARE - -static const uint8_t STARKWARE_REGISTER_ID[SELECTOR_SIZE] = {0xdd, 0x24, 0x14, 0xd4}; -static const uint8_t STARKWARE_DEPOSIT_TOKEN_ID[SELECTOR_SIZE] = {0x25, 0x05, 0xc3, 0xd9}; -static const uint8_t STARKWARE_DEPOSIT_ETH_ID[SELECTOR_SIZE] = {0x00, 0xae, 0xef, 0x8a}; -static const uint8_t STARKWARE_DEPOSIT_CANCEL_ID[SELECTOR_SIZE] = {0x7d, 0xf7, 0xdc, 0x04}; -static const uint8_t STARKWARE_DEPOSIT_RECLAIM_ID[SELECTOR_SIZE] = {0xae, 0x87, 0x38, 0x16}; -static const uint8_t STARKWARE_WITHDRAW_ID[SELECTOR_SIZE] = {0x44, 0x1a, 0x3e, 0x70}; -static const uint8_t STARKWARE_FULL_WITHDRAWAL_ID[SELECTOR_SIZE] = {0xa9, 0x33, 0x10, 0xc4}; -static const uint8_t STARKWARE_FREEZE_ID[SELECTOR_SIZE] = {0x93, 0xc1, 0xe4, 0x66}; -static const uint8_t STARKWARE_ESCAPE_ID[SELECTOR_SIZE] = {0x9e, 0x3a, 0xda, 0xc4}; -static const uint8_t STARKWARE_VERIFY_ESCAPE_ID[SELECTOR_SIZE] = {0x2d, 0xd5, 0x30, 0x06}; - -static const uint8_t STARKWARE_WITHDRAW_TO_ID[SELECTOR_SIZE] = {0x14, 0xcd, 0x70, 0xe4}; -static const uint8_t STARKWARE_DEPOSIT_NFT_ID[SELECTOR_SIZE] = {0xae, 0x1c, 0xdd, 0xe6}; -static const uint8_t STARKWARE_DEPOSIT_NFT_RECLAIM_ID[SELECTOR_SIZE] = {0xfc, 0xb0, 0x58, 0x22}; -static const uint8_t STARKWARE_WITHDRAW_AND_MINT_ID[SELECTOR_SIZE] = {0xd9, 0x14, 0x43, 0xb7}; -static const uint8_t STARKWARE_WITHDRAW_NFT_ID[SELECTOR_SIZE] = {0x01, 0x9b, 0x41, 0x7a}; -static const uint8_t STARKWARE_WITHDRAW_NFT_TO_ID[SELECTOR_SIZE] = {0xeb, 0xef, 0x0f, 0xd0}; -static const uint8_t STARKWARE_REGISTER_AND_DEPOSIT_TOKEN_ID[SELECTOR_SIZE] = {0x10, - 0x82, - 0x08, - 0xcf}; -static const uint8_t STARKWARE_REGISTER_AND_DEPOSIT_ETH_ID[SELECTOR_SIZE] = {0xa7, - 0x78, - 0xc0, - 0xc3}; -static const uint8_t STARKWARE_PROXY_DEPOSIT_TOKEN_ID[SELECTOR_SIZE] = {0xdc, 0xca, 0xd5, 0x24}; -static const uint8_t STARKWARE_PROXY_DEPOSIT_ETH_ID[SELECTOR_SIZE] = {0x6c, 0xe5, 0xd9, 0x57}; - -const uint8_t* const STARKWARE_SELECTORS[NUM_STARKWARE_SELECTORS] = { - STARKWARE_REGISTER_ID, - STARKWARE_DEPOSIT_TOKEN_ID, - STARKWARE_DEPOSIT_ETH_ID, - STARKWARE_DEPOSIT_CANCEL_ID, - STARKWARE_DEPOSIT_RECLAIM_ID, - STARKWARE_WITHDRAW_ID, - STARKWARE_FULL_WITHDRAWAL_ID, - STARKWARE_FREEZE_ID, - STARKWARE_ESCAPE_ID, - STARKWARE_VERIFY_ESCAPE_ID, - STARKWARE_WITHDRAW_TO_ID, - STARKWARE_DEPOSIT_NFT_ID, - STARKWARE_DEPOSIT_NFT_RECLAIM_ID, - STARKWARE_WITHDRAW_AND_MINT_ID, - STARKWARE_WITHDRAW_NFT_ID, - STARKWARE_WITHDRAW_NFT_TO_ID, - STARKWARE_REGISTER_AND_DEPOSIT_TOKEN_ID, - STARKWARE_REGISTER_AND_DEPOSIT_ETH_ID, - STARKWARE_PROXY_DEPOSIT_TOKEN_ID, - STARKWARE_PROXY_DEPOSIT_ETH_ID}; - -#endif - // All internal alias names start with 'minus' const internalEthPlugin_t INTERNAL_ETH_PLUGINS[] = { - {erc20_plugin_available_check, - (const uint8_t**) ERC20_SELECTORS, - NUM_ERC20_SELECTORS, - "-erc20", - erc20_plugin_call}, + {NULL, (const uint8_t**) ERC20_SELECTORS, NUM_ERC20_SELECTORS, "-erc20", erc20_plugin_call}, #ifdef HAVE_ETH2 {NULL, (const uint8_t**) ETH2_SELECTORS, NUM_ETH2_SELECTORS, "-eth2", eth2_plugin_call}, -#endif - -#ifdef HAVE_STARKWARE - - {NULL, - (const uint8_t**) STARKWARE_SELECTORS, - NUM_STARKWARE_SELECTORS, - "-strk", - starkware_plugin_call}, - #endif {NULL, NULL, 0, "", NULL}}; diff --git a/src/eth_plugin_internal.h b/src/eth_plugin_internal.h index 6cc09ce6b..ea84e407d 100644 --- a/src/eth_plugin_internal.h +++ b/src/eth_plugin_internal.h @@ -29,11 +29,4 @@ extern const uint8_t* const ETH2_SELECTORS[NUM_ETH2_SELECTORS]; #endif -#ifdef HAVE_STARKWARE - -#define NUM_STARKWARE_SELECTORS 20 -extern const uint8_t* const STARKWARE_SELECTORS[NUM_STARKWARE_SELECTORS]; - -#endif - extern internalEthPlugin_t const INTERNAL_ETH_PLUGINS[]; diff --git a/src/main.c b/src/main.c index ac74de410..4f5ce6d7f 100644 --- a/src/main.c +++ b/src/main.c @@ -32,10 +32,6 @@ #include "challenge.h" #include "domain_name.h" -#ifdef HAVE_STARKWARE -#include "stark_crypto.h" -#endif - unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B]; void ui_idle(void); @@ -55,9 +51,6 @@ uint16_t apdu_response_code; bool G_called_from_swap; bool G_swap_response_ready; pluginType_t pluginType; -#ifdef HAVE_STARKWARE -bool quantumSet; -#endif #ifdef HAVE_ETH2 uint32_t eth2WithdrawalIndex; @@ -81,9 +74,6 @@ void reset_app_context() { G_called_from_swap = false; G_swap_response_ready = false; pluginType = OLD_INTERNAL; -#ifdef HAVE_STARKWARE - quantumSet = false; -#endif #ifdef HAVE_ETH2 eth2WithdrawalIndex = 0; #endif @@ -232,52 +222,6 @@ void handleApdu(unsigned int *flags, unsigned int *tx) { #endif // HAVE_WALLET_ID_SDK -#ifdef HAVE_STARKWARE - - if (G_io_apdu_buffer[OFFSET_CLA] == STARKWARE_CLA) { - switch (G_io_apdu_buffer[OFFSET_INS]) { - case STARKWARE_INS_GET_PUBLIC_KEY: - handleStarkwareGetPublicKey(G_io_apdu_buffer[OFFSET_P1], - G_io_apdu_buffer[OFFSET_P2], - G_io_apdu_buffer + OFFSET_CDATA, - G_io_apdu_buffer[OFFSET_LC], - flags, - tx); - break; - case STARKWARE_INS_SIGN_MESSAGE: - handleStarkwareSignMessage(G_io_apdu_buffer[OFFSET_P1], - G_io_apdu_buffer[OFFSET_P2], - G_io_apdu_buffer + OFFSET_CDATA, - G_io_apdu_buffer[OFFSET_LC], - flags, - tx); - break; - case STARKWARE_INS_PROVIDE_QUANTUM: - handleStarkwareProvideQuantum(G_io_apdu_buffer[OFFSET_P1], - G_io_apdu_buffer[OFFSET_P2], - G_io_apdu_buffer + OFFSET_CDATA, - G_io_apdu_buffer[OFFSET_LC], - flags, - tx); - break; - case STARKWARE_INS_UNSAFE_SIGN: - handleStarkwareUnsafeSign(G_io_apdu_buffer[OFFSET_P1], - G_io_apdu_buffer[OFFSET_P2], - G_io_apdu_buffer + OFFSET_CDATA, - G_io_apdu_buffer[OFFSET_LC], - flags, - tx); - break; - default: - THROW(0x6D00); - break; - } - CLOSE_TRY; - return; - } - -#endif - if (G_io_apdu_buffer[OFFSET_CLA] != CLA) { THROW(0x6E00); } diff --git a/src/poorstream.c b/src/poorstream.c deleted file mode 100644 index 2dc2fa807..000000000 --- a/src/poorstream.c +++ /dev/null @@ -1,43 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "poorstream.h" - -void poorstream_init(poorstream_t *stream, uint8_t *buffer) { - memset((void *) stream, 0, sizeof(poorstream_t)); - stream->pointer = buffer; -} - -void poorstream_flush(poorstream_t *stream) { - // PRINTF("Flush\n"); - *(stream->pointer + 0) = (stream->accumulator >> 56); - *(stream->pointer + 1) = (stream->accumulator >> 48); - *(stream->pointer + 2) = (stream->accumulator >> 40); - *(stream->pointer + 3) = (stream->accumulator >> 32); - *(stream->pointer + 4) = (stream->accumulator >> 24); - *(stream->pointer + 5) = (stream->accumulator >> 16); - *(stream->pointer + 6) = (stream->accumulator >> 8); - *(stream->pointer + 7) = (stream->accumulator >> 0); -} - -void poorstream_write_bits(poorstream_t *stream, uint64_t bits, uint32_t num_bits) { - stream->offset += num_bits; - if (stream->offset < 64) { - stream->accumulator |= (bits << (64 - stream->offset)); - // PRINTF("ACC |= << %d\n", (64 - stream->offset)); - } else { - stream->offset -= 64; - stream->mask = ((1 << (num_bits - stream->offset)) - 1); - // PRINTF("Mask %lx\n", stream->mask); - // PRINTF("Offset %d\n", stream->offset); - stream->accumulator |= ((bits >> stream->offset) & stream->mask); - poorstream_flush(stream); - stream->accumulator = 0; - stream->pointer += 8; - if (stream->offset) { - stream->mask = ((1 << stream->offset) - 1); - stream->accumulator |= ((bits & stream->mask) << (64 - stream->offset)); - } - } -} - -#endif diff --git a/src/poorstream.h b/src/poorstream.h deleted file mode 100644 index 6ac17a527..000000000 --- a/src/poorstream.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _POORSTREAM_H_ -#define _POORSTREAM_H_ - -#include -#include -#include - -#include "os.h" - -typedef struct poorstream_t { - uint8_t *pointer; - uint32_t offset; - uint64_t mask; - uint64_t accumulator; -} poorstream_t; - -void poorstream_init(poorstream_t *stream, uint8_t *buffer); -void poorstream_flush(poorstream_t *stream); -void poorstream_write_bits(poorstream_t *stream, uint64_t bits, uint32_t num_bits); - -#endif // _POORSTREAM_H_ diff --git a/src/shared_context.h b/src/shared_context.h index 40113d3bb..4c1591404 100644 --- a/src/shared_context.h +++ b/src/shared_context.h @@ -40,21 +40,6 @@ typedef struct internalStorage_t { bool initialized; } internalStorage_t; -#ifdef HAVE_STARKWARE - -typedef enum starkQuantumType_e { - - STARK_QUANTUM_LEGACY = 0x00, - STARK_QUANTUM_ETH, - STARK_QUANTUM_ERC20, - STARK_QUANTUM_ERC721, - STARK_QUANTUM_MINTABLE_ERC20, - STARK_QUANTUM_MINTABLE_ERC721 - -} starkQuantumType_e; - -#endif - typedef struct tokenContext_t { char pluginName[PLUGIN_ID_LENGTH]; @@ -78,13 +63,6 @@ typedef struct tokenContext_t { uint8_t pluginStatus; -#ifdef HAVE_STARKWARE - uint8_t quantum[32]; - uint8_t mintingBlob[32]; - uint8_t quantumIndex; - uint8_t quantumType; -#endif - } tokenContext_t; _Static_assert((offsetof(tokenContext_t, pluginContext) % 4) == 0, "Plugin context not aligned"); @@ -129,27 +107,8 @@ typedef union { char tmp[100]; } tmpContent_t; -#ifdef HAVE_STARKWARE - -typedef struct starkContext_t { - uint8_t w1[32]; - uint8_t w2[32]; - uint8_t w3[32]; - uint8_t w4[32]; - uint8_t conditional; - uint8_t transferDestination[32]; - uint8_t fact[32]; - uint8_t conditionAddress[20]; -} starkContext_t; - -#endif - typedef union { tokenContext_t tokenContext; - -#ifdef HAVE_STARKWARE - starkContext_t starkContext; -#endif } dataContext_t; typedef enum { APP_STATE_IDLE, APP_STATE_SIGNING_TX, APP_STATE_SIGNING_MESSAGE } app_state_t; @@ -158,18 +117,6 @@ typedef enum { CONTRACT_NONE, CONTRACT_ERC20, CONTRACT_ALLOWANCE, -#ifdef HAVE_STARKWARE - CONTRACT_STARKWARE_REGISTER, - CONTRACT_STARKWARE_DEPOSIT_TOKEN, - CONTRACT_STARKWARE_DEPOSIT_ETH, - CONTRACT_STARKWARE_WITHDRAW, - CONTRACT_STARKWARE_DEPOSIT_CANCEL, - CONTRACT_STARKWARE_DEPOSIT_RECLAIM, - CONTRACT_STARKWARE_FULL_WITHDRAWAL, - CONTRACT_STARKWARE_FREEZE, - CONTRACT_STARKWARE_ESCAPE, - CONTRACT_STARKWARE_VERIFY_ESCAPE -#endif } contract_call_t; // must be able to hold in decimal up to : floor(MAX_UINT64 / 2) - 36 @@ -223,9 +170,6 @@ typedef enum { extern pluginType_t pluginType; extern uint8_t appState; -#ifdef HAVE_STARKWARE -extern bool quantumSet; -#endif #ifdef HAVE_ETH2 extern uint32_t eth2WithdrawalIndex; #endif diff --git a/src/starkDisplayUtils.c b/src/starkDisplayUtils.c deleted file mode 100644 index a59ae9927..000000000 --- a/src/starkDisplayUtils.c +++ /dev/null @@ -1,17 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "shared_context.h" - -void stark_sign_display_master_account() { - snprintf(strings.tmp.tmp, - sizeof(strings.tmp.tmp), - "0x%.*H", - 32, - dataContext.starkContext.transferDestination); -} - -void stark_sign_display_condition_fact() { - snprintf(strings.tmp.tmp, sizeof(strings.tmp.tmp), "0x%.*H", 32, dataContext.starkContext.fact); -} - -#endif \ No newline at end of file diff --git a/src/starkDisplayUtils.h b/src/starkDisplayUtils.h deleted file mode 100644 index 48399b82d..000000000 --- a/src/starkDisplayUtils.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifdef HAVE_STARKWARE - -void stark_sign_display_master_account(); -void stark_sign_display_condition_fact(); - -#endif \ No newline at end of file diff --git a/src/stark_crypto.c b/src/stark_crypto.c deleted file mode 100644 index f5b252013..000000000 --- a/src/stark_crypto.c +++ /dev/null @@ -1,91 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "shared_context.h" -#include "stark_utils.h" -#include "uint256.h" -#include "common_utils.h" - -extraInfo_t *getKnownToken(uint8_t *contractAddress); - -static unsigned char const C_cx_Stark256_n[] = { - // n: 0x0800000000000010ffffffffffffffffb781126dcae7b2321e66a241adc64d2f - 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xb7, 0x81, 0x12, 0x6d, 0xca, 0xe7, 0xb2, 0x32, 0x1e, 0x66, 0xa2, 0x41, 0xad, 0xc6, 0x4d, 0x2f}; - -// C_cx_secp256k1_n - (C_cx_secp256k1_n % C_cx_Stark256_n) -static unsigned char const STARK_DERIVE_BIAS[] = { - 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x0e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, - 0x38, 0xa1, 0x3b, 0x4b, 0x92, 0x0e, 0x94, 0x11, 0xae, 0x6d, 0xa5, 0xf4, 0x0b, 0x03, 0x58, 0xb1}; - -void starkDerivePrivateKey(uint32_t *bip32Path, uint32_t bip32PathLength, uint8_t *privateKeyData) { -#if 0 - // Sanity check - if (bip32Path[0] != STARK_BIP32_PATH_0) { - PRINTF("Invalid Stark derivation path %d\n", bip32Path[0]); - THROW(0x6a80); - } - os_perso_derive_node_bip32(CX_CURVE_256K1, bip32Path, bip32PathLength, privateKeyData, NULL); - PRINTF("Private key before processing %.*H\n", 32, privateKeyData); - // TODO - support additional schemes - cx_math_modm(privateKeyData, 32, C_cx_Stark256_n, 32); - PRINTF("Private key after processing %.*H\n", 32, privateKeyData); -#else - uint8_t tmp[33]; - uint8_t index = 0; - // Sanity check - if ((bip32PathLength < 2) || (bip32Path[0] != STARK_BIP32_PATH_0) || - (bip32Path[1] != STARK_BIP32_PATH_1)) { - PRINTF("Invalid Stark derivation path %d %d\n", bip32Path[0], bip32Path[1]); - THROW(0x6a80); - } - os_perso_derive_node_bip32(CX_CURVE_256K1, bip32Path, bip32PathLength, tmp, NULL); - PRINTF("Private key before processing %.*H\n", 32, tmp); - for (;;) { - tmp[32] = index; - cx_hash_sha256(tmp, 33, privateKeyData, 32); - PRINTF("Key hash %.*H\n", 32, privateKeyData); - if (cx_math_cmp(privateKeyData, STARK_DERIVE_BIAS, 32) < 0) { - cx_math_modm(privateKeyData, 32, C_cx_Stark256_n, 32); - break; - } - index++; - } - PRINTF("Key result %.*H\n", 32, privateKeyData); - -#endif -} - -void stark_get_amount_string(uint8_t *contractAddress, - uint8_t *quantum256, - uint8_t *amount64, - char *tmp100, - char *target100) { - uint256_t amountPre, quantum, amount; - uint8_t decimals; - char *ticker = chainConfig->coinName; - - PRINTF("stark_get_amount_string %.*H\n", 20, contractAddress); - - if (allzeroes(contractAddress, 20)) { - decimals = WEI_TO_ETHER; - PRINTF("stark_get_amount_string - ETH\n"); - } else { - tokenDefinition_t *token = &getKnownToken(contractAddress)->token; - if (token == NULL) { // caught earlier - THROW(0x6A80); - } - decimals = token->decimals; - ticker = (char *) token->ticker; - PRINTF("stark_get_amount_string - decimals %d ticker %s\n", decimals, ticker); - } - convertUint256BE(amount64, 8, &amountPre); - readu256BE(quantum256, &quantum); - mul256(&amountPre, &quantum, &amount); - tostring256(&amount, 10, tmp100, 100); - PRINTF("stark_get_amount_string - mul256 %s\n", tmp100); - strlcpy(target100, ticker, 100); - adjustDecimals(tmp100, strlen(tmp100), target100 + strlen(ticker), 100, decimals); - PRINTF("get_amount_string %s\n", target100); -} - -#endif // HAVE_STARK diff --git a/src/stark_crypto.h b/src/stark_crypto.h deleted file mode 100644 index 5ce1be31e..000000000 --- a/src/stark_crypto.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _STARK_CRYPTO_H_ -#define _STARK_CRYPTO_H_ - -#include -#include -#include - -#include "os.h" -#include "cx.h" - -/* EC points */ -#define FIELD_ELEMENT_SIZE (32) -#define EC_POINT_SIZE (2 * FIELD_ELEMENT_SIZE + 1) -typedef unsigned char FieldElement[FIELD_ELEMENT_SIZE]; -typedef unsigned char ECPoint[EC_POINT_SIZE]; - -void pedersen(FieldElement res, /* out */ - FieldElement a, - FieldElement b); - -#endif // _STARK_CRYPTO_H_ diff --git a/src/stark_utils.c b/src/stark_utils.c deleted file mode 100644 index 13cf5483f..000000000 --- a/src/stark_utils.c +++ /dev/null @@ -1,245 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "stark_crypto.h" -#include "shared_context.h" -#include "uint256.h" -#include "uint_common.h" - -#include "os_io_seproxyhal.h" - -#define SIGNATURE_MAX_LEN (72) - -static const ECPoint PEDERSEN_SHIFT[] = {{ - 0x04, - - 0x04, 0x9e, 0xe3, 0xeb, 0xa8, 0xc1, 0x60, 0x07, 0x00, 0xee, 0x1b, 0x87, 0xeb, 0x59, 0x9f, 0x16, - 0x71, 0x6b, 0x0b, 0x10, 0x22, 0x94, 0x77, 0x33, 0x55, 0x1f, 0xde, 0x40, 0x50, 0xca, 0x68, 0x04, - - 0x03, 0xca, 0x0c, 0xfe, 0x4b, 0x3b, 0xc6, 0xdd, 0xf3, 0x46, 0xd4, 0x9d, 0x06, 0xea, 0x0e, 0xd3, - 0x4e, 0x62, 0x10, 0x62, 0xc0, 0xe0, 0x56, 0xc1, 0xd0, 0x40, 0x5d, 0x26, 0x6e, 0x10, 0x26, 0x8a, -}}; - -static const ECPoint PEDERSEN_POINTS[4] = { - { - 0x04, - - 0x02, 0x34, 0x28, 0x7d, 0xcb, 0xaf, 0xfe, 0x7f, 0x96, 0x9c, 0x74, - 0x86, 0x55, 0xfc, 0xa9, 0xe5, 0x8f, 0xa8, 0x12, 0x0b, 0x6d, 0x56, - 0xeb, 0x0c, 0x10, 0x80, 0xd1, 0x79, 0x57, 0xeb, 0xe4, 0x7b, - - 0x03, 0xb0, 0x56, 0xf1, 0x00, 0xf9, 0x6f, 0xb2, 0x1e, 0x88, 0x95, - 0x27, 0xd4, 0x1f, 0x4e, 0x39, 0x94, 0x01, 0x35, 0xdd, 0x7a, 0x6c, - 0x94, 0xcc, 0x6e, 0xd0, 0x26, 0x8e, 0xe8, 0x9e, 0x56, 0x15, - }, - { - 0x04, - - 0x04, 0xfa, 0x56, 0xf3, 0x76, 0xc8, 0x3d, 0xb3, 0x3f, 0x9d, 0xab, - 0x26, 0x56, 0x55, 0x8f, 0x33, 0x99, 0x09, 0x9e, 0xc1, 0xde, 0x5e, - 0x30, 0x18, 0xb7, 0xa6, 0x93, 0x2d, 0xba, 0x8a, 0xa3, 0x78, - - 0x03, 0xfa, 0x09, 0x84, 0xc9, 0x31, 0xc9, 0xe3, 0x81, 0x13, 0xe0, - 0xc0, 0xe4, 0x7e, 0x44, 0x01, 0x56, 0x27, 0x61, 0xf9, 0x2a, 0x7a, - 0x23, 0xb4, 0x51, 0x68, 0xf4, 0xe8, 0x0f, 0xf5, 0xb5, 0x4d, - }, - { - 0x04, - - 0x04, 0xba, 0x4c, 0xc1, 0x66, 0xbe, 0x8d, 0xec, 0x76, 0x49, 0x10, - 0xf7, 0x5b, 0x45, 0xf7, 0x4b, 0x40, 0xc6, 0x90, 0xc7, 0x47, 0x09, - 0xe9, 0x0f, 0x3a, 0xa3, 0x72, 0xf0, 0xbd, 0x2d, 0x69, 0x97, - - 0x00, 0x40, 0x30, 0x1c, 0xf5, 0xc1, 0x75, 0x1f, 0x4b, 0x97, 0x1e, - 0x46, 0xc4, 0xed, 0xe8, 0x5f, 0xca, 0xc5, 0xc5, 0x9a, 0x5c, 0xe5, - 0xae, 0x7c, 0x48, 0x15, 0x1f, 0x27, 0xb2, 0x4b, 0x21, 0x9c, - }, - { - 0x04, - - 0x05, 0x43, 0x02, 0xdc, 0xb0, 0xe6, 0xcc, 0x1c, 0x6e, 0x44, 0xcc, - 0xa8, 0xf6, 0x1a, 0x63, 0xbb, 0x2c, 0xa6, 0x50, 0x48, 0xd5, 0x3f, - 0xb3, 0x25, 0xd3, 0x6f, 0xf1, 0x2c, 0x49, 0xa5, 0x82, 0x02, - - 0x01, 0xb7, 0x7b, 0x3e, 0x37, 0xd1, 0x35, 0x04, 0xb3, 0x48, 0x04, - 0x62, 0x68, 0xd8, 0xae, 0x25, 0xce, 0x98, 0xad, 0x78, 0x3c, 0x25, - 0x56, 0x1a, 0x87, 0x9d, 0xcc, 0x77, 0xe9, 0x9c, 0x24, 0x26, - }}; - -void accum_ec_mul(ECPoint *hash, uint8_t *buf, int len, int pedersen_idx) { - ECPoint tmp; - if (!allzeroes(buf, len)) { - uint8_t pad[32]; - memcpy(tmp, PEDERSEN_POINTS[pedersen_idx], sizeof(ECPoint)); - io_seproxyhal_io_heartbeat(); - memset(pad, 0, sizeof(pad)); - memmove(pad + 32 - len, buf, len); - cx_ecfp_scalar_mult(CX_CURVE_Stark256, tmp, sizeof(ECPoint), pad, sizeof(pad)); - io_seproxyhal_io_heartbeat(); - cx_ecfp_add_point(CX_CURVE_Stark256, *hash, *hash, tmp, sizeof(ECPoint)); - } -} - -void pedersen(FieldElement res, /* out */ - FieldElement a, - FieldElement b) { - ECPoint hash; - - memcpy(hash, PEDERSEN_SHIFT, sizeof(hash)); - - accum_ec_mul(&hash, a, 1, 1); - accum_ec_mul(&hash, a + 1, FIELD_ELEMENT_SIZE - 1, 0); - accum_ec_mul(&hash, b, 1, 3); - accum_ec_mul(&hash, b + 1, FIELD_ELEMENT_SIZE - 1, 2); - - memcpy(res, hash + 1, FIELD_ELEMENT_SIZE); -} - -void shift_stark_hash(FieldElement hash) { - uint256_t hash256, final_hash256; - readu256BE(hash, &hash256); - uint32_t bits_count = bits256(&hash256); - if (bits_count < 248) { - return; - } else if (bits_count >= 248 && bits_count % 8 >= 1 && bits_count % 8 <= 4) { - shiftl256(&hash256, 4, &final_hash256); - write_u64_be(hash, UPPER(UPPER_P((&final_hash256)))); - write_u64_be(hash + 8, LOWER(UPPER_P((&final_hash256)))); - write_u64_be(hash + 16, UPPER(LOWER_P((&final_hash256)))); - write_u64_be(hash + 24, LOWER(LOWER_P((&final_hash256)))); - return; - } else { - THROW(0x6A80); - } -} - -int stark_sign(uint8_t *signature, /* out */ - uint8_t *privateKeyData, - FieldElement token1, - FieldElement token2, - FieldElement msg, - FieldElement condition) { - unsigned int info = 0; - FieldElement hash; - cx_ecfp_private_key_t privateKey; - PRINTF("Stark sign msg w1 %.*H\n", 32, token1); - PRINTF("Stark sign msg w2 %.*H\n", 32, token2); - PRINTF("Stark sign w3 %.*H\n", 32, msg); - if (condition != NULL) { - PRINTF("Stark sign w4 %.*H\n", 32, condition); - } - pedersen(hash, token1, token2); - PRINTF("Pedersen hash 1 %.*H\n", 32, hash); - if (condition != NULL) { - pedersen(hash, hash, condition); - PRINTF("Pedersen hash condition %.*H\n", 32, hash); - } - pedersen(hash, hash, msg); - PRINTF("Pedersen hash 2 %.*H\n", 32, hash); - shift_stark_hash(hash); - cx_ecfp_init_private_key(CX_CURVE_Stark256, privateKeyData, 32, &privateKey); - io_seproxyhal_io_heartbeat(); - int signatureLength = cx_ecdsa_sign(&privateKey, - CX_RND_RFC6979 | CX_LAST, - CX_SHA256, - hash, - sizeof(hash), - signature, - SIGNATURE_MAX_LEN, - &info); - PRINTF("Stark signature %.*H\n", signatureLength, signature); - return signatureLength; -} - -// ERC20Token(address) -static const uint8_t ERC20_SELECTOR[] = {0xf4, 0x72, 0x61, 0xb0}; -// ETH() -static const uint8_t ETH_SELECTOR[] = {0x83, 0x22, 0xff, 0xf2}; -// ERC721Token(address, uint256) -static const uint8_t ERC721_SELECTOR[] = {0x02, 0x57, 0x17, 0x92}; -// MintableERC20Token(address) -static const uint8_t MINTABLE_ERC20_SELECTOR[] = {0x68, 0x64, 0x6e, 0x2d}; -// MintableERC721Token(address,uint256) -static const uint8_t MINTABLE_ERC721_SELECTOR[] = {0xb8, 0xb8, 0x66, 0x72}; -static const char NFT_ASSET_ID_PREFIX[] = {'N', 'F', 'T', ':', 0}; -static const char MINTABLE_ASSET_ID_PREFIX[] = {'M', 'I', 'N', 'T', 'A', 'B', 'L', 'E', ':', 0}; - -void compute_token_id(cx_sha3_t *sha3, - uint8_t *contractAddress, - uint8_t quantumType, - uint8_t *quantum, - uint8_t *mintingBlob, - bool assetTypeOnly, - uint8_t *output) { - uint8_t tmp[36]; - cx_keccak_init(sha3, 256); - if ((contractAddress != NULL) && (!allzeroes(contractAddress, 20))) { - const uint8_t *selector = NULL; - switch (quantumType) { - case STARK_QUANTUM_ERC20: - case STARK_QUANTUM_LEGACY: - selector = ERC20_SELECTOR; - break; - case STARK_QUANTUM_ERC721: - selector = ERC721_SELECTOR; - break; - case STARK_QUANTUM_MINTABLE_ERC20: - selector = MINTABLE_ERC20_SELECTOR; - break; - case STARK_QUANTUM_MINTABLE_ERC721: - selector = MINTABLE_ERC721_SELECTOR; - break; - default: - PRINTF("Unsupported quantum type %d\n", quantumType); - return; - } - PRINTF("compute_token_id for %.*H\n", 20, contractAddress); - memset(tmp, 0, sizeof(tmp)); - memmove(tmp, selector, 4); - memmove(tmp + 16, contractAddress, 20); - cx_hash((cx_hash_t *) sha3, 0, tmp, sizeof(tmp), NULL, 0); - } else { - PRINTF("compute_token_id for ETH\n"); - cx_hash((cx_hash_t *) sha3, 0, ETH_SELECTOR, sizeof(ETH_SELECTOR), NULL, 0); - } - if ((quantumType == STARK_QUANTUM_ERC721) || (quantumType == STARK_QUANTUM_MINTABLE_ERC721)) { - memset(tmp, 0, 32); - tmp[31] = 1; - PRINTF("compute_token_id quantum %.*H\n", 32, tmp); - cx_hash((cx_hash_t *) sha3, CX_LAST, tmp, 32, output, 32); - } else { - PRINTF("compute_token_id quantum %.*H\n", 32, quantum); - cx_hash((cx_hash_t *) sha3, CX_LAST, quantum, 32, output, 32); - } - if (!assetTypeOnly && - ((quantumType != STARK_QUANTUM_LEGACY) && (quantumType != STARK_QUANTUM_ETH) && - (quantumType != STARK_QUANTUM_ERC20))) { - const char *prefix = NULL; - output[0] &= 0x03; - cx_keccak_init(sha3, 256); - switch (quantumType) { - case STARK_QUANTUM_ERC721: - prefix = NFT_ASSET_ID_PREFIX; - break; - case STARK_QUANTUM_MINTABLE_ERC20: - case STARK_QUANTUM_MINTABLE_ERC721: - prefix = MINTABLE_ASSET_ID_PREFIX; - break; - default: - PRINTF("Unsupported non default quantum type %d\n", quantumType); - return; - } - cx_hash((cx_hash_t *) sha3, 0, (const uint8_t *) prefix, strlen(prefix), NULL, 0); - cx_hash((cx_hash_t *) sha3, 0, output, 32, NULL, 0); - cx_hash((cx_hash_t *) sha3, CX_LAST, mintingBlob, 32, output, 32); - } - if (!assetTypeOnly && ((quantumType == STARK_QUANTUM_MINTABLE_ERC20) || - (quantumType == STARK_QUANTUM_MINTABLE_ERC721))) { - output[0] = 0x04; - output[1] = 0x00; - } else { - output[0] &= 0x03; - } - PRINTF("compute_token_id computed token %.*H\n", 32, output); -} - -#endif // HAVE_STARK diff --git a/src/stark_utils.h b/src/stark_utils.h deleted file mode 100644 index 9ba69a2b9..000000000 --- a/src/stark_utils.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef _STARK_UTILS_H_ -#define _STARK_UTILS_H_ - -#include -#include -#include - -#include "os.h" -#include "cx.h" -#include "stark_crypto.h" - -void compute_token_id(cx_sha3_t *sha3, - uint8_t *contractAddress, - uint8_t quantumType, - uint8_t *quantum, - uint8_t *mintingBlob, - bool assetTypeOnly, - uint8_t *output); - -void starkDerivePrivateKey(uint32_t *bip32Path, uint32_t bip32PathLength, uint8_t *privateKeyData); - -void stark_get_amount_string(uint8_t *contractAddress, - uint8_t *quantum256, - uint8_t *amount64, - char *tmp100, - char *target100); - -int stark_sign(uint8_t *signature, /* out */ - uint8_t *privateKeyData, - FieldElement token1, - FieldElement token2, - FieldElement msg, - FieldElement condition); - -#endif // _STARK_UTILS_H_ diff --git a/src/ui_callbacks.h b/src/ui_callbacks.h index 041f7173e..306340076 100644 --- a/src/ui_callbacks.h +++ b/src/ui_callbacks.h @@ -21,9 +21,6 @@ unsigned int io_seproxyhal_touch_data_cancel(const bagl_element_t *e); unsigned int io_seproxyhal_touch_eth2_address_ok(const bagl_element_t *e); unsigned int io_seproxyhal_touch_privacy_ok(const bagl_element_t *e); unsigned int io_seproxyhal_touch_privacy_cancel(const bagl_element_t *e); -unsigned int io_seproxyhal_touch_stark_unsafe_sign_ok(const bagl_element_t *e); -unsigned int io_seproxyhal_touch_stark_pubkey_ok(const bagl_element_t *e); -unsigned int io_seproxyhal_touch_stark_ok(const bagl_element_t *e); void ui_warning_contract_data(void); diff --git a/src_bagl/common_ui.c b/src_bagl/common_ui.c index 19ff47e4d..dc6450496 100644 --- a/src_bagl/common_ui.c +++ b/src_bagl/common_ui.c @@ -37,32 +37,6 @@ void ui_sign_712_v0(void) { ux_flow_init(0, ux_sign_712_v0_flow, NULL); } -#ifdef HAVE_STARKWARE -void ui_display_stark_public(void) { - ux_flow_init(0, ux_display_stark_public_flow, NULL); -} -void ui_stark_limit_order(void) { - ux_flow_init(0, ux_stark_limit_order_flow, NULL); -} - -void ui_stark_unsafe_sign(void) { - ux_flow_init(0, ux_stark_unsafe_sign_flow, NULL); -} - -void ui_stark_transfer(bool selfTransfer, bool conditional) { - if (selfTransfer) { - ux_flow_init( - 0, - (conditional ? ux_stark_self_transfer_conditional_flow : ux_stark_self_transfer_flow), - NULL); - } else { - ux_flow_init(0, - (conditional ? ux_stark_transfer_conditional_flow : ux_stark_transfer_flow), - NULL); - } -} -#endif // HAVE_STARKWARE - void ui_confirm_selector(void) { ux_flow_init(0, ux_confirm_selector_flow, NULL); } diff --git a/src_bagl/ui_flow.h b/src_bagl/ui_flow.h index 184036b67..ae2590d90 100644 --- a/src_bagl/ui_flow.h +++ b/src_bagl/ui_flow.h @@ -30,34 +30,4 @@ extern const ux_flow_step_t* const ux_display_privacy_shared_secret_flow[]; extern const ux_flow_step_t* ux_approval_tx_flow[15]; -#ifdef HAVE_STARKWARE - -extern const ux_flow_step_t* const ux_display_stark_public_flow[]; - -extern const ux_flow_step_t* const ux_stark_limit_order_flow[]; - -extern const ux_flow_step_t* const ux_stark_transfer_flow[]; - -extern const ux_flow_step_t* const ux_stark_self_transfer_flow[]; - -extern const ux_flow_step_t* const ux_stark_transfer_conditional_flow[]; - -extern const ux_flow_step_t* const ux_stark_self_transfer_conditional_flow[]; - -extern const ux_flow_step_t* const ux_approval_starkware_register_flow[]; - -extern const ux_flow_step_t* const ux_approval_starkware_deposit_flow[]; - -extern const ux_flow_step_t* const ux_approval_starkware_withdraw_flow[]; - -extern const ux_flow_step_t* const ux_approval_starkware_verify_vault_id_flow[]; - -extern const ux_flow_step_t* const ux_approval_starkware_escape_flow[]; - -extern const ux_flow_step_t* const ux_approval_starkware_verify_escape_flow[]; - -extern const ux_flow_step_t* const ux_stark_unsafe_sign_flow[]; - -#endif - #endif // _UI_FLOW_H_ diff --git a/src_bagl/ui_flow_stark_getPublicKey.c b/src_bagl/ui_flow_stark_getPublicKey.c deleted file mode 100644 index 958874fc2..000000000 --- a/src_bagl/ui_flow_stark_getPublicKey.c +++ /dev/null @@ -1,46 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "shared_context.h" -#include "ui_callbacks.h" - -// clang-format off -UX_STEP_NOCB( - ux_display_stark_public_flow_1_step, - pnn, - { - &C_icon_eye, - "Verify", - "Stark key", - }); -UX_STEP_NOCB( - ux_display_stark_public_flow_2_step, - bnnn_paging, - { - .title = "Stark Key", - .text = strings.tmp.tmp, - }); -UX_STEP_CB( - ux_display_stark_public_flow_3_step, - pb, - io_seproxyhal_touch_stark_pubkey_ok(NULL), - { - &C_icon_validate_14, - "Approve", - }); -UX_STEP_CB( - ux_display_stark_public_flow_4_step, - pb, - io_seproxyhal_touch_address_cancel(NULL), - { - &C_icon_crossmark, - "Reject", - }); -// clang-format on - -UX_FLOW(ux_display_stark_public_flow, - &ux_display_stark_public_flow_1_step, - &ux_display_stark_public_flow_2_step, - &ux_display_stark_public_flow_3_step, - &ux_display_stark_public_flow_4_step); - -#endif diff --git a/src_bagl/ui_flow_stark_sign.c b/src_bagl/ui_flow_stark_sign.c deleted file mode 100644 index 18905e608..000000000 --- a/src_bagl/ui_flow_stark_sign.c +++ /dev/null @@ -1,234 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "shared_context.h" -#include "ui_callbacks.h" -#include "starkDisplayUtils.h" -#include "apdu_constants.h" - -// clang-format off -UX_STEP_NOCB(ux_stark_limit_order_1_step, - pnn, - { - &C_icon_eye, - "Review", - "transaction", - }); - -UX_STEP_NOCB(ux_stark_limit_order_2_step, - bnnn_paging, - { - .title = "Limit", - .text = "Order" - }); - -UX_STEP_NOCB(ux_stark_limit_order_3_step, - bnnn_paging, - { - .title = "Trading", - .text = "Pair" - }); - -UX_STEP_NOCB(ux_stark_limit_order_4_step, - bnnn_paging, - { - .title = "Sell", - .text = strings.common.fullAmount - }); - -UX_STEP_NOCB(ux_stark_limit_order_5_step, - bnnn_paging, - { - .title = "Buy", - .text = strings.common.maxFee - }); - -UX_STEP_NOCB(ux_stark_limit_order_6_step, - bnnn_paging, - { - .title = "Token Account", - .text = strings.common.fullAddress - }); - -UX_STEP_CB( - ux_stark_limit_order_7_step, - pbb, - io_seproxyhal_touch_stark_ok(NULL), - { - &C_icon_validate_14, - "Accept", - "and send", - }); -UX_STEP_CB( - ux_stark_limit_order_8_step, - pb, - io_seproxyhal_touch_tx_cancel(NULL), - { - &C_icon_crossmark, - "Reject", - }); -// clang-format on - -UX_FLOW(ux_stark_limit_order_flow, - &ux_stark_limit_order_1_step, - &ux_stark_limit_order_2_step, - &ux_stark_limit_order_3_step, - &ux_stark_limit_order_4_step, - &ux_stark_limit_order_5_step, - &ux_stark_limit_order_6_step, - &ux_stark_limit_order_7_step, - &ux_stark_limit_order_8_step); - -static void stark_format_address(void) { - if (!getEthDisplayableAddress(dataContext.starkContext.conditionAddress, - strings.tmp.tmp, - sizeof(strings.tmp.tmp), - &global_sha3, - chainConfig->chainId)) { - THROW(APDU_RESPONSE_ERROR_NO_INFO); - } -} - -////////////////////////////////////////////////////////////////////// -// clang-format off -UX_STEP_NOCB(ux_stark_transfer_1_step, - pnn, - { - &C_icon_eye, - "Review", - "transaction", - }); - -UX_STEP_NOCB(ux_stark_transfer_2_step, - bnnn_paging, - { - .title = "Transfer", - .text = " " - }); - -UX_STEP_NOCB(ux_stark_self_transfer_2_step, - bnnn_paging, - { - .title = "Self", - .text = "Transfer" - }); - -UX_STEP_NOCB(ux_stark_conditional_transfer_2_step, - bnnn_paging, - { - .title = "Conditional", - .text = "Transfer" - }); - -UX_STEP_NOCB(ux_stark_self_conditional_transfer_2_step, - bnnn_paging, - { - .title = "Conditional", - .text = "Self Transfer" - }); - -UX_STEP_NOCB(ux_stark_transfer_3_step, - bnnn_paging, - { - .title = "Amount", - .text = tmpContent.tmp - }); - -UX_STEP_NOCB(ux_stark_transfer_4_step, - bnnn_paging, - { - .title = "Master Account", - .text = strings.tmp.tmp - }); - -UX_STEP_NOCB(ux_stark_transfer_5_step, - bnnn_paging, - { - .title = "Token Account", - .text = strings.tmp.tmp2 - }); - -UX_STEP_CB( - ux_stark_transfer_6_step, - pbb, - io_seproxyhal_touch_stark_ok(NULL), - { - &C_icon_validate_14, - "Accept", - "and send", - }); -UX_STEP_CB( - ux_stark_transfer_7_step, - pb, - io_seproxyhal_touch_tx_cancel(NULL), - { - &C_icon_crossmark, - "Reject", - }); - -UX_STEP_NOCB_INIT( - ux_stark_conditional_transfer_4_step, - bnnn_paging, - stark_sign_display_master_account(), - { - .title = "Master Account", - .text = strings.tmp.tmp - }); - -UX_STEP_NOCB_INIT( - ux_stark_conditional_transfer_8_step, - bnnn_paging, - stark_format_address(), - { - .title = "Cond. Address", - .text = strings.tmp.tmp - }); - -UX_STEP_NOCB_INIT( - ux_stark_conditional_transfer_9_step, - bnnn_paging, - stark_sign_display_condition_fact(), - { - .title = "Cond. Fact", - .text = strings.tmp.tmp - }); -// clang-format on - -UX_FLOW(ux_stark_transfer_flow, - &ux_stark_transfer_1_step, - &ux_stark_transfer_2_step, - &ux_stark_transfer_3_step, - &ux_stark_transfer_4_step, - &ux_stark_transfer_5_step, - &ux_stark_transfer_6_step, - &ux_stark_transfer_7_step); - -UX_FLOW(ux_stark_self_transfer_flow, - &ux_stark_transfer_1_step, - &ux_stark_self_transfer_2_step, - &ux_stark_transfer_3_step, - &ux_stark_transfer_5_step, - &ux_stark_transfer_6_step, - &ux_stark_transfer_7_step); - -UX_FLOW(ux_stark_transfer_conditional_flow, - &ux_stark_transfer_1_step, - &ux_stark_conditional_transfer_2_step, - &ux_stark_transfer_3_step, - &ux_stark_conditional_transfer_4_step, - &ux_stark_transfer_5_step, - &ux_stark_conditional_transfer_8_step, - &ux_stark_conditional_transfer_9_step, - &ux_stark_transfer_6_step, - &ux_stark_transfer_7_step); - -UX_FLOW(ux_stark_self_transfer_conditional_flow, - &ux_stark_transfer_1_step, - &ux_stark_self_conditional_transfer_2_step, - &ux_stark_transfer_3_step, - &ux_stark_transfer_5_step, - &ux_stark_conditional_transfer_8_step, - &ux_stark_conditional_transfer_9_step, - &ux_stark_transfer_6_step, - &ux_stark_transfer_7_step); - -#endif diff --git a/src_bagl/ui_flow_stark_unsafe_sign.c b/src_bagl/ui_flow_stark_unsafe_sign.c deleted file mode 100644 index 1c080582e..000000000 --- a/src_bagl/ui_flow_stark_unsafe_sign.c +++ /dev/null @@ -1,70 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "shared_context.h" -#include "ui_callbacks.h" - -unsigned int io_seproxyhal_touch_stark_unsafe_sign_ok(const bagl_element_t *e); - -void stark_unsafe_sign_display_account() { - snprintf(strings.tmp.tmp, sizeof(strings.tmp.tmp), "0x%.*H", 32, dataContext.starkContext.w1); -} - -void stark_unsafe_sign_display_hash() { - snprintf(strings.tmp.tmp, sizeof(strings.tmp.tmp), "0x%.*H", 32, dataContext.starkContext.w2); -} - -// clang-format off -UX_STEP_NOCB(ux_stark_unsafe_sign_1_step, - pnn, - { - &C_icon_warning, - "StarkNet", - "Blind Sign", - }); - -UX_STEP_NOCB_INIT( - ux_stark_unsafe_sign_2_step, - bnnn_paging, - stark_unsafe_sign_display_account(), - { - .title = "From Account", - .text = strings.tmp.tmp - }); - -UX_STEP_NOCB_INIT( - ux_stark_unsafe_sign_3_step, - bnnn_paging, - stark_unsafe_sign_display_hash(), - { - .title = "Tx Hash", - .text = strings.tmp.tmp - }); - - -UX_STEP_CB( - ux_stark_unsafe_sign_4_step, - pbb, - io_seproxyhal_touch_stark_unsafe_sign_ok(NULL), - { - &C_icon_validate_14, - "Accept", - "and send", - }); -UX_STEP_CB( - ux_stark_unsafe_sign_5_step, - pb, - io_seproxyhal_touch_tx_cancel(NULL), - { - &C_icon_crossmark, - "Reject", - }); -// clang-format on - -UX_FLOW(ux_stark_unsafe_sign_flow, - &ux_stark_unsafe_sign_1_step, - &ux_stark_unsafe_sign_2_step, - &ux_stark_unsafe_sign_3_step, - &ux_stark_unsafe_sign_4_step, - &ux_stark_unsafe_sign_5_step); - -#endif diff --git a/src_features/getAppConfiguration/cmd_getAppConfiguration.c b/src_features/getAppConfiguration/cmd_getAppConfiguration.c index fe0130ee3..c882b115b 100644 --- a/src_features/getAppConfiguration/cmd_getAppConfiguration.c +++ b/src_features/getAppConfiguration/cmd_getAppConfiguration.c @@ -14,10 +14,6 @@ void handleGetAppConfiguration(uint8_t p1, UNUSED(flags); G_io_apdu_buffer[0] = (N_storage.dataAllowed ? APP_FLAG_DATA_ALLOWED : 0x00); G_io_apdu_buffer[0] |= APP_FLAG_EXTERNAL_TOKEN_NEEDED; -#ifdef HAVE_STARKWARE - G_io_apdu_buffer[0] |= APP_FLAG_STARKWARE; - G_io_apdu_buffer[0] |= APP_FLAG_STARKWARE_V2; -#endif G_io_apdu_buffer[1] = LEDGER_MAJOR_VERSION; G_io_apdu_buffer[2] = LEDGER_MINOR_VERSION; G_io_apdu_buffer[3] = LEDGER_PATCH_VERSION; diff --git a/src_features/signTx/logic_signTx.c b/src_features/signTx/logic_signTx.c index b40bfb9c4..b1ca0654a 100644 --- a/src_features/signTx/logic_signTx.c +++ b/src_features/signTx/logic_signTx.c @@ -2,9 +2,6 @@ #include "shared_context.h" #include "common_utils.h" #include "feature_signTx.h" -#ifdef HAVE_STARKWARE -#include "stark_utils.h" -#endif #include "uint256.h" #include "eth_plugin_handler.h" #include "network.h" diff --git a/src_features/stark_getPublicKey/cmd_stark_getPublicKey.c b/src_features/stark_getPublicKey/cmd_stark_getPublicKey.c deleted file mode 100644 index 760318828..000000000 --- a/src_features/stark_getPublicKey/cmd_stark_getPublicKey.c +++ /dev/null @@ -1,66 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "shared_context.h" -#include "apdu_constants.h" -#include "stark_utils.h" -#include "feature_stark_getPublicKey.h" -#include "common_ui.h" -#include "os_io_seproxyhal.h" - -void handleStarkwareGetPublicKey(uint8_t p1, - uint8_t p2, - const uint8_t *dataBuffer, - uint8_t dataLength, - unsigned int *flags, - unsigned int *tx) { - bip32_path_t bip32; - cx_ecfp_private_key_t privateKey; - uint8_t privateKeyData[32]; - - reset_app_context(); - - if ((p1 != P1_CONFIRM) && (p1 != P1_NON_CONFIRM)) { - THROW(0x6B00); - } - - if (p2 != 0) { - THROW(0x6B00); - } - - dataBuffer = parseBip32(dataBuffer, &dataLength, &bip32); - - if (dataBuffer == NULL) { - THROW(0x6a80); - } - - io_seproxyhal_io_heartbeat(); - starkDerivePrivateKey(bip32.path, bip32.length, privateKeyData); - cx_ecfp_init_private_key(CX_CURVE_Stark256, privateKeyData, 32, &privateKey); - io_seproxyhal_io_heartbeat(); - cx_ecfp_generate_pair(CX_CURVE_Stark256, &tmpCtx.publicKeyContext.publicKey, &privateKey, 1); - explicit_bzero(&privateKey, sizeof(privateKey)); - explicit_bzero(privateKeyData, sizeof(privateKeyData)); - io_seproxyhal_io_heartbeat(); -#ifndef NO_CONSENT - if (p1 == P1_NON_CONFIRM) -#endif // NO_CONSENT - { - *tx = set_result_get_stark_publicKey(); - THROW(0x9000); - } -#ifndef NO_CONSENT - else { - // prepare for a UI based reply - snprintf(strings.tmp.tmp, - sizeof(strings.tmp.tmp), - "0x%.*H", - 32, - tmpCtx.publicKeyContext.publicKey.W + 1); - ui_display_stark_public(); - - *flags |= IO_ASYNCH_REPLY; - } -#endif // NO_CONSENT -} - -#endif diff --git a/src_features/stark_getPublicKey/feature_stark_getPublicKey.h b/src_features/stark_getPublicKey/feature_stark_getPublicKey.h deleted file mode 100644 index 4859722c4..000000000 --- a/src_features/stark_getPublicKey/feature_stark_getPublicKey.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _STARK_GET_PUB_KEY_H_ -#define _STARK_GET_PUB_KEY_H_ - -#include "shared_context.h" - -uint32_t set_result_get_stark_publicKey(void); - -#endif // _STARK_GET_PUB_KEY_H_ diff --git a/src_features/stark_getPublicKey/logic_stark_getPublicKey.c b/src_features/stark_getPublicKey/logic_stark_getPublicKey.c deleted file mode 100644 index 9338cc470..000000000 --- a/src_features/stark_getPublicKey/logic_stark_getPublicKey.c +++ /dev/null @@ -1,14 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include -#include "shared_context.h" -#include "feature_stark_getPublicKey.h" - -uint32_t set_result_get_stark_publicKey() { - uint32_t tx = 0; - memmove(G_io_apdu_buffer + tx, tmpCtx.publicKeyContext.publicKey.W, 65); - tx += 65; - return tx; -} - -#endif // HAVE_STARKWARE diff --git a/src_features/stark_getPublicKey/ui_common_stark_getPublicKey.c b/src_features/stark_getPublicKey/ui_common_stark_getPublicKey.c deleted file mode 100644 index 31b97144f..000000000 --- a/src_features/stark_getPublicKey/ui_common_stark_getPublicKey.c +++ /dev/null @@ -1,19 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "shared_context.h" -#include "common_ui.h" -#include "feature_stark_getPublicKey.h" - -unsigned int io_seproxyhal_touch_stark_pubkey_ok(__attribute__((unused)) const bagl_element_t *e) { - uint32_t tx = set_result_get_stark_publicKey(); - G_io_apdu_buffer[tx++] = 0x90; - G_io_apdu_buffer[tx++] = 0x00; - reset_app_context(); - // Send back the response, do not restart the event loop - io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx); - // Display back the original UX - ui_idle(); - return 0; // do not redraw the widget -} - -#endif diff --git a/src_features/stark_provideQuantum/cmd_stark_provideQuantum.c b/src_features/stark_provideQuantum/cmd_stark_provideQuantum.c deleted file mode 100644 index 614669d48..000000000 --- a/src_features/stark_provideQuantum/cmd_stark_provideQuantum.c +++ /dev/null @@ -1,64 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "shared_context.h" -#include "apdu_constants.h" -#include "common_ui.h" - -void handleStarkwareProvideQuantum(uint8_t p1, - __attribute__((unused)) uint8_t p2, - const uint8_t *dataBuffer, - uint8_t dataLength, - __attribute__((unused)) unsigned int *flags, - __attribute__((unused)) unsigned int *tx) { - size_t i = 0; - uint8_t expectedDataSize = 20 + 32; - uint8_t addressZero = 0; - tokenDefinition_t *currentToken = NULL; - if (appState != APP_STATE_IDLE) { - reset_app_context(); - } - switch (p1) { - case STARK_QUANTUM_LEGACY: - break; - case STARK_QUANTUM_ETH: - case STARK_QUANTUM_ERC20: - case STARK_QUANTUM_ERC721: - case STARK_QUANTUM_MINTABLE_ERC20: - case STARK_QUANTUM_MINTABLE_ERC721: - expectedDataSize += 32; - break; - default: - THROW(0x6B00); - } - if (dataLength != expectedDataSize) { - THROW(0x6700); - } - if (p1 == STARK_QUANTUM_LEGACY) { - addressZero = allzeroes((void *) dataBuffer, 20); - } - if ((p1 != STARK_QUANTUM_ETH) && !addressZero) { - for (i = 0; i < MAX_ITEMS; i++) { - currentToken = &tmpCtx.transactionContext.extraInfo[i].token; - if (tmpCtx.transactionContext.tokenSet[i] && - (memcmp(currentToken->address, dataBuffer, 20) == 0)) { - break; - } - } - if (i == MAX_ITEMS) { - PRINTF("Associated token not found\n"); - THROW(0x6A80); - } - } else { - i = MAX_ITEMS; - } - memmove(dataContext.tokenContext.quantum, dataBuffer + 20, 32); - if (p1 != STARK_QUANTUM_LEGACY) { - memmove(dataContext.tokenContext.mintingBlob, dataBuffer + 20 + 32, 32); - } - dataContext.tokenContext.quantumIndex = i; - dataContext.tokenContext.quantumType = p1; - quantumSet = true; - THROW(0x9000); -} - -#endif diff --git a/src_features/stark_sign/cmd_stark_sign.c b/src_features/stark_sign/cmd_stark_sign.c deleted file mode 100644 index 7810f779d..000000000 --- a/src_features/stark_sign/cmd_stark_sign.c +++ /dev/null @@ -1,259 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "shared_context.h" -#include "apdu_constants.h" -#include "stark_utils.h" -#include "poorstream.h" -#include "common_ui.h" -#include "os_io_seproxyhal.h" - -#define U8BE(buf, off) \ - (uint64_t)((((uint64_t) U4BE(buf, off)) << 32) | (((uint64_t) U4BE(buf, off + 4)) & 0xFFFFFFFF)) -#define TMP_OFFSET 140 - -void handleStarkwareSignMessage(uint8_t p1, - uint8_t p2, - uint8_t *dataBuffer, - uint8_t dataLength, - unsigned int *flags, - __attribute__((unused)) unsigned int *tx) { - uint8_t privateKeyData[INT256_LENGTH]; - uint32_t i; - uint8_t bip32PathLength; - uint8_t offset = 1; - cx_ecfp_private_key_t privateKey; - poorstream_t bitstream; - bool selfTransfer = false; - uint8_t order = 1; - uint8_t protocol = 2; - uint8_t preOffset, postOffset; - uint8_t zeroTest; - - // Initial checks - if (appState != APP_STATE_IDLE) { - reset_app_context(); - } - - if (dataLength < 1) { - PRINTF("Invalid data\n"); - THROW(0x6a80); - } - - bip32PathLength = *(dataBuffer); - - if ((bip32PathLength < 0x01) || (bip32PathLength > MAX_BIP32_PATH)) { - PRINTF("Invalid path\n"); - THROW(0x6a80); - } - switch (p1) { - case P1_STARK_ORDER: - protocol = 1; - break; - case P1_STARK_TRANSFER: - protocol = 1; - order = 0; - break; - case P1_STARK_ORDER_V2: - break; - case P1_STARK_TRANSFER_V2: - case P1_STARK_CONDITIONAL_TRANSFER: - order = 0; - break; - default: - THROW(0x6B00); - } - postOffset = (protocol == 2 ? 1 + 32 : 0); - preOffset = (protocol == 2 ? 1 : 0); - if (order) { - if (dataLength != (20 + 32 + 20 + 32 + 4 + 4 + 8 + 8 + 4 + 4 + 1 + 4 * bip32PathLength + - 2 * postOffset)) { - THROW(0x6700); - } - } else { - if (dataLength != (20 + 32 + 32 + 4 + 4 + 8 + 4 + 4 + 1 + 4 * bip32PathLength + postOffset + - (p1 == P1_STARK_CONDITIONAL_TRANSFER ? 32 + 20 : 0))) { - THROW(0x6700); - } - } - if (p2 != 0) { - THROW(0x6B00); - } - tmpCtx.transactionContext.bip32.length = bip32PathLength; - for (i = 0; i < bip32PathLength; i++) { - tmpCtx.transactionContext.bip32.path[i] = U4BE(dataBuffer, offset); - PRINTF("Storing path %d %d\n", i, tmpCtx.transactionContext.bip32.path[i]); - offset += 4; - } - // Discard the path to use part of dataBuffer as a temporary buffer - memmove(dataBuffer, dataBuffer + offset, dataLength - offset); - dataContext.starkContext.conditional = (p1 == P1_STARK_CONDITIONAL_TRANSFER); - if (dataContext.starkContext.conditional) { - memmove(dataContext.starkContext.fact, - dataBuffer + 20 + 32 + postOffset + 32 + 4 + 4 + 8 + 4 + 4, - 32); - memmove(dataContext.starkContext.conditionAddress, - dataBuffer + 20 + 32 + postOffset + 32 + 4 + 4 + 8 + 4 + 4 + 32, - 20); - PRINTF("Fact %.*H\n", 32, dataContext.starkContext.fact); - PRINTF("Address %.*H\n", 20, dataContext.starkContext.conditionAddress); - } - - zeroTest = allzeroes(dataBuffer + preOffset, 20); - if (zeroTest && (protocol == 2) && (dataBuffer[0] != STARK_QUANTUM_ETH)) { - PRINTF("stark - unexpected quantum descriptor type for null first address %d\n", - dataBuffer[0]); - THROW(0x6A80); - } - if (!zeroTest && getKnownToken(dataBuffer + preOffset) == NULL) { - PRINTF("stark - cannot process unknown token %.*H", 20, dataBuffer + preOffset); - THROW(0x6A80); - } - if (order) { - zeroTest = allzeroes(dataBuffer + 20 + 32 + postOffset + preOffset, 20); - if (zeroTest && (protocol == 2) && (dataBuffer[1 + 20 + 32 + 32] != STARK_QUANTUM_ETH)) { - PRINTF("stark - unexpected quantum descriptor type for null second address %d\n", - dataBuffer[1 + 20 + 32 + 32]); - THROW(0x6A80); - } - if (!zeroTest && getKnownToken(dataBuffer + 20 + 32 + postOffset + preOffset) == NULL) { - PRINTF("stark - cannot process unknown token %.*H", - 20, - dataBuffer + 20 + 32 + postOffset + preOffset); - THROW(0x6A80); - } - } - // Prepare the Stark parameters - io_seproxyhal_io_heartbeat(); - compute_token_id(&global_sha3, - dataBuffer + preOffset, - (protocol == 2 ? dataBuffer[0] : STARK_QUANTUM_LEGACY), - dataBuffer + preOffset + 20, - (protocol == 2 ? dataBuffer + 1 + 20 + 32 : NULL), - false, - dataContext.starkContext.w1); - if (order) { - io_seproxyhal_io_heartbeat(); - compute_token_id(&global_sha3, - dataBuffer + 20 + 32 + postOffset + preOffset, - (protocol == 2 ? dataBuffer[1 + 20 + 32 + 32] : STARK_QUANTUM_LEGACY), - dataBuffer + 20 + 32 + postOffset + preOffset + 20, - (protocol == 2 ? dataBuffer + 1 + 20 + 32 + 32 + 1 + 20 + 32 : NULL), - false, - dataContext.starkContext.w2); - offset = 20 + 32 + postOffset + 20 + 32 + postOffset; - } else { - memmove(dataContext.starkContext.w2, dataBuffer + 20 + 32 + postOffset, 32); - offset = 20 + 32 + postOffset + 32; - } - - poorstream_init(&bitstream, dataContext.starkContext.w3); - poorstream_write_bits(&bitstream, 0, 11); // padding - poorstream_write_bits(&bitstream, - (p1 == P1_STARK_CONDITIONAL_TRANSFER ? STARK_CONDITIONAL_TRANSFER_TYPE - : order ? STARK_ORDER_TYPE - : STARK_TRANSFER_TYPE), - 4); - poorstream_write_bits(&bitstream, U4BE(dataBuffer, offset), 31); - poorstream_write_bits(&bitstream, U4BE(dataBuffer, offset + 4), 31); - poorstream_write_bits(&bitstream, U8BE(dataBuffer, offset + 4 + 4), 63); - if (order) { - poorstream_write_bits(&bitstream, U8BE(dataBuffer, offset + 4 + 4 + 8), 63); - offset += 4 + 4 + 8 + 8; - } else { - poorstream_write_bits(&bitstream, 0, 63); - offset += 4 + 4 + 8; - } - poorstream_write_bits(&bitstream, U4BE(dataBuffer, offset), 31); - poorstream_write_bits(&bitstream, U4BE(dataBuffer, offset + 4), 22); - - PRINTF("stark w1 %.*H\n", 32, dataContext.starkContext.w1); - PRINTF("stark w2 %.*H\n", 32, dataContext.starkContext.w2); - PRINTF("stark w3 %.*H\n", 32, dataContext.starkContext.w3); - - if (dataContext.starkContext.conditional) { - cx_keccak_init(&global_sha3, 256); - cx_hash((cx_hash_t *) &global_sha3, - 0, - dataContext.starkContext.conditionAddress, - 20, - NULL, - 0); - cx_hash((cx_hash_t *) &global_sha3, - CX_LAST, - dataContext.starkContext.fact, - 32, - dataContext.starkContext.w4, - 32); - dataContext.starkContext.w4[0] &= 0x03; - PRINTF("stark w4 %.*H\n", 32, dataContext.starkContext.w4); - } - // Prepare the UI - if (order) { - io_seproxyhal_io_heartbeat(); - // amount to sell - stark_get_amount_string(dataBuffer + preOffset, - dataBuffer + preOffset + 20, - dataBuffer + 20 + 32 + postOffset + 20 + 32 + postOffset + 4 + 4, - (char *) (dataBuffer + TMP_OFFSET), - strings.common.fullAmount); - io_seproxyhal_io_heartbeat(); - // amount to buy - stark_get_amount_string( - dataBuffer + 20 + 32 + postOffset + preOffset, - dataBuffer + 20 + 32 + postOffset + preOffset + 20, - dataBuffer + 20 + 32 + postOffset + 20 + 32 + postOffset + 4 + 4 + 8, - (char *) (dataBuffer + TMP_OFFSET), - strings.common.maxFee); - // src vault ID - snprintf(strings.common.fullAddress, - sizeof(strings.common.fullAddress), - "%d", - U4BE(dataBuffer, 20 + 32 + postOffset + 20 + 32 + postOffset)); - } else { - cx_ecfp_public_key_t publicKey; - // Check if the transfer is a self transfer - io_seproxyhal_io_heartbeat(); - starkDerivePrivateKey(tmpCtx.transactionContext.bip32.path, - bip32PathLength, - privateKeyData); - cx_ecfp_init_private_key(CX_CURVE_Stark256, privateKeyData, 32, &privateKey); - io_seproxyhal_io_heartbeat(); - cx_ecfp_generate_pair(CX_CURVE_Stark256, &publicKey, &privateKey, 1); - explicit_bzero(&privateKey, sizeof(privateKey)); - explicit_bzero(privateKeyData, sizeof(privateKeyData)); - io_seproxyhal_io_heartbeat(); - selfTransfer = (memcmp(publicKey.W + 1, dataBuffer + 20 + 32 + postOffset, 32) == 0); - PRINTF("self transfer %d\n", selfTransfer); - io_seproxyhal_io_heartbeat(); - // amount to transfer - stark_get_amount_string(dataBuffer + preOffset, - dataBuffer + preOffset + 20, - dataBuffer + 20 + 32 + postOffset + 32 + 4 + 4, - (char *) (dataBuffer + TMP_OFFSET), - tmpContent.tmp); - // dest vault ID - snprintf(strings.tmp.tmp2, - sizeof(strings.tmp.tmp2), - "%d", - U4BE(dataBuffer, 20 + 32 + postOffset + 32 + 4)); - if (!selfTransfer) { - memmove(dataContext.starkContext.transferDestination, - dataBuffer + 20 + 32 + postOffset, - 32); - snprintf(strings.tmp.tmp, - sizeof(strings.tmp.tmp), - "0x%.*H", - 32, - dataBuffer + 20 + 32 + postOffset); - } - } - if (order) { - ui_stark_limit_order(); - } else { - ui_stark_transfer(selfTransfer, dataContext.starkContext.conditional); - } - - *flags |= IO_ASYNCH_REPLY; -} - -#endif diff --git a/src_features/stark_sign/ui_common_stark_sign.c b/src_features/stark_sign/ui_common_stark_sign.c deleted file mode 100644 index a45f7f918..000000000 --- a/src_features/stark_sign/ui_common_stark_sign.c +++ /dev/null @@ -1,36 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "os_io_seproxyhal.h" -#include "shared_context.h" -#include "stark_utils.h" -#include "common_ui.h" - -unsigned int io_seproxyhal_touch_stark_ok(__attribute__((unused)) const bagl_element_t *e) { - uint8_t privateKeyData[32]; - uint8_t signature[72]; - uint32_t tx = 0; - io_seproxyhal_io_heartbeat(); - starkDerivePrivateKey(tmpCtx.transactionContext.bip32.path, - tmpCtx.transactionContext.bip32.length, - privateKeyData); - io_seproxyhal_io_heartbeat(); - stark_sign(signature, - privateKeyData, - dataContext.starkContext.w1, - dataContext.starkContext.w2, - dataContext.starkContext.w3, - (dataContext.starkContext.conditional ? dataContext.starkContext.w4 : NULL)); - G_io_apdu_buffer[0] = 0; - format_signature_out(signature); - tx = 65; - G_io_apdu_buffer[tx++] = 0x90; - G_io_apdu_buffer[tx++] = 0x00; - reset_app_context(); - // Send back the response, do not restart the event loop - io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx); - // Display back the original UX - ui_idle(); - return 0; // do not redraw the widget -} - -#endif // HAVE_STARKWARE diff --git a/src_features/stark_unsafe_sign/cmd_stark_unsafe_sign.c b/src_features/stark_unsafe_sign/cmd_stark_unsafe_sign.c deleted file mode 100644 index 314fb22e4..000000000 --- a/src_features/stark_unsafe_sign/cmd_stark_unsafe_sign.c +++ /dev/null @@ -1,55 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "shared_context.h" -#include "apdu_constants.h" -#include "stark_utils.h" -#include "common_ui.h" -#include "os_io_seproxyhal.h" - -void handleStarkwareUnsafeSign(uint8_t p1, - uint8_t p2, - const uint8_t *dataBuffer, - uint8_t dataLength, - unsigned int *flags, - __attribute__((unused)) unsigned int *tx) { - uint8_t privateKeyData[INT256_LENGTH]; - cx_ecfp_public_key_t publicKey; - cx_ecfp_private_key_t privateKey; - - // Initial checks - if (appState != APP_STATE_IDLE) { - reset_app_context(); - } - - if ((p1 != 0) || (p2 != 0)) { - THROW(0x6B00); - } - - dataBuffer = parseBip32(dataBuffer, &dataLength, &tmpCtx.transactionContext.bip32); - - if (dataBuffer == NULL) { - THROW(0x6a80); - } - - if (dataLength != 32) { - THROW(0x6700); - } - - memmove(dataContext.starkContext.w2, dataBuffer, 32); - io_seproxyhal_io_heartbeat(); - starkDerivePrivateKey(tmpCtx.transactionContext.bip32.path, - tmpCtx.transactionContext.bip32.length, - privateKeyData); - cx_ecfp_init_private_key(CX_CURVE_Stark256, privateKeyData, 32, &privateKey); - io_seproxyhal_io_heartbeat(); - cx_ecfp_generate_pair(CX_CURVE_Stark256, &publicKey, &privateKey, 1); - explicit_bzero(&privateKey, sizeof(privateKey)); - explicit_bzero(privateKeyData, sizeof(privateKeyData)); - io_seproxyhal_io_heartbeat(); - memmove(dataContext.starkContext.w1, publicKey.W + 1, 32); - ui_stark_unsafe_sign(); - - *flags |= IO_ASYNCH_REPLY; -} - -#endif diff --git a/src_features/stark_unsafe_sign/ui_common_stark_unsafe_sign.c b/src_features/stark_unsafe_sign/ui_common_stark_unsafe_sign.c deleted file mode 100644 index 4774627b8..000000000 --- a/src_features/stark_unsafe_sign/ui_common_stark_unsafe_sign.c +++ /dev/null @@ -1,42 +0,0 @@ -#ifdef HAVE_STARKWARE - -#include "os_io_seproxyhal.h" -#include "shared_context.h" -#include "stark_utils.h" -#include "common_ui.h" - -unsigned int io_seproxyhal_touch_stark_unsafe_sign_ok(__attribute__((unused)) - const bagl_element_t *e) { - cx_ecfp_private_key_t privateKey; - uint8_t privateKeyData[INT256_LENGTH]; - uint8_t signature[72]; - unsigned int info = 0; - uint32_t tx = 0; - io_seproxyhal_io_heartbeat(); - starkDerivePrivateKey(tmpCtx.transactionContext.bip32.path, - tmpCtx.transactionContext.bip32.length, - privateKeyData); - io_seproxyhal_io_heartbeat(); - cx_ecfp_init_private_key(CX_CURVE_Stark256, privateKeyData, 32, &privateKey); - cx_ecdsa_sign(&privateKey, - CX_RND_RFC6979 | CX_LAST, - CX_SHA256, - dataContext.starkContext.w2, - sizeof(dataContext.starkContext.w2), - signature, - sizeof(signature), - &info); - G_io_apdu_buffer[0] = 0; - format_signature_out(signature); - tx = 65; - G_io_apdu_buffer[tx++] = 0x90; - G_io_apdu_buffer[tx++] = 0x00; - reset_app_context(); - // Send back the response, do not restart the event loop - io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx); - // Display back the original UX - ui_idle(); - return 0; // do not redraw the widget -} - -#endif // HAVE_STARKWARE diff --git a/src_nbgl/ui_get_stark_public_key.c b/src_nbgl/ui_get_stark_public_key.c deleted file mode 100644 index ce5778750..000000000 --- a/src_nbgl/ui_get_stark_public_key.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include "shared_context.h" -#include "ui_callbacks.h" -#include "ui_nbgl.h" - -static void reviewReject(void) { - io_seproxyhal_touch_address_cancel(NULL); -} - -static void confirmTransation(void) { - io_seproxyhal_touch_stark_pubkey_ok(NULL); -} - -static void reviewChoice(bool confirm) { - if (confirm) { - // display a status page and go back to main - nbgl_useCaseStatus("ADDRESS\nVERIFIED", true, confirmTransation); - } else { - nbgl_useCaseStatus("Address verification\ncancelled", false, reviewReject); - } -} - -static void buildScreen(void) { - nbgl_useCaseAddressConfirmation(strings.tmp.tmp, reviewChoice); -} - -void ui_display_stark_public(void) { - buildScreen(); -} \ No newline at end of file diff --git a/src_nbgl/ui_stark_limit_order.c b/src_nbgl/ui_stark_limit_order.c deleted file mode 100644 index 89cfdbf83..000000000 --- a/src_nbgl/ui_stark_limit_order.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "common_ui.h" -#include "ui_signing.h" -#include "ui_nbgl.h" -#include "ui_callbacks.h" -#include "nbgl_use_case.h" -#include "network.h" - -#ifdef HAVE_STARKWARE - -static nbgl_layoutTagValue_t pairs[3]; - -static void reviewReject(void) { - io_seproxyhal_touch_tx_cancel(NULL); -} - -static void confirmTransation(void) { - io_seproxyhal_touch_stark_ok(NULL); -} - -static void reviewChoice(bool confirm) { - if (confirm) { - confirmTransation(); - } else { - reviewReject(); - } -} - -static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) { - if (page == 0) { - pairs[0].item = "Sell"; - pairs[0].value = strings.common.fullAmount; - pairs[1].item = "Buy"; - pairs[1].value = strings.common.maxFee; - pairs[2].item = "Token Account"; - pairs[2].value = strings.common.fullAddress; - - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 3; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *) pairs; - } else if (page == 1) { - content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(false); - content->infoLongPress.text = "Review stark limit order"; - content->infoLongPress.longPressText = SIGN_BUTTON; - } else { - return false; - } - // valid page so return true - return true; -} - -static void reviewContinue(void) { - nbgl_useCaseRegularReview(0, 2, REJECT_BUTTON, NULL, displayTransactionPage, reviewChoice); -} - -static void buildFirstPage(void) { - nbgl_useCaseReviewStart(get_app_icon(false), - "Review stark limit order", - NULL, - REJECT_BUTTON, - reviewContinue, - reviewReject); -} - -void ui_stark_limit_order(void) { - buildFirstPage(); -} - -#endif diff --git a/src_nbgl/ui_stark_transfer.c b/src_nbgl/ui_stark_transfer.c deleted file mode 100644 index 40dca2307..000000000 --- a/src_nbgl/ui_stark_transfer.c +++ /dev/null @@ -1,134 +0,0 @@ -#include -#include "shared_context.h" -#include "ui_callbacks.h" -#include "ui_nbgl.h" -#include "ui_signing.h" -#include "starkDisplayUtils.h" -#include "network.h" - -#ifdef HAVE_STARKWARE - -static nbgl_layoutTagValue_t pairs[3]; -static char condAddressBuffer[43]; -struct stark_transfer_context { - bool selfTransfer; - bool conditional; -}; - -static struct stark_transfer_context context; - -static void reviewReject(void) { - io_seproxyhal_touch_tx_cancel(NULL); -} - -static void confirmTransation(void) { - io_seproxyhal_touch_stark_ok(NULL); -} - -static void reviewChoice(bool confirm) { - if (confirm) { - confirmTransation(); - } else { - reviewReject(); - } -} - -static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) { - uint8_t count = 0; - if (page == 0) { - pairs[count].item = "Amount"; - pairs[count].value = tmpContent.tmp; - count++; - - if (context.selfTransfer == false && context.conditional == false) { - pairs[count].item = "Master Account"; - pairs[count].value = strings.tmp.tmp; - count++; - } - if (context.conditional) { - stark_sign_display_master_account(); - pairs[count].item = "Master Account"; - pairs[count].value = strings.tmp.tmp; - count++; - } - - pairs[count].item = "Token Account"; - pairs[count].value = strings.tmp.tmp2; - count++; - - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = count; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *) pairs; - - return true; - } - if (page == 1) { - if (context.conditional) { - if (!getEthDisplayableAddress(dataContext.starkContext.conditionAddress, - condAddressBuffer, - sizeof(condAddressBuffer), - &global_sha3, - chainConfig->chainId)) { - return false; - } - pairs[0].item = "Cond. Address"; - pairs[0].value = condAddressBuffer; - - stark_sign_display_condition_fact(); - pairs[1].item = "Cond. Address"; - pairs[1].value = strings.tmp.tmp; - - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 2; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *) pairs; - - return true; - } else { - page++; - } - } - if (page == 2) { - content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(false); - content->infoLongPress.text = "Review transaction"; - content->infoLongPress.longPressText = SIGN_BUTTON; - return true; - } - - return false; -} - -static void reviewContinue(void) { - nbgl_useCaseRegularReview(0, - context.conditional ? 3 : 2, - REJECT_BUTTON, - NULL, - displayTransactionPage, - reviewChoice); -} - -void ui_stark_transfer(bool selfTransfer, bool conditional) { - context.selfTransfer = selfTransfer; - context.conditional = conditional; - char *subTitle; - if (conditional) { - if (selfTransfer) { - subTitle = (char *) "Conditional Self Transfer"; - } else { - subTitle = (char *) "Conditional Transfer"; - } - } else { - if (selfTransfer) { - subTitle = (char *) "Self Transfer"; - } else { - subTitle = (char *) "Transfer"; - } - } - nbgl_useCaseReviewStart(get_app_icon(false), - "Review stark\ntransaction", - subTitle, - REJECT_BUTTON, - reviewContinue, - reviewReject); -} - -#endif // #ifdef HAVE_STARKWARE diff --git a/src_nbgl/ui_stark_unsafe_sign.c b/src_nbgl/ui_stark_unsafe_sign.c deleted file mode 100644 index 45a8556db..000000000 --- a/src_nbgl/ui_stark_unsafe_sign.c +++ /dev/null @@ -1,70 +0,0 @@ -#include "common_ui.h" -#include "ui_signing.h" -#include "ui_nbgl.h" -#include "ui_callbacks.h" -#include "nbgl_use_case.h" -#include "network.h" - -#ifdef HAVE_STARKWARE - -static nbgl_layoutTagValue_t pairs[2]; -static char from_account[64]; -static char message_hash[64]; - -static void reviewReject(void) { - io_seproxyhal_touch_tx_cancel(NULL); -} - -static void confirmTransation(void) { - io_seproxyhal_touch_stark_unsafe_sign_ok(NULL); -} - -static void reviewChoice(bool confirm) { - if (confirm) { - confirmTransation(); - } else { - reviewReject(); - } -} - -static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) { - snprintf(from_account, sizeof(from_account), "0x%.*H", 32, dataContext.starkContext.w1); - snprintf(message_hash, sizeof(message_hash), "0x%.*H", 32, dataContext.starkContext.w2); - - if (page == 0) { - pairs[0].item = "From Account"; - pairs[0].value = from_account; - pairs[1].item = "Hash"; - pairs[1].value = message_hash; - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 2; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *) pairs; - } else if (page == 1) { - content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(false); - content->infoLongPress.text = "Unsafe Stark Sign"; - content->infoLongPress.longPressText = SIGN_BUTTON; - } else { - return false; - } - // valid page so return true - return true; -} - -static void reviewContinue(void) { - nbgl_useCaseRegularReview(0, 2, REJECT_BUTTON, NULL, displayTransactionPage, reviewChoice); -} - -static void buildFirstPage(void) { - nbgl_useCaseReviewStart(get_app_icon(false), - "Unsafe Stark Sign", - NULL, - REJECT_BUTTON, - reviewContinue, - reviewReject); -} - -void ui_stark_unsafe_sign(void) { - buildFirstPage(); -} - -#endif // HAVE_STARKWARE diff --git a/src_plugins/erc20/erc20_plugin.c b/src_plugins/erc20/erc20_plugin.c index 5e40f0d8c..e5b1ba008 100644 --- a/src_plugins/erc20/erc20_plugin.c +++ b/src_plugins/erc20/erc20_plugin.c @@ -73,23 +73,6 @@ bool check_contract(erc20_parameters_t *context) { return false; } -bool erc20_plugin_available_check() { -#ifdef HAVE_STARKWARE - if (quantumSet) { - switch (dataContext.tokenContext.quantumType) { - case STARK_QUANTUM_LEGACY: - case STARK_QUANTUM_ETH: - case STARK_QUANTUM_ERC20: - case STARK_QUANTUM_MINTABLE_ERC20: - return true; - default: - return false; - } - } -#endif - return true; -} - void erc20_plugin_call(int message, void *parameters) { switch (message) { case ETH_PLUGIN_INIT_CONTRACT: { diff --git a/src_plugins/starkware/starkware_plugin.c b/src_plugins/starkware/starkware_plugin.c deleted file mode 100644 index 427fca7f4..000000000 --- a/src_plugins/starkware/starkware_plugin.c +++ /dev/null @@ -1,944 +0,0 @@ -#include -#include "os_io_seproxyhal.h" -#include "uint256.h" -#include "eth_plugin_interface.h" -#include "shared_context.h" // TODO : rewrite as independant code -#include "eth_plugin_internal.h" // TODO : rewrite as independant code -#include "stark_utils.h" -#include "plugin_utils.h" -#include "common_utils.h" -#include "apdu_constants.h" - -#ifdef HAVE_STARKWARE - -typedef enum { - - STARKWARE_REGISTER = 0, - STARKWARE_DEPOSIT_TOKEN, - STARKWARE_DEPOSIT_ETH, - STARKWARE_DEPOSIT_CANCEL, - STARKWARE_DEPOSIT_RECLAIM, - STARKWARE_WITHDRAW, - STARKWARE_FULL_WITHDRAW, - STARKWARE_FREEZE, - STARKWARE_ESCAPE, - STARKWARE_VERIFY_ESCAPE, - STARKWARE_WITHDRAW_TO, - STARKWARE_DEPOSIT_NFT, - STARKWARE_DEPOSIT_NFT_RECLAIM, - STARKWARE_WITHDRAW_AND_MINT, - STARKWARE_WITHDRAW_NFT, - STARKWARE_WITHDRAW_NFT_TO, - STARKWARE_REGISTER_AND_DEPOSIT_TOKEN, - STARKWARE_REGISTER_AND_DEPOSIT_ETH, - STARKWARE_PROXY_DEPOSIT_TOKEN, - STARKWARE_PROXY_DEPOSIT_ETH, -} starkwareSelector_t; - -#ifndef HAVE_TOKENS_EXTRA_LIST - -static const uint8_t DEVERSIFI_CONTRACT[] = { - 0x02, - - 0x5d, 0x22, 0x04, 0x5d, 0xac, 0xea, 0xb0, 0x3b, 0x15, 0x80, - 0x31, 0xec, 0xb7, 0xd9, 0xd0, 0x6f, 0xad, 0x24, 0x60, 0x9b, - - 0x7d, 0xe1, 0xf0, 0x42, 0x04, 0xef, 0x29, 0x22, 0x9d, 0x84, - 0xe7, 0xc0, 0xc2, 0xd1, 0x21, 0x6c, 0x28, 0x64, 0x5a, 0x15}; - -#else - -static const uint8_t DEVERSIFI_CONTRACT[] = { - 0x02, 0xe7, 0x3a, 0x39, 0x4a, 0xde, 0x4d, 0x94, 0xa0, 0x73, 0x50, 0x2d, 0xa8, 0x70, - 0x3e, 0xa2, 0x34, 0x90, 0xdc, 0x7b, 0x6a, 0x69, 0xC6, 0x39, 0x2E, 0xb0, 0x2a, 0x28, - 0x82, 0x31, 0x41, 0x34, 0xc9, 0x8D, 0xDC, 0xBF, 0x73, 0xB7, 0xAd, 0xBa, 0xb1}; - -#endif - -// register : address (20), stark key (32), drop param 3 -// Registration -// Contract Name -// From ETH address -// Master account -// deposit token : stark key (32), verify assetType (32), vaultId (4), quantized Amount (32) -// Deposit -// Contract Name -// Master Account -// Token Account -// Amount -// deposit : stark key (32), verify assetType (32), vaultId (4) -// Flow similar to deposit -// deposit cancel, deposit reclaim : stark key (32), assetType (reclaim) / assetId (cancel) (32) -// ignored, vaultId(4) full withdrawal, freeze : stark key (32), vaultId (4) Cancel Deposit | -// Reclaim Deposit | Full Withdrawal | Freeze Contract Name Master Account Token Account -// withdrawal : stark key (32), verify assetType (32) -// Withdrawal -// Contract Name -// Master Account -// To Eth Address -// Token Symbol -// withdrawal to : stark key (32), verify assetType (32), address (20) -// Withdrawal To -// Contract Name -// Master Account -// To Eth Address -// Token Symbol -// escape : stark key (32), vaultId (4), verify assetType (32), quantized Amount (32) -// Escape -// Contract Name -// Amount -// Master Account -// Token Account -// verify escape : escapeProof (ignore) -// Verify Escape -// Contract Name -// deposit NFT : stark key (32), verify assetType (32), vault id (4), token id (32) -// Deposit -// Contract Name -// Master Account -// Token Account -// NFT Contract -// Token ID -// deposit NFT reclaim : stark key (32), verify assetType (32), vault id (4), token id (32) -// Reclaim Deposit -// Contract Name -// Master Account -// Token Account -// NFT Contract -// Token ID -// withdraw and mint : stark key (32), verify assetType (32), mintable blob (ignored variable) -// Withdrawal -// Contract Name -// Master Account -// Asset Contract -// withdraw NFT : stark key (32), verify assetType (32), token id (32) -// Withdrawal -// Contract Name -// Master Account -// To Eth Address -// NFT Contract -// Token ID -// withdraw NFT To : stark key (32), verify assetType (32), token id (32), address (20) -// Withdrawal To -// Contract Name -// Master Account -// To Eth Address -// NFT Contract -// Token ID -// register and deposit token : stark key (32), variable signature, verify assetType (32), vault Id -// (4), quantized amount (32), token address (20), quantum (32) Register and deposit Contract Name -// From ETH address -// Master account -// Token Account -// Amount -// register and deposit : stark key (32), variable signature, verify assetType (32), vault Id (4) -// flow similar to register and deposit -// deposit token proxy : stark key (32), verify assetType (32), vault Id (4), quantized Amount (32), -// token address (20), quantum (32) flow similar to deposit deposit proxy : stark key (32), verify -// assetType (32), vault Id (4) flow similar to deposit - -static const uint8_t STARKWARE_EXPECTED_DATA_SIZE[] = {0, - 4 + 32 + 32 + 32 + 32, - 4 + 32 + 32 + 32, - 4 + 32 + 32 + 32, - 4 + 32 + 32 + 32, - 4 + 32 + 32, - 4 + 32 + 32, - 4 + 32 + 32, - 4 + 32 + 32 + 32 + 32, - 0, - 4 + 32 + 32 + 32, - 4 + 32 + 32 + 32 + 32, - 4 + 32 + 32 + 32 + 32, - 0, - 4 + 32 + 32 + 32, - 4 + 32 + 32 + 32 + 32, - 0, - 0, - 4 + 32 + 32 + 32 + 32 + 32 + 32, - 4 + 32 + 32 + 32}; - -static const uint8_t STARKWARE_NUM_SCREENS[] = {4 - 1, 5 - 1, 5 - 1, 4 - 1, 4 - 1, 5 - 1, 4 - 1, - 4 - 1, 5 - 1, 2 - 1, 5 - 1, 6 - 1, 6 - 1, 4 - 1, - 6 - 1, 6 - 1, 6 - 1, 6 - 1, 5 - 1, 5 - 1}; - -typedef struct starkware_parameters_t { - uint8_t vaultId[4]; - uint8_t selectorIndex; - uint8_t starkKey[32]; - uint8_t amount[32]; - uint8_t validToken; - -} starkware_parameters_t; - -#define STARK_KEY_LENGTH (2 + length * 2 + 1) -#define VAULT_ID_LENGTH 10 - -bool is_deversify_contract(const uint8_t *address) { - uint32_t offset = 0; - uint8_t i; - - for (i = 0; i < DEVERSIFI_CONTRACT[0]; i++) { - if (memcmp(address, DEVERSIFI_CONTRACT + offset + 1, 20) == 0) { - return true; - } - offset += 20; - } - return false; -} - -// TODO : rewrite as independant code -bool starkware_verify_asset_id(uint8_t *tmp32, const uint8_t *tokenId, bool assetTypeOnly) { - if (quantumSet) { - cx_sha3_t sha3; - tokenDefinition_t *currentToken = NULL; - if (dataContext.tokenContext.quantumIndex != MAX_ITEMS) { - currentToken = - &tmpCtx.transactionContext.extraInfo[dataContext.tokenContext.quantumIndex].token; - } - cx_keccak_init(&sha3, 256); - compute_token_id(&sha3, - (currentToken != NULL ? currentToken->address : NULL), - dataContext.tokenContext.quantumType, - dataContext.tokenContext.quantum, - dataContext.tokenContext.mintingBlob, - assetTypeOnly, - tmp32); - if (memcmp(tokenId, tmp32, 32) != 0) { - PRINTF("Token ID not matching - computed %.*H\n", 32, tmp32); - PRINTF("Current quantum %.*H\n", 32, dataContext.tokenContext.quantum); - PRINTF("Requested %.*H\n", 32, tokenId); - return false; - } - } else { - PRINTF("Quantum not set\n"); - return false; - } - return true; -} - -bool starkware_verify_token(const uint8_t *token) { - if (quantumSet) { - if (dataContext.tokenContext.quantumIndex != MAX_ITEMS) { - tokenDefinition_t *currentToken = - &tmpCtx.transactionContext.extraInfo[dataContext.tokenContext.quantumIndex].token; - if (memcmp(token + 32 - 20, currentToken->address, 20) != 0) { - PRINTF("Token not matching got %.*H\n", 20, token + 32 - 20); - PRINTF("Current token %.*H\n", 20, currentToken->address); - return false; - } - } else { - PRINTF("Quantum not set\n"); - return false; - } - } else { - PRINTF("Quantum not set\n"); - return false; - } - return true; -} - -bool starkware_verify_quantum(const uint8_t *quantum) { - if (quantumSet) { - if (dataContext.tokenContext.quantumIndex != MAX_ITEMS) { - if (memcmp(quantum, dataContext.tokenContext.quantum, 32) != 0) { - PRINTF("Quantum not matching got %.*H\n", 32, quantum); - PRINTF("Current quantum %.*H\n", 32, dataContext.tokenContext.quantum); - return false; - } - } else { - PRINTF("Quantum not set\n"); - return false; - } - } else { - PRINTF("Quantum not set\n"); - return false; - } - return true; -} - -bool starkware_verify_nft_token_id(const uint8_t *tokenId) { - if (!quantumSet) { - PRINTF("Quantum not set\n"); - return false; - } - switch (dataContext.tokenContext.quantumType) { - case STARK_QUANTUM_ERC721: - case STARK_QUANTUM_MINTABLE_ERC721: - break; - default: - PRINTF("Unexpected quantum type for NFT token id check %d\n", - dataContext.tokenContext.quantumType); - return false; - } - if (memcmp(dataContext.tokenContext.quantum, tokenId, 32) != 0) { - PRINTF("Token ID not matching - expected %.*H\n", 32, dataContext.tokenContext.quantum); - PRINTF("Current token ID %.*H\n", 32, tokenId); - return false; - } - return true; -} - -void starkware_print_vault_id(uint32_t vaultId, char *destination, size_t max_length) { - if (VAULT_ID_LENGTH > max_length) { - os_sched_exit(EXCEPTION_OVERFLOW); - } - snprintf(destination, max_length, "%d", vaultId); -} - -void starkware_print_stark_key(uint8_t *starkKey, - size_t length, - char *destination, - size_t max_length) { - if (STARK_KEY_LENGTH > max_length) { - os_sched_exit(EXCEPTION_OVERFLOW); - } - snprintf(destination, max_length, "0x%.*H", length, starkKey); -} - -// TODO : rewrite as independant code -void starkware_print_amount(uint8_t *amountData, - char *destination, - size_t destinationLength, - bool forEscape) { - uint256_t amount, amountPre, quantum; - uint8_t decimals; - char *ticker = chainConfig->coinName; - - if ((amountData == NULL) || - (forEscape && (dataContext.tokenContext.quantumIndex == MAX_ITEMS))) { - decimals = WEI_TO_ETHER; - if (!forEscape) { - convertUint256BE(tmpContent.txContent.value.value, - tmpContent.txContent.value.length, - &amount); - } else { - readu256BE(amountData, &amountPre); - } - } else { - tokenDefinition_t *token = - &tmpCtx.transactionContext.extraInfo[dataContext.tokenContext.quantumIndex].token; - decimals = token->decimals; - ticker = token->ticker; - readu256BE(amountData, &amountPre); - } - if (amountData != NULL) { - readu256BE(dataContext.tokenContext.quantum, &quantum); - mul256(&amountPre, &quantum, &amount); - } - tostring256(&amount, 10, (char *) (G_io_apdu_buffer + 100), 100); - strlcpy(destination, ticker, destinationLength); - strlcat(destination, " ", destinationLength); - adjustDecimals((char *) (G_io_apdu_buffer + 100), - strlen((char *) (G_io_apdu_buffer + 100)), - destination + strlen(ticker) + 1, - destinationLength - strlen(ticker) - 1, - decimals); -} - -// TODO : rewrite as independant code -void starkware_print_ticker(char *destination, size_t destinationLength) { - char *ticker = chainConfig->coinName; - - if (dataContext.tokenContext.quantumIndex != MAX_ITEMS) { - tokenDefinition_t *token = - &tmpCtx.transactionContext.extraInfo[dataContext.tokenContext.quantumIndex].token; - ticker = token->ticker; - } - strlcpy(destination, ticker, destinationLength); -} - -// TODO : rewrite as independant code -void starkware_print_asset_contract(char *destination, size_t destinationLength) { - // token has been validated to be present previously - if (dataContext.tokenContext.quantumIndex != MAX_ITEMS) { - tokenDefinition_t *token = - &tmpCtx.transactionContext.extraInfo[dataContext.tokenContext.quantumIndex].token; - if (!getEthDisplayableAddress(token->address, - destination, - destinationLength, - &global_sha3, - chainConfig->chainId)) { - THROW(APDU_RESPONSE_ERROR_NO_INFO); - } - } else { - strlcpy(destination, "UNKNOWN", destinationLength); - } -} - -// TODO : rewrite as independant code -void starkware_get_source_address(char *destination) { - uint8_t privateKeyData[INT256_LENGTH]; - cx_ecfp_private_key_t privateKey; - cx_ecfp_public_key_t publicKey; - os_perso_derive_node_bip32(CX_CURVE_256K1, - tmpCtx.transactionContext.bip32.path, - tmpCtx.transactionContext.bip32.length, - privateKeyData, - NULL); - cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey); - io_seproxyhal_io_heartbeat(); - cx_ecfp_generate_pair(CX_CURVE_256K1, &publicKey, &privateKey, 1); - explicit_bzero(&privateKey, sizeof(privateKey)); - explicit_bzero(privateKeyData, sizeof(privateKeyData)); - io_seproxyhal_io_heartbeat(); - destination[0] = '0'; - destination[1] = 'x'; - if (!getEthAddressStringFromKey(&publicKey, - destination + 2, - &global_sha3, - chainConfig->chainId)) { - THROW(CX_INVALID_PARAMETER); - } - destination[42] = '\0'; -} - -void starkware_plugin_call(int message, void *parameters) { - switch (message) { - case ETH_PLUGIN_INIT_CONTRACT: { - uint8_t i; - ethPluginInitContract_t *msg = (ethPluginInitContract_t *) parameters; - starkware_parameters_t *context = (starkware_parameters_t *) msg->pluginContext; - PRINTF("starkware plugin init\n"); - for (i = 0; i < NUM_STARKWARE_SELECTORS; i++) { - if (memcmp((const void *) PIC(STARKWARE_SELECTORS[i]), - msg->selector, - SELECTOR_SIZE) == 0) { - context->selectorIndex = i; - break; - } - } - if (i == NUM_STARKWARE_SELECTORS) { - PRINTF("Unknown selector %.*H\n", SELECTOR_SIZE, msg->selector); - break; - } - if (STARKWARE_EXPECTED_DATA_SIZE[context->selectorIndex] != 0) { - if (msg->dataSize != STARKWARE_EXPECTED_DATA_SIZE[context->selectorIndex]) { - PRINTF("Unexpected data size for command %d expected %d got %d\n", - context->selectorIndex, - STARKWARE_EXPECTED_DATA_SIZE[context->selectorIndex], - msg->dataSize); - break; - } - } - context->validToken = true; - msg->result = ETH_PLUGIN_RESULT_OK; - } break; - - case ETH_PLUGIN_PROVIDE_PARAMETER: { - ethPluginProvideParameter_t *msg = (ethPluginProvideParameter_t *) parameters; - starkware_parameters_t *context = (starkware_parameters_t *) msg->pluginContext; - PRINTF("starkware plugin provide parameter %d %.*H\n", - msg->parameterOffset, - 32, - msg->parameter); - // Ignore for verify escape - if (context->selectorIndex == STARKWARE_VERIFY_ESCAPE) { - msg->result = ETH_PLUGIN_RESULT_OK; - break; - } - switch (msg->parameterOffset) { - case 4: - switch (context->selectorIndex) { - case STARKWARE_REGISTER: - memmove(context->amount, msg->parameter + 32 - 20, 20); - break; - - case STARKWARE_DEPOSIT_TOKEN: - case STARKWARE_DEPOSIT_ETH: - case STARKWARE_DEPOSIT_CANCEL: - case STARKWARE_DEPOSIT_RECLAIM: - case STARKWARE_WITHDRAW: - case STARKWARE_FULL_WITHDRAW: - case STARKWARE_FREEZE: - case STARKWARE_ESCAPE: - case STARKWARE_WITHDRAW_TO: - case STARKWARE_DEPOSIT_NFT: - case STARKWARE_DEPOSIT_NFT_RECLAIM: - case STARKWARE_WITHDRAW_AND_MINT: - case STARKWARE_WITHDRAW_NFT: - case STARKWARE_WITHDRAW_NFT_TO: - case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: - case STARKWARE_REGISTER_AND_DEPOSIT_ETH: - case STARKWARE_PROXY_DEPOSIT_TOKEN: - case STARKWARE_PROXY_DEPOSIT_ETH: - memmove(context->starkKey, msg->parameter, 32); - break; - - default: - break; - } - msg->result = ETH_PLUGIN_RESULT_OK; - break; - - case 4 + 32: - switch (context->selectorIndex) { - case STARKWARE_REGISTER: - memmove(context->starkKey, msg->parameter, 32); - break; - - case STARKWARE_ESCAPE: - memmove(context->vaultId, msg->parameter + 32 - 4, 4); - break; - - case STARKWARE_DEPOSIT_CANCEL: - case STARKWARE_DEPOSIT_RECLAIM: - break; - - case STARKWARE_FULL_WITHDRAW: - case STARKWARE_FREEZE: - memmove(context->vaultId, msg->parameter + 32 - 4, 4); - break; - - case STARKWARE_DEPOSIT_ETH: - case STARKWARE_DEPOSIT_TOKEN: - case STARKWARE_WITHDRAW: - case STARKWARE_WITHDRAW_TO: - case STARKWARE_DEPOSIT_NFT: - case STARKWARE_DEPOSIT_NFT_RECLAIM: - case STARKWARE_WITHDRAW_AND_MINT: - case STARKWARE_WITHDRAW_NFT: - case STARKWARE_WITHDRAW_NFT_TO: - case STARKWARE_PROXY_DEPOSIT_TOKEN: - case STARKWARE_PROXY_DEPOSIT_ETH: - context->validToken = - starkware_verify_asset_id(context->amount, msg->parameter, true); - break; - - case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: - case STARKWARE_REGISTER_AND_DEPOSIT_ETH: - // drop variable byte array signature offset - break; - - default: - break; - } - msg->result = ETH_PLUGIN_RESULT_OK; - break; - - case 4 + 32 + 32: - switch (context->selectorIndex) { - case STARKWARE_ESCAPE: - case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: - case STARKWARE_REGISTER_AND_DEPOSIT_ETH: - context->validToken = - starkware_verify_asset_id(context->amount, msg->parameter, true); - break; - - case STARKWARE_DEPOSIT_CANCEL: - case STARKWARE_DEPOSIT_RECLAIM: - case STARKWARE_DEPOSIT_ETH: - case STARKWARE_DEPOSIT_TOKEN: - case STARKWARE_DEPOSIT_NFT: - case STARKWARE_DEPOSIT_NFT_RECLAIM: - case STARKWARE_PROXY_DEPOSIT_TOKEN: - case STARKWARE_PROXY_DEPOSIT_ETH: - memmove(context->vaultId, msg->parameter + 32 - 4, 4); - break; - - case STARKWARE_WITHDRAW_TO: - memmove(context->amount, msg->parameter + 32 - 20, 20); - break; - - case STARKWARE_WITHDRAW_NFT: - case STARKWARE_WITHDRAW_NFT_TO: - context->validToken = starkware_verify_nft_token_id(msg->parameter); - break; - - default: - break; - } - msg->result = ETH_PLUGIN_RESULT_OK; - break; - - case 4 + 32 + 32 + 32: - switch (context->selectorIndex) { - case STARKWARE_ESCAPE: - case STARKWARE_DEPOSIT_TOKEN: - case STARKWARE_PROXY_DEPOSIT_TOKEN: - memmove(context->amount, msg->parameter, 32); - break; - - case STARKWARE_WITHDRAW_NFT_TO: - memmove(context->amount, msg->parameter + 32 - 20, 20); - break; - - case STARKWARE_DEPOSIT_NFT: - case STARKWARE_DEPOSIT_NFT_RECLAIM: - context->validToken = starkware_verify_nft_token_id(msg->parameter); - break; - - case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: - case STARKWARE_REGISTER_AND_DEPOSIT_ETH: - memmove(context->vaultId, msg->parameter + 32 - 4, 4); - break; - - default: - break; - } - msg->result = ETH_PLUGIN_RESULT_OK; - break; - - case 4 + 32 + 32 + 32 + 32: - switch (context->selectorIndex) { - switch (context->selectorIndex) { - case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: - memmove(context->amount, msg->parameter, 32); - break; - - case STARKWARE_PROXY_DEPOSIT_TOKEN: - context->validToken = starkware_verify_token(msg->parameter); - break; - - default: - break; - } - } - msg->result = ETH_PLUGIN_RESULT_OK; - break; - - case 4 + 32 + 32 + 32 + 32 + 32: - switch (context->selectorIndex) { - switch (context->selectorIndex) { - case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: - context->validToken = starkware_verify_token(msg->parameter); - break; - - case STARKWARE_PROXY_DEPOSIT_TOKEN: - context->validToken = starkware_verify_quantum(msg->parameter); - break; - - default: - break; - } - } - msg->result = ETH_PLUGIN_RESULT_OK; - break; - - case 4 + 32 + 32 + 32 + 32 + 32 + 32: - switch (context->selectorIndex) { - switch (context->selectorIndex) { - case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: - context->validToken = starkware_verify_quantum(msg->parameter); - break; - - default: - break; - } - } - msg->result = ETH_PLUGIN_RESULT_OK; - break; - - default: - switch (context->selectorIndex) { - case STARKWARE_REGISTER: - case STARKWARE_VERIFY_ESCAPE: - case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: - case STARKWARE_REGISTER_AND_DEPOSIT_ETH: - msg->result = ETH_PLUGIN_RESULT_OK; - break; - - default: - PRINTF("Unhandled parameter offset\n"); - break; - } - } - } break; - - case ETH_PLUGIN_FINALIZE: { - ethPluginFinalize_t *msg = (ethPluginFinalize_t *) parameters; - starkware_parameters_t *context = (starkware_parameters_t *) msg->pluginContext; - PRINTF("starkware plugin finalize\n"); - if (!context->validToken) { - msg->result = ETH_PLUGIN_RESULT_FALLBACK; - } else { - msg->uiType = ETH_UI_TYPE_GENERIC; - msg->numScreens = STARKWARE_NUM_SCREENS[context->selectorIndex]; - msg->result = ETH_PLUGIN_RESULT_OK; - } - } break; - - case ETH_PLUGIN_QUERY_CONTRACT_ID: { - ethQueryContractID_t *msg = (ethQueryContractID_t *) parameters; - starkware_parameters_t *context = (starkware_parameters_t *) msg->pluginContext; - PRINTF("starkware query contract id\n"); - switch (context->selectorIndex) { - case STARKWARE_REGISTER: - strlcpy(msg->name, "Register", msg->nameLength); - break; - case STARKWARE_DEPOSIT_TOKEN: - case STARKWARE_DEPOSIT_ETH: - case STARKWARE_DEPOSIT_NFT: - case STARKWARE_PROXY_DEPOSIT_TOKEN: - case STARKWARE_PROXY_DEPOSIT_ETH: - strlcpy(msg->name, "Deposit", msg->nameLength); - break; - case STARKWARE_DEPOSIT_CANCEL: - strlcpy(msg->name, "Cancel Deposit", msg->nameLength); - break; - case STARKWARE_DEPOSIT_RECLAIM: - case STARKWARE_DEPOSIT_NFT_RECLAIM: - strlcpy(msg->name, "Reclaim Deposit", msg->nameLength); - break; - case STARKWARE_WITHDRAW: - case STARKWARE_WITHDRAW_NFT: - case STARKWARE_WITHDRAW_AND_MINT: - strlcpy(msg->name, "Withdrawal", msg->nameLength); - break; - case STARKWARE_FULL_WITHDRAW: - strlcpy(msg->name, "Full Withdrawal", msg->nameLength); - break; - case STARKWARE_FREEZE: - strlcpy(msg->name, "Freeze", msg->nameLength); - break; - case STARKWARE_ESCAPE: - strlcpy(msg->name, "Escape", msg->nameLength); - break; - case STARKWARE_VERIFY_ESCAPE: - strlcpy(msg->name, "Verify Escape", msg->nameLength); - break; - case STARKWARE_WITHDRAW_TO: - case STARKWARE_WITHDRAW_NFT_TO: - strlcpy(msg->name, "Withdrawal To", msg->nameLength); - break; - case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: - case STARKWARE_REGISTER_AND_DEPOSIT_ETH: - strlcpy(msg->name, "Register&Deposit", msg->nameLength); - break; - - default: - break; - } - strlcpy( - msg->version, - is_deversify_contract(tmpContent.txContent.destination) ? "DeversiFi" : "Starkware", - msg->versionLength); - msg->result = ETH_PLUGIN_RESULT_OK; - } break; - - case ETH_PLUGIN_QUERY_CONTRACT_UI: { - ethQueryContractUI_t *msg = (ethQueryContractUI_t *) parameters; - starkware_parameters_t *context = (starkware_parameters_t *) msg->pluginContext; - switch (msg->screenIndex) { - case 0: - strlcpy(msg->title, "Contract Name", msg->titleLength); - if (is_deversify_contract(tmpContent.txContent.destination)) { - strlcpy(msg->msg, "DeversiFi", msg->msgLength); - } else { - if (!getEthDisplayableAddress(tmpContent.txContent.destination, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId)) { - THROW(APDU_RESPONSE_ERROR_NO_INFO); - } - } - msg->result = ETH_PLUGIN_RESULT_OK; - break; - case 1: - switch (context->selectorIndex) { - case STARKWARE_REGISTER: - case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: - case STARKWARE_REGISTER_AND_DEPOSIT_ETH: - strlcpy(msg->title, "From ETH Address", msg->titleLength); - if (!getEthDisplayableAddress(context->amount, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId)) { - THROW(APDU_RESPONSE_ERROR_NO_INFO); - } - break; - case STARKWARE_ESCAPE: - strlcpy(msg->title, "Amount", msg->titleLength); - starkware_print_amount(context->amount, msg->msg, msg->msgLength, true); - break; - case STARKWARE_DEPOSIT_TOKEN: - case STARKWARE_DEPOSIT_ETH: - case STARKWARE_PROXY_DEPOSIT_TOKEN: - case STARKWARE_PROXY_DEPOSIT_ETH: - case STARKWARE_DEPOSIT_CANCEL: - case STARKWARE_DEPOSIT_RECLAIM: - case STARKWARE_WITHDRAW: - case STARKWARE_FULL_WITHDRAW: - case STARKWARE_FREEZE: - case STARKWARE_VERIFY_ESCAPE: - case STARKWARE_WITHDRAW_TO: - case STARKWARE_DEPOSIT_NFT: - case STARKWARE_DEPOSIT_NFT_RECLAIM: - case STARKWARE_WITHDRAW_AND_MINT: - case STARKWARE_WITHDRAW_NFT: - case STARKWARE_WITHDRAW_NFT_TO: - strlcpy(msg->title, "Master Account", msg->titleLength); - starkware_print_stark_key(context->starkKey, - sizeof(context->starkKey), - msg->msg, - msg->msgLength); - break; - default: - PRINTF("Unexpected screen %d for %d\n", - msg->screenIndex, - context->selectorIndex); - break; - } - msg->result = ETH_PLUGIN_RESULT_OK; - break; - case 2: - switch (context->selectorIndex) { - case STARKWARE_REGISTER: - case STARKWARE_ESCAPE: - case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: - case STARKWARE_REGISTER_AND_DEPOSIT_ETH: - strlcpy(msg->title, "Master Account", msg->titleLength); - starkware_print_stark_key(context->starkKey, - sizeof(context->starkKey), - msg->msg, - msg->msgLength); - break; - - case STARKWARE_DEPOSIT_TOKEN: - case STARKWARE_DEPOSIT_ETH: - case STARKWARE_PROXY_DEPOSIT_TOKEN: - case STARKWARE_PROXY_DEPOSIT_ETH: - case STARKWARE_DEPOSIT_CANCEL: - case STARKWARE_DEPOSIT_RECLAIM: - case STARKWARE_FULL_WITHDRAW: - case STARKWARE_FREEZE: - case STARKWARE_DEPOSIT_NFT: - case STARKWARE_DEPOSIT_NFT_RECLAIM: - strlcpy(msg->title, "Token Account", msg->titleLength); - starkware_print_vault_id(U4BE(context->vaultId, 0), - msg->msg, - msg->msgLength); - break; - case STARKWARE_WITHDRAW: - case STARKWARE_WITHDRAW_NFT: - strlcpy(msg->title, "To ETH Address", msg->titleLength); - starkware_get_source_address(msg->msg); - break; - case STARKWARE_WITHDRAW_TO: - case STARKWARE_WITHDRAW_NFT_TO: - strlcpy(msg->title, "To ETH Address", msg->titleLength); - if (!getEthDisplayableAddress(context->amount, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId)) { - THROW(APDU_RESPONSE_ERROR_NO_INFO); - } - break; - case STARKWARE_WITHDRAW_AND_MINT: - strlcpy(msg->title, "Asset Contract", msg->titleLength); - starkware_print_asset_contract(msg->msg, msg->msgLength); - break; - - default: - PRINTF("Unexpected screen %d for %d\n", - msg->screenIndex, - context->selectorIndex); - break; - } - msg->result = ETH_PLUGIN_RESULT_OK; - break; - - case 3: - switch (context->selectorIndex) { - case STARKWARE_ESCAPE: - strlcpy(msg->title, "Token Account", msg->titleLength); - starkware_print_vault_id(U4BE(context->vaultId, 0), - msg->msg, - msg->msgLength); - break; - case STARKWARE_DEPOSIT_TOKEN: - case STARKWARE_DEPOSIT_ETH: - case STARKWARE_PROXY_DEPOSIT_TOKEN: - case STARKWARE_PROXY_DEPOSIT_ETH: - strlcpy(msg->title, "Amount", msg->titleLength); - starkware_print_amount( - (((context->selectorIndex == STARKWARE_DEPOSIT_ETH) || - (context->selectorIndex == STARKWARE_PROXY_DEPOSIT_ETH)) - ? NULL - : context->amount), - msg->msg, - msg->msgLength, - false); - break; - case STARKWARE_WITHDRAW: - case STARKWARE_WITHDRAW_TO: - strlcpy(msg->title, "Token Symbol", msg->titleLength); - starkware_print_ticker(msg->msg, msg->msgLength); - break; - - case STARKWARE_WITHDRAW_NFT: - case STARKWARE_WITHDRAW_NFT_TO: - case STARKWARE_DEPOSIT_NFT: - case STARKWARE_DEPOSIT_NFT_RECLAIM: - strlcpy(msg->title, "NFT Contract", msg->titleLength); - starkware_print_asset_contract(msg->msg, msg->msgLength); - break; - - case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: - case STARKWARE_REGISTER_AND_DEPOSIT_ETH: - strlcpy(msg->title, "Token Account", msg->titleLength); - starkware_print_vault_id(U4BE(context->vaultId, 0), - msg->msg, - msg->msgLength); - break; - - default: - PRINTF("Unexpected screen %d for %d\n", - msg->screenIndex, - context->selectorIndex); - break; - } - msg->result = ETH_PLUGIN_RESULT_OK; - break; - - case 4: - switch (context->selectorIndex) { - case STARKWARE_WITHDRAW_NFT: - case STARKWARE_WITHDRAW_NFT_TO: - case STARKWARE_DEPOSIT_NFT: - case STARKWARE_DEPOSIT_NFT_RECLAIM: - strlcpy(msg->title, "TokenID", msg->titleLength); - starkware_print_stark_key(dataContext.tokenContext.quantum, - sizeof(dataContext.tokenContext.quantum), - msg->msg, - msg->msgLength); - break; - - case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: - case STARKWARE_REGISTER_AND_DEPOSIT_ETH: - strlcpy(msg->title, "Amount", msg->titleLength); - starkware_print_amount( - ((context->selectorIndex == STARKWARE_REGISTER_AND_DEPOSIT_ETH) - ? NULL - : context->amount), - msg->msg, - msg->msgLength, - false); - break; - - default: - PRINTF("Unexpected screen %d for %d\n", - msg->screenIndex, - context->selectorIndex); - break; - } - msg->result = ETH_PLUGIN_RESULT_OK; - break; - - default: - PRINTF("Unexpected screen %d for %d\n", - msg->screenIndex, - context->selectorIndex); - break; - } - } break; - - default: - PRINTF("Unhandled message %d\n", message); - } -} - -#endif From a5dde47b90c59fa0a044d69d37b4d1947fe5207d Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Tue, 13 Feb 2024 15:29:25 +0100 Subject: [PATCH 2/3] Update doc --- doc/eth_contract_support_embedded.adoc | 59 +-- doc/eth_starkware_extensions.adoc | 348 -------------- doc/ethapp_plugins.adoc | 628 ++++++++++++------------- 3 files changed, 318 insertions(+), 717 deletions(-) delete mode 100644 doc/eth_starkware_extensions.adoc diff --git a/doc/eth_contract_support_embedded.adoc b/doc/eth_contract_support_embedded.adoc index 67c27c0c6..36a582c98 100644 --- a/doc/eth_contract_support_embedded.adoc +++ b/doc/eth_contract_support_embedded.adoc @@ -6,24 +6,24 @@ Application version 1.3.0 - 05th of July 2020 ## 1.3.0 - Initial release -## About +## About This document described how a specific device UI for a smart contract can be added in the current version of the Ethereum application, before plugins are added ## Standard support -The applications already includes dedicated UI support for those specific contract calls : +The applications already includes dedicated UI support for those specific contract calls : * ERC 20 approve(address, uint256) - implementation in *src_features/erc20_approval* * ERC 20 transfer(address, uint256) - implementation in *src_features/signTx* ## Requirements -The following data is necessary for a specific contract support +The following data is necessary for a specific contract support * Smart contract ABI (at least for calls that are to be supported by the application) -The following data is optional for a specific contract support +The following data is optional for a specific contract support * Contract address (can be optional if supported by multiple instances) @@ -38,60 +38,11 @@ The first four bytes of the call data for a function call specifies the function The following online tool can be used to compute selectors https://emn178.github.io/online-tools/keccak_256.html -## Limitations - - * The total number of parameters of a contract call is 4 (as defined in *src/shared_context.h* for tokenContext_t.data, each parameter being encoded as an uint256). Additional parameters can be supported if not required to handle the displaying logic (see "Also handle exception that only need to process the beginning of data" in *src_features/signTx/logic_signTx.c* for CONTRACT_STARKWARE_VERIFY_ESCAPE and CONTRACT_STARKWARE_REGISTER) - - * Non fixed size types (dynamic sized byte sequences, dynamic sized strings, variable length arrays) are not directly supported - -## Sample implementation of a function call - -This example describes how to implement a specific UI for a contract call. This exemple is using Starkex token deposit - *deposit(uint256 tokenId, uint256 vaultId, uint256 quantizedAmount)* - - - * Implement the specific UI logic in a new *src_features* subdirectory - note that strings.common.maxFee will be provisioned with the maximum fee to pay for this call - -``` -See src_features/stark_contract_deposit for this example -``` - - * Compute the selector - - -``` -keccak-256("deposit(uint256,uint256,uint256)") = 00aeef8a... -``` - - * Add an entry to the contract_call_t enum of *src/shared_context.h* for this function call - -``` -CONTRACT_STARKWARE_DEPOSIT_TOKEN -``` - - * Check for the selector being called and the arguments size in *src_features/signTx/logic_signTx.c* customProcessor function - additional logic can be applied (quantumSet in this example) - -```C -if ((context->currentFieldLength == STARKWARE_DEPOSIT_TOKEN_DATA_SIZE) && - (memcmp(context->workBuffer, STARKWARE_DEPOSIT_TOKEN_ID, 4) == 0) && - quantumSet) { - contractProvisioned = CONTRACT_STARKWARE_DEPOSIT_TOKEN; -} -``` - - * Call the dedicated UI at the end of the transaction parsing in *src_features/signTx/logic_signTx.c* finalizeParsing function - -```C -if (contractProvisioned == CONTRACT_STARKWARE_DEPOSIT_TOKEN) { - ux_flow_init(0, ux_approval_starkware_deposit_flow, NULL); - return; -} -``` - ## Using ERC 20 token tickers A UI implementation might want to convert an ERC 20 token contract address to a ticker for easier validation -2 tickers can be temporarily provisioned to the application by using the PROVIDE ERC 20 TOKEN INFORMATION APDU, described in *src_features/provideErc20TokenInformation* - the UI can then iterate on the provisioned tickers to display relevant information to the user +2 tickers can be temporarily provisioned to the application by using the PROVIDE ERC 20 TOKEN INFORMATION APDU, described in *src_features/provideErc20TokenInformation* - the UI can then iterate on the provisioned tickers to display relevant information to the user The same mechanism will be extended to support well known contract addresses in the future diff --git a/doc/eth_starkware_extensions.adoc b/doc/eth_starkware_extensions.adoc deleted file mode 100644 index 48e91fd8e..000000000 --- a/doc/eth_starkware_extensions.adoc +++ /dev/null @@ -1,348 +0,0 @@ -Ethereum application : Starkware extensions -============================================ -Ledger Firmware Team -Application version 1.5.0 - 4th of October 2020 - -## 1.3.0 - - Initial release - -## 1.5.0 - - Update with Starkex v2 APIs - -## About - -This specification describes the APDU messages interface implementing the Starkware extensions for the Ethereum appilcation - -## Modified general purpose APDUs - -### GET APP CONFIGURATION - -#### Description - -This command returns specific application configuration - -It is modified to notify Stark extensions support on flag 0x04 - -#### Coding - -'Command' - -[width="80%"] -|============================================================================================================================== -| *CLA* | *INS* | *P1* | *P2* | *Lc* | *Le* -| E0 | 06 | 00 | 00 | 00 | 04 -|============================================================================================================================== - -'Input data' - -None - -'Output data' - -[width="80%"] -|============================================================================================================================== -| *Description* | *Length* -| Flags - 0x01 : arbitrary data signature enabled by user - - 0x02 : ERC 20 Token information needs to be provided externally - - 0x04 : Stark extensions are supported - - 0x08 : Stark protocol v2 is supported - | 01 -| Application major version | 01 -| Application minor version | 01 -| Application patch version | 01 -|============================================================================================================================== - - -## Additional APDUs - -Additional APDUs use the APDU CLA F0 - -### GET STARK PUBLIC KEY - -#### Description - -This command returns the public Stark key (X and Y coordinates) for the given BIP 32 path. - -The key can be optionally checked on the device before being returned - in that case, only the X coordinate is displayed, as this is what is used in the contract - -#### Coding - -'Command' - -[width="80%"] -|============================================================================================================================== -| *CLA* | *INS* | *P1* | *P2* | *Lc* | *Le* -| F0 | 02 | 00 : return address - - 01 : display address and confirm before returning - | 00 | variable | variable -|============================================================================================================================== - -'Input data' - -[width="80%"] -|============================================================================================================================== -| *Description* | *Length* -| Number of BIP 32 derivations to perform (max 10) | 1 -| First derivation index (big endian) | 4 -| ... | 4 -| Last derivation index (big endian) | 4 -|============================================================================================================================== - -'Output data' - -[width="80%"] -|============================================================================================================================== -| *Description* | *Length* -| Stark key | 65 -|============================================================================================================================== - -### SIGN STARK MESSAGE - -#### Description - -This command signs an order or a transfer on the Starkware curve. - -The contract addressed associated to the token shall have be provisioned previously with the PROVIDE ERC 20 TOKEN INFORMATION command or this command will fail. - -The quantum type for v2 messages is encoded as p1 for the PROVIDE QUANTUM command - -#### Coding - -'Command' - -[width="80%"] -|============================================================================================================================== -| *CLA* | *INS* | *P1* | *P2* | *Lc* | *Le* -| F0 | 04 | - 01 : sign a Stark Order (protocol v1, handles ETH and regular ERC 20) - - 02 : sign a Stark Transfer (protocol v1, handles ETH and regular ERC 20) - - 03 : sign a Stark Order (since protocol v2) - - 04 : sign a Stark Transfer (since protocol v2) - - 05 : sign a Stark Conditional Transfer (since protocol v2) - - | 00 | variable | variable -|============================================================================================================================== - -'Input data for a Stark Order (v1)' - -[width="80%"] -|============================================================================================================================== -| *Description* | *Length* -| Number of BIP 32 derivations to perform (max 10) | 1 -| First derivation index (big endian) | 4 -| ... | 4 -| Last derivation index (big endian) | 4 -| Contract address of the token to be sold (or 00..00 for ETH) | 20 -| Quantization of the token to be sold (big endian) | 32 -| Contract address of the token to be bought (or 00..00 for ETH) | 20 -| Quantization of the token to be bought (big endian) | 32 -| ID of the source vault (big endian encoded) | 4 -| ID of the destination vault (big endian encoded) | 4 -| Amount to be sold (big endian encoded) | 8 -| Amount to buy (big endian encoded) | 8 -| Transaction nonce (big endian encoded) | 4 -| Transaction timestamp (big endian encoded) | 4 -|============================================================================================================================== - -'Input data for a Stark Transfer (v1)' - -[width="80%"] -|============================================================================================================================== -| *Description* | *Length* -| Number of BIP 32 derivations to perform (max 10) | 1 -| First derivation index (big endian) | 4 -| ... | 4 -| Last derivation index (big endian) | 4 -| Contract address of the token to be transferred (or 00..00 for ETH) | 20 -| Quantization of the token to be transferred (big endian) | 32 -| Token target public key | 32 -| ID of the source vault (big endian encoded) | 4 -| ID of the destination vault (big endian encoded) | 4 -| Amount to be transferred (big endian encoded) | 8 -| Transaction nonce (big endian encoded) | 4 -| Transaction timestamp (big endian encoded) | 4 -|============================================================================================================================== - -'Input data for a Stark Order (v2)' - -[width="80%"] -|============================================================================================================================== -| *Description* | *Length* -| Number of BIP 32 derivations to perform (max 10) | 1 -| First derivation index (big endian) | 4 -| ... | 4 -| Last derivation index (big endian) | 4 -| Quantization type of the token to be sold | 1 -| Contract address of the token to be sold (or 00..00 for ETH) | 20 -| Quantization or Token ID of the token to be sold (big endian) | 32 -| Minting blob of the token to be sold (ignored if non mintable) | 32 -| Quantization type of the token to be bought | 1 -| Contract address of the token to be bought (or 00..00 for ETH) | 20 -| Quantization or Token ID of the token to be bought (big endian) | 32 -| Minting blob of the token to be bought (ignored if non mintable) | 32 -| ID of the source vault (big endian encoded) | 4 -| ID of the destination vault (big endian encoded) | 4 -| Amount to be sold (big endian encoded) | 8 -| Amount to buy (big endian encoded) | 8 -| Transaction nonce (big endian encoded) | 4 -| Transaction timestamp (big endian encoded) | 4 -|============================================================================================================================== - -'Input data for a Stark Transfer (v2)' - -[width="80%"] -|============================================================================================================================== -| *Description* | *Length* -| Number of BIP 32 derivations to perform (max 10) | 1 -| First derivation index (big endian) | 4 -| ... | 4 -| Last derivation index (big endian) | 4 -| Quantization type of the token to be transferred | 1 -| Contract address of the token to be transferred (or 00..00 for ETH) | 20 -| Quantization or Token ID of the token to be transferred (big endian) | 32 -| Minting blob of the token to be transferred (ignored if non mintable) | 32 -| Token target public key | 32 -| ID of the source vault (big endian encoded) | 4 -| ID of the destination vault (big endian encoded) | 4 -| Amount to be transferred (big endian encoded) | 8 -| Transaction nonce (big endian encoded) | 4 -| Transaction timestamp (big endian encoded) | 4 -|============================================================================================================================== - -'Input data for a Stark Conditional Transfer' - -[width="80%"] -|============================================================================================================================== -| *Description* | *Length* -| Number of BIP 32 derivations to perform (max 10) | 1 -| First derivation index (big endian) | 4 -| ... | 4 -| Last derivation index (big endian) | 4 -| Quantization type of the token to be transferred | 1 -| Contract address of the token to be transferred (or 00..00 for ETH) | 20 -| Quantization or Token ID of the token to be transferred (big endian) | 32 -| Minting blob of the token to be transferred (ignored if non mintable) | 32 -| Token target public key | 32 -| ID of the source vault (big endian encoded) | 4 -| ID of the destination vault (big endian encoded) | 4 -| Amount to be transferred (big endian encoded) | 8 -| Transaction nonce (big endian encoded) | 4 -| Transaction timestamp (big endian encoded) | 4 -| Conditional transfer fact (big endian) | 32 -| Conditional transfer L1 condition logic address | 20 -|============================================================================================================================== - -'Output data' - -[width="80%"] -|============================================================================================================================== -| *Description* | *Length* -| RFU (00) | 1 -| r | 32 -| s | 32 -|============================================================================================================================== - - -### PROVIDES QUANTUM - -#### Description - -This command provides quantization data used to compute a tokenId and provide additional information to the user before signing a transaction performing a deposit or withdrawal call on a Stark powered smart contract. - -It shall be called following a PROVIDE ERC 20 TOKEN INFORMATION command called for the associated contract - -#### Coding - -'Command' - -[width="80%"] -|============================================================================================================================== -| *CLA* | *INS* | *P1* | *P2* | *Lc* | *Le* -| F0 | 08 | - 00 : legacy (protocol v1, handles ETH and regular ERC 20) - - 01 : quantum encoded for ETH (since protocol v2) - - 02 : quantum encoded for a regular ERC 20 (since protocol v2) - - 03 : quantum encoded for a regular ERC 721 (since protocol v2) - - 04 : quantum encoded for a mintable ERC 20 (since protocol v2) - - 05 : quantum encoded for a mintable ERC 721 (since protocol v2) - - | 00 | variable | variable -|============================================================================================================================== - -'Legacy Input data' - -[width="80%"] -|============================================================================================================================== -| *Description* | *Length* -| Contract address used in the next transaction | 20 -| Quantization to be used in the next transaction | 32 -|============================================================================================================================== - -'v2 Input data' - -[width="80%"] -|============================================================================================================================== -| *Description* | *Length* -| Contract address used in the next transaction (ignored for ETH) | 20 -| Quantization to be used in the next transaction (ignored for ERC 721s) | 32 -| Minting blob to be used in the next transaction (ignored for non mintable) | 32 -|============================================================================================================================== - -'Output data' - -None - -### UNSAFE SIGN - -#### Description - -This command signs an arbitrary hash on the Starkware Curve after presenting the hash to the user. It is intended for speed of execution in case an unknown Stark model is pushed and should be avoided as much as possible. - -#### Coding - -'Command' - -[width="80%"] -|============================================================================================================================== -| *CLA* | *INS* | *P1* | *P2* | *Lc* | *Le* -| F0 | 0A | - 00 - | 00 | variable | variable -|============================================================================================================================== - -'Input data' - -[width="80%"] -|============================================================================================================================== -| *Description* | *Length* -| Number of BIP 32 derivations to perform (max 10) | 1 -| First derivation index (big endian) | 4 -| ... | 4 -| Last derivation index (big endian) | 4 -| Hash to sign | 32 -|============================================================================================================================== - -'Output data' - -[width="80%"] -|============================================================================================================================== -| *Description* | *Length* -| RFU (00) | 1 -| r | 32 -| s | 32 -|============================================================================================================================== - diff --git a/doc/ethapp_plugins.adoc b/doc/ethapp_plugins.adoc index a3bdbbe27..886928a4b 100644 --- a/doc/ethapp_plugins.adoc +++ b/doc/ethapp_plugins.adoc @@ -1,315 +1,313 @@ -Ethereum application Plugins : Technical Specifications -======================================================= -Ledger Firmware Team -Specification version 1.0 - 24th of September 2020 - - -## 1.0 - - Initial release - -## About - -This specification describes the plugin interface used to display a specific UI on device for Ethereum smart contracts. - -Feel free to checkout the ParaSwap plugin to see an actual implementation. Link: https://github.com/LedgerHQ/app-ethereum/blob/named-external-plugins/doc/ethapp_plugins.asc . - -## Flow overview - -When signing an Ethereum transaction containing data, the Ethereum application looks for a plugin using .either a selector list or the contract address. - -If a plugin is found, each network serialized data field (32 bytes) is passed to the plugin along with the field offset. The plugin can decide to stop the signature process if a data field isn't expected - -After all fields have been received, the plugin can report to the Ethereum application whether the full data is accepted, and the user interface model that'll be used to display the data - -### Amount/Address user interface - -In this model, the generic (without data) transaction display is used, with the amount and destination address replaced by data provided by the plugin - -### Generic user interface - -In this model, the plugin first reports a number of screens (2 lines of text, the second line being scrollable) to be displayed - -The Ethereum application will request each screen to be displayed to the plugin and let the user browse through them. - -The first screen being displayed is always a description of the plugin being used (name and version reported by the plugin), and the last screens include the transaction fees in ETH and a confirmation prompt - -### Code flow - -The plugin interfacing logic is described in _src/eth_plugin_interface.h_ - -The plugin common dispatcher is found in _src/eth_plugin_handler.c_ - -The plugin generic UI dispatcher is found in _src/eth_plugin_ui.c_ - -Sample internal plugins are provided in _src_plugins/_ - -## Creating a plugin - -### Creating an internal plugin - -Internal plugins are triggered on specific selectors. You can modify _src/eth_plugin_internal.c_ to add your mapping. - -Other specific mappings can be also added by modifying the common dispatcher - -### Creating an external plugin - -An external plugin is a library application named after the base64 encoding of the 20 bytes smart contract address - -## Detailed flow messages - -### Generic fields - -The following generic fields are present in all messages : - - * pluginSharedRW : scratch objects and utilities available to the plugin (can be read and written) - - * pluginSharedRO : transaction data available to the plugin (can only be read) - - * pluginContext : arbitrary data blob holding the plugin context, to be set and used by the plugin - - * result : return code set by the plugin following the message processing - -### ETH_PLUGIN_INIT_CONTRACT - -[source,C] ----- - -typedef struct ethPluginInitContract_t { - - // in - - ethPluginSharedRW_t *pluginSharedRW; - ethPluginSharedRO_t *pluginSharedRO; - uint8_t *pluginContext; - uint32_t pluginContextLength; - uint8_t *selector; // 4 bytes selector - uint32_t dataSize; - - char *alias; // 29 bytes alias if ETH_PLUGIN_RESULT_OK_ALIAS set - - uint8_t result; - -} ethPluginInitContract_t; - ----- - -This message is sent when the selector of the data has been parsed. The following specific fields are filled when the plugin is called : - - * pluginContextLength : length of the data field available to store the plugin context - * selector : 4 bytes selector of the data field - * dataSize : size in bytes of the data field - -The following return codes are expected, any other will abort the signing process : - - * ETH_PLUGIN_RESULT_OK : if the plugin can be successfully initialized - * ETH_PLUGIN_RESULT_OK_ALIAS : if a base64 encoded alias of another plugin to call is copied to the _alias_ field. In this case, the dispatcher will follow the alias chain, and the original plugin will only be called to retrieve its name when using a generic user interface - * ETH_PLUGIN_RESULT_FALLBACK : if the signing logic should fallback to the generic one - -### ETH_PLUGIN_PROVIDE_PARAMETER - -[source,C] ----- - -typedef struct ethPluginProvideParameter_t { - - ethPluginSharedRW_t *pluginSharedRW; - ethPluginSharedRO_t *pluginSharedRO; - uint8_t *pluginContext; - uint8_t *parameter; // 32 bytes parameter - uint32_t parameterOffset; - - uint8_t result; - -} ethPluginProvideParameter_t; - ----- - -This message is sent when a new 32 bytes component of the data field is available. The following specific fields are filled when the plugin is called : - - * parameter : pointer to the 32 bytes parameter being parsed - * parameterOffset : offset to this parameter from the beginning of the data field (starts at 4, following the selector) - -The following return codes are expected, any other will abort the signing process : - - * ETH_PLUGIN_RESULT_OK : if the plugin can be successfully initialized - * ETH_PLUGIN_RESULT_FALLBACK : if the signing logic should fallback to the generic one - -There are already defined functions to extract data from a parameter: -[source,C] ----- -void copy_address(uint8_t* dst, const uint8_t* parameter, uint8_t dst_size); -void copy_parameter(uint8_t* dst, const uint8_t* parameter, uint8_t dst_size); - -// Get the value from the beginning of the parameter (right to left) and check if the rest of it is zero -bool U2BE_from_parameter(const uint8_t* parameter, uint16_t* value); -bool U4BE_from_parameter(const uint8_t* parameter, uint32_t* value); ----- - -### ETH_PLUGIN_FINALIZE - -[source,C] ----- - -typedef struct ethPluginFinalize_t { - - ethPluginSharedRW_t *pluginSharedRW; - ethPluginSharedRO_t *pluginSharedRO; - uint8_t *pluginContext; - - uint8_t *itemLookup1; // set by the plugin if a token or an nft should be looked up - uint8_t *itemLookup2; - - uint8_t *amount; // set an uint256 pointer if uiType is UI_AMOUNT_ADDRESS - uint8_t *address; // set to the destination address if uiType is UI_AMOUNT_ADDRESS. Set to the user's address if uiType is UI_TYPE_GENERIC - - uint8_t uiType; - uint8_t numScreens; // ignored if uiType is UI_AMOUNT_ADDRESS - uint8_t result; - -} ethPluginFinalize_t; - ----- - -This message is sent when the data field has been fully parsed. The following specific fields can be filled by the plugin : - - * itemLookup1 : the pointer shall be set to a 20 bytes address to look up an ERC20 token or NFT if needed by the plugin - * itemLookup2 : the pointer shall be set to a 20 bytes address to look up an ERC20 token or NFT if needed by the plugin - * uiType : set to either ETH_UI_TYPE_AMOUNT_ADDRESS for an amount/address UI or ETH_UI_TYPE_GENERIC for a generic UI - -The following specific fields are filled by the plugin when returning an amount/address UI : - - * amount : set to a pointer to a 256 bits number - * address : set to a pointer to a 20 bytes address - -The following specific fields are filled by the plugin when returning a generic UI : - - * numScreens : number of screens handled by the plugin - -The following return codes are expected, any other will abort the signing process : - - * ETH_PLUGIN_RESULT_OK : if the plugin can be successfully initialized - * ETH_PLUGIN_RESULT_FALLBACK : if the signing logic should fallback to the generic one - -### ETH_PLUGIN_PROVIDE_INFO - -[source,C] ----- - -typedef struct ethPluginProvideInfo_t { - - ethPluginSharedRW_t *pluginSharedRW; - ethPluginSharedRO_t *pluginSharedRO; - uint8_t *pluginContext; - - union extraInfo *item1; // set by the ETH application, to be saved by the plugin - union extraInfo *item2; - - uint8_t additionalScreens; // Used by the plugin if it needs to display additional screens based on the information received. - - uint8_t result; - -} ethPluginProvideInfo_t; - ----- - -This message is sent if an information lookup was required by the plugin when parsing a finalize message. The following specific fields are filled when the plugin is called : - - * item1 : pointer to an union matching itemLookup1, or NULL if not found - * item2 : pointer to an union matching itemLookup2, or NULL if not found - -The following return codes are expected, any other will abort the signing process : - - * ETH_PLUGIN_RESULT_OK : if the plugin can be successfully initialized - * ETH_PLUGIN_RESULT_FALLBACK : if the signing logic should fallback to the generic one - -### ETH_PLUGIN_QUERY_CONTRACT_ID - -[source,C] ----- - -typedef struct ethQueryContractID_t { - - ethPluginSharedRW_t *pluginSharedRW; - ethPluginSharedRO_t *pluginSharedRO; - uint8_t *pluginContext; - - char *name; - uint32_t nameLength; - char *version; - uint32_t versionLength; - - uint8_t result; - -} ethQueryContractID_t; - ----- - -This message is sent after the parsing finalization and information lookups if requested if a generic UI is used. The following specific fields are provided when the plugin is called : - - * name : pointer to the name of the plugin, to be filled by the plugin - * nameLength : maximum name length - * version : pointer to the version of the plugin, to be filled by the plugin - * versionLength : maximum version length - -The following return codes are expected, any other will abort the signing process : - - * ETH_PLUGIN_RESULT_OK : if the plugin can be successfully initialized - -### ETH_PLUGIN_QUERY_CONTRACT_UI - -[source,C] ----- - -typedef struct ethQueryContractUI_t { - - ethPluginSharedRW_t *pluginSharedRW; - ethPluginSharedRO_t *pluginSharedRO; - union extraInfo_t *item1; - union extraInfo_t *item2; - char network_ticker[MAX_TICKER_LEN]; - uint8_t *pluginContext; - uint8_t screenIndex; - char *title; - uint32_t titleLength; - char *msg; - uint32_t msgLength; - - uint8_t result; - -} ethQueryContractUI_t; - ----- - -This message is sent when a plugin screen shall be displayed if a generic UI is used. The following specific fields are provided when the plugin is called : - - - * item1 : pointer to token / nft information - * item2 : pointer to token / nft information - * network_ticker : string that holds the network ticker - * screenIndex : index of the screen to display, starting from 0 - * title : pointer to the first line of the screen, to be filled by the plugin - * titleLength : maximum title length - * msg : pointer to the second line of the screen, to be filled by the plugin - * msgLength : maximum msg length - -The following return codes are expected, any other will abort the signing process : - - * ETH_PLUGIN_RESULT_OK : if the plugin can be successfully initialized - -## Caveats - -When setting a pointer from the plugin space, make sure to use an address that will be accessible from the Ethereum application (typically in the plugin RAM context, *not* on the plugin stack) - -Do not use data types that need to be aligned (such as uint32_t) in the plugin context. - -## TODOs - -Provide a sample callback mechanism for common plugin actions (amount to string, 256 bits number multiplication ...) to avoid duplicating code in the plugin space - -Provide external plugins samples - -Fully support Starkware as an independant application (APDU logic added) - -Support extra flags for the generic UI (fast confirmation on first screen, ...) - -Support extra plugin provisioning (signed list of associated smart contract addresses, ...) +Ethereum application Plugins : Technical Specifications +======================================================= +Ledger Firmware Team +Specification version 1.0 - 24th of September 2020 + + +## 1.0 + - Initial release + +## About + +This specification describes the plugin interface used to display a specific UI on device for Ethereum smart contracts. + +Feel free to checkout the ParaSwap plugin to see an actual implementation. Link: https://github.com/LedgerHQ/app-ethereum/blob/named-external-plugins/doc/ethapp_plugins.asc . + +## Flow overview + +When signing an Ethereum transaction containing data, the Ethereum application looks for a plugin using .either a selector list or the contract address. + +If a plugin is found, each network serialized data field (32 bytes) is passed to the plugin along with the field offset. The plugin can decide to stop the signature process if a data field isn't expected + +After all fields have been received, the plugin can report to the Ethereum application whether the full data is accepted, and the user interface model that'll be used to display the data + +### Amount/Address user interface + +In this model, the generic (without data) transaction display is used, with the amount and destination address replaced by data provided by the plugin + +### Generic user interface + +In this model, the plugin first reports a number of screens (2 lines of text, the second line being scrollable) to be displayed + +The Ethereum application will request each screen to be displayed to the plugin and let the user browse through them. + +The first screen being displayed is always a description of the plugin being used (name and version reported by the plugin), and the last screens include the transaction fees in ETH and a confirmation prompt + +### Code flow + +The plugin interfacing logic is described in _src/eth_plugin_interface.h_ + +The plugin common dispatcher is found in _src/eth_plugin_handler.c_ + +The plugin generic UI dispatcher is found in _src/eth_plugin_ui.c_ + +Sample internal plugins are provided in _src_plugins/_ + +## Creating a plugin + +### Creating an internal plugin + +Internal plugins are triggered on specific selectors. You can modify _src/eth_plugin_internal.c_ to add your mapping. + +Other specific mappings can be also added by modifying the common dispatcher + +### Creating an external plugin + +An external plugin is a library application named after the base64 encoding of the 20 bytes smart contract address + +## Detailed flow messages + +### Generic fields + +The following generic fields are present in all messages : + + * pluginSharedRW : scratch objects and utilities available to the plugin (can be read and written) + + * pluginSharedRO : transaction data available to the plugin (can only be read) + + * pluginContext : arbitrary data blob holding the plugin context, to be set and used by the plugin + + * result : return code set by the plugin following the message processing + +### ETH_PLUGIN_INIT_CONTRACT + +[source,C] +---- + +typedef struct ethPluginInitContract_t { + + // in + + ethPluginSharedRW_t *pluginSharedRW; + ethPluginSharedRO_t *pluginSharedRO; + uint8_t *pluginContext; + uint32_t pluginContextLength; + uint8_t *selector; // 4 bytes selector + uint32_t dataSize; + + char *alias; // 29 bytes alias if ETH_PLUGIN_RESULT_OK_ALIAS set + + uint8_t result; + +} ethPluginInitContract_t; + +---- + +This message is sent when the selector of the data has been parsed. The following specific fields are filled when the plugin is called : + + * pluginContextLength : length of the data field available to store the plugin context + * selector : 4 bytes selector of the data field + * dataSize : size in bytes of the data field + +The following return codes are expected, any other will abort the signing process : + + * ETH_PLUGIN_RESULT_OK : if the plugin can be successfully initialized + * ETH_PLUGIN_RESULT_OK_ALIAS : if a base64 encoded alias of another plugin to call is copied to the _alias_ field. In this case, the dispatcher will follow the alias chain, and the original plugin will only be called to retrieve its name when using a generic user interface + * ETH_PLUGIN_RESULT_FALLBACK : if the signing logic should fallback to the generic one + +### ETH_PLUGIN_PROVIDE_PARAMETER + +[source,C] +---- + +typedef struct ethPluginProvideParameter_t { + + ethPluginSharedRW_t *pluginSharedRW; + ethPluginSharedRO_t *pluginSharedRO; + uint8_t *pluginContext; + uint8_t *parameter; // 32 bytes parameter + uint32_t parameterOffset; + + uint8_t result; + +} ethPluginProvideParameter_t; + +---- + +This message is sent when a new 32 bytes component of the data field is available. The following specific fields are filled when the plugin is called : + + * parameter : pointer to the 32 bytes parameter being parsed + * parameterOffset : offset to this parameter from the beginning of the data field (starts at 4, following the selector) + +The following return codes are expected, any other will abort the signing process : + + * ETH_PLUGIN_RESULT_OK : if the plugin can be successfully initialized + * ETH_PLUGIN_RESULT_FALLBACK : if the signing logic should fallback to the generic one + +There are already defined functions to extract data from a parameter: +[source,C] +---- +void copy_address(uint8_t* dst, const uint8_t* parameter, uint8_t dst_size); +void copy_parameter(uint8_t* dst, const uint8_t* parameter, uint8_t dst_size); + +// Get the value from the beginning of the parameter (right to left) and check if the rest of it is zero +bool U2BE_from_parameter(const uint8_t* parameter, uint16_t* value); +bool U4BE_from_parameter(const uint8_t* parameter, uint32_t* value); +---- + +### ETH_PLUGIN_FINALIZE + +[source,C] +---- + +typedef struct ethPluginFinalize_t { + + ethPluginSharedRW_t *pluginSharedRW; + ethPluginSharedRO_t *pluginSharedRO; + uint8_t *pluginContext; + + uint8_t *itemLookup1; // set by the plugin if a token or an nft should be looked up + uint8_t *itemLookup2; + + uint8_t *amount; // set an uint256 pointer if uiType is UI_AMOUNT_ADDRESS + uint8_t *address; // set to the destination address if uiType is UI_AMOUNT_ADDRESS. Set to the user's address if uiType is UI_TYPE_GENERIC + + uint8_t uiType; + uint8_t numScreens; // ignored if uiType is UI_AMOUNT_ADDRESS + uint8_t result; + +} ethPluginFinalize_t; + +---- + +This message is sent when the data field has been fully parsed. The following specific fields can be filled by the plugin : + + * itemLookup1 : the pointer shall be set to a 20 bytes address to look up an ERC20 token or NFT if needed by the plugin + * itemLookup2 : the pointer shall be set to a 20 bytes address to look up an ERC20 token or NFT if needed by the plugin + * uiType : set to either ETH_UI_TYPE_AMOUNT_ADDRESS for an amount/address UI or ETH_UI_TYPE_GENERIC for a generic UI + +The following specific fields are filled by the plugin when returning an amount/address UI : + + * amount : set to a pointer to a 256 bits number + * address : set to a pointer to a 20 bytes address + +The following specific fields are filled by the plugin when returning a generic UI : + + * numScreens : number of screens handled by the plugin + +The following return codes are expected, any other will abort the signing process : + + * ETH_PLUGIN_RESULT_OK : if the plugin can be successfully initialized + * ETH_PLUGIN_RESULT_FALLBACK : if the signing logic should fallback to the generic one + +### ETH_PLUGIN_PROVIDE_INFO + +[source,C] +---- + +typedef struct ethPluginProvideInfo_t { + + ethPluginSharedRW_t *pluginSharedRW; + ethPluginSharedRO_t *pluginSharedRO; + uint8_t *pluginContext; + + union extraInfo *item1; // set by the ETH application, to be saved by the plugin + union extraInfo *item2; + + uint8_t additionalScreens; // Used by the plugin if it needs to display additional screens based on the information received. + + uint8_t result; + +} ethPluginProvideInfo_t; + +---- + +This message is sent if an information lookup was required by the plugin when parsing a finalize message. The following specific fields are filled when the plugin is called : + + * item1 : pointer to an union matching itemLookup1, or NULL if not found + * item2 : pointer to an union matching itemLookup2, or NULL if not found + +The following return codes are expected, any other will abort the signing process : + + * ETH_PLUGIN_RESULT_OK : if the plugin can be successfully initialized + * ETH_PLUGIN_RESULT_FALLBACK : if the signing logic should fallback to the generic one + +### ETH_PLUGIN_QUERY_CONTRACT_ID + +[source,C] +---- + +typedef struct ethQueryContractID_t { + + ethPluginSharedRW_t *pluginSharedRW; + ethPluginSharedRO_t *pluginSharedRO; + uint8_t *pluginContext; + + char *name; + uint32_t nameLength; + char *version; + uint32_t versionLength; + + uint8_t result; + +} ethQueryContractID_t; + +---- + +This message is sent after the parsing finalization and information lookups if requested if a generic UI is used. The following specific fields are provided when the plugin is called : + + * name : pointer to the name of the plugin, to be filled by the plugin + * nameLength : maximum name length + * version : pointer to the version of the plugin, to be filled by the plugin + * versionLength : maximum version length + +The following return codes are expected, any other will abort the signing process : + + * ETH_PLUGIN_RESULT_OK : if the plugin can be successfully initialized + +### ETH_PLUGIN_QUERY_CONTRACT_UI + +[source,C] +---- + +typedef struct ethQueryContractUI_t { + + ethPluginSharedRW_t *pluginSharedRW; + ethPluginSharedRO_t *pluginSharedRO; + union extraInfo_t *item1; + union extraInfo_t *item2; + char network_ticker[MAX_TICKER_LEN]; + uint8_t *pluginContext; + uint8_t screenIndex; + char *title; + uint32_t titleLength; + char *msg; + uint32_t msgLength; + + uint8_t result; + +} ethQueryContractUI_t; + +---- + +This message is sent when a plugin screen shall be displayed if a generic UI is used. The following specific fields are provided when the plugin is called : + + + * item1 : pointer to token / nft information + * item2 : pointer to token / nft information + * network_ticker : string that holds the network ticker + * screenIndex : index of the screen to display, starting from 0 + * title : pointer to the first line of the screen, to be filled by the plugin + * titleLength : maximum title length + * msg : pointer to the second line of the screen, to be filled by the plugin + * msgLength : maximum msg length + +The following return codes are expected, any other will abort the signing process : + + * ETH_PLUGIN_RESULT_OK : if the plugin can be successfully initialized + +## Caveats + +When setting a pointer from the plugin space, make sure to use an address that will be accessible from the Ethereum application (typically in the plugin RAM context, *not* on the plugin stack) + +Do not use data types that need to be aligned (such as uint32_t) in the plugin context. + +## TODOs + +Provide a sample callback mechanism for common plugin actions (amount to string, 256 bits number multiplication ...) to avoid duplicating code in the plugin space + +Provide external plugins samples + +Support extra flags for the generic UI (fast confirmation on first screen, ...) + +Support extra plugin provisioning (signed list of associated smart contract addresses, ...) From 726ffc1ac739681d09b13be35768de2e6ba14dcc Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Tue, 13 Feb 2024 17:01:00 +0100 Subject: [PATCH 3/3] Update tests --- tests/speculos/test_configuration_cmd.py | 9 +--- .../nanos_starkware_usdt_deposit/00000.png | Bin 374 -> 0 bytes .../nanos_starkware_usdt_deposit/00001.png | Bin 359 -> 0 bytes .../nanos_starkware_usdt_deposit/00002.png | Bin 488 -> 0 bytes .../nanos_starkware_usdt_deposit/00003.png | Bin 477 -> 0 bytes .../nanos_starkware_usdt_deposit/00004.png | Bin 408 -> 0 bytes .../nanos_starkware_usdt_deposit/00005.png | Bin 391 -> 0 bytes .../nanos_starkware_usdt_deposit/00006.png | Bin 420 -> 0 bytes .../nanos_starkware_usdt_deposit/00007.png | Bin 429 -> 0 bytes .../nanos_starkware_usdt_deposit/00008.png | Bin 409 -> 0 bytes .../nanos_starkware_usdt_deposit/00009.png | Bin 313 -> 0 bytes .../nanos_starkware_usdt_deposit/00010.png | Bin 315 -> 0 bytes .../nanos_starkware_usdt_deposit/00011.png | Bin 281 -> 0 bytes .../nanos_starkware_usdt_deposit/00012.png | Bin 359 -> 0 bytes .../nanos_starkware_usdt_deposit/00013.png | Bin 414 -> 0 bytes .../nanos_starkware_usdt_deposit/00014.png | Bin 340 -> 0 bytes .../nanos_starkware_usdt_deposit/00015.png | Bin 414 -> 0 bytes .../nanos_starkware_usdt_deposit/00016.png | Bin 349 -> 0 bytes .../nanox_starkware_usdt_deposit/00000.png | Bin 414 -> 0 bytes .../nanox_starkware_usdt_deposit/00001.png | Bin 405 -> 0 bytes .../nanox_starkware_usdt_deposit/00002.png | Bin 735 -> 0 bytes .../nanox_starkware_usdt_deposit/00003.png | Bin 621 -> 0 bytes .../nanox_starkware_usdt_deposit/00004.png | Bin 479 -> 0 bytes .../nanox_starkware_usdt_deposit/00005.png | Bin 364 -> 0 bytes .../nanox_starkware_usdt_deposit/00006.png | Bin 379 -> 0 bytes .../nanox_starkware_usdt_deposit/00007.png | Bin 321 -> 0 bytes .../nanox_starkware_usdt_deposit/00008.png | Bin 433 -> 0 bytes .../nanox_starkware_usdt_deposit/00009.png | Bin 472 -> 0 bytes .../nanox_starkware_usdt_deposit/00010.png | Bin 365 -> 0 bytes .../nanox_starkware_usdt_deposit/00011.png | 1 - .../nanox_starkware_usdt_deposit/00012.png | Bin 382 -> 0 bytes tests/zemu/src/starkware.test.js | 40 ------------------ 32 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00000.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00001.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00002.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00003.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00004.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00005.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00006.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00007.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00008.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00009.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00010.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00011.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00012.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00013.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00014.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00015.png delete mode 100644 tests/zemu/snapshots/nanos_starkware_usdt_deposit/00016.png delete mode 100644 tests/zemu/snapshots/nanox_starkware_usdt_deposit/00000.png delete mode 100644 tests/zemu/snapshots/nanox_starkware_usdt_deposit/00001.png delete mode 100644 tests/zemu/snapshots/nanox_starkware_usdt_deposit/00002.png delete mode 100644 tests/zemu/snapshots/nanox_starkware_usdt_deposit/00003.png delete mode 100644 tests/zemu/snapshots/nanox_starkware_usdt_deposit/00004.png delete mode 100644 tests/zemu/snapshots/nanox_starkware_usdt_deposit/00005.png delete mode 100644 tests/zemu/snapshots/nanox_starkware_usdt_deposit/00006.png delete mode 100644 tests/zemu/snapshots/nanox_starkware_usdt_deposit/00007.png delete mode 100644 tests/zemu/snapshots/nanox_starkware_usdt_deposit/00008.png delete mode 100644 tests/zemu/snapshots/nanox_starkware_usdt_deposit/00009.png delete mode 100644 tests/zemu/snapshots/nanox_starkware_usdt_deposit/00010.png delete mode 120000 tests/zemu/snapshots/nanox_starkware_usdt_deposit/00011.png delete mode 100644 tests/zemu/snapshots/nanox_starkware_usdt_deposit/00012.png delete mode 100644 tests/zemu/src/starkware.test.js diff --git a/tests/speculos/test_configuration_cmd.py b/tests/speculos/test_configuration_cmd.py index 36e4cede8..c27915612 100644 --- a/tests/speculos/test_configuration_cmd.py +++ b/tests/speculos/test_configuration_cmd.py @@ -1,10 +1,3 @@ def test_configuration(cmd): - if cmd.model == "nanos": - assert cmd.get_configuration() == (14, 1, 10, 4) - - if cmd.model == "nanox": - assert cmd.get_configuration() == (14, 1, 10, 4) - - if cmd.model == "nanosp": - assert cmd.get_configuration() == (14, 1, 10, 4) + assert cmd.get_configuration() == (2, 1, 10, 4) diff --git a/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00000.png b/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00000.png deleted file mode 100644 index 8d84cc70fea8013b7e8b25c0982ce142fa103d5c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 374 zcmV-+0g3*JP)K?4J2QqX3 zXn7ePqhBDwvA-|J28LIrjF%tX0z{3v6!_gF&(SYH)S*7TN;1RxW-%}TLH9_+sttDO z-T32w&rL(!1@Vr`jm5G(8dd=Ruu#)JAN?l#rFLU`oQ(r?$33AC7s0}pw!fi~(9k^# zU9aci?pXN=I7A<-f!Mw2untnw9MivqZYw}c5&)gweYhbTnv#2#t$0X2wST7_1F;LR zw?>Da2SkSfG>qWq1mej-6nW@2l+Z=0om5jdB%3o3Qx19_LNUlTqF4R_1Iaj%@^2O= z@;n%h1N>H$2;%-~Dvx1!0LtkT-;cq73rgisOElFtPbcL{d3TfNQvm<~003s>1*i4o Uje8$F8UO$Q07*qoM6N<$g5rpv%m4rY diff --git a/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00001.png b/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00001.png deleted file mode 100644 index 049c0d8476cb0e434cfa8d66ace208f854b01b52..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 359 zcmV-t0hs=YP)5z#wgHv;Vv3C@TDnG1{gH006+hlB@+hS(mrlG^-4u(d|WG z3&3tw$1>$^EntA%UfF-C`KU*;*Qy_;d27tS*bpyTJ3zSjs8MJ)YI*m>?|Ap6$*63hnQOkkpfNqQ6?5er$A*2 z7noHnum+Zdk3ymGat`PG_E?r1*HIiPFQtr&b2N>!xG6=jB4wFvRkNqPz)6!YcHQmD zbzY`N8GNdKEz~<(E#=d0SFO?YvD*RE`%2gAnq$1gHqwP)-||_RSActRi>AGXu`97E6}8tkqE0(gfp*Hfs%0AFbKc;#XIA zv9A`rd{ytCRd;@yCNp>6OxcX==Ug!W*3-!TGL%$D_7@Xlu#>1lJNZoVp*&V^SL}Ti z>NF+l=C4D?2)g<@YU{Bnm0mr^9~*I+GkLQX-?maI#0r+>Gg;E zp|j6UzT+;)fGmJy_L)OFd9b&g$^p9-n129h(-h6z4O}$prc$dcOt~49fLoFKOVC87 zq*c}%TzIZyUd8jz0D5d$JA)J(k9)2JCe7Ui>Y##Z=cWCft?C$dIy~CeNC~>;;|ziz e2!bH^_xu4Hx~&z&^clba0000Z|Kzy}KDTEM02*mHt|L1rl&d*#IR+p

AA_N#8^&7h{4C-fP=IXt|c| zq%XC17h%mr`5hOkrjYHWA5m2Y3}(Tp`h9gv46cATc(QxQMX+EEY|=X#oVKMFUqcrR zK+*P!oz{@7EhQJ>Gp2t0Sn_P3#=n%UnB$KWK~g-#MUht(VQRHE9H zX4N9%^!TzALUvT0X)r00z!XQyCP@9ySH?~G3W*`LpGcfi$Cn7QOA)=Z=eNh{6%Q}t zIClCpwcF(sse?!a*#ltJlLwH?^YlKc-c%hmOGhnh?;BAmlFvdDLI@#*5MuKO%6y+n T?B?HV00000NkvXXu0mjfRjAv5 diff --git a/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00004.png b/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00004.png deleted file mode 100644 index 8aa3536956cd1dec5ac10e85a34715077480cecd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 408 zcmV;J0cZY+P)G1!BhzzglXK~< zVE?PrG8cV*Jod1C=EcBP6pd*L{noy{11df!1_sx-ObS`;N0JMWIbK>^-xu%RWN$$(pV#bKri>?-~H2VCMUgtT=uXpk9OnywE1!0(z4zc16$FuzCX;r%Nm%Z#4|de0M&XJlv}dJ$G7a2k4|0Asi=?g zZ_Qw8WCIsw47E=_GBMdztV&H-Q)*9J)e>qn4AboKti43<3ZRWzDtU4w4?l9MIV<~8 ztfzBC0+8!VD%LiHqKQtshrfXt)s&(|;Eqj?3eY&2yfoK_V=shu1()0@0NTdKoX8Fm zMnci997s0Se$;HMt|E_R3B*no&LcxO|7J+Hc{u3}=Zn3YzTcyJ0IWIT{o5$G8s5Jd z#9$=Yg+}u2%G#tgtztDR7$2YLWzTkUKzoe;-RYQ#rMTxvq5`KSs200000QhEW9#GX$6@iMsp O0000C*2u0~;`~M%@hwg(L!hl+^R>$U^OeU>GK?H|7L;wH)K#lXD^SEevNbg+OfHYrg zPrb!q|4+Mde%kza9<=S_)}XFv+y6hxzuO)dB*$;GLk6ie8N@AYar(AT?X6Rnb13N} zzAhOojcnk-h>`Z$TP0>6WwWv*TvA#e_EJlzu{3^EV|Lh2dS`%aEQOLMM!0*5sphEc z2|v~`RK0000`**Ds^f~1k%zGNMcLR(Ur z#i!b>TJFVh-)LFma^N(SjrFqL8S2lsN;?C$ces)yDT2qRyeluAwwy!p=%nwO!`w;D zda)*&)D8DfUS8DXt?YW#lr^LFuth6XLVNsLyV=1RudVn zcA=hxp2J4p)ZbwpO7kJ1C2n_G{5_d*G#k*q9WC+yHkn290pSUlC8kkLz#c0AFk%ys zT87%63e#y0jd8eLgtKVQ$1E?GVXvV800000fQX2Gu(qJWSm52l00000NkvXXu0mjf DN1(rO diff --git a/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00009.png b/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00009.png deleted file mode 100644 index d242dc57515de93b14dbd054485897308b6d2cf9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 313 zcmeAS@N?(olHy`uVBq!ia0vp^4M42G!2~2j9iA64FfcNBx;TbZ%y~QGpwJ-&9+!g? z|Nnm=_lmK-lSSj=j45UJD<%ku@A73579w-8O2MA;;82>g*w|Hmtb}xwQ>FVdQ I&MBb@05%zi8vpW3Kt$}c@{?YJG$p8*?gwcS&{y^v zBuD`7ob;|jW^Yv6GF{1E(k5K&0D5D{3-uisiVXGLP^5m=n8tYaPz=+6eh3vzn3T$lnZTKI=k`Sx{jTC!j_{N-&C0;dOs$(Tpz2 ziQfQP-yWmYr|bz>N&@vMz66OcF!Q0b>iK2-(Pzs`(EtDd006+B*a30RlT6E802%-Q N002ovPDHLkV1i?Dh;;w} diff --git a/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00011.png b/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00011.png deleted file mode 100644 index 6c0730332de69c4b36de575419de5965d255c81b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 281 zcmV+!0p|XRP)oCCejS|bL^z9X4Q005Yor`*R1XEgP&UVx<2iFgX` zEi>HU&E?@P}zX5Wqu+w`cjh+$%P7>_K@HsO0HyB)nZY5!@6x<SC-{-yYt&P_7F<2G%R zNM=mdXJIl8!$1HOStT7MKed*s1#JwURS#~#D-{CPi|!6L)n2SlomS z>`PB3BQMmSfG9H5pGHDzs6QFRU?o_ERx*4aKKB2wq*~R7$j<%Dw6rmGit{m)bVV9! zWakG*Rfj(p3;i(mB`lo^aJ!*Tr%MbAKqQ%7Rg8-L5sV2ygZgj9%n}sVbm@{nx-Gal zV-Dl=^*TBIr4&Kxw9xkclWmZ_V6p!i3IG5A004-H=m*9i4kMvM;gJ9U002ovPDHLk FV1iKVl=J`q diff --git a/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00013.png b/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00013.png deleted file mode 100644 index 1c9156c31edf73cb072eaebf2db3fbe1ba5c612b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 414 zcmV;P0b%}$P)j~f|{k#}B z4)Di%0(GQh%XXzDG$sKK-Q2JkKR-`QsiPFD-4d_!i{fwH;J|_aEL%ZYNu#B0FJ7G| z;=_VQWOA9;dQ4Y9)LpKCV=ri`X({49JagUwO3&5UdSK)wEJxPN%9wG}45n;lzK(aC zKtbL$y*-#9uSql`7 zENOEh^0jsFWbV&<+yj5)WEX_aERLO-`${sQhD#B5ZCio#Fr4qHlr^7X|9DL69eFa= z#kf#}$Pcl(QEE=tNl8Pt$o;~Fk*8r@j8mpwSGW8d!1&11FbzPh@^gWj=oh7f%f7G)4s^6#xJL07*qo IM6N<$g02I(Gynhq diff --git a/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00014.png b/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00014.png deleted file mode 100644 index 9c7e7049cb3e9bcfb1601ec510ee465d38229d4d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 340 zcmV-a0jvIrP)b=%MgRq*37h4eRxPbkJCLY|1VIo49_}P}TKpH4$L<8?X{t;p zy+UQc_4@p%0?~E_&igM#?#L~IOHR(-<@sYotiy&C*Y&GII0yeh-p3zW9cv$Q0k>6Y_)5~SfP=m zSMUtz)%Ex|-o}7!H9hbQ(8{%C?kQVa?C`*Uj-J(h>P7(Y#?ZWvi?6}@n{fGLp>YTp myqR(V_$?>^<%seR_VWh!j~f|{k#}B z4)Di%0(GQh%XXzDG$sKK-Q2JkKR-`QsiPFD-4d_!i{fwH;J|_aEL%ZYNu#B0FJ7G| z;=_VQWOA9;dQ4Y9)LpKCV=ri`X({49JagUwO3&5UdSK)wEJxPN%9wG}45n;lzK(aC zKtbL$y*-#9uSql`7 zENOEh^0jsFWbV&<+yj5)WEX_aERLO-`${sQhD#B5ZCio#Fr4qHlr^7X|9DL69eFa= z#kf#}$Pcl(QEE=tNl8Pt$o;~Fk*8r@j8mpwSGW8d!1&11FbzPh@^gWj=oh7f%f7G)4s^6#xJL07*qo IM6N<$g02I(Gynhq diff --git a/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00016.png b/tests/zemu/snapshots/nanos_starkware_usdt_deposit/00016.png deleted file mode 100644 index ce795f34e8569e986af689fded3b59c9a8af2961..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 349 zcmV-j0iyniP)O41}p;-~WL<=z+0=1Om1tEU@3H#qtw22}5*_5JCvCo4!52c$FXo$VhXU?0M$^Bekqgf%Ka;M*^X|4 zEs9YCQ(xfJKmNC#+8dY%2&wT+>D^<3C%}_*k1^mvtO~`RE00000NkvXXu0mjf-kqOA diff --git a/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00000.png b/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00000.png deleted file mode 100644 index 487ea10fcfeb2f3e6b79239459672251d49addd7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 414 zcmV;P0b%}$P)vpO}&+|8}fC)JNq`>?#dJ%s{^>GN_4usXQirk{^@^BA?p!El9&T9q~zMsh2=YdLB`_ONiP zKy6XlUGFZ>Cn7mP3u*9qxynrE*YEzX_R`$S z_UZFBx7xjXtS=}VTm9R)_F+)}ZRJQ|M<4wSypCMqBGB23_I~Gx_{2R zyE-p80_rb4Jb%T}lX?do_^IhkNC(RZ39i5q#C%Mfi z=S23upAV;QSkqV|v|_naK^51nYhSN9o0^*0>1Un}3f;5nsGon;+CP_H$3~o;;8{O= w@(Ry-;9<691qT`%Ul6@Y|2UHx3vIVCg!00s%Rs{jB1 diff --git a/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00002.png b/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00002.png deleted file mode 100644 index 6735a0784eb960ea0c99395750bb87fc0dcf3ca1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 735 zcmV<50wDc~P)5OmE}cYwHprE zs(URD3s;R=!~9OxH;}QAP8Wg5*D0meP3Et3Z^>^95tpj6^sv=u)mmemH3GC}`etmZ zozW^m)b@QZD)#CW-5sM(}mR(Q_H4HXZFA{Y3a1857^i(Mm3F8$CDP_FJg%F^*Q0*MAJGvDHmkefYGncX#+NHqcWjwyVTtQ zxHN(ryH;9w03*FxZE>b8BcWYz;(35eNLcfFqZgj@2%Pb{M*!Zppw1-4#^a$Y!JC2I zg|?|mX&s$YY}pt(11;KWV2N%T@zWWg*NopUrx|2M|1v6}X7n$HeQ+n7h3$j#*37=I)xKPLecd{eue8GH!^nbWAU+E?7isH>5{Sy0$s`<5kIw!U7`t2#>vK_ z(hP1Hgor8`%xWE9hy*Hf!0W*Uy2Cw$7uk1KcMLd?aPy zF1YiRcNQHTaAi6-mX$Mfcc!DsW{d!R@S-Q~>fwyuWx6(1v-J7r2-^VHX}M$*dkjSg zA%qY@!u}~ANHtO6?uoTcp~)R&H%98Q*Ji0VbICK_gvZj82a7-ZtN%9C06chEIr`hm zBfyQF%uhU*MLQtm$<3<*axz8UxTlgvVOQN1Sac1*4W= R)%pMc002ovPDHLkV1g~OT?+sJ diff --git a/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00003.png b/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00003.png deleted file mode 100644 index 85f3a2b4cdbc022a329dced99125aaa190dfae4a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 621 zcmV-z0+RiSP)kuc@fw|HZ2*ig0g<~<;%1)ip}vD^lTv6Oil3esBSZHbm3<%DWP z#17g!ijfJ+=bUz`{xI(6!;j9WM{s`tMtK4N0N~s4?AqFS6c)|mg`8fUnsia#0u3<| z8eYUakMq1`JXyn;_WGsxq|39FUQVkcuF;gn8A=YSp>O>2bgZ(i8akx@ccx}b^h4_k7*hW`P_q%F zp!X8V$=VpI8A|*hLk~zs-k71pF_d=slw&9W000000Q2|*1}B-OdZa5S00000NkvXX Hu0mjfGJG55 diff --git a/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00004.png b/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00004.png deleted file mode 100644 index e56268e93dc8a16732654671f8f5b56f4b6d44eb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 479 zcmV<50U-W~P)DCNhyIlO(!%MpjnpLjaxNf7{{{*Szob?55M6ZY|D9Wev zsFB)uaHX4_coC7F7)wmhOI!2eW@Wl=KLPnqQunjQ>+qtbzOcL8bYq=>8Sy$7J-3z8 zX^U~=-nz`J+$X>j%*snNE_b}pf@=pOi%tAJzKhJAYREb1e8D+J5QcEM+@ClZoW%!@4x7g|WyEm82LT7kd z8E?9LOZUYTZvBwFw@z!K828PpQ;fgo_I24B^N)p>eomY#HjmLb)a>@hm9ZZA$L%tC zO(i}GOV6=7D>6Blm4V?v{KM@D%NBnzQMkF@JmH~z;+X}ECo>$3q$Zp(dvN{y7X9zb z_Jq_o=S^Jsn`0v>lj%sBKedZjVsi6<_HZs_7hI@|Jt46Q$XP1M7Jzf1=);T3K F0RS?Lm}>w4 diff --git a/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00006.png b/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00006.png deleted file mode 100644 index 9fce3dc7d8480ec63409347f73c8e26b595d1a1b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 379 zcmeAS@N?(olHy`uVBq!ia0vp^4M6O`!2~2@x4h6`U|@9eba4!+nDh2#E?=_(Ps78! zo4z~#Ppq2$*Fe!%@TT|{?)RU))fF@sYjgqiFx(Cb4efpB+E87>?&6a5VtTLRypMG* zf}^jlKGeQt8G4K}|w$_y92B({_|$;TJ+GInSo*3$Cddnz8Tc;Z=9?BPw;oRh{6memf(g2 zt^&hq+rXUf62H>6R{x#hYs(w?>om`zY5$V41U$vNp4iEF?g0h@6nsdpV>rpWqH$Mo Qk{d|K)78&qol`;+0PQk{zyJUM diff --git a/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00008.png b/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00008.png deleted file mode 100644 index fcc883ef0cf6d0828f181c9b9bf892ffa91bbcf4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 433 zcmV;i0Z#sjP) zm@meO_n7?yu5_ck7c&PS=bTciCa?UT&Rb6P67esWHjW+K6Z3Mv!Toupo$T3Z^U}>! z&bef>d{M{gHtJ5_@Yftzu>`eiLiV{o8jtdsDuNExZLIFbkHNG7sESEDb7hdJv%Qq- zQSGXF4<3WbCCH!RQv=gYqLJBI^+y&gLAulw-3PUuvMSE@;cnyHhcEyDz<0XrG}Jz0 z(T&yS$awP`-ED(NZ_gFevWn5>$bO?Ywp8tIpxdqwd8(KJ7q46KFizZaU)G$AXI!}x zb{-TTP9J~vKfsj(;LJ|7T%tRHMiRbW4q!$1H000000000000000 b0C<}}PbYO_j-}Nd00000NkvXXu0mjfMbylE diff --git a/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00009.png b/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00009.png deleted file mode 100644 index 570ce28d53e82ac396ba25c370110058f3a638f9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 472 zcmV;}0Vn>6P)Nkl`l1;k+@4An6g^M6kcbtxu@7*hfO000000DuchDWw$aQJnB& zJ%BsK3VrpQ1hnYqoNY&PO0WdV>i`7cs)e_@w@x()p@w=B24`klR6(CLpxqtlZO|2 zIWjpO-F~*EHtLqUMt)Wc_@bMv^h#{CUFW0M(vJ1P=5N1GhWcHM(-Xu*&bc@D4_o$^ z7Y|pL)I@*DzttR=&yLH#^{|TW)8Sp0qphw%epiuSUG#WHS~ht|j~;`U4>BXmdi9@& zuz>%00000G5i7^TsbXePb2LB O0000MjqtrV%Nn6esuj!jIMi}Btw`sohxwi1&U@}K{{10Q-!s%eVxF#kF6*2U FngGM>p?d%T diff --git a/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00011.png b/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00011.png deleted file mode 120000 index 489390ada..000000000 --- a/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00011.png +++ /dev/null @@ -1 +0,0 @@ -00009.png \ No newline at end of file diff --git a/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00012.png b/tests/zemu/snapshots/nanox_starkware_usdt_deposit/00012.png deleted file mode 100644 index a58590b988714545e7960f7f400f360ffc5de41f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 382 zcmeAS@N?(olHy`uVBq!ia0vp^4M6O`!2~2@x4h6`U|@9hba4!+nDh2#bl+hG9*4k? zQuR0Wo;SViCn%lTo!KM1sAjk5Y(@*V#~rbuHu`7A_H&AxgwHf8y4cdKvg$JbB4n%ez%sZ31aBYd&Oo@(7)_WJ(Znl2o8^PD` zFE`_Y-IS+Kdq0Q2-7r_C=}F(5ev`U`H~)QH|9$1FHE$YjoVax+e0xei%S`SAGlOm! zp7{T3NA-mVOYb&rdU8MdyIHo@@7cE*uj@I+Zu{2i)KMSV-E~o { - - // Provide USDT token info to the app - const usdt_info = byContractAddressAndChainId("0xdac17f958d2ee523a2206206994597c13d831ec7", 1); - await eth.provideERC20TokenInformation(usdt_info); - - // Provide Stark quantum - const quantization = new BigNumber(1); - await eth.starkProvideQuantum_v2( - "0xdac17f958d2ee523a2206206994597c13d831ec7", - "erc20", - quantization, - null - ) - - const tx = eth.signTransaction( - "44'/60'/1'/0/0", - 'f8b5018a0472698b413b43200000825208940102030405060708090a0b0c0d0e0f1011121314872bd72a24874000b8842505c3d9010101010101010102020202020202020303030303030303040404040404040402ce625e94458d39dd0bf3b45a843544dd4a14b8169045a3a3d15aa564b936c500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000030d40808080', - ); - - await waitForAppScreen(sim); - let clicks; - if (model.letter === 'S') clicks = 14; - else clicks = 10; - await sim.navigateAndCompareSnapshots('.', model.name + '_starkware_usdt_deposit', [clicks, -1, 0]); - - await expect(tx).resolves.toEqual({ - "r": "14c368c0d32e399470d6113cf796c5f4cd70300766337d8b0ba71ecad21b3d52", - "s": "4207c027959e84fc2242a1f4fd955603f137ba28f67268ffc91fef5d65071b0a", - "v": "1c", - }); - })); -});