Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge branch Release 2.34.14 after P1 deployment #35

Merged
merged 15 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@ endif

APP_LOAD_PARAMS = --curve secp256k1 $(COMMON_LOAD_PARAMS) --path $(APPPATH)

NANOS_STACK_SIZE := 1890
include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.devices

# On zxlib v19.7.1, Makefile.devices will set a default value for APP_STACK_SIZE
# to follow the most recent nanos-secure-sdk rules we will clean APP_STACK_SIZE value
# and set a minimum value
APP_STACK_SIZE :=
APP_STACK_MIN_SIZE := 1444

$(info TARGET_NAME = [$(TARGET_NAME)])
$(info ICONNAME = [$(ICONNAME)])

Expand All @@ -64,7 +69,6 @@ endif

include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.platform

DEFINES += HAVE_HASH HAVE_BLAKE2 HAVE_SHA256 HAVE_SHA512
APP_SOURCE_PATH += $(MY_DIR)/../deps/jsmn/src

.PHONY: rust
Expand Down
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -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=12
APPVERSION_P=14
6 changes: 6 additions & 0 deletions app/src/chain_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ typedef struct {
static const chain_config_t chainConfig[] = {
// {118, cosmos, BECH32_COSMOS},
{60, "inj", BECH32_ETH},
{60, "evmos", BECH32_ETH},
{60, "xpla", BECH32_ETH},
{60, "dym", BECH32_ETH},
{60, "zeta", BECH32_ETH},
{60, "bera", BECH32_ETH},
{60, "human", BECH32_ETH}
};

static const uint32_t chainConfigLen = sizeof(chainConfig) / sizeof(chainConfig[0]);
Expand Down
53 changes: 17 additions & 36 deletions app/src/crypto.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* (c) 2019 Zondax GmbH
* (c) 2023 Zondax AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,11 +51,11 @@ static zxerr_t crypto_extractUncompressedPublicKey(uint8_t *pubKey, uint16_t pub
privateKeyData,
NULL,
NULL,
0))
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))
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;

Expand Down Expand Up @@ -89,7 +89,6 @@ __Z_INLINE zxerr_t compressPubkey(const uint8_t *pubkey, uint16_t pubkeyLen, uin
return zxerr_ok;
}


static zxerr_t crypto_hashBuffer(const uint8_t *input, const uint16_t inputLen,
uint8_t *output, uint16_t outputLen) {

Expand All @@ -100,15 +99,7 @@ static zxerr_t crypto_hashBuffer(const uint8_t *input, const uint16_t inputLen,
}

case BECH32_ETH: {
cx_sha3_t sha3 = {0};
cx_err_t status = cx_keccak_init_no_throw(&sha3, 256);
if (status != CX_OK) {
return zxerr_ledger_api_error;
}
status = cx_hash_no_throw((cx_hash_t*) &sha3, CX_LAST, input, inputLen, output, outputLen);
if (status != CX_OK) {
return zxerr_ledger_api_error;
}
CHECK_CX_OK(cx_keccak_256_hash(input, inputLen, output));
break;
}

Expand All @@ -131,7 +122,7 @@ zxerr_t crypto_sign(uint8_t *output,
const uint8_t *message = tx_get_buffer();
const uint16_t messageLen = tx_get_buffer_length();

CHECK_ZXERR(crypto_hashBuffer(message, messageLen, messageDigest, CX_SHA256_SIZE))
CHECK_ZXERR(crypto_hashBuffer(message, messageLen, messageDigest, CX_SHA256_SIZE));
CHECK_APP_CANARY()

cx_ecfp_private_key_t cx_privateKey;
Expand All @@ -149,15 +140,15 @@ zxerr_t crypto_sign(uint8_t *output,
privateKeyData,
NULL,
NULL,
0))
CATCH_CXERROR(cx_ecfp_init_private_key_no_throw(CX_CURVE_256K1, privateKeyData, 32, &cx_privateKey))
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))
&signatureLength, &tmpInfo));
*sigSize = signatureLength;
error = zxerr_ok;

Expand All @@ -172,21 +163,15 @@ zxerr_t crypto_sign(uint8_t *output,
return error;
}

void ripemd160_32(uint8_t *out, uint8_t *in) {
cx_ripemd160_t rip160;
cx_ripemd160_init(&rip160);
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) {
if (buffer_len < PK_LEN_SECP256K1 + 50) {
return zxerr_buffer_too_small;
}

// extract pubkey
uint8_t uncompressedPubkey [PK_LEN_SECP256K1_UNCOMPRESSED] = {0};
CHECK_ZXERR(crypto_extractUncompressedPublicKey(uncompressedPubkey, sizeof(uncompressedPubkey)))
CHECK_ZXERR(compressPubkey(uncompressedPubkey, sizeof(uncompressedPubkey), buffer, buffer_len))
CHECK_ZXERR(crypto_extractUncompressedPublicKey(uncompressedPubkey, sizeof(uncompressedPubkey)));
CHECK_ZXERR(compressPubkey(uncompressedPubkey, sizeof(uncompressedPubkey), buffer, buffer_len));
char *addr = (char *) (buffer + PK_LEN_SECP256K1);

uint8_t hashed1_pk[CX_SHA256_SIZE] = {0};
Expand All @@ -195,19 +180,15 @@ zxerr_t crypto_fillAddress(uint8_t *buffer, uint16_t buffer_len, uint16_t *addrR
case BECH32_COSMOS: {
// Hash it
cx_hash_sha256(buffer, PK_LEN_SECP256K1, hashed1_pk, CX_SHA256_SIZE);
uint8_t hashed2_pk[CX_RIPEMD160_SIZE];
ripemd160_32(hashed2_pk, hashed1_pk);
CHECK_ZXERR(bech32EncodeFromBytes(addr, buffer_len - PK_LEN_SECP256K1, bech32_hrp, hashed2_pk, CX_RIPEMD160_SIZE, 1, BECH32_ENCODING_BECH32))
uint8_t hashed2_pk[CX_RIPEMD160_SIZE] = {0};
CHECK_CX_OK(cx_ripemd160_hash(hashed1_pk, CX_SHA256_SIZE, hashed2_pk));
CHECK_ZXERR(bech32EncodeFromBytes(addr, buffer_len - PK_LEN_SECP256K1, bech32_hrp, hashed2_pk, CX_RIPEMD160_SIZE, 1, BECH32_ENCODING_BECH32));
break;
}

case BECH32_ETH: {
cx_sha3_t ctx;
if (cx_keccak_init_no_throw(&ctx, 256) != CX_OK) {
return zxerr_unknown;
}
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))
CHECK_CX_OK(cx_keccak_256_hash(uncompressedPubkey+1, sizeof(uncompressedPubkey)-1, 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;
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/json/json_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extern "C" {
// we must limit the number
#if defined(TARGET_NANOS)
#undef MAX_NUMBER_OF_TOKENS
#define MAX_NUMBER_OF_TOKENS 70
#define MAX_NUMBER_OF_TOKENS 96
#endif

#if defined(TARGET_STAX)
Expand Down
2 changes: 1 addition & 1 deletion deps/nanos-secure-sdk
Submodule nanos-secure-sdk updated 228 files
2 changes: 1 addition & 1 deletion deps/nanosplus-secure-sdk
2 changes: 1 addition & 1 deletion deps/nanox-secure-sdk
Submodule nanox-secure-sdk updated 2045 files
7 changes: 7 additions & 0 deletions ledger_app.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[app]
build_directory = "./app/"
sdk = "C"
devices = ["nanos", "nanox", "nanos+", "stax"]

[tests]
unit_directory = "./tests/"
16 changes: 8 additions & 8 deletions tests_zemu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@
},
"dependencies": {
"@zondax/ledger-cosmos-js": "^3.0.3",
"@zondax/zemu": "^0.43.1"
"@zondax/zemu": "^0.47.0"
},
"devDependencies": {
"@types/jest": "^29.5.3",
"@types/ledgerhq__hw-transport": "^4.21.4",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"bech32": "^2.0.0",
"blakejs": "^1.1.1",
"crypto-js": "4.1.1",
"crypto-js": "4.2.0",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "29.6.1",
"jest": "29.7.0",
"jest-serial-runner": "^1.1.0",
"js-sha3": "0.8.0",
"js-sha3": "0.9.3",
"jssha": "^3.2.0",
"keccak256": "^1.0.6",
"prettier": "^3.0.0",
Expand Down
Binary file modified tests_zemu/snapshots/s-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-ibc_denoms/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-ibc_denoms/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-ibc_denoms/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-ibc_denoms/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-ibc_denoms/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-ibc_denoms/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-show_address/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-show_eth_address/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-sign_basic/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-sign_basic/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-sign_basic2/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-sign_basic2/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-sign_basic_eth/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-sign_basic_eth/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-sign_basic_eth/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-sign_basic_eth/00007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-sign_basic_eth/00008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-sign_basic_eth_warning/00000.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_extra_fields/00002.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_extra_fields/00003.png
Binary file modified tests_zemu/snapshots/st-ibc_denoms/00000.png
Binary file modified tests_zemu/snapshots/st-ibc_denoms/00001.png
Binary file modified tests_zemu/snapshots/st-ibc_denoms/00002.png
Binary file modified tests_zemu/snapshots/st-ibc_denoms/00003.png
Binary file modified tests_zemu/snapshots/st-ibc_denoms/00004.png
Binary file modified tests_zemu/snapshots/st-ibc_denoms/00005.png
Binary file modified tests_zemu/snapshots/st-mainmenu/00000.png
Binary file modified tests_zemu/snapshots/st-mainmenu/00001.png
Binary file modified tests_zemu/snapshots/st-mainmenu/00002.png
Binary file modified tests_zemu/snapshots/st-mainmenu/00003.png
Binary file modified tests_zemu/snapshots/st-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/st-mainmenu/00005.png
Binary file modified tests_zemu/snapshots/st-show_address/00000.png
Binary file modified tests_zemu/snapshots/st-show_address/00001.png
Binary file modified tests_zemu/snapshots/st-show_address/00002.png
Binary file modified tests_zemu/snapshots/st-show_address_huge/00000.png
Binary file modified tests_zemu/snapshots/st-show_address_huge/00001.png
Binary file modified tests_zemu/snapshots/st-show_address_huge/00002.png
Binary file modified tests_zemu/snapshots/st-show_address_huge/00003.png
Binary file modified tests_zemu/snapshots/st-show_eth_address/00000.png
Binary file modified tests_zemu/snapshots/st-show_eth_address/00001.png
Binary file modified tests_zemu/snapshots/st-show_eth_address/00002.png
Binary file modified tests_zemu/snapshots/st-show_eth_address/00003.png
Binary file modified tests_zemu/snapshots/st-sign_basic/00000.png
Binary file modified tests_zemu/snapshots/st-sign_basic/00001.png
Binary file modified tests_zemu/snapshots/st-sign_basic/00002.png
Binary file modified tests_zemu/snapshots/st-sign_basic/00003.png
Binary file modified tests_zemu/snapshots/st-sign_basic/00004.png
Binary file modified tests_zemu/snapshots/st-sign_basic2/00000.png
Binary file modified tests_zemu/snapshots/st-sign_basic2/00001.png
Binary file modified tests_zemu/snapshots/st-sign_basic2/00002.png
Binary file modified tests_zemu/snapshots/st-sign_basic2/00003.png
Binary file modified tests_zemu/snapshots/st-sign_basic2/00004.png
Binary file modified tests_zemu/snapshots/st-sign_basic_eth/00000.png
Binary file modified tests_zemu/snapshots/st-sign_basic_eth/00001.png
Binary file modified tests_zemu/snapshots/st-sign_basic_eth/00002.png
Binary file modified tests_zemu/snapshots/st-sign_basic_eth/00003.png
Binary file modified tests_zemu/snapshots/st-sign_basic_eth/00004.png
Binary file modified tests_zemu/snapshots/st-sign_basic_eth/00005.png
Binary file modified tests_zemu/snapshots/st-sign_basic_eth/00006.png
Binary file modified tests_zemu/snapshots/st-sign_basic_eth_warning/00000.png
Binary file modified tests_zemu/snapshots/st-sign_basic_eth_warning/00001.png
Binary file modified tests_zemu/snapshots/st-sign_basic_extra_fields/00000.png
Binary file modified tests_zemu/snapshots/st-sign_basic_extra_fields/00001.png
Binary file modified tests_zemu/snapshots/st-sign_basic_extra_fields/00002.png
Binary file modified tests_zemu/snapshots/st-sign_basic_extra_fields/00003.png
Binary file modified tests_zemu/snapshots/st-sign_basic_extra_fields/00004.png
Binary file modified tests_zemu/snapshots/x-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/x-mainmenu/00010.png
Loading