Skip to content

Commit

Permalink
Merge pull request #106 from cosmos/dev
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
ftheirs committed Dec 29, 2023
2 parents 697dbd7 + 4783d05 commit 80fa74d
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 37 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/guidelines_enforcer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ jobs:
guidelines_enforcer:
name: Call Ledger guidelines_enforcer
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_guidelines_enforcer.yml@v1
with:
relative_app_directory: 'app'
1 change: 0 additions & 1 deletion app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ endif

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

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

$(info TARGET_NAME = [$(TARGET_NAME)])
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=35
# This is the patch version of this release
APPVERSION_P=15
APPVERSION_P=16
35 changes: 18 additions & 17 deletions app/src/crypto.c
Original file line number Diff line number Diff line change
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 @@ -122,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 @@ -140,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 @@ -163,10 +163,11 @@ zxerr_t crypto_sign(uint8_t *output,
return error;
}

void ripemd160_32(uint8_t *out, uint8_t *in) {
static zxerr_t 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);
CHECK_CX_OK(cx_ripemd160_init_no_throw(&rip160));
CHECK_CX_OK(cx_hash_no_throw(&rip160.header, CX_LAST, in, CX_SHA256_SIZE, out, CX_RIPEMD160_SIZE));
return zxerr_ok;
}

zxerr_t crypto_fillAddress(uint8_t *buffer, uint16_t buffer_len, uint16_t *addrResponseLen) {
Expand All @@ -176,8 +177,8 @@ 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(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 @@ -187,8 +188,8 @@ zxerr_t crypto_fillAddress(uint8_t *buffer, uint16_t buffer_len, uint16_t *addrR
// Hash it
cx_hash_sha256(buffer, PK_LEN_SECP256K1, hashed1_pk, CX_SHA256_SIZE);
uint8_t hashed2_pk[CX_RIPEMD160_SIZE] = {0};
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))
CHECK_ZXERR(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));
break;
}

Expand All @@ -197,8 +198,8 @@ 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_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_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;
}

Expand Down
2 changes: 1 addition & 1 deletion deps/nanosplus-secure-sdk
Submodule nanosplus-secure-sdk updated 98 files
+0 −2 .github/workflows/build_all_apps.yml
+26 −0 Makefile
+126 −0 Makefile.app_params
+9 −23 Makefile.defines
+18 −11 Makefile.glyphs
+54 −6 Makefile.rules
+46 −22 Makefile.rules_generic
+10 −14 Makefile.standard_app
+7 −1 README.md
+1 −3 doc/Doxyfile
+6 −6 doc/mainpage.dox
+20 −0 extract_param.py
+0 −1 include/checks.h
+156 −0 include/ledger_assert.h
+4 −0 include/os.h
+4 −0 include/os_endorsement.h
+1 −0 include/os_ux.h
+53 −52 include/syscalls.h
+192 −0 install_params.py
+1 −1 lib_cxng/src/cx_cmac.c
+2 −1 lib_cxng/src/cx_hmac.c
+1 −1 lib_nbgl/doc/mainpage.dox
+4 −9 lib_nbgl/doc/mainpage_nanos.dox
+0 −1 lib_nbgl/doc/nbgl_layout.dox
+5 −6 lib_nbgl/doc/nbgl_page.dox
+7 −7 lib_nbgl/doc/nbgl_use_case.dox
+208 −244 lib_nbgl/doc/nbgl_use_case_nanos.dox
+ lib_nbgl/doc/resources/UseCase-Nano-About1.png
+ lib_nbgl/doc/resources/UseCase-Nano-Home.png
+ lib_nbgl/doc/resources/UseCase-Nano-Review1.png
+ lib_nbgl/doc/resources/UseCase-Review-Transitions.png
+ lib_nbgl/doc/resources/UseCase-Status.png
+ lib_nbgl/doc/resources/page3.png
+ lib_nbgl/glyphs_nano/icon_back_x.gif
+ lib_nbgl/glyphs_nano/icon_backspace.gif
+ lib_nbgl/glyphs_nano/icon_backspace_invert.gif
+ lib_nbgl/glyphs_nano/icon_certificate.gif
+ lib_nbgl/glyphs_nano/icon_classes.gif
+ lib_nbgl/glyphs_nano/icon_classes_invert.gif
+ lib_nbgl/glyphs_nano/icon_crossmark.gif
+ lib_nbgl/glyphs_nano/icon_dashboard_x.gif
+ lib_nbgl/glyphs_nano/icon_digits.gif
+ lib_nbgl/glyphs_nano/icon_digits_invert.gif
+ lib_nbgl/glyphs_nano/icon_down.gif
+ lib_nbgl/glyphs_nano/icon_eye.gif
+ lib_nbgl/glyphs_nano/icon_left.gif
+ lib_nbgl/glyphs_nano/icon_lowercase.gif
+ lib_nbgl/glyphs_nano/icon_lowercase_invert.gif
+ lib_nbgl/glyphs_nano/icon_right.gif
+ lib_nbgl/glyphs_nano/icon_up.gif
+ lib_nbgl/glyphs_nano/icon_uppercase.gif
+ lib_nbgl/glyphs_nano/icon_uppercase_invert.gif
+ lib_nbgl/glyphs_nano/icon_validate.gif
+ lib_nbgl/glyphs_nano/icon_validate_10.gif
+ lib_nbgl/glyphs_nano/icon_validate_14.gif
+ lib_nbgl/glyphs_nano/icon_validate_invert.gif
+ lib_nbgl/glyphs_nano/pin_bullet_empty.gif
+ lib_nbgl/glyphs_nano/pin_bullet_filled.gif
+0 −1 lib_nbgl/include/nbgl_font_rom.inc
+0 −4 lib_nbgl/include/nbgl_font_rom_struct.inc
+0 −1 lib_nbgl/include/nbgl_fonts.h
+0 −1 lib_nbgl/include/nbgl_layout.h
+0 −1 lib_nbgl/include/nbgl_obj.h
+13 −0 lib_nbgl/include/nbgl_use_case.h
+2 −2 lib_nbgl/serialization/generate_data_test.c
+4 −6 lib_nbgl/serialization/nbgl_lib.py
+2 −2 lib_nbgl/serialization/test_bytes_deserialize.py
+2 −2 lib_nbgl/serialization/test_json_ser_deser.py
+16 −8 lib_nbgl/src/nbgl_flow.c
+5 −2 lib_nbgl/src/nbgl_fonts.c
+17 −21 lib_nbgl/src/nbgl_layout.c
+0 −28 lib_nbgl/src/nbgl_obj.c
+8 −12 lib_nbgl/src/nbgl_obj_keypad.c
+6 −6 lib_nbgl/src/nbgl_page.c
+8 −6 lib_nbgl/src/nbgl_serialize.c
+4 −5 lib_nbgl/src/nbgl_touch.c
+100 −3 lib_nbgl/src/nbgl_use_case.c
+75 −22 lib_nbgl/src/nbgl_use_case_nanos.c
+0 −71 lib_standard_app/debug.c
+0 −3 lib_standard_app/debug.h
+0 −2 lib_standard_app/io.c
+5 −5 lib_standard_app/main.c
+7 −0 lib_ux/include/ux.h
+28 −4 lib_ux_stax/ux.c
+15 −0 lib_ux_stax/ux.h
+76 −0 src/app_metadata.c
+5 −2 src/checks.c
+147 −0 src/ledger_assert.c
+13 −15 src/os.c
+7 −0 src/os_io_seproxyhal.c
+12 −0 src/syscalls.c
+13 −0 target/nanos/script.ld
+13 −0 target/nanos2/script.ld
+13 −0 target/nanox/script.ld
+13 −0 target/stax/script.ld
+3 −4 tools/ttf2inc.py
+0 −1 unit-tests/lib_nbgl/nbgl_stubs.c
+1 −1 unit-tests/lib_nbgl/test_nbgl_obj.c
2 changes: 1 addition & 1 deletion deps/nanox-secure-sdk
Submodule nanox-secure-sdk updated 98 files
+0 −2 .github/workflows/build_all_apps.yml
+26 −0 Makefile
+126 −0 Makefile.app_params
+9 −23 Makefile.defines
+18 −11 Makefile.glyphs
+54 −6 Makefile.rules
+46 −22 Makefile.rules_generic
+10 −14 Makefile.standard_app
+7 −1 README.md
+1 −3 doc/Doxyfile
+6 −6 doc/mainpage.dox
+20 −0 extract_param.py
+0 −1 include/checks.h
+156 −0 include/ledger_assert.h
+4 −0 include/os.h
+4 −0 include/os_endorsement.h
+1 −0 include/os_ux.h
+53 −52 include/syscalls.h
+192 −0 install_params.py
+1 −1 lib_cxng/src/cx_cmac.c
+2 −1 lib_cxng/src/cx_hmac.c
+1 −1 lib_nbgl/doc/mainpage.dox
+4 −9 lib_nbgl/doc/mainpage_nanos.dox
+0 −1 lib_nbgl/doc/nbgl_layout.dox
+5 −6 lib_nbgl/doc/nbgl_page.dox
+7 −7 lib_nbgl/doc/nbgl_use_case.dox
+208 −244 lib_nbgl/doc/nbgl_use_case_nanos.dox
+ lib_nbgl/doc/resources/UseCase-Nano-About1.png
+ lib_nbgl/doc/resources/UseCase-Nano-Home.png
+ lib_nbgl/doc/resources/UseCase-Nano-Review1.png
+ lib_nbgl/doc/resources/UseCase-Review-Transitions.png
+ lib_nbgl/doc/resources/UseCase-Status.png
+ lib_nbgl/doc/resources/page3.png
+ lib_nbgl/glyphs_nano/icon_back_x.gif
+ lib_nbgl/glyphs_nano/icon_backspace.gif
+ lib_nbgl/glyphs_nano/icon_backspace_invert.gif
+ lib_nbgl/glyphs_nano/icon_certificate.gif
+ lib_nbgl/glyphs_nano/icon_classes.gif
+ lib_nbgl/glyphs_nano/icon_classes_invert.gif
+ lib_nbgl/glyphs_nano/icon_crossmark.gif
+ lib_nbgl/glyphs_nano/icon_dashboard_x.gif
+ lib_nbgl/glyphs_nano/icon_digits.gif
+ lib_nbgl/glyphs_nano/icon_digits_invert.gif
+ lib_nbgl/glyphs_nano/icon_down.gif
+ lib_nbgl/glyphs_nano/icon_eye.gif
+ lib_nbgl/glyphs_nano/icon_left.gif
+ lib_nbgl/glyphs_nano/icon_lowercase.gif
+ lib_nbgl/glyphs_nano/icon_lowercase_invert.gif
+ lib_nbgl/glyphs_nano/icon_right.gif
+ lib_nbgl/glyphs_nano/icon_up.gif
+ lib_nbgl/glyphs_nano/icon_uppercase.gif
+ lib_nbgl/glyphs_nano/icon_uppercase_invert.gif
+ lib_nbgl/glyphs_nano/icon_validate.gif
+ lib_nbgl/glyphs_nano/icon_validate_10.gif
+ lib_nbgl/glyphs_nano/icon_validate_14.gif
+ lib_nbgl/glyphs_nano/icon_validate_invert.gif
+ lib_nbgl/glyphs_nano/pin_bullet_empty.gif
+ lib_nbgl/glyphs_nano/pin_bullet_filled.gif
+0 −1 lib_nbgl/include/nbgl_font_rom.inc
+0 −4 lib_nbgl/include/nbgl_font_rom_struct.inc
+0 −1 lib_nbgl/include/nbgl_fonts.h
+0 −1 lib_nbgl/include/nbgl_layout.h
+0 −1 lib_nbgl/include/nbgl_obj.h
+13 −0 lib_nbgl/include/nbgl_use_case.h
+2 −2 lib_nbgl/serialization/generate_data_test.c
+4 −6 lib_nbgl/serialization/nbgl_lib.py
+2 −2 lib_nbgl/serialization/test_bytes_deserialize.py
+2 −2 lib_nbgl/serialization/test_json_ser_deser.py
+16 −8 lib_nbgl/src/nbgl_flow.c
+5 −2 lib_nbgl/src/nbgl_fonts.c
+17 −21 lib_nbgl/src/nbgl_layout.c
+0 −28 lib_nbgl/src/nbgl_obj.c
+8 −12 lib_nbgl/src/nbgl_obj_keypad.c
+6 −6 lib_nbgl/src/nbgl_page.c
+8 −6 lib_nbgl/src/nbgl_serialize.c
+4 −5 lib_nbgl/src/nbgl_touch.c
+100 −3 lib_nbgl/src/nbgl_use_case.c
+75 −22 lib_nbgl/src/nbgl_use_case_nanos.c
+0 −71 lib_standard_app/debug.c
+0 −3 lib_standard_app/debug.h
+0 −2 lib_standard_app/io.c
+5 −5 lib_standard_app/main.c
+7 −0 lib_ux/include/ux.h
+28 −4 lib_ux_stax/ux.c
+15 −0 lib_ux_stax/ux.h
+76 −0 src/app_metadata.c
+5 −2 src/checks.c
+147 −0 src/ledger_assert.c
+13 −15 src/os.c
+7 −0 src/os_io_seproxyhal.c
+12 −0 src/syscalls.c
+13 −0 target/nanos/script.ld
+13 −0 target/nanos2/script.ld
+13 −0 target/nanox/script.ld
+13 −0 target/stax/script.ld
+3 −4 tools/ttf2inc.py
+0 −1 unit-tests/lib_nbgl/nbgl_stubs.c
+1 −1 unit-tests/lib_nbgl/test_nbgl_obj.c
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/"
24 changes: 12 additions & 12 deletions tests_zemu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@
},
"dependencies": {
"@zondax/ledger-cosmos-js": "^3.0.3",
"@zondax/zemu": "^0.45.0"
"@zondax/zemu": "^0.46.0"
},
"devDependencies": {
"@types/jest": "^29.5.10",
"@types/jest": "^29.5.11",
"@types/ledgerhq__hw-transport": "^4.21.8",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"bech32": "^2.0.0",
"blakejs": "^1.1.1",
"crypto-js": "4.2.0",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-prettier": "^5.1.2",
"jest": "29.7.0",
"jest-serial-runner": "^1.1.0",
"js-sha3": "0.9.2",
"js-sha3": "0.9.3",
"jssha": "^3.2.0",
"keccak256": "^1.0.6",
"prettier": "^3.1.0",
"prettier": "^3.1.1",
"secp256k1": "^5.0.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.3.2"
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
}
}
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-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/st-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/x-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/x-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.

0 comments on commit 80fa74d

Please sign in to comment.