diff --git a/.github/workflows/check_version.yml b/.github/workflows/check_version.yml index 0d5a2fb..0d0fdbe 100644 --- a/.github/workflows/check_version.yml +++ b/.github/workflows/check_version.yml @@ -7,7 +7,7 @@ on: - main - develop - master # for safety reasons - - dev # for safety reasons + - dev # for safety reasons jobs: configure: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 982f4cf..0676a18 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -8,7 +8,7 @@ on: - main - develop - master # for safety reasons - - dev # for safety reasons + - dev # for safety reasons jobs: analyse: @@ -17,7 +17,7 @@ jobs: if: github.event.repository.private == false strategy: matrix: - sdk: ["$NANOS_SDK", "$NANOX_SDK", "$NANOSP_SDK", "$STAX_SDK", "$FLEX_SDK"] + sdk: ["$NANOX_SDK", "$NANOSP_SDK", "$STAX_SDK", "$FLEX_SDK"] container: image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-legacy:latest diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f9a810..946949f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -58,61 +58,6 @@ jobs: cd ./app/rust cargo clippy --all-targets --features "clippy" - build_ledger: - needs: configure - runs-on: ubuntu-latest - container: - image: zondax/ledger-app-builder:latest - options: --user ${{ needs.configure.outputs.uid_gid }} - env: - BOLOS_SDK: /opt/nanos-secure-sdk - outputs: - size: ${{steps.build.outputs.size}} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Build Standard app - id: build - shell: bash -l {0} - run: | - make PRODUCTION_BUILD=0 - echo "size=$(python3 deps/ledger-zxlib/scripts/getSize.py s)" >> $GITHUB_OUTPUT - - build_ledger_production: - needs: configure - runs-on: ubuntu-latest - container: - image: zondax/ledger-app-builder:latest - options: --user ${{ needs.configure.outputs.uid_gid }} - env: - BOLOS_SDK: /opt/nanos-secure-sdk - outputs: - size: ${{steps.build.outputs.size}} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Build Production app - id: build - shell: bash -l {0} - run: | - make PRODUCTION_BUILD=1 - echo "size=$(python3 deps/ledger-zxlib/scripts/getSize.py s)" >> $GITHUB_OUTPUT - - size_nano_s: - needs: build_ledger - runs-on: ubuntu-latest - continue-on-error: true - env: - NANOS_LIMIT_SIZE: 136 - steps: - - run: | - echo "LNS app size: ${{needs.build_ledger.outputs.size}} KiB" - [ ${{needs.build_ledger.outputs.size}} -le $NANOS_LIMIT_SIZE ] - test_zemu: runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }} steps: @@ -157,41 +102,24 @@ jobs: name: snapshots-tmp path: tests_zemu/snapshots-tmp/ - build_package_nanos: - needs: [configure, build_ledger, test_zemu, rust_tests] - if: ${{ github.ref == 'refs/heads/master' }} + build_ledger: + needs: configure runs-on: ubuntu-latest container: image: zondax/ledger-app-builder:latest options: --user ${{ needs.configure.outputs.uid_gid }} env: - BOLOS_SDK: /opt/nanos-secure-sdk + BOLOS_SDK: /opt/nanosplus-secure-sdk steps: - name: Checkout uses: actions/checkout@v4 with: - submodules: true - - name: Install deps - run: pip install ledgerblue - - - name: Build NanoS + submodules: recursive + - name: Build Standard app + id: build shell: bash -l {0} run: | - PRODUCTION_BUILD=0 make - mv ./app/pkg/installer_s.sh ./app/pkg/installer_nanos.sh - - name: Set tag - id: nanos - run: echo "tag_name=$(./app/pkg/installer_nanos.sh version)" >> $GITHUB_OUTPUT - - name: Create or Update Release (1) - id: create_release_0 - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token - with: - files: ./app/pkg/installer_nanos.sh - tag_name: ${{ steps.nanos.outputs.tag_name }} - draft: false - prerelease: false + make PRODUCTION_BUILD=0 build_package_nanosp: needs: [configure, build_ledger, test_zemu, rust_tests] diff --git a/app/Makefile b/app/Makefile index e4c5c21..8b05e9b 100755 --- a/app/Makefile +++ b/app/Makefile @@ -52,14 +52,14 @@ DEFINES += PRODUCTION_BUILD=$(PRODUCTION_BUILD) include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.app_testing ifndef COIN -COIN=PEN +COIN=UM endif include $(CURDIR)/Makefile.version $(info COIN = [$(COIN)]) -ifeq ($(COIN), PEN) +ifeq ($(COIN), UM) # Main app configuration DEFINES += APP_STANDARD APPNAME = "Penumbra" @@ -160,7 +160,7 @@ dep/%.d: %.c Makefile .PHONY: listvariants listvariants: - @echo VARIANTS COIN PEN + @echo VARIANTS COIN UM .PHONY: version version: diff --git a/app/Makefile.version b/app/Makefile.version index 3881cb0..9a374df 100644 --- a/app/Makefile.version +++ b/app/Makefile.version @@ -3,4 +3,4 @@ APPVERSION_M=0 # This is the minor version APPVERSION_N=0 # This is the patch version -APPVERSION_P=1 +APPVERSION_P=2 diff --git a/app/src/addr.c b/app/src/addr.c index c23120f..377a316 100644 --- a/app/src/addr.c +++ b/app/src/addr.c @@ -28,6 +28,7 @@ #include "zxmacros.h" bool is_randomized = false; +uint32_t address_idx_account = 0; #define BECH32_PREFIX "penumbra" @@ -52,12 +53,8 @@ bool is_randomized = false; zxerr_t addr_getNumItems(uint8_t *num_items) { zemu_log_stack("addr_getNumItems"); - // address and is_randomized flag - *num_items = 2; - // in expert mode we show the path - if (app_mode_expert()) { - *num_items = 3; - } + // address, account and is_randomized flag + *num_items = 3; return zxerr_ok; } @@ -77,23 +74,27 @@ zxerr_t addr_getItem(int8_t displayIdx, char *outKey, uint16_t outKeyLen, char * if (ret < 0) return zxerr_unknown; pageString(outVal, outValLen, encoded_addr, pageIdx, pageCount); - return zxerr_ok; + case 1: { - snprintf(outKey, outKeyLen, "Randomized"); - const char *buffer = is_randomized ? "Yes" : "No"; + snprintf(outKey, outKeyLen, "Account"); + char buffer[100] = {0}; + ZEMU_LOGF(50, "[Account****] %d\n", address_idx_account) + + const char *err = NULL; + err = uint32_to_str(buffer, sizeof(buffer), address_idx_account); + + if (err != NULL) { + return zxerr_unknown; + } + pageString(outVal, outValLen, buffer, pageIdx, pageCount); return zxerr_ok; } case 2: { - if (!app_mode_expert()) { - return zxerr_no_data; - } - - snprintf(outKey, outKeyLen, "Your Path"); - char buffer[300]; - bip32_to_str(buffer, sizeof(buffer), hdPath, HDPATH_LEN_DEFAULT); + snprintf(outKey, outKeyLen, "Randomized"); + const char *buffer = is_randomized ? "Yes" : "No"; pageString(outVal, outValLen, buffer, pageIdx, pageCount); return zxerr_ok; diff --git a/app/src/apdu_handler.c b/app/src/apdu_handler.c index a68d39e..23062cf 100644 --- a/app/src/apdu_handler.c +++ b/app/src/apdu_handler.c @@ -43,13 +43,26 @@ void extractHDPath(uint32_t rx, uint32_t offset) { memcpy(hdPath, G_io_apdu_buffer + offset, sizeof(uint32_t) * HDPATH_LEN_DEFAULT); // #{TODO} --> testnet necessary? - const bool mainnet = hdPath[0] == HDPATH_0_DEFAULT && hdPath[1] == HDPATH_1_DEFAULT; + const bool mainnet = hdPath[0] == HDPATH_0_DEFAULT && hdPath[1] == HDPATH_1_DEFAULT && hdPath[2] == HDPATH_2_DEFAULT; if (!mainnet) { THROW(APDU_CODE_DATA_INVALID); } } +void extractAddressIndex(uint32_t rx, uint32_t offset, address_index_t *address_index) { + if (address_index == NULL) { + THROW(APDU_CODE_DATA_INVALID); + } + + // check for account data + if (rx < offset || (rx - offset) < sizeof(address_index_t)) { + THROW(APDU_CODE_WRONG_LENGTH); + } + + memcpy(address_index, &G_io_apdu_buffer[offset], sizeof(address_index_t)); +} + __Z_INLINE bool process_chunk(__Z_UNUSED volatile uint32_t *tx, uint32_t rx) { const uint8_t payloadType = G_io_apdu_buffer[OFFSET_PAYLOAD_TYPE]; if (rx < OFFSET_DATA) { @@ -104,30 +117,10 @@ __Z_INLINE void handleGetAddr(volatile uint32_t *flags, volatile uint32_t *tx, u const uint8_t requireConfirmation = G_io_apdu_buffer[OFFSET_P1]; // go to the account + randomizer data - uint32_t account_offset = OFFSET_DATA + sizeof(uint32_t) * HDPATH_LEN_DEFAULT; - uint32_t rand_offset = account_offset + sizeof(uint32_t); - - uint32_t account = 0; - - // check for account data - if (rx < account_offset || (rx - account_offset) < sizeof(uint32_t)) { - THROW(APDU_CODE_WRONG_LENGTH); - } - - U32_BE(&G_io_apdu_buffer[account_offset], account); + address_index_t address_index = {0}; + extractAddressIndex(rx, OFFSET_DATA + sizeof(uint32_t) * HDPATH_LEN_DEFAULT, &address_index); - uint8_t *randomizer = NULL; - uint8_t rand_data[ADDR_RANDOMIZER_LEN] = {0}; - - // check if we received the randomizer, if so check also we received - // the expected amount of bytes for it. - if (rx > rand_offset && (rx - rand_offset) >= ADDR_RANDOMIZER_LEN) { - memcpy(rand_data, &G_io_apdu_buffer[rand_offset], ADDR_RANDOMIZER_LEN); - randomizer = &rand_data[0]; - } - - // TODO: I have to send 0 instead of account to get the same result as penumbra repo - zxerr_t zxerr = app_fill_address(0, randomizer); + zxerr_t zxerr = app_fill_address(address_index); if (zxerr != zxerr_ok) { *tx = 0; @@ -219,6 +212,7 @@ __Z_INLINE void handle_getversion(__Z_UNUSED volatile uint32_t *flags, volatile void handleTest(volatile uint32_t *flags, volatile uint32_t *tx, uint32_t rx) { THROW(APDU_CODE_OK); } #endif +#if defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX) || defined(TARGET_FLEX) void handleApdu(volatile uint32_t *flags, volatile uint32_t *tx, uint32_t rx) { zemu_log("handleApdu\n"); volatile uint16_t sw = 0; @@ -289,3 +283,52 @@ void handleApdu(volatile uint32_t *flags, volatile uint32_t *tx, uint32_t rx) { } END_TRY; } +#elif defined(TARGET_NANOS) +void handleApdu(volatile uint32_t *flags, volatile uint32_t *tx, uint32_t rx) { + zemu_log("handleApdu\n"); + volatile uint16_t sw = 0; + + BEGIN_TRY { + TRY { + if (G_io_apdu_buffer[OFFSET_CLA] != CLA) { + zemu_log("CLA not supported\n"); + THROW(APDU_CODE_CLA_NOT_SUPPORTED); + } + + if (rx < APDU_MIN_LENGTH) { + THROW(APDU_CODE_WRONG_LENGTH); + } + if (G_io_apdu_buffer[OFFSET_INS] == INS_GET_VERSION) { + handle_getversion(flags, tx); + } +#if defined(APP_TESTING) + else if (G_io_apdu_buffer[OFFSET_INS] == INS_TEST) { + handleTest(flags, tx, rx); + THROW(APDU_CODE_OK); + } +#endif + else { + zemu_log("ins_not_supported**\n"); + THROW(APDU_CODE_INS_NOT_SUPPORTED); + } + } + CATCH(EXCEPTION_IO_RESET) { THROW(EXCEPTION_IO_RESET); } + CATCH_OTHER(e) { + switch (e & 0xF000) { + case 0x6000: + case APDU_CODE_OK: + sw = e; + break; + default: + sw = 0x6800 | (e & 0x7FF); + break; + } + G_io_apdu_buffer[*tx] = sw >> 8; + G_io_apdu_buffer[*tx + 1] = sw & 0xFF; + *tx += 2; + } + FINALLY {} + } + END_TRY; +} +#endif diff --git a/app/src/coin.h b/app/src/coin.h index e322744..23d5dfd 100644 --- a/app/src/coin.h +++ b/app/src/coin.h @@ -19,16 +19,14 @@ extern "C" { #endif -// #{TODO} ---> Replace CLA, Token symbol, HDPATH, etc etc #define CLA 0x80 // according to penumbra docs: -// m/44'/6532'/x' +// m/44'/6532'/0' #define HDPATH_LEN_DEFAULT 3 #define HDPATH_0_DEFAULT (0x80000000u | 0x2c) // 44 #define HDPATH_1_DEFAULT (0x80000000u | 0x1984) // 6532 - -#define HDPATH_2_DEFAULT (0x80000000u | 0u) +#define HDPATH_2_DEFAULT (0x80000000u | 0u) // 0 #define SECP256K1_PK_LEN 65u diff --git a/app/src/common/actions.h b/app/src/common/actions.h index a3e7ba0..821bb25 100644 --- a/app/src/common/actions.h +++ b/app/src/common/actions.h @@ -26,15 +26,17 @@ #include "zxerror.h" extern uint16_t cmdResponseLen; +extern uint32_t address_idx_account; + +__Z_INLINE zxerr_t app_fill_address(address_index_t address_index) { -__Z_INLINE zxerr_t app_fill_address(uint32_t account, uint8_t *randomizer) { check_app_canary(); // Put data directly in the apdu buffer MEMZERO(G_io_apdu_buffer, IO_APDU_BUFFER_SIZE); cmdResponseLen = 0; - zxerr_t error = crypto_fillAddress(G_io_apdu_buffer, IO_APDU_BUFFER_SIZE - 2, &cmdResponseLen, account, randomizer); + zxerr_t error = crypto_fillAddress(G_io_apdu_buffer, IO_APDU_BUFFER_SIZE - 2, &cmdResponseLen, address_index.account, address_index.randomizer); if (error != zxerr_ok || cmdResponseLen == 0) { THROW(APDU_CODE_EXECUTION_ERROR); @@ -42,10 +44,10 @@ __Z_INLINE zxerr_t app_fill_address(uint32_t account, uint8_t *randomizer) { // Set flag to show in case of requireConfirmation // that the address is indeed being randomized - is_randomized = false; - if (randomizer != NULL) { - is_randomized = true; - } + is_randomized = address_index.has_randomizer; + // Set the account in used to show it to the user + // in case a review is enabled + address_idx_account = address_index.account; return error; } diff --git a/app/src/keys_def.h b/app/src/keys_def.h index 2062ca9..b090b2d 100644 --- a/app/src/keys_def.h +++ b/app/src/keys_def.h @@ -97,6 +97,12 @@ typedef struct { address_t address; } keys_t; +typedef struct { + uint32_t account; + uint8_t has_randomizer; + uint8_t randomizer[ADDR_RANDOMIZER_LEN]; +} __attribute__((packed)) address_index_t; + #ifdef __cplusplus } #endif diff --git a/deps/ledger-zxlib b/deps/ledger-zxlib index d9ded97..eebf9d5 160000 --- a/deps/ledger-zxlib +++ b/deps/ledger-zxlib @@ -1 +1 @@ -Subproject commit d9ded9795bcb2700602907ccfff4d34087372225 +Subproject commit eebf9d533a497f01e60f7a6f8bd5465b1379882c diff --git a/docs/APDUSPEC.md b/docs/APDUSPEC.md index a035140..43522ac 100644 --- a/docs/APDUSPEC.md +++ b/docs/APDUSPEC.md @@ -2,15 +2,13 @@ ## General structure -# #{TODO} --> Update CLA, HDPATH and APDU messages - The general structure of commands and responses is as follows: ### Commands | Field | Type | Content | Note | | :------ | :------- | :--------------------- | ---- | -| CLA | byte (1) | Application Identifier | 0x98 | +| CLA | byte (1) | Application Identifier | 0x80 | | INS | byte (1) | Instruction ID | | | P1 | byte (1) | Parameter 1 | | | P2 | byte (1) | Parameter 2 | | @@ -29,25 +27,54 @@ The general structure of commands and responses is as follows: | Return code | Description | | ----------- | ----------------------- | | 0x6400 | Execution Error | +| 0x6700 | Wrong buffer length | | 0x6982 | Empty buffer | | 0x6983 | Output buffer too small | +| 0x6984 | Data is invalid | | 0x6986 | Command not allowed | +| 0x6987 | Tx is not initialized | +| 0x6B00 | P1/P2 are invalid | | 0x6D00 | INS not supported | | 0x6E00 | CLA not supported | | 0x6F00 | Unknown | +| 0x6F01 | Sign / verify error | | 0x9000 | Success | --- ## Command definition +### GET_DEVICE_INFO + +#### Command + +| Field | Type | Content | Expected | +| ----- | -------- | ---------------------- | -------- | +| CLA | byte (1) | Application Identifier | 0xE0 | +| INS | byte (1) | Instruction ID | 0x01 | +| P1 | byte (1) | Parameter 1 | 0x00 | +| P2 | byte (1) | Parameter 2 | 0x00 | +| L | byte (1) | Bytes in payload | 0x00 | + +#### Response + +| Field | Type | Content | Note | +| --------- | -------- | ------------------ | ------------------------ | +| TARGET_ID | byte (4) | Target Id | | +| OS_LEN | byte (1) | OS version length | 0..64 | +| OS | byte (?) | OS version | Non terminated string | +| FLAGS_LEN | byte (1) | Flags length | 0 | +| MCU_LEN | byte (1) | MCU version length | 0..64 | +| MCU | byte (?) | MCU version | Non terminated string | +| SW1-SW2 | byte (2) | Return code | see list of return codes | + ### GET_VERSION #### Command | Field | Type | Content | Expected | | ----- | -------- | ---------------------- | -------- | -| CLA | byte (1) | Application Identifier | 0x98 | +| CLA | byte (1) | Application Identifier | 0x80 | | INS | byte (1) | Instruction ID | 0x00 | | P1 | byte (1) | Parameter 1 | ignored | | P2 | byte (1) | Parameter 2 | ignored | @@ -66,140 +93,57 @@ The general structure of commands and responses is as follows: --- -### INS_GET_ADDR_ED25519 +### INS_GET_ADDR #### Command -| Field | Type | Content | Expected | -| ------- | -------- | ------------------------- | ---------- | -| CLA | byte (1) | Application Identifier | 0x98 | -| INS | byte (1) | Instruction ID | 0x01 | -| P1 | byte (1) | Request User confirmation | No = 0 | -| P2 | byte (1) | Parameter 2 | ignored | -| L | byte (1) | Bytes in payload | (depends) | -| Path[0] | byte (4) | Derivation Path Data | 0x80000000 | 44 | -| Path[1] | byte (4) | Derivation Path Data | 0x80000000 | 434 | -| Path[2] | byte (4) | Derivation Path Data | ? | -| Path[3] | byte (4) | Derivation Path Data | ? | -| Path[4] | byte (4) | Derivation Path Data | ? | +| Field | Type | Content | Expected | +| ------------- | --------- | ------------------------- | ------------------ | +| CLA | byte (1) | Application Identifier | 0x80 | +| INS | byte (1) | Instruction ID | 0x01 | +| P1 | byte (1) | Request User confirmation | No = 0 / Yes = 1 | +| P2 | byte (1) | Parameter 2 | ignored | +| L | byte (1) | Bytes in payload | 20 | +| Path[0] | byte (4) | Derivation Path Data | 0x80000000 \| 44 | +| Path[1] | byte (4) | Derivation Path Data | 0x80000000 \| 6532 | +| Path[2] | byte (4) | Derivation Path Data | 0x80000000 \| 0 | +| Account Index | byte (21) | Account Index | ? | #### Response | Field | Type | Content | Note | | ------- | --------- | ----------- | ------------------------ | -| PK | byte (32) | Public Key | | -| ADDR | byte (??) | address | | +| ADDR | byte (80) | Address | | | SW1-SW2 | byte (2) | Return code | see list of return codes | ---- - -### INS_GET_ADDR_SR25519 +### INS_GET_FVK #### Command -| Field | Type | Content | Expected | -| ------- | -------- | ------------------------- | ---------- | -| CLA | byte (1) | Application Identifier | 0x98 | -| INS | byte (1) | Instruction ID | 0x11 | -| P1 | byte (1) | Request User confirmation | No = 0 | -| P2 | byte (1) | Parameter 2 | ignored | -| L | byte (1) | Bytes in payload | (depends) | -| Path[0] | byte (4) | Derivation Path Data | 0x80000000 | 44 | -| Path[1] | byte (4) | Derivation Path Data | 0x80000000 | 434 | -| Path[2] | byte (4) | Derivation Path Data | ? | -| Path[3] | byte (4) | Derivation Path Data | ? | -| Path[4] | byte (4) | Derivation Path Data | ? | +| Field | Type | Content | Expected | +| ------------- | --------- | ------------------------- | ------------------ | +| CLA | byte (1) | Application Identifier | 0x80 | +| INS | byte (1) | Instruction ID | 0x03 | +| P1 | byte (1) | Request User confirmation | No = 0 / Yes = 1 | +| P2 | byte (1) | Parameter 2 | ignored | +| L | byte (1) | Bytes in payload | 20 | +| Path[0] | byte (4) | Derivation Path Data | 0x80000000 \| 44 | +| Path[1] | byte (4) | Derivation Path Data | 0x80000000 \| 6532 | +| Path[2] | byte (4) | Derivation Path Data | 0x80000000 \| 0 | +| Account Index | byte (21) | Account Index | ? | #### Response -| Field | Type | Content | Note | -| ------- | --------- | ----------- | ------------------------ | -| PK | byte (32) | Public Key | | -| ADDR | byte (??) | DOT address | | -| SW1-SW2 | byte (2) | Return code | see list of return codes | - ---- - -### INS_SIGN_ED25519 - -#### Command - -| Field | Type | Content | Expected | -| ----- | -------- | ---------------------- | --------- | -| CLA | byte (1) | Application Identifier | 0x98 | -| INS | byte (1) | Instruction ID | 0x02 | -| P1 | byte (1) | Payload desc | 0 = init | -| | | | 1 = add | -| | | | 2 = last | -| P2 | byte (1) | ---- | not used | -| L | byte (1) | Bytes in payload | (depends) | - -The first packet/chunk includes only the derivation path - -All other packets/chunks contain data chunks that are described below - -##### First Packet - -| Field | Type | Content | Expected | -| ------- | -------- | -------------------- | -------- | -| Path[0] | byte (4) | Derivation Path Data | 44 | -| Path[1] | byte (4) | Derivation Path Data | 434 | -| Path[2] | byte (4) | Derivation Path Data | ? | -| Path[3] | byte (4) | Derivation Path Data | ? | -| Path[4] | byte (4) | Derivation Path Data | ? | +| Field | Type | Content | Note | +| ------- | --------- | ---------------------------- | ------------------------ | +| AK | byte (32) | Spend authorization key | | +| NK | byte (32) | Nullifier deriving key | | +| SW1-SW2 | byte (2) | Return code | see list of return codes | -##### Other Chunks/Packets +#### Account Index -| Field | Type | Content | Expected | -| ------- | -------- | --------------- | -------- | -| Message | bytes... | Message to Sign | | - -#### Response - -| Field | Type | Content | Note | -| ------- | --------- | ----------- | ------------------------ | -| SIG | byte (65) | Signature | | -| SW1-SW2 | byte (2) | Return code | see list of return codes | - ---- - -### INS_SIGN_SR25519 - -#### Command - -| Field | Type | Content | Expected | -| ----- | -------- | ---------------------- | --------- | -| CLA | byte (1) | Application Identifier | 0x98 | -| INS | byte (1) | Instruction ID | 0x12 | -| P1 | byte (1) | Payload desc | 0 = init | -| | | | 1 = add | -| | | | 2 = last | -| P2 | byte (1) | ---- | not used | -| L | byte (1) | Bytes in payload | (depends) | - -The first packet/chunk includes only the derivation path - -All other packets/chunks contain data chunks that are described below - -##### First Packet - -| Field | Type | Content | Expected | -| ------- | -------- | -------------------- | -------- | -| Path[0] | byte (4) | Derivation Path Data | 44 | -| Path[1] | byte (4) | Derivation Path Data | 434 | -| Path[2] | byte (4) | Derivation Path Data | ? | -| Path[3] | byte (4) | Derivation Path Data | ? | -| Path[4] | byte (4) | Derivation Path Data | ? | - -##### Other Chunks/Packets - -| Field | Type | Content | Expected | -| ------- | -------- | --------------- | -------- | -| Message | bytes... | Message to Sign | | - -#### Response - -| Field | Type | Content | Note | -| ------- | --------- | ----------- | ------------------------ | -| SIG | byte (65) | Signature | | -| SW1-SW2 | byte (2) | Return code | see list of return codes | +| Field | Type | Content | Note | +| -------------- | ---------- | ---------------- | ------------ | +| Account | u32 | Account | 4 bytes | +| Has randomizer | u8 | Has randomizer | 1 byte | +| Randomizer | u8 (12) | Randomizer | 12 bytes | diff --git a/ledger_app.toml b/ledger_app.toml index 7f63dfe..7cdd3db 100644 --- a/ledger_app.toml +++ b/ledger_app.toml @@ -1,7 +1,7 @@ [app] build_directory = "./app/" sdk = "C" -devices = ["nanos", "nanox", "nanos+", "stax", "flex"] +devices = ["nanox", "nanos+", "stax", "flex"] [tests] unit_directory = "./tests/" diff --git a/tests_zemu/package.json b/tests_zemu/package.json index 8b1ea4b..b513860 100644 --- a/tests_zemu/package.json +++ b/tests_zemu/package.json @@ -20,7 +20,7 @@ "try": "node try.mjs" }, "dependencies": { - "@zondax/ledger-penumbra": "^0.1.0", + "@zondax/ledger-penumbra": "v0.1.1", "@zondax/zemu": "^0.50.3" }, "devDependencies": { diff --git a/tests_zemu/snapshots/fl-mainmenu/00001.png b/tests_zemu/snapshots/fl-mainmenu/00001.png index 27f3935..83f3325 100644 Binary files a/tests_zemu/snapshots/fl-mainmenu/00001.png and b/tests_zemu/snapshots/fl-mainmenu/00001.png differ diff --git a/tests_zemu/snapshots/fl-mainmenu/00002.png b/tests_zemu/snapshots/fl-mainmenu/00002.png index 6ebca3b..295c189 100644 Binary files a/tests_zemu/snapshots/fl-mainmenu/00002.png and b/tests_zemu/snapshots/fl-mainmenu/00002.png differ diff --git a/tests_zemu/snapshots/fl-mainmenu/00003.png b/tests_zemu/snapshots/fl-mainmenu/00003.png index 27f3935..83f3325 100644 Binary files a/tests_zemu/snapshots/fl-mainmenu/00003.png and b/tests_zemu/snapshots/fl-mainmenu/00003.png differ diff --git a/tests_zemu/snapshots/fl-mainmenu/00004.png b/tests_zemu/snapshots/fl-mainmenu/00004.png index d0efa07..3b8e2d0 100644 Binary files a/tests_zemu/snapshots/fl-mainmenu/00004.png and b/tests_zemu/snapshots/fl-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/fl-show_address/00001.png b/tests_zemu/snapshots/fl-show_address/00001.png index ffebb7d..c84b105 100644 Binary files a/tests_zemu/snapshots/fl-show_address/00001.png and b/tests_zemu/snapshots/fl-show_address/00001.png differ diff --git a/tests_zemu/snapshots/fl-show_address/00002.png b/tests_zemu/snapshots/fl-show_address/00002.png index 7f07b44..6d7df09 100644 Binary files a/tests_zemu/snapshots/fl-show_address/00002.png and b/tests_zemu/snapshots/fl-show_address/00002.png differ diff --git a/tests_zemu/snapshots/fl-show_address_randomized/00001.png b/tests_zemu/snapshots/fl-show_address_randomized/00001.png index cd9c8a3..7fd4cdd 100644 Binary files a/tests_zemu/snapshots/fl-show_address_randomized/00001.png and b/tests_zemu/snapshots/fl-show_address_randomized/00001.png differ diff --git a/tests_zemu/snapshots/fl-show_address_randomized/00002.png b/tests_zemu/snapshots/fl-show_address_randomized/00002.png index 5a4b038..7922ca6 100644 Binary files a/tests_zemu/snapshots/fl-show_address_randomized/00002.png and b/tests_zemu/snapshots/fl-show_address_randomized/00002.png differ diff --git a/tests_zemu/snapshots/s-mainmenu/00000.png b/tests_zemu/snapshots/s-mainmenu/00000.png deleted file mode 100644 index 407a27d..0000000 Binary files a/tests_zemu/snapshots/s-mainmenu/00000.png and /dev/null differ diff --git a/tests_zemu/snapshots/s-mainmenu/00001.png b/tests_zemu/snapshots/s-mainmenu/00001.png deleted file mode 100644 index 853a061..0000000 Binary files a/tests_zemu/snapshots/s-mainmenu/00001.png and /dev/null differ diff --git a/tests_zemu/snapshots/s-mainmenu/00002.png b/tests_zemu/snapshots/s-mainmenu/00002.png deleted file mode 100644 index 802e312..0000000 Binary files a/tests_zemu/snapshots/s-mainmenu/00002.png and /dev/null differ diff --git a/tests_zemu/snapshots/s-mainmenu/00003.png b/tests_zemu/snapshots/s-mainmenu/00003.png deleted file mode 100644 index 853a061..0000000 Binary files a/tests_zemu/snapshots/s-mainmenu/00003.png and /dev/null differ diff --git a/tests_zemu/snapshots/s-mainmenu/00004.png b/tests_zemu/snapshots/s-mainmenu/00004.png deleted file mode 100644 index fff75be..0000000 Binary files a/tests_zemu/snapshots/s-mainmenu/00004.png and /dev/null differ diff --git a/tests_zemu/snapshots/s-mainmenu/00005.png b/tests_zemu/snapshots/s-mainmenu/00005.png deleted file mode 100644 index 14687cb..0000000 Binary files a/tests_zemu/snapshots/s-mainmenu/00005.png and /dev/null differ diff --git a/tests_zemu/snapshots/s-mainmenu/00006.png b/tests_zemu/snapshots/s-mainmenu/00006.png deleted file mode 100644 index 616c3d4..0000000 Binary files a/tests_zemu/snapshots/s-mainmenu/00006.png and /dev/null differ diff --git a/tests_zemu/snapshots/s-mainmenu/00007.png b/tests_zemu/snapshots/s-mainmenu/00007.png deleted file mode 100644 index 3ad1234..0000000 Binary files a/tests_zemu/snapshots/s-mainmenu/00007.png and /dev/null differ diff --git a/tests_zemu/snapshots/s-mainmenu/00008.png b/tests_zemu/snapshots/s-mainmenu/00008.png deleted file mode 100644 index 616c3d4..0000000 Binary files a/tests_zemu/snapshots/s-mainmenu/00008.png and /dev/null differ diff --git a/tests_zemu/snapshots/s-mainmenu/00009.png b/tests_zemu/snapshots/s-mainmenu/00009.png deleted file mode 100644 index 14687cb..0000000 Binary files a/tests_zemu/snapshots/s-mainmenu/00009.png and /dev/null differ diff --git a/tests_zemu/snapshots/s-mainmenu/00010.png b/tests_zemu/snapshots/s-mainmenu/00010.png deleted file mode 100644 index fff75be..0000000 Binary files a/tests_zemu/snapshots/s-mainmenu/00010.png and /dev/null differ diff --git a/tests_zemu/snapshots/s-mainmenu/00011.png b/tests_zemu/snapshots/s-mainmenu/00011.png deleted file mode 100644 index 853a061..0000000 Binary files a/tests_zemu/snapshots/s-mainmenu/00011.png and /dev/null differ diff --git a/tests_zemu/snapshots/s-mainmenu/00012.png b/tests_zemu/snapshots/s-mainmenu/00012.png deleted file mode 100644 index 407a27d..0000000 Binary files a/tests_zemu/snapshots/s-mainmenu/00012.png and /dev/null differ diff --git a/tests_zemu/snapshots/sp-mainmenu/00004.png b/tests_zemu/snapshots/sp-mainmenu/00004.png index 28c5b93..61978ed 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 28c5b93..61978ed 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/sp-show_address/00001.png b/tests_zemu/snapshots/sp-show_address/00001.png index f63e148..e1c3756 100644 Binary files a/tests_zemu/snapshots/sp-show_address/00001.png and b/tests_zemu/snapshots/sp-show_address/00001.png differ diff --git a/tests_zemu/snapshots/sp-show_address/00002.png b/tests_zemu/snapshots/sp-show_address/00002.png index 81b0e89..3579381 100644 Binary files a/tests_zemu/snapshots/sp-show_address/00002.png and b/tests_zemu/snapshots/sp-show_address/00002.png differ diff --git a/tests_zemu/snapshots/sp-show_address/00003.png b/tests_zemu/snapshots/sp-show_address/00003.png index 5c508cc..20708a8 100644 Binary files a/tests_zemu/snapshots/sp-show_address/00003.png and b/tests_zemu/snapshots/sp-show_address/00003.png differ diff --git a/tests_zemu/snapshots/sp-show_address/00004.png b/tests_zemu/snapshots/sp-show_address/00004.png index 336c6fd..4b72727 100644 Binary files a/tests_zemu/snapshots/sp-show_address/00004.png and b/tests_zemu/snapshots/sp-show_address/00004.png differ diff --git a/tests_zemu/snapshots/sp-show_address/00005.png b/tests_zemu/snapshots/sp-show_address/00005.png index 1e4be69..336c6fd 100644 Binary files a/tests_zemu/snapshots/sp-show_address/00005.png and b/tests_zemu/snapshots/sp-show_address/00005.png differ diff --git a/tests_zemu/snapshots/sp-show_address/00006.png b/tests_zemu/snapshots/sp-show_address/00006.png index 283d3cc..1e4be69 100644 Binary files a/tests_zemu/snapshots/sp-show_address/00006.png and b/tests_zemu/snapshots/sp-show_address/00006.png differ diff --git a/tests_zemu/snapshots/sp-show_address/00007.png b/tests_zemu/snapshots/sp-show_address/00007.png new file mode 100644 index 0000000..283d3cc Binary files /dev/null and b/tests_zemu/snapshots/sp-show_address/00007.png differ diff --git a/tests_zemu/snapshots/sp-show_address_randomized/00001.png b/tests_zemu/snapshots/sp-show_address_randomized/00001.png index 78fe414..8db7e1a 100644 Binary files a/tests_zemu/snapshots/sp-show_address_randomized/00001.png and b/tests_zemu/snapshots/sp-show_address_randomized/00001.png differ diff --git a/tests_zemu/snapshots/sp-show_address_randomized/00002.png b/tests_zemu/snapshots/sp-show_address_randomized/00002.png index 86db7fa..dc96dbb 100644 Binary files a/tests_zemu/snapshots/sp-show_address_randomized/00002.png and b/tests_zemu/snapshots/sp-show_address_randomized/00002.png differ diff --git a/tests_zemu/snapshots/sp-show_address_randomized/00003.png b/tests_zemu/snapshots/sp-show_address_randomized/00003.png index b015ca7..49257c6 100644 Binary files a/tests_zemu/snapshots/sp-show_address_randomized/00003.png and b/tests_zemu/snapshots/sp-show_address_randomized/00003.png differ diff --git a/tests_zemu/snapshots/sp-show_address_randomized/00004.png b/tests_zemu/snapshots/sp-show_address_randomized/00004.png index 807131c..4b72727 100644 Binary files a/tests_zemu/snapshots/sp-show_address_randomized/00004.png and b/tests_zemu/snapshots/sp-show_address_randomized/00004.png differ diff --git a/tests_zemu/snapshots/sp-show_address_randomized/00005.png b/tests_zemu/snapshots/sp-show_address_randomized/00005.png index 1e4be69..807131c 100644 Binary files a/tests_zemu/snapshots/sp-show_address_randomized/00005.png and b/tests_zemu/snapshots/sp-show_address_randomized/00005.png differ diff --git a/tests_zemu/snapshots/sp-show_address_randomized/00006.png b/tests_zemu/snapshots/sp-show_address_randomized/00006.png index 283d3cc..1e4be69 100644 Binary files a/tests_zemu/snapshots/sp-show_address_randomized/00006.png and b/tests_zemu/snapshots/sp-show_address_randomized/00006.png differ diff --git a/tests_zemu/snapshots/sp-show_address_randomized/00007.png b/tests_zemu/snapshots/sp-show_address_randomized/00007.png new file mode 100644 index 0000000..283d3cc Binary files /dev/null and b/tests_zemu/snapshots/sp-show_address_randomized/00007.png differ diff --git a/tests_zemu/snapshots/st-mainmenu/00001.png b/tests_zemu/snapshots/st-mainmenu/00001.png index d346ccf..778c832 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/st-mainmenu/00002.png b/tests_zemu/snapshots/st-mainmenu/00002.png index 7beef93..458d377 100644 Binary files a/tests_zemu/snapshots/st-mainmenu/00002.png and b/tests_zemu/snapshots/st-mainmenu/00002.png differ diff --git a/tests_zemu/snapshots/st-mainmenu/00003.png b/tests_zemu/snapshots/st-mainmenu/00003.png index d346ccf..778c832 100644 Binary files a/tests_zemu/snapshots/st-mainmenu/00003.png and b/tests_zemu/snapshots/st-mainmenu/00003.png differ diff --git a/tests_zemu/snapshots/st-mainmenu/00004.png b/tests_zemu/snapshots/st-mainmenu/00004.png index 7594585..abb6e54 100644 Binary files a/tests_zemu/snapshots/st-mainmenu/00004.png and b/tests_zemu/snapshots/st-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/st-show_address/00001.png b/tests_zemu/snapshots/st-show_address/00001.png index 9584449..6b14dba 100644 Binary files a/tests_zemu/snapshots/st-show_address/00001.png and b/tests_zemu/snapshots/st-show_address/00001.png differ diff --git a/tests_zemu/snapshots/st-show_address/00002.png b/tests_zemu/snapshots/st-show_address/00002.png index 7c32a18..2dbce46 100644 Binary files a/tests_zemu/snapshots/st-show_address/00002.png and b/tests_zemu/snapshots/st-show_address/00002.png differ diff --git a/tests_zemu/snapshots/st-show_address_randomized/00001.png b/tests_zemu/snapshots/st-show_address_randomized/00001.png index 485db2a..209cfb2 100644 Binary files a/tests_zemu/snapshots/st-show_address_randomized/00001.png and b/tests_zemu/snapshots/st-show_address_randomized/00001.png differ diff --git a/tests_zemu/snapshots/st-show_address_randomized/00002.png b/tests_zemu/snapshots/st-show_address_randomized/00002.png index 4a02411..9b92d06 100644 Binary files a/tests_zemu/snapshots/st-show_address_randomized/00002.png and b/tests_zemu/snapshots/st-show_address_randomized/00002.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00004.png b/tests_zemu/snapshots/x-mainmenu/00004.png index 28c5b93..61978ed 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 28c5b93..61978ed 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-show_address/00001.png b/tests_zemu/snapshots/x-show_address/00001.png index f63e148..e1c3756 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_address/00002.png b/tests_zemu/snapshots/x-show_address/00002.png index 81b0e89..3579381 100644 Binary files a/tests_zemu/snapshots/x-show_address/00002.png and b/tests_zemu/snapshots/x-show_address/00002.png differ diff --git a/tests_zemu/snapshots/x-show_address/00003.png b/tests_zemu/snapshots/x-show_address/00003.png index 5c508cc..20708a8 100644 Binary files a/tests_zemu/snapshots/x-show_address/00003.png and b/tests_zemu/snapshots/x-show_address/00003.png differ diff --git a/tests_zemu/snapshots/x-show_address/00004.png b/tests_zemu/snapshots/x-show_address/00004.png index 336c6fd..4b72727 100644 Binary files a/tests_zemu/snapshots/x-show_address/00004.png and b/tests_zemu/snapshots/x-show_address/00004.png differ diff --git a/tests_zemu/snapshots/x-show_address/00005.png b/tests_zemu/snapshots/x-show_address/00005.png index 1e4be69..336c6fd 100644 Binary files a/tests_zemu/snapshots/x-show_address/00005.png and b/tests_zemu/snapshots/x-show_address/00005.png differ diff --git a/tests_zemu/snapshots/x-show_address/00006.png b/tests_zemu/snapshots/x-show_address/00006.png index 283d3cc..1e4be69 100644 Binary files a/tests_zemu/snapshots/x-show_address/00006.png and b/tests_zemu/snapshots/x-show_address/00006.png differ diff --git a/tests_zemu/snapshots/x-show_address/00007.png b/tests_zemu/snapshots/x-show_address/00007.png new file mode 100644 index 0000000..283d3cc Binary files /dev/null and b/tests_zemu/snapshots/x-show_address/00007.png differ diff --git a/tests_zemu/snapshots/x-show_address_randomized/00001.png b/tests_zemu/snapshots/x-show_address_randomized/00001.png index 78fe414..8db7e1a 100644 Binary files a/tests_zemu/snapshots/x-show_address_randomized/00001.png and b/tests_zemu/snapshots/x-show_address_randomized/00001.png differ diff --git a/tests_zemu/snapshots/x-show_address_randomized/00002.png b/tests_zemu/snapshots/x-show_address_randomized/00002.png index 86db7fa..dc96dbb 100644 Binary files a/tests_zemu/snapshots/x-show_address_randomized/00002.png and b/tests_zemu/snapshots/x-show_address_randomized/00002.png differ diff --git a/tests_zemu/snapshots/x-show_address_randomized/00003.png b/tests_zemu/snapshots/x-show_address_randomized/00003.png index b015ca7..49257c6 100644 Binary files a/tests_zemu/snapshots/x-show_address_randomized/00003.png and b/tests_zemu/snapshots/x-show_address_randomized/00003.png differ diff --git a/tests_zemu/snapshots/x-show_address_randomized/00004.png b/tests_zemu/snapshots/x-show_address_randomized/00004.png index 807131c..4b72727 100644 Binary files a/tests_zemu/snapshots/x-show_address_randomized/00004.png and b/tests_zemu/snapshots/x-show_address_randomized/00004.png differ diff --git a/tests_zemu/snapshots/x-show_address_randomized/00005.png b/tests_zemu/snapshots/x-show_address_randomized/00005.png index 1e4be69..807131c 100644 Binary files a/tests_zemu/snapshots/x-show_address_randomized/00005.png and b/tests_zemu/snapshots/x-show_address_randomized/00005.png differ diff --git a/tests_zemu/snapshots/x-show_address_randomized/00006.png b/tests_zemu/snapshots/x-show_address_randomized/00006.png index 283d3cc..1e4be69 100644 Binary files a/tests_zemu/snapshots/x-show_address_randomized/00006.png and b/tests_zemu/snapshots/x-show_address_randomized/00006.png differ diff --git a/tests_zemu/snapshots/x-show_address_randomized/00007.png b/tests_zemu/snapshots/x-show_address_randomized/00007.png new file mode 100644 index 0000000..283d3cc Binary files /dev/null and b/tests_zemu/snapshots/x-show_address_randomized/00007.png differ diff --git a/tests_zemu/tests/common.ts b/tests_zemu/tests/common.ts index d574924..2ca1a2d 100644 --- a/tests_zemu/tests/common.ts +++ b/tests_zemu/tests/common.ts @@ -3,17 +3,19 @@ import { IDeviceModel, DEFAULT_START_OPTIONS } from '@zondax/zemu' import { resolve } from 'path' export const APP_SEED = 'equip will roof matter pink blind book anxiety banner elbow sun young' -export const PEN_PATH = "m/44'/6532'" +export const PENUMBRA_PATH = "m/44'/6532'/0'" export const ACCOUNT_ID = 1 export const ACCOUNT_ID2 = 2 -const APP_PATH_S = resolve('../app/output/app_s.elf') +// Due to binary size problems nanos is not supported +// const APP_PATH_S = resolve('../app/output/app_s.elf') const APP_PATH_X = resolve('../app/output/app_x.elf') const APP_PATH_SP = resolve('../app/output/app_s2.elf') const APP_PATH_ST = resolve('../app/output/app_stax.elf') const APP_PATH_FL = resolve('../app/output/app_flex.elf') export const models: IDeviceModel[] = [ + // Due to binary size problems nanos is not supported // { name: 'nanos', prefix: 'S', path: APP_PATH_S }, { name: 'nanox', prefix: 'X', path: APP_PATH_X }, { name: 'nanosp', prefix: 'SP', path: APP_PATH_SP }, @@ -30,4 +32,3 @@ export const defaultOptions = { export const txBlobExample = '0aaf020aac020aa1010a290a0308904e12220a2029ea9c2f3371f6a487e7e95c247041f4a356f983eb064e5d2b3bcf322ca96a1012207fa50bfe8946e53b33e8328672a0c6300ad9333c04707475f2d6cc502ec8513a1a520a50e0783360338067fc2ba548f460b3f06f33d3e756ebefa8a8c08c5e12a1e667df228df0720fb9bd963894183bc447e1c7ef591fa9625d4a66b7703eec2ec1ef543454673bb61a4f2a3d861114d6891d691a208d0887fd0d20bd002c336054772d56b8f9704a80ac8da45533e72f155f7145032220d1241d9d9f051c437455998e7c1eff33cd085ba9a9092d852d0381278bb6b1012a205e3505d5b6b1b99a8284f054bd650e8d4b64a23f6322c05a0ccee46bb481cb0932208c6abfdd0dd9111868fbed6a30c9dd5477b123f7aefd15bc73b68185f0a036110ab2020aaf020aa2010a2a0a0408a09c0112220a2029ea9c2f3371f6a487e7e95c247041f4a356f983eb064e5d2b3bcf322ca96a10122079ce0fe2f6695ebe61c22edb8de45e1290448500e0058156cb4e29f4d7234f091a520a50e0783360338067fc2ba548f460b3f06f33d3e756ebefa8a8c08c5e12a1e667df228df0720fb9bd963894183bc447e1c7ef591fa9625d4a66b7703eec2ec1ef543454673bb61a4f2a3d861114d6891d6910011a20c3021eb39eed577b5d609f5436d9128ff6c8bcc13e326a4fcab5c749e2f489002220c05b9ffb6512d40cc8cf03eb1e2b47f3fcc323a0f2db077362b2300eb77658022a20a45a2fc5a64032c3a68ce4ec9c542b564cfaa9b14d3af386bd142a645212540f32208cb5d93be25ba643ee760f56624cd051e53ca0e7047e4a95a5faf82f0636f60d0a8b021288020a2a0a0408b0ea0112220a2029ea9c2f3371f6a487e7e95c247041f4a356f983eb064e5d2b3bcf322ca96a1012520a50e0783360338067fc2ba548f460b3f06f33d3e756ebefa8a8c08c5e12a1e667df228df0720fb9bd963894183bc447e1c7ef591fa9625d4a66b7703eec2ec1ef543454673bb61a4f2a3d861114d6891d691a20cde64106162059a6800918036eb3c0e9b2872f56d4902259fba9b52d18dbd7c52220a1417029703aa865b08f19acc96eba15928a2178956f6c9c538ea5577a03ef032a20df5538e38602a2bd15119182c50d0f1b22fd8deba0a728a8fbbfb7e9b8c6fc0932207dee2a1d6d9c85ba68560cfa514b73897e77fe0355d92c9cc2bb3b522b5f3d110abc021ab9020ad0010a480a220a20116d0cd6de9349c686f5802f7c98179e70d4898a38e1cc3df93705c94e941d0c12220a2029ea9c2f3371f6a487e7e95c247041f4a356f983eb064e5d2b3bcf322ca96a10120408a08d061a02080122040a0208032a520a50e0783360338067fc2ba548f460b3f06f33d3e756ebefa8a8c08c5e12a1e667df228df0720fb9bd963894183bc447e1c7ef591fa9625d4a66b7703eec2ec1ef543454673bb61a4f2a3d861114d6891d69322057798bc1a097c26b47e61a9870ca98eb8cbe48e9cba4db86f5d8b67c12086afb1220fbf22b3005fdd84a03bdf0950c851a9c6e0618b0eea1004ca75e53ce3deef1031a205f9ddbd8093a028de6597d03d785302d8336e20a2148e15ae016bad0536d7e0122200d358f3968b24d5e612504b211cadb44ace485ceb3ad38821aa96b926279e6001213120d70656e756d6272612d746573741a020a0022f4012a780a520a50e0783360338067fc2ba548f460b3f06f33d3e756ebefa8a8c08c5e12a1e667df228df0720fb9bd963894183bc447e1c7ef591fa9625d4a66b7703eec2ec1ef543454673bb61a4f2a3d861114d6891d691220361218d216cfe90f77f54f045ff21b464795517c05057c595fd59e4958e3941718032a780a520a50e0783360338067fc2ba548f460b3f06f33d3e756ebefa8a8c08c5e12a1e667df228df0720fb9bd963894183bc447e1c7ef591fa9625d4a66b7703eec2ec1ef543454673bb61a4f2a3d861114d6891d69122013296da8c9dfdf969be7c7bd74e67e80977cd91635eb32038619f62c732dc46a18022a780a540a520a506ece16f387e0b932082cb0cf6823590fc287d068d6f684a36d1fb19bfd6dce8b22850f535824aeb66cb8c41309e6f5b2d58ff7b651ef4e09a09c7e48d770d190880e1827b47823a1d01f0c4b438a7b43122018bd5cedd0eb952244a296c1e3fba4f417ebdcc1cfec04cb9441a394316a58bd' - diff --git a/tests_zemu/tests/standard.test.ts b/tests_zemu/tests/standard.test.ts index 1bdfe0b..3fc460b 100644 --- a/tests_zemu/tests/standard.test.ts +++ b/tests_zemu/tests/standard.test.ts @@ -15,15 +15,15 @@ ******************************************************************************* */ import Zemu, { ButtonKind, zondaxMainmenuNavigation, isTouchDevice } from '@zondax/zemu' -import { ACCOUNT_ID, PEN_PATH, defaultOptions, models, txBlobExample } from './common' -import { PenumbraApp } from '@zondax/ledger-penumbra' +import { ACCOUNT_ID, PENUMBRA_PATH, defaultOptions, models, txBlobExample } from './common' +import { PenumbraApp, AddressIndex } from '@zondax/ledger-penumbra' jest.setTimeout(60000) const EXPECTED_FVK = - '3cd58bbb8725bfe4566504b04d7a31b67bb67fd5d09a28364ac7ac2c2fd8710e4fb0d8c51486fc24938ca96564842a84201d266c92b72761e4e99a16b3405103' + '92c3e768d3ecf0f2c4d93d879dbc16226fe8540443a8216d6b093d8684865a063a35ee29cccf93149dfa565ea693aa5cd36dc5cf8adff15081038d31e796580b' const EXPECTED_ADDRESS = - 'e0783360338067fc2ba548f460b3f06f33d3e756ebefa8a8c08c5e12a1e667df228df0720fb9bd963894183bc447e1c7ef591fa9625d4a66b7703eec2ec1ef543454673bb61a4f2a3d861114d6891d69' + 'fc48056bc3fa38105dec3bbf85360034324a68f5f9ad7b1b5b6796f97d8279ae15308df6d619d93aab071c2ea360d09dd0f3fa4d3a8a49b9f9b208ee42e491efff1162c3525990477dfc81a681b7d7c1' const RANDOMIZER = '770187941264c925f8ba8776' @@ -48,7 +48,7 @@ describe('Standard', function () { } }) - test.concurrent.each(models)('get app version', async function (m) { + test.concurrent.each(models)('$name get app version', async function (m) { const sim = new Zemu(m.path) try { await sim.start({ ...defaultOptions, model: m.name }) @@ -69,18 +69,23 @@ describe('Standard', function () { } }) - test.concurrent.each(models)('getFvk', async function (m) { + test.concurrent.each(models)('$name getFvk', async function (m) { const sim = new Zemu(m.path) try { await sim.start({ ...defaultOptions, model: m.name }) const app = new PenumbraApp(sim.getTransport()) + const addressIndex: AddressIndex = { + account: ACCOUNT_ID, + randomizer: undefined, + } + //Define HDPATH - const resp = await app.getFVK(PEN_PATH, ACCOUNT_ID) + const resp = await app.getFVK(PENUMBRA_PATH, addressIndex) console.log(resp) - const fvk = resp.fvk !== undefined ? resp.fvk.toString('hex') : '' + const fvk = Buffer.concat([resp.ak, resp.nk]).toString('hex') expect(fvk).toEqual(EXPECTED_FVK) } finally { @@ -88,14 +93,19 @@ describe('Standard', function () { } }) - test.concurrent.each(models)('getAddress', async function (m) { + test.concurrent.each(models)('$name getAddress', async function (m) { const sim = new Zemu(m.path) try { await sim.start({ ...defaultOptions, model: m.name }) const app = new PenumbraApp(sim.getTransport()) + const addressIndex: AddressIndex = { + account: ACCOUNT_ID, + randomizer: undefined, + } + //Define HDPATH - const resp = await app.getAddress(PEN_PATH, ACCOUNT_ID) + const resp = await app.getAddress(PENUMBRA_PATH, addressIndex) console.log(resp) @@ -107,14 +117,19 @@ describe('Standard', function () { } }) - test.concurrent.each(models)('getAddressRandomized', async function (m) { + test.concurrent.each(models)('$name getAddressRandomized', async function (m) { const sim = new Zemu(m.path) try { await sim.start({ ...defaultOptions, model: m.name }) const app = new PenumbraApp(sim.getTransport()) + const addressIndex: AddressIndex = { + account: ACCOUNT_ID, + randomizer: Buffer.from(RANDOMIZER, 'hex'), + } + //Define HDPATH - const resp = await app.getAddress(PEN_PATH, ACCOUNT_ID, RANDOMIZER) + const resp = await app.getAddress(PENUMBRA_PATH, addressIndex) console.log(resp) @@ -126,7 +141,7 @@ describe('Standard', function () { } }) - test.concurrent.each(models)('showAddress', async function (m) { + test.concurrent.each(models)('$name showAddress', async function (m) { const sim = new Zemu(m.path) try { await sim.start({ @@ -138,8 +153,13 @@ describe('Standard', function () { const app = new PenumbraApp(sim.getTransport()) + const addressIndex: AddressIndex = { + account: 1, + randomizer: undefined, + } + //Define HDPATH - const resp = app.showAddress(PEN_PATH, ACCOUNT_ID) + const resp = app.showAddress(PENUMBRA_PATH, addressIndex) // Wait until we are not in the main menu await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-show_address`) @@ -168,8 +188,13 @@ describe('Standard', function () { const app = new PenumbraApp(sim.getTransport()) + const addressIndex: AddressIndex = { + account: ACCOUNT_ID, + randomizer: Buffer.from(RANDOMIZER, 'hex'), + } + //Define HDPATH - const resp = app.showAddress(PEN_PATH, ACCOUNT_ID, RANDOMIZER) + const resp = app.showAddress(PENUMBRA_PATH, addressIndex) // Wait until we are not in the main menu await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-show_address_randomized`) @@ -177,7 +202,6 @@ describe('Standard', function () { const resp2 = await resp console.log(resp2) - } finally { await sim.close() } @@ -200,7 +224,6 @@ describe('Standard', function () { // // await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) // // await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign`) - // const signatureResponse = await signatureRequest // console.log(signatureResponse)