diff --git a/app/Makefile.version b/app/Makefile.version index 91f5f7c3..c4068ebb 100644 --- a/app/Makefile.version +++ b/app/Makefile.version @@ -3,4 +3,4 @@ APPVERSION_M=2 # This is the `spec_version` field of `Runtime` APPVERSION_N=34 # This is the patch version of this release -APPVERSION_P=11 +APPVERSION_P=12 diff --git a/app/src/apdu_handler.c b/app/src/apdu_handler.c index efac26e8..94dcb2e0 100644 --- a/app/src/apdu_handler.c +++ b/app/src/apdu_handler.c @@ -61,7 +61,25 @@ __Z_INLINE void handle_getversion(__Z_UNUSED volatile uint32_t *flags, volatile THROW(APDU_CODE_OK); } -static void extractHDPath(uint32_t rx, uint32_t offset) { +__Z_INLINE uint8_t extractHRP(uint32_t rx, uint32_t offset) { + if (rx < offset + 1) { + THROW(APDU_CODE_DATA_INVALID); + } + MEMZERO(bech32_hrp, MAX_BECH32_HRP_LEN); + + bech32_hrp_len = G_io_apdu_buffer[offset]; + + if (bech32_hrp_len == 0 || bech32_hrp_len > MAX_BECH32_HRP_LEN) { + THROW(APDU_CODE_DATA_INVALID); + } + + memcpy(bech32_hrp, G_io_apdu_buffer + offset + 1, bech32_hrp_len); + bech32_hrp[bech32_hrp_len] = 0; // zero terminate + + return bech32_hrp_len; +} + +__Z_INLINE void extractHDPath(uint32_t rx, uint32_t offset) { if ((rx - offset) < sizeof(uint32_t) * HDPATH_LEN_DEFAULT) { THROW(APDU_CODE_WRONG_LENGTH); } @@ -75,12 +93,6 @@ static void extractHDPath(uint32_t rx, uint32_t offset) { THROW(APDU_CODE_DATA_INVALID); } - encoding = checkChainConfig(hdPath[1], bech32_hrp, bech32_hrp_len); - if (encoding == UNSUPPORTED) { - ZEMU_LOGF(50, "Chain config not supported for: %s\n", bech32_hrp) - THROW(APDU_CODE_COMMAND_NOT_ALLOWED); - } - // Limit values unless the app is running in expert mode if (!app_mode_expert()) { for(int i=2; i < HDPATH_LEN_DEFAULT; i++) { @@ -90,6 +102,24 @@ static void extractHDPath(uint32_t rx, uint32_t offset) { } } +static void extractHDPath_HRP(uint32_t rx, uint32_t offset) { + extractHDPath(rx, offset); + // Set BECH32_COSMOS as default for backward compatibility + encoding = BECH32_COSMOS; + + // Check if HRP was sent + if ((rx - offset) > sizeof(uint32_t) * HDPATH_LEN_DEFAULT) { + extractHRP(rx, offset + sizeof(uint32_t) * HDPATH_LEN_DEFAULT); + encoding = checkChainConfig(hdPath[1], bech32_hrp, bech32_hrp_len); + if (encoding == UNSUPPORTED) { + ZEMU_LOGF(50, "Chain config not supported for: %s\n", bech32_hrp) + THROW(APDU_CODE_COMMAND_NOT_ALLOWED); + } + } else if (hdPath[1] == HDPATH_ETH_1_DEFAULT) { + THROW(APDU_CODE_COMMAND_NOT_ALLOWED); + } +} + static bool process_chunk(volatile uint32_t *tx, uint32_t rx) { UNUSED(tx); @@ -108,7 +138,8 @@ static bool process_chunk(volatile uint32_t *tx, uint32_t rx) { case P1_INIT: tx_initialize(); tx_reset(); - extractHDPath(rx, OFFSET_DATA); + extractHDPath_HRP(rx, OFFSET_DATA); + return false; case P1_ADD: added = tx_append(&(G_io_apdu_buffer[OFFSET_DATA]), rx - OFFSET_DATA); @@ -131,6 +162,13 @@ __Z_INLINE void handleGetAddrSecp256K1(volatile uint32_t *flags, volatile uint32 uint8_t len = extractHRP(rx, OFFSET_DATA); extractHDPath(rx, OFFSET_DATA + 1 + len); + // Verify encoding + encoding = checkChainConfig(hdPath[1], bech32_hrp, bech32_hrp_len); + if (encoding == UNSUPPORTED) { + ZEMU_LOGF(50, "Chain config not supported for: %s\n", bech32_hrp) + THROW(APDU_CODE_COMMAND_NOT_ALLOWED); + } + uint8_t requireConfirmation = G_io_apdu_buffer[OFFSET_P1]; zxerr_t zxerr = app_fill_address(); if (zxerr != zxerr_ok) { @@ -154,6 +192,13 @@ __Z_INLINE void handleSignSecp256K1(volatile uint32_t *flags, volatile uint32_t THROW(APDU_CODE_OK); } + if ((hdPath[1] == HDPATH_ETH_1_DEFAULT) && !app_mode_expert()) { + *flags |= IO_ASYNCH_REPLY; + view_custom_error_show(PIC(msg_error1),PIC(msg_error2)); + THROW(APDU_CODE_DATA_INVALID); + } + + // Put address in output buffer, we will use it to confirm source address zxerr_t zxerr = app_fill_address(); if (zxerr != zxerr_ok) { @@ -161,12 +206,6 @@ __Z_INLINE void handleSignSecp256K1(volatile uint32_t *flags, volatile uint32_t THROW(APDU_CODE_DATA_INVALID); } parser_tx_obj.own_addr = (const char *) (G_io_apdu_buffer + VIEW_ADDRESS_OFFSET_SECP256K1); - - if ((encoding != BECH32_COSMOS) && !app_mode_expert()) { - *flags |= IO_ASYNCH_REPLY; - view_custom_error_show(PIC(msg_error1),PIC(msg_error2)); - THROW(APDU_CODE_DATA_INVALID); - } const char *error_msg = tx_parse(); if (error_msg != NULL) { @@ -183,7 +222,7 @@ __Z_INLINE void handleSignSecp256K1(volatile uint32_t *flags, volatile uint32_t } void handleApdu(volatile uint32_t *flags, volatile uint32_t *tx, uint32_t rx) { - uint16_t sw = 0; + volatile uint16_t sw = 0; BEGIN_TRY { @@ -235,7 +274,7 @@ void handleApdu(volatile uint32_t *flags, volatile uint32_t *tx, uint32_t rx) { break; } G_io_apdu_buffer[*tx] = sw >> 8; - G_io_apdu_buffer[*tx + 1] = sw; + G_io_apdu_buffer[*tx + 1] = sw & 0xFF; *tx += 2; } FINALLY diff --git a/app/src/common/actions.h b/app/src/common/actions.h index 37805713..79032a64 100644 --- a/app/src/common/actions.h +++ b/app/src/common/actions.h @@ -25,10 +25,6 @@ extern uint16_t action_addrResponseLen; -__Z_INLINE void app_set_hrp(char *p) { - crypto_set_hrp(p); -} - __Z_INLINE void app_sign() { uint16_t replyLen = 0; diff --git a/app/src/crypto.c b/app/src/crypto.c index 7c7d4b15..23b4a31e 100644 --- a/app/src/crypto.c +++ b/app/src/crypto.c @@ -23,6 +23,8 @@ #include #include "chain_config.h" +#define MAX_DER_SIGNATURE_LEN 73u + uint32_t hdPath[HDPATH_LEN_DEFAULT]; uint8_t bech32_hrp_len; @@ -31,41 +33,41 @@ address_encoding_e encoding; #include "cx.h" -zxerr_t crypto_extractUncompressedPublicKey(const uint32_t path[HDPATH_LEN_DEFAULT], uint8_t *pubKey, uint16_t pubKeyLen) { +static zxerr_t crypto_extractUncompressedPublicKey(uint8_t *pubKey, uint16_t pubKeyLen) { + if (pubKey == NULL || pubKeyLen < PK_LEN_SECP256K1_UNCOMPRESSED) { + return zxerr_invalid_crypto_settings; + } + cx_ecfp_public_key_t cx_publicKey = {0}; cx_ecfp_private_key_t cx_privateKey = {0}; - uint8_t privateKeyData[32] = {0}; + uint8_t privateKeyData[64] = {0}; + + zxerr_t error = zxerr_unknown; + // Generate keys + CATCH_CXERROR(os_derive_bip32_with_seed_no_throw(HDW_NORMAL, + CX_CURVE_256K1, + hdPath, + HDPATH_LEN_DEFAULT, + privateKeyData, + NULL, + NULL, + 0)) + + CATCH_CXERROR(cx_ecfp_init_private_key_no_throw(CX_CURVE_256K1, privateKeyData, 32, &cx_privateKey)) + CATCH_CXERROR(cx_ecfp_init_public_key_no_throw(CX_CURVE_256K1, NULL, 0, &cx_publicKey)) + CATCH_CXERROR(cx_ecfp_generate_pair_no_throw(CX_CURVE_256K1, &cx_publicKey, &cx_privateKey, 1)) + memcpy(pubKey, cx_publicKey.W, PK_LEN_SECP256K1_UNCOMPRESSED); + error = zxerr_ok; - if (pubKeyLen < PK_LEN_SECP256K1_UNCOMPRESSED) { - return zxerr_invalid_crypto_settings; - } +catch_cx_error: + MEMZERO(&cx_privateKey, sizeof(cx_privateKey)); + MEMZERO(privateKeyData, sizeof(privateKeyData)); - volatile zxerr_t err = zxerr_unknown; - BEGIN_TRY - { - TRY { - os_perso_derive_node_bip32(CX_CURVE_256K1, - path, - HDPATH_LEN_DEFAULT, - privateKeyData, NULL); - - cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &cx_privateKey); - cx_ecfp_init_public_key(CX_CURVE_256K1, NULL, 0, &cx_publicKey); - cx_ecfp_generate_pair(CX_CURVE_256K1, &cx_publicKey, &cx_privateKey, 1); - err = zxerr_ok; - } - CATCH_OTHER(e) { - err = zxerr_ledger_api_error; - } - FINALLY { - MEMZERO(&cx_privateKey, sizeof(cx_privateKey)); - MEMZERO(privateKeyData, 32); - } + if (error != zxerr_ok) { + MEMZERO(pubKey, pubKeyLen); } - END_TRY; - memcpy(pubKey, cx_publicKey.W, PK_LEN_SECP256K1_UNCOMPRESSED); - return err; + return error; } __Z_INLINE zxerr_t compressPubkey(const uint8_t *pubkey, uint16_t pubkeyLen, uint8_t *output, uint16_t outputLen) { @@ -116,9 +118,13 @@ static zxerr_t crypto_hashBuffer(const uint8_t *input, const uint16_t inputLen, return zxerr_ok; } -zxerr_t crypto_sign(uint8_t *signature, - uint16_t signatureMaxlen, +zxerr_t crypto_sign(uint8_t *output, + uint16_t outputLen, uint16_t *sigSize) { + if (output == NULL || sigSize == NULL || outputLen < MAX_DER_SIGNATURE_LEN) { + return zxerr_invalid_crypto_settings; + } + uint8_t messageDigest[CX_SHA256_SIZE] = {0}; // Hash it @@ -129,77 +135,47 @@ zxerr_t crypto_sign(uint8_t *signature, CHECK_APP_CANARY() cx_ecfp_private_key_t cx_privateKey; - uint8_t privateKeyData[32]; - unsigned int info = 0; - volatile int signatureLength = 0; - - volatile zxerr_t err = zxerr_unknown; - BEGIN_TRY - { - TRY - { - // Generate keys - os_perso_derive_node_bip32(CX_CURVE_SECP256K1, - hdPath, - HDPATH_LEN_DEFAULT, - privateKeyData, NULL); - - cx_ecfp_init_private_key(CX_CURVE_SECP256K1, privateKeyData, 32, &cx_privateKey); - - // Sign - signatureLength = cx_ecdsa_sign(&cx_privateKey, - CX_RND_RFC6979 | CX_LAST, - CX_SHA256, - messageDigest, - CX_SHA256_SIZE, - signature, - signatureMaxlen, - &info); - err = zxerr_ok; - } - CATCH_OTHER(e) { - err = zxerr_ledger_api_error; - } - FINALLY { - MEMZERO(&cx_privateKey, sizeof(cx_privateKey)); - MEMZERO(privateKeyData, 32); - } - } - END_TRY; - + uint8_t privateKeyData[64] = {0}; + size_t signatureLength = MAX_DER_SIGNATURE_LEN; + uint32_t tmpInfo = 0; + *sigSize = 0; + + zxerr_t error = zxerr_unknown; + + CATCH_CXERROR(os_derive_bip32_with_seed_no_throw(HDW_NORMAL, + CX_CURVE_256K1, + hdPath, + HDPATH_LEN_DEFAULT, + privateKeyData, + NULL, + NULL, + 0)) + CATCH_CXERROR(cx_ecfp_init_private_key_no_throw(CX_CURVE_256K1, privateKeyData, 32, &cx_privateKey)) + CATCH_CXERROR(cx_ecdsa_sign_no_throw(&cx_privateKey, + CX_RND_RFC6979 | CX_LAST, + CX_SHA256, + messageDigest, + CX_SHA256_SIZE, + output, + &signatureLength, &tmpInfo)) *sigSize = signatureLength; - return err; -} + error = zxerr_ok; -uint8_t extractHRP(uint32_t rx, uint32_t offset) { - if (rx < offset + 1) { - THROW(APDU_CODE_DATA_INVALID); - } - MEMZERO(bech32_hrp, MAX_BECH32_HRP_LEN); - - bech32_hrp_len = G_io_apdu_buffer[offset]; +catch_cx_error: + MEMZERO(&cx_privateKey, sizeof(cx_privateKey)); + MEMZERO(privateKeyData, sizeof(privateKeyData)); - if (bech32_hrp_len == 0 || bech32_hrp_len > MAX_BECH32_HRP_LEN) { - THROW(APDU_CODE_DATA_INVALID); + if (error != zxerr_ok) { + MEMZERO(output, outputLen); } - memcpy(bech32_hrp, G_io_apdu_buffer + offset + 1, bech32_hrp_len); - bech32_hrp[bech32_hrp_len] = 0; // zero terminate - - return bech32_hrp_len; + return error; } void ripemd160_32(uint8_t *out, uint8_t *in) { cx_ripemd160_t rip160; cx_ripemd160_init(&rip160); - cx_hash(&rip160.header, CX_LAST, in, CX_SHA256_SIZE, out, CX_RIPEMD160_SIZE); -} - -void crypto_set_hrp(char *p) { - bech32_hrp_len = strlen(p); - if (bech32_hrp_len < MAX_BECH32_HRP_LEN) { - snprintf(bech32_hrp, sizeof(bech32_hrp), "%s", p); - } + cx_hash_no_throw(&rip160.header, CX_LAST, in, CX_SHA256_SIZE, out, CX_RIPEMD160_SIZE); } zxerr_t crypto_fillAddress(uint8_t *buffer, uint16_t buffer_len, uint16_t *addrResponseLen) { @@ -209,7 +185,7 @@ zxerr_t crypto_fillAddress(uint8_t *buffer, uint16_t buffer_len, uint16_t *addrR // extract pubkey uint8_t uncompressedPubkey [PK_LEN_SECP256K1_UNCOMPRESSED] = {0}; - CHECK_ZXERR(crypto_extractUncompressedPublicKey(hdPath, uncompressedPubkey, sizeof(uncompressedPubkey))) + CHECK_ZXERR(crypto_extractUncompressedPublicKey(uncompressedPubkey, sizeof(uncompressedPubkey))) CHECK_ZXERR(compressPubkey(uncompressedPubkey, sizeof(uncompressedPubkey), buffer, buffer_len)) char *addr = (char *) (buffer + PK_LEN_SECP256K1); @@ -230,7 +206,7 @@ zxerr_t crypto_fillAddress(uint8_t *buffer, uint16_t buffer_len, uint16_t *addrR if (cx_keccak_init_no_throw(&ctx, 256) != CX_OK) { return zxerr_unknown; } - cx_hash((cx_hash_t *)&ctx, CX_LAST, uncompressedPubkey+1, sizeof(uncompressedPubkey)-1, hashed1_pk, sizeof(hashed1_pk)); + cx_hash_no_throw((cx_hash_t *)&ctx, CX_LAST, uncompressedPubkey+1, sizeof(uncompressedPubkey)-1, hashed1_pk, sizeof(hashed1_pk)); CHECK_ZXERR(bech32EncodeFromBytes(addr, buffer_len - PK_LEN_SECP256K1, bech32_hrp, hashed1_pk + 12, sizeof(hashed1_pk) - 12, 1, BECH32_ENCODING_BECH32)) break; } diff --git a/app/src/crypto.h b/app/src/crypto.h index 6a7d319f..12a0ea6e 100644 --- a/app/src/crypto.h +++ b/app/src/crypto.h @@ -33,8 +33,6 @@ extern char bech32_hrp[MAX_BECH32_HRP_LEN + 1]; extern uint8_t bech32_hrp_len; extern address_encoding_e encoding; -uint8_t extractHRP(uint32_t rx, uint32_t offset); - void crypto_set_hrp(char *p); zxerr_t crypto_fillAddress(uint8_t *buffer, uint16_t bufferLen, uint16_t *addrResponseLen); diff --git a/deps/ledger-zxlib b/deps/ledger-zxlib index bae8872f..37aeeff6 160000 --- a/deps/ledger-zxlib +++ b/deps/ledger-zxlib @@ -1 +1 @@ -Subproject commit bae8872fb572e3fb79f34813800c7981d4d01050 +Subproject commit 37aeeff64192e71b5cff0b4295a58b57a4d91fbc diff --git a/docs/APDUSPEC.md b/docs/APDUSPEC.md index 11c71043..4bc751f1 100644 --- a/docs/APDUSPEC.md +++ b/docs/APDUSPEC.md @@ -63,7 +63,7 @@ The general structure of commands and responses is as follows: -------------- -### INS_GET_ADDR_SECP256K1 +### INS_GET_ADDR #### Command @@ -78,7 +78,7 @@ The general structure of commands and responses is as follows: | HRP_LEN | byte(1) | Bech32 HRP Length | 1<=HRP_LEN<=83 | | HRP | byte (HRP_LEN) | Bech32 HRP | | | Path[0] | byte (4) | Derivation Path Data | 44 | -| Path[1] | byte (4) | Derivation Path Data | 118 | +| Path[1] | byte (4) | Derivation Path Data | 118 / 60 | | Path[2] | byte (4) | Derivation Path Data | ? | | Path[3] | byte (4) | Derivation Path Data | ? | | Path[4] | byte (4) | Derivation Path Data | ? | @@ -93,7 +93,7 @@ First three items in the derivation path will be hardened automatically hardened | ADDR | byte (65) | Bech 32 addr | | | SW1-SW2 | byte (2) | Return code | see list of return codes | -### SIGN_SECP256K1 +### INS_SIGN #### Command @@ -107,7 +107,8 @@ First three items in the derivation path will be hardened automatically hardened | P2 | byte (1) | ---- | not used | | L | byte (1) | Bytes in payload | (depends) | -The first packet/chunk includes only the derivation path +The first packet/chunk includes only the derivation path and HRP. +At the moment, seding HRP is optional but it will be mandatory in a future version. All other packets/chunks should contain message to sign @@ -115,11 +116,13 @@ All other packets/chunks should contain message to sign | Field | Type | Content | Expected | | ---------- | -------- | ---------------------- | --------- | -| Path[0] | byte (4) | Derivation Path Data | 44 | -| Path[1] | byte (4) | Derivation Path Data | 118 | -| Path[2] | byte (4) | Derivation Path Data | ? | -| Path[3] | byte (4) | Derivation Path Data | ? | -| Path[4] | byte (4) | Derivation Path Data | ? | +| Path[0] | byte (4) | Derivation Path Data | 44 | +| Path[1] | byte (4) | Derivation Path Data | 118 / 60 | +| Path[2] | byte (4) | Derivation Path Data | ? | +| Path[3] | byte (4) | Derivation Path Data | ? | +| Path[4] | byte (4) | Derivation Path Data | ? | +| HRP_LEN | byte(1) | Bech32 HRP Length | 1<=HRP_LEN<=83 | +| HRP | byte (HRP_LEN) | Bech32 HRP | | *Other Chunks/Packets* diff --git a/tests_zemu/package.json b/tests_zemu/package.json index 2354bf91..eb6bd2da 100644 --- a/tests_zemu/package.json +++ b/tests_zemu/package.json @@ -18,31 +18,31 @@ "test": "yarn clean && jest --maxConcurrency 2" }, "dependencies": { - "@zondax/zemu": "^0.42.1", - "@zondax/ledger-cosmos-js": "^3.0.0" + "@zondax/ledger-cosmos-js": "^3.0.3", + "@zondax/zemu": "^0.43.1" }, "devDependencies": { - "@types/jest": "^29.4.0", + "@types/jest": "^29.5.3", "@types/ledgerhq__hw-transport": "^4.21.4", - "@typescript-eslint/eslint-plugin": "^5.52.0", - "@typescript-eslint/parser": "^5.52.0", + "@typescript-eslint/eslint-plugin": "^6.0.0", + "@typescript-eslint/parser": "^6.0.0", + "bech32": "^2.0.0", "blakejs": "^1.1.1", "crypto-js": "4.1.1", - "eslint": "^8.34.0", + "eslint": "^8.44.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-import": "^2.25.4", "eslint-plugin-jest": "^27.2.1", - "eslint-plugin-prettier": "^4.0.0", - "jest": "29.4.2", + "eslint-plugin-prettier": "^5.0.0", + "jest": "29.6.1", "jest-serial-runner": "^1.1.0", "js-sha3": "0.8.0", "jssha": "^3.2.0", - "prettier": "^2.5.1", - "secp256k1": "^4.0.3", - "ts-jest": "^29.0.5", - "ts-node": "^10.9.1", "keccak256": "^1.0.6", - "bech32": "^2.0.0", + "prettier": "^3.0.0", + "secp256k1": "^5.0.0", + "ts-jest": "^29.1.1", + "ts-node": "^10.9.1", "typescript": "^5.0.4" } } diff --git a/tests_zemu/snapshots/s-mainmenu/00004.png b/tests_zemu/snapshots/s-mainmenu/00004.png index 1ede1af1..5c2e7827 100644 Binary files a/tests_zemu/snapshots/s-mainmenu/00004.png and b/tests_zemu/snapshots/s-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/s-mainmenu/00010.png b/tests_zemu/snapshots/s-mainmenu/00010.png index 1ede1af1..5c2e7827 100644 Binary files a/tests_zemu/snapshots/s-mainmenu/00010.png and b/tests_zemu/snapshots/s-mainmenu/00010.png differ diff --git a/tests_zemu/snapshots/sp-mainmenu/00004.png b/tests_zemu/snapshots/sp-mainmenu/00004.png index a3922694..e88f0b3f 100644 Binary files a/tests_zemu/snapshots/sp-mainmenu/00004.png and b/tests_zemu/snapshots/sp-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/sp-mainmenu/00010.png b/tests_zemu/snapshots/sp-mainmenu/00010.png index a3922694..e88f0b3f 100644 Binary files a/tests_zemu/snapshots/sp-mainmenu/00010.png and b/tests_zemu/snapshots/sp-mainmenu/00010.png differ diff --git a/tests_zemu/snapshots/st-mainmenu/00001.png b/tests_zemu/snapshots/st-mainmenu/00001.png index 841da079..eb93bdd4 100644 Binary files a/tests_zemu/snapshots/st-mainmenu/00001.png and b/tests_zemu/snapshots/st-mainmenu/00001.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00001.png b/tests_zemu/snapshots/x-ibc_denoms/00001.png index 70772708..b8f6cdc1 100644 Binary files a/tests_zemu/snapshots/x-ibc_denoms/00001.png and b/tests_zemu/snapshots/x-ibc_denoms/00001.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00002.png b/tests_zemu/snapshots/x-ibc_denoms/00002.png index 46ba8198..1009a3c2 100644 Binary files a/tests_zemu/snapshots/x-ibc_denoms/00002.png and b/tests_zemu/snapshots/x-ibc_denoms/00002.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00003.png b/tests_zemu/snapshots/x-ibc_denoms/00003.png index e42e6ee7..da1b3f2b 100644 Binary files a/tests_zemu/snapshots/x-ibc_denoms/00003.png and b/tests_zemu/snapshots/x-ibc_denoms/00003.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00004.png b/tests_zemu/snapshots/x-ibc_denoms/00004.png index 19374588..58eed79e 100644 Binary files a/tests_zemu/snapshots/x-ibc_denoms/00004.png and b/tests_zemu/snapshots/x-ibc_denoms/00004.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00005.png b/tests_zemu/snapshots/x-ibc_denoms/00005.png index e234dbb0..b5ec39f8 100644 Binary files a/tests_zemu/snapshots/x-ibc_denoms/00005.png and b/tests_zemu/snapshots/x-ibc_denoms/00005.png differ diff --git a/tests_zemu/snapshots/x-ibc_denoms/00006.png b/tests_zemu/snapshots/x-ibc_denoms/00006.png index a1980245..5d38a7e5 100644 Binary files a/tests_zemu/snapshots/x-ibc_denoms/00006.png and b/tests_zemu/snapshots/x-ibc_denoms/00006.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00001.png b/tests_zemu/snapshots/x-mainmenu/00001.png index e10e0049..8472e5d9 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00001.png and b/tests_zemu/snapshots/x-mainmenu/00001.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00002.png b/tests_zemu/snapshots/x-mainmenu/00002.png index 7e236da6..f7921677 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00002.png and b/tests_zemu/snapshots/x-mainmenu/00002.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00003.png b/tests_zemu/snapshots/x-mainmenu/00003.png index e10e0049..8472e5d9 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00003.png and b/tests_zemu/snapshots/x-mainmenu/00003.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00004.png b/tests_zemu/snapshots/x-mainmenu/00004.png index a3922694..e88f0b3f 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00004.png and b/tests_zemu/snapshots/x-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00010.png b/tests_zemu/snapshots/x-mainmenu/00010.png index a3922694..e88f0b3f 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00010.png and b/tests_zemu/snapshots/x-mainmenu/00010.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00011.png b/tests_zemu/snapshots/x-mainmenu/00011.png index e10e0049..8472e5d9 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00011.png and b/tests_zemu/snapshots/x-mainmenu/00011.png differ diff --git a/tests_zemu/snapshots/x-show_address/00001.png b/tests_zemu/snapshots/x-show_address/00001.png index 4a1aa7e1..79a82065 100644 Binary files a/tests_zemu/snapshots/x-show_address/00001.png and b/tests_zemu/snapshots/x-show_address/00001.png differ diff --git a/tests_zemu/snapshots/x-show_eth_address/00001.png b/tests_zemu/snapshots/x-show_eth_address/00001.png index 84ed31e4..35024425 100644 Binary files a/tests_zemu/snapshots/x-show_eth_address/00001.png and b/tests_zemu/snapshots/x-show_eth_address/00001.png differ diff --git a/tests_zemu/snapshots/x-sign_basic/00002.png b/tests_zemu/snapshots/x-sign_basic/00002.png index b47dabb4..5a83f183 100644 Binary files a/tests_zemu/snapshots/x-sign_basic/00002.png and b/tests_zemu/snapshots/x-sign_basic/00002.png differ diff --git a/tests_zemu/snapshots/x-sign_basic/00003.png b/tests_zemu/snapshots/x-sign_basic/00003.png index 4e0f2906..88e82f3d 100644 Binary files a/tests_zemu/snapshots/x-sign_basic/00003.png and b/tests_zemu/snapshots/x-sign_basic/00003.png differ diff --git a/tests_zemu/snapshots/x-sign_basic2/00003.png b/tests_zemu/snapshots/x-sign_basic2/00003.png index 17f84d47..c9e22f2d 100644 Binary files a/tests_zemu/snapshots/x-sign_basic2/00003.png and b/tests_zemu/snapshots/x-sign_basic2/00003.png differ diff --git a/tests_zemu/snapshots/x-sign_basic2/00004.png b/tests_zemu/snapshots/x-sign_basic2/00004.png index 0e82ee25..262628b3 100644 Binary files a/tests_zemu/snapshots/x-sign_basic2/00004.png and b/tests_zemu/snapshots/x-sign_basic2/00004.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_eth/00003.png b/tests_zemu/snapshots/x-sign_basic_eth/00003.png index 7da06771..8f46e011 100644 Binary files a/tests_zemu/snapshots/x-sign_basic_eth/00003.png and b/tests_zemu/snapshots/x-sign_basic_eth/00003.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_eth/00005.png b/tests_zemu/snapshots/x-sign_basic_eth/00005.png index d5c15863..88e2d4c9 100644 Binary files a/tests_zemu/snapshots/x-sign_basic_eth/00005.png and b/tests_zemu/snapshots/x-sign_basic_eth/00005.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_eth/00006.png b/tests_zemu/snapshots/x-sign_basic_eth/00006.png index b47dabb4..5a83f183 100644 Binary files a/tests_zemu/snapshots/x-sign_basic_eth/00006.png and b/tests_zemu/snapshots/x-sign_basic_eth/00006.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_eth/00007.png b/tests_zemu/snapshots/x-sign_basic_eth/00007.png index d5c15863..88e2d4c9 100644 Binary files a/tests_zemu/snapshots/x-sign_basic_eth/00007.png and b/tests_zemu/snapshots/x-sign_basic_eth/00007.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_eth/00008.png b/tests_zemu/snapshots/x-sign_basic_eth/00008.png index 4e0f2906..88e82f3d 100644 Binary files a/tests_zemu/snapshots/x-sign_basic_eth/00008.png and b/tests_zemu/snapshots/x-sign_basic_eth/00008.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_eth_warning/00000.png b/tests_zemu/snapshots/x-sign_basic_eth_warning/00000.png index 53e74dc2..50d75f83 100644 Binary files a/tests_zemu/snapshots/x-sign_basic_eth_warning/00000.png and b/tests_zemu/snapshots/x-sign_basic_eth_warning/00000.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_extra_fields/00002.png b/tests_zemu/snapshots/x-sign_basic_extra_fields/00002.png index b47dabb4..5a83f183 100644 Binary files a/tests_zemu/snapshots/x-sign_basic_extra_fields/00002.png and b/tests_zemu/snapshots/x-sign_basic_extra_fields/00002.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_extra_fields/00003.png b/tests_zemu/snapshots/x-sign_basic_extra_fields/00003.png index 4e0f2906..88e82f3d 100644 Binary files a/tests_zemu/snapshots/x-sign_basic_extra_fields/00003.png and b/tests_zemu/snapshots/x-sign_basic_extra_fields/00003.png differ diff --git a/tests_zemu/tests/standard.test.ts b/tests_zemu/tests/standard.test.ts index 29987414..e36e759e 100644 --- a/tests_zemu/tests/standard.test.ts +++ b/tests_zemu/tests/standard.test.ts @@ -431,20 +431,15 @@ test.concurrent.each(DEVICE_MODELS)('sign basic normal Eth', async function (m) const path = [44, 60, 0, 0, 0] const tx = Buffer.from(JSON.stringify(example_tx_str_basic), "utf-8") + const hrp = 'inj' // check with invalid HRP const errorRespPk = await app.getAddressAndPubKey(path, 'forbiddenHRP') expect(errorRespPk.return_code).toEqual(0x6986) expect(errorRespPk.error_message).toEqual('Transaction rejected') - // get address / publickey - const respPk = await app.getAddressAndPubKey(path, 'inj') - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') - console.log(respPk) - // do not wait here.. - const signatureRequest = app.sign(path, tx) + const signatureRequest = app.sign(path, tx, hrp) // Wait until we are not in the main menu await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) @@ -457,6 +452,12 @@ test.concurrent.each(DEVICE_MODELS)('sign basic normal Eth', async function (m) expect(resp.error_message).toEqual('No errors') expect(resp).toHaveProperty('signature') + // get address / publickey + const respPk = await app.getAddressAndPubKey(path, hrp) + expect(respPk.return_code).toEqual(0x9000) + expect(respPk.error_message).toEqual('No errors') + console.log(respPk) + // Now verify the signature const sha3 = require('js-sha3') const msgHash = Buffer.from(sha3.keccak256(tx), 'hex')