diff --git a/.clang-format b/.clang-format index 1f7d191..456cafb 100644 --- a/.clang-format +++ b/.clang-format @@ -1,5 +1,5 @@ BasedOnStyle: Google IndentWidth: 4 -ColumnLimit: 125 +ColumnLimit: 120 DerivePointerAlignment: false PointerAlignment: Right diff --git a/.github/workflows/check_version.yml b/.github/workflows/check_version.yml index 7992123..c1515f4 100644 --- a/.github/workflows/check_version.yml +++ b/.github/workflows/check_version.yml @@ -6,7 +6,8 @@ on: branches: - main - develop - - master # for safety reasons + - master + - dev jobs: configure: @@ -25,6 +26,7 @@ jobs: options: --user ${{ needs.configure.outputs.uid_gid }} env: SDK_VARNAME: NANOSP_SDK + BOLOS_SDK: /opt/nanosplus-secure-sdk outputs: version: ${{ steps.store-version.outputs.version }} steps: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0549b3c..7d990ac 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: @@ -28,7 +28,7 @@ jobs: submodules: recursive - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: cpp queries: security-and-quality @@ -37,4 +37,4 @@ jobs: run: | make -j BOLOS_SDK=${{ matrix.sdk }} - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/guidelines_enforcer.yml b/.github/workflows/guidelines_enforcer.yml index 5b6fb33..e1f53dc 100644 --- a/.github/workflows/guidelines_enforcer.yml +++ b/.github/workflows/guidelines_enforcer.yml @@ -14,12 +14,12 @@ on: branches: - main - develop - - master # for safety reasons - - dev # for safety reasons + - master + - dev pull_request: jobs: guidelines_enforcer: if: github.event.repository.private == false - name: Call Ledger guidelines_enforcer + name: Call Ledger guidelines enforcer uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_guidelines_enforcer.yml@v1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fc5462c..473db9d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,12 +6,12 @@ on: branches: - main - develop - - master # for safety reasons - - dev # for safety reasons + - master + - dev jobs: configure: - runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }} + runs-on: ubuntu-latest outputs: uid_gid: ${{ steps.get-user.outputs.uid_gid }} steps: @@ -23,6 +23,7 @@ jobs: uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1 with: upload_app_binaries_artifact: "compiled_app_binaries" + builder: ledger-app-builder cpp_tests: runs-on: ubuntu-latest @@ -37,56 +38,30 @@ jobs: make deps - run: make cpp_test - build: - runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }} - steps: - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y curl protobuf-compiler build-essential git wget unzip python3 python3-pip \ - libssl-dev libffi-dev libreadline-dev zlib1g-dev libbz2-dev libsqlite3-dev libncurses5-dev \ - libgdbm-dev libnss3-dev liblzma-dev libxml2-dev libxmlsec1-dev libffi-dev libyaml-dev - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: true - - name: Install CMake 3.28 - run: | - wget https://github.com/Kitware/CMake/releases/download/v3.28.0/cmake-3.28.0-linux-x86_64.sh - sudo mkdir /opt/cmake - sudo sh cmake-3.28.0-linux-x86_64.sh --skip-license --prefix=/opt/cmake - sudo ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake - sudo ln -sf /opt/cmake/bin/ctest /usr/local/bin/ctest - - name: Verify CMake version - run: cmake --version - - name: Install deps - run: | - sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10 - make deps - - name: Run CMake - run: mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. && make build_ledger: - needs: configure - runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }} + 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 + options: --user root + env: + BOLOS_SDK: /opt/nanosplus-secure-sdk outputs: size: ${{steps.build.outputs.size}} steps: - name: Checkout uses: actions/checkout@v4 with: - submodules: true + submodules: recursive - name: Build Standard app id: build shell: bash -l {0} run: | - make - echo "size=$(python3 deps/ledger-zxlib/scripts/getSize.py s)" >> $GITHUB_OUTPUT + make PRODUCTION_BUILD=0 + echo "size=$(python3 deps/ledger-zxlib/scripts/getSize.py s2)" >> $GITHUB_OUTPUT test_zemu: runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }} @@ -114,7 +89,7 @@ jobs: - name: Install node uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 - name: Install yarn run: | npm install -g yarn @@ -129,32 +104,37 @@ jobs: path: tests_zemu/snapshots-tmp/ build_package_nanosp: - needs: [configure, build, build_ledger, test_zemu] - if: ${{ github.ref == 'refs/heads/main' }} - runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }} + needs: + [ + configure, + cpp_tests, + build_ledger, + test_zemu, + ] + runs-on: ubuntu-latest container: image: zondax/ledger-app-builder:latest - options: --user ${{ needs.configure.outputs.uid_gid }} + options: --user root env: BOLOS_SDK: /opt/nanosplus-secure-sdk steps: - name: Checkout uses: actions/checkout@v4 with: - submodules: true + submodules: recursive - name: Install deps run: pip install --break-system-packages ledgerblue - - name: Build NanoSP shell: bash -l {0} run: | - PRODUCTION_BUILD=0 make + make PRODUCTION_BUILD=0 mv ./app/pkg/installer_s2.sh ./app/pkg/installer_nanos_plus.sh - name: Set tag id: nanosp run: echo "tag_name=$(./app/pkg/installer_nanos_plus.sh version)" >> $GITHUB_OUTPUT - name: Update Release - id: update_release_2 + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }} + id: update_release_nanosp 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 @@ -165,30 +145,36 @@ jobs: prerelease: false build_package_stax: - needs: [configure, build, build_ledger, test_zemu] - if: ${{ github.ref == 'refs/heads/main' }} - runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }} + needs: + [ + configure, + cpp_tests, + build_ledger, + test_zemu, + ] + runs-on: ubuntu-latest container: image: zondax/ledger-app-builder:latest - options: --user ${{ needs.configure.outputs.uid_gid }} + options: --user root env: BOLOS_SDK: /opt/stax-secure-sdk steps: - name: Checkout uses: actions/checkout@v4 with: - submodules: true + submodules: recursive - name: Install deps run: pip install --break-system-packages ledgerblue - - name: Build Stax shell: bash -l {0} - run: PRODUCTION_BUILD=0 make + run: | + make PRODUCTION_BUILD=0 - name: Set tag id: stax run: echo "tag_name=$(./app/pkg/installer_stax.sh version)" >> $GITHUB_OUTPUT - name: Update Release - id: update_release_2 + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }} + id: update_release_stax 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 @@ -200,35 +186,42 @@ jobs: prerelease: false build_package_flex: - needs: [configure, build, build_ledger, test_zemu] - if: ${{ github.ref == 'refs/heads/main' }} - runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }} + needs: + [ + configure, + cpp_tests, + build_ledger, + test_zemu, + ] + runs-on: ubuntu-latest container: image: zondax/ledger-app-builder:latest - options: --user ${{ needs.configure.outputs.uid_gid }} + options: --user root env: BOLOS_SDK: /opt/flex-secure-sdk steps: - name: Checkout uses: actions/checkout@v4 with: - submodules: true + submodules: recursive - name: Install deps run: pip install --break-system-packages ledgerblue - - name: Build Flex shell: bash -l {0} - run: PRODUCTION_BUILD=0 make + run: | + make PRODUCTION_BUILD=0 - name: Set tag id: flex run: echo "tag_name=$(./app/pkg/installer_flex.sh version)" >> $GITHUB_OUTPUT - name: Update Release - id: update_release_2 + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }} + id: update_release_flex 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_flex.sh + files: | + ./app/pkg/installer_flex.sh tag_name: ${{ steps.flex.outputs.tag_name }} draft: false prerelease: false diff --git a/CMakeLists.txt b/CMakeLists.txt index 13e2943..012228b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,10 +14,11 @@ #* limitations under the License. #******************************************************************************** cmake_minimum_required(VERSION 3.28) + include("cmake/HunterGate.cmake") HunterGate( - URL "https://github.com/cpp-pm/hunter/archive/v0.25.5.tar.gz" - SHA1 "a20151e4c0740ee7d0f9994476856d813cdead29" + URL "https://github.com/cpp-pm/hunter/archive/v0.26.1.tar.gz" + SHA1 "e41ac7a18c49b35ebac99ff2b5244317b2638a65" LOCAL ) @@ -48,12 +49,18 @@ string(APPEND CMAKE_C_FLAGS " -fno-omit-frame-pointer -g") string(APPEND CMAKE_CXX_FLAGS " -fno-omit-frame-pointer -g") string(APPEND CMAKE_LINKER_FLAGS " -fno-omit-frame-pointer -g") +# Use FetchContent to get nlohmann_json 3.12.0 since Hunter doesn't support this version +include(FetchContent) +FetchContent_Declare( + nlohmann_json + URL https://github.com/nlohmann/json/releases/download/v3.12.0/json.tar.xz + URL_HASH SHA256=42f6e95cad6ec532fd372391373363b62a14af6d771056dbfc86160e6dfff7aa +) +FetchContent_MakeAvailable(nlohmann_json) + hunter_add_package(fmt) find_package(fmt CONFIG REQUIRED) -hunter_add_package(jsoncpp) -find_package(jsoncpp CONFIG REQUIRED) - hunter_add_package(GTest) find_package(GTest CONFIG REQUIRED) @@ -208,7 +215,7 @@ else() app_lib GTest::gtest_main fmt::fmt - JsonCpp::JsonCpp) + nlohmann_json::nlohmann_json) add_compile_definitions(TESTVECTORS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/tests/") add_test(NAME unittests COMMAND unittests) diff --git a/README.md b/README.md index 5217ddc..91bc8da 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ then run: - This project requires Ledger firmware 2.0 - The current repository keeps track of Ledger's SDK but it is possible to override it by changing the git submodule. -*Warning*: Some IDEs may not use the same python interpreter or virtual enviroment as the one you used when running `pip`. +*Warning*: Some IDEs may not use the same python interpreter or virtual environment as the one you used when running `pip`. If you see conan is not found, check that you installed the package in the same interpreter as the one that launches `cmake`. ## How to build ? @@ -179,7 +179,7 @@ Many of our integration tests expect the device to be configured with a known te - Enter your pin if necessary -- Run `make dev_ca`. The device will receive a development certificate to avoid constant manual confirmations. +- Run `make dev_caS2`. The device will receive a development certificate to avoid constant manual confirmations. ### Loading into your development device diff --git a/app/Makefile b/app/Makefile index 32d1a94..c10a32e 100755 --- a/app/Makefile +++ b/app/Makefile @@ -38,7 +38,6 @@ APP_SOURCE_PATH += src # Application icons following guidelines: # https://developers.ledger.com/docs/embedded-app/design-requirements/#device-icon -ICON_NANOS = nanos_icon.gif ICON_NANOX = nanox_icon.gif ICON_NANOSP = nanox_icon.gif ICON_STAX = stax_icon.gif diff --git a/app/nanos_icon.gif b/app/nanos_icon.gif deleted file mode 100644 index d4dcfa4..0000000 Binary files a/app/nanos_icon.gif and /dev/null differ diff --git a/app/src/addr.c b/app/src/addr.c index 5e0389d..7d670fc 100644 --- a/app/src/addr.c +++ b/app/src/addr.c @@ -34,8 +34,8 @@ zxerr_t addr_getNumItems(uint8_t *num_items) { return zxerr_ok; } -zxerr_t addr_getItem(int8_t displayIdx, char *outKey, uint16_t outKeyLen, char *outVal, uint16_t outValLen, uint8_t pageIdx, - uint8_t *pageCount) { +zxerr_t addr_getItem(int8_t displayIdx, char *outKey, uint16_t outKeyLen, char *outVal, uint16_t outValLen, + uint8_t pageIdx, uint8_t *pageCount) { ZEMU_LOGF(50, "[addr_getItem] %d/%d\n", displayIdx, pageIdx) switch (displayIdx) { diff --git a/app/src/common/parser.h b/app/src/common/parser.h index 1f8c027..75ca56e 100644 --- a/app/src/common/parser.h +++ b/app/src/common/parser.h @@ -35,8 +35,8 @@ parser_error_t parser_validate(parser_tx_t *txObj); parser_error_t parser_getNumItems(const parser_tx_t *txObj, uint8_t *num_items); // retrieves a readable output for each field / page -parser_error_t parser_getItem(const parser_tx_t *txObj, uint8_t displayIdx, char *outKey, uint16_t outKeyLen, char *outVal, - uint16_t outValLen, uint8_t pageIdx, uint8_t *pageCount); +parser_error_t parser_getItem(const parser_tx_t *txObj, uint8_t displayIdx, char *outKey, uint16_t outKeyLen, + char *outVal, uint16_t outValLen, uint8_t pageIdx, uint8_t *pageCount); #ifdef __cplusplus } diff --git a/app/src/common/tx.c b/app/src/common/tx.c index d5644f1..0105a21 100644 --- a/app/src/common/tx.c +++ b/app/src/common/tx.c @@ -23,13 +23,8 @@ #include "parser.h" #include "zxmacros.h" -#if defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX) || defined(TARGET_FLEX) #define RAM_BUFFER_SIZE 4096 #define FLASH_BUFFER_SIZE 16384 -#elif defined(TARGET_NANOS) -#define RAM_BUFFER_SIZE 256 -#define FLASH_BUFFER_SIZE 8192 -#endif // Ram uint8_t ram_buffer[RAM_BUFFER_SIZE]; @@ -39,10 +34,8 @@ typedef struct { uint8_t buffer[FLASH_BUFFER_SIZE]; } storage_t; -#if defined(TARGET_NANOS) || defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX) || defined(TARGET_FLEX) storage_t NV_CONST N_appdata_impl __attribute__((aligned(64))); #define N_appdata (*(NV_VOLATILE storage_t *)PIC(&N_appdata_impl)) -#endif static parser_tx_t tx_obj = {0}; static parser_context_t ctx_parsed_tx = {0}; @@ -92,8 +85,8 @@ zxerr_t tx_getNumItems(uint8_t *num_items) { return zxerr_ok; } -zxerr_t tx_getItem(int8_t displayIdx, char *outKey, uint16_t outKeyLen, char *outVal, uint16_t outValLen, uint8_t pageIdx, - uint8_t *pageCount) { +zxerr_t tx_getItem(int8_t displayIdx, char *outKey, uint16_t outKeyLen, char *outVal, uint16_t outValLen, + uint8_t pageIdx, uint8_t *pageCount) { uint8_t numItems = 0; CHECK_ZXERR(tx_getNumItems(&numItems)) diff --git a/app/src/crypto.c b/app/src/crypto.c index 98c72e3..bdfc7bc 100644 --- a/app/src/crypto.c +++ b/app/src/crypto.c @@ -71,7 +71,8 @@ zxerr_t crypto_sign(uint8_t *signature, uint16_t signatureMaxlen, const uint8_t CATCH_CXERROR(os_derive_bip32_with_seed_no_throw(HDW_ED25519_SLIP10, CX_CURVE_Ed25519, hdPath, HDPATH_LEN_DEFAULT, privateKeyData, NULL, NULL, 0)); - CATCH_CXERROR(cx_ecfp_init_private_key_no_throw(CX_CURVE_Ed25519, privateKeyData, SCALAR_LEN_ED25519, &cx_privateKey)); + CATCH_CXERROR( + cx_ecfp_init_private_key_no_throw(CX_CURVE_Ed25519, privateKeyData, SCALAR_LEN_ED25519, &cx_privateKey)); // Sign CATCH_CXERROR(cx_eddsa_sign_no_throw(&cx_privateKey, CX_SHA512, message, messageLen, signature, signatureMaxlen)); diff --git a/app/src/crypto_helper.c b/app/src/crypto_helper.c index 616b11f..e564947 100644 --- a/app/src/crypto_helper.c +++ b/app/src/crypto_helper.c @@ -86,8 +86,8 @@ zxerr_t crypto_computeAddress(uint8_t *address, uint16_t addressLen, const uint8 uint8_t sha[PK_LEN_25519] = {0}; CHECK_ZXERR(crypto_sha256_one_shot(sha, sizeof(sha), pubkey, PK_LEN_25519)); - CHECK_ZXERR( - bech32EncodeFromBytes((char *)address, ADDRESS_MAX_LENGTH, HRP, sha, PUBKEY_SHA_LEN, 1, BECH32_ENCODING_BECH32M)); + CHECK_ZXERR(bech32EncodeFromBytes((char *)address, ADDRESS_MAX_LENGTH, HRP, sha, PUBKEY_SHA_LEN, 1, + BECH32_ENCODING_BECH32M)); return zxerr_ok; } diff --git a/app/src/parser.c b/app/src/parser.c index a38c41f..f09238f 100644 --- a/app/src/parser.c +++ b/app/src/parser.c @@ -86,8 +86,8 @@ static parser_error_t checkSanity(uint8_t numItems, uint8_t displayIdx) { return parser_ok; } -parser_error_t page_title(parser_tx_t *txObj, char *outKey, uint16_t outKeyLen, const char *title, primitive_t *primitive, - parser_context_t *data_context) { +parser_error_t page_title(parser_tx_t *txObj, char *outKey, uint16_t outKeyLen, const char *title, + primitive_t *primitive, parser_context_t *data_context) { CHECK_INPUT(outKey); CHECK_INPUT(title); @@ -130,8 +130,8 @@ static uint8_t calculate_page_count(const char *text, uint16_t maxCharsPerPage) return pageCount; } -parser_error_t page_item(parser_tx_t *txObj, char *outValue, uint16_t outValueLen, const char *title, primitive_t *primitive, - parser_context_t *data_context, uint8_t pageIdx, uint8_t *pageCount) { +parser_error_t page_item(parser_tx_t *txObj, char *outValue, uint16_t outValueLen, const char *title, + primitive_t *primitive, parser_context_t *data_context, uint8_t pageIdx, uint8_t *pageCount) { CHECK_INPUT(outValue); CHECK_INPUT(title); CHECK_INPUT(primitive); @@ -188,8 +188,8 @@ parser_error_t page_item(parser_tx_t *txObj, char *outValue, uint16_t outValueLe return parser_ok; } -parser_error_t parser_getItem(const parser_tx_t *txObj, uint8_t displayIdx, char *outKey, uint16_t outKeyLen, char *outVal, - uint16_t outValLen, uint8_t pageIdx, uint8_t *pageCount) { +parser_error_t parser_getItem(const parser_tx_t *txObj, uint8_t displayIdx, char *outKey, uint16_t outKeyLen, + char *outVal, uint16_t outValLen, uint8_t pageIdx, uint8_t *pageCount) { UNUSED(pageIdx); *pageCount = 1; uint8_t numItems = 0; diff --git a/app/src/render.c b/app/src/render.c index f85711b..add734e 100644 --- a/app/src/render.c +++ b/app/src/render.c @@ -153,8 +153,8 @@ parser_error_t render_fixed_point(parser_context_t *ctx, fixed_point_display_t d } } -parser_error_t render_primitive_integer(parser_context_t *ctx, integer_display_t display, uint128_t value, char *outValue, - uint16_t outValueLen) { +parser_error_t render_primitive_integer(parser_context_t *ctx, integer_display_t display, uint128_t value, + char *outValue, uint16_t outValueLen) { CHECK_INPUT(ctx); CHECK_INPUT(outValue); MEMZERO(outValue, outValueLen); @@ -177,7 +177,8 @@ parser_error_t render_primitive_integer(parser_context_t *ctx, integer_display_t return parser_ok; } -parser_error_t render_integer(parser_context_t *ctx, primitive_integer_t *primitive, char *outValue, uint16_t outValueLen) { +parser_error_t render_integer(parser_context_t *ctx, primitive_integer_t *primitive, char *outValue, + uint16_t outValueLen) { CHECK_INPUT(ctx); CHECK_INPUT(primitive); diff --git a/app/src/schema_helper.c b/app/src/schema_helper.c index aefed62..075fc35 100644 --- a/app/src/schema_helper.c +++ b/app/src/schema_helper.c @@ -27,7 +27,8 @@ * @param found Output: set to true if the index is found, false otherwise. * @return parser_error_t Error code indicating success or failure. */ -parser_error_t schema_find_index(uint64_t index_leaf, merkle_leaves_indices_t *indices, uint64_t *index_vec, bool *found) { +parser_error_t schema_find_index(uint64_t index_leaf, merkle_leaves_indices_t *indices, uint64_t *index_vec, + bool *found) { CHECK_INPUT(indices); CHECK_INPUT(index_vec); diff --git a/app/src/schema_helper.h b/app/src/schema_helper.h index 93bbb89..f9fc5e7 100644 --- a/app/src/schema_helper.h +++ b/app/src/schema_helper.h @@ -22,7 +22,8 @@ extern "C" { #include "parser_common.h" -parser_error_t schema_find_index(uint64_t index_leaf, merkle_leaves_indices_t *indices, uint64_t *index_vec, bool *found); +parser_error_t schema_find_index(uint64_t index_leaf, merkle_leaves_indices_t *indices, uint64_t *index_vec, + bool *found); parser_error_t schema_move_leaf_offset(merkle_leaves_data_t *leaves, uint64_t index); parser_error_t schema_reset_leaf_offset(merkle_leaves_data_t *leaves); parser_error_t get_schema_type(parser_tx_t *txObj, uint32_t index, uint8_t *type); diff --git a/app/src/schema_proof.c b/app/src/schema_proof.c index 0d5208c..1753d19 100644 --- a/app/src/schema_proof.c +++ b/app/src/schema_proof.c @@ -70,7 +70,8 @@ static uint32_t next_smaller_po2(uint32_t n) { * @param tree_size The output buffer for the computed tree size. * @return parser_error_t Error code indicating the result of the operation. */ -parser_error_t compute_tree_size(uint32_t num_right_siblings, uint32_t index_of_last_included_leaf, uint32_t *tree_size) { +parser_error_t compute_tree_size(uint32_t num_right_siblings, uint32_t index_of_last_included_leaf, + uint32_t *tree_size) { uint32_t index_of_final_node = index_of_last_included_leaf; uint32_t mask = 1; uint32_t remaining_right_siblings = num_right_siblings; diff --git a/app/src/schema_reader.c b/app/src/schema_reader.c index ee1bf1c..f0a27f6 100644 --- a/app/src/schema_reader.c +++ b/app/src/schema_reader.c @@ -747,7 +747,8 @@ parser_error_t compute_internal_data_hash(parser_tx_t *txObj, uint8_t *internal_ crypto_sha256_init(); crypto_sha256_update(txObj->schema.root_type_indices.complete_borsh_data.ptr, txObj->schema.root_type_indices.complete_borsh_data.len); - crypto_sha256_update(txObj->schema.chain_data.complete_borsh_data.ptr, txObj->schema.chain_data.complete_borsh_data.len); + crypto_sha256_update(txObj->schema.chain_data.complete_borsh_data.ptr, + txObj->schema.chain_data.complete_borsh_data.len); crypto_sha256_final(internal_data_hash); return parser_ok; diff --git a/app/src/schema_txn_parser.c b/app/src/schema_txn_parser.c index 9dc2cf6..e74b86f 100644 --- a/app/src/schema_txn_parser.c +++ b/app/src/schema_txn_parser.c @@ -30,7 +30,8 @@ bool ui_expert_mode = false; #define NONE_STRING "None" -parser_error_t append_structured_show_as_title(const bytes_t *structured_show_as, uint32_t field_index, bool *remove_title) { +parser_error_t append_structured_show_as_title(const bytes_t *structured_show_as, uint32_t field_index, + bool *remove_title) { CHECK_INPUT(structured_show_as); CHECK_INPUT(remove_title); @@ -45,7 +46,8 @@ parser_error_t append_structured_show_as_title(const bytes_t *structured_show_as return parser_ok; } -parser_error_t schema_display_integer(parser_context_t *ctx, primitive_integer_t *primitive, parser_context_t *ctx_to_push) { +parser_error_t schema_display_integer(parser_context_t *ctx, primitive_integer_t *primitive, + parser_context_t *ctx_to_push) { CHECK_INPUT(ctx); CHECK_INPUT(primitive); CHECK_INPUT(ctx_to_push); @@ -103,7 +105,8 @@ parser_error_t schema_display_integer(parser_context_t *ctx, primitive_integer_t return parser_unexpected_type; case FIXED_POINT_DISPLAY_FROM_SIBLING_FIELD: // get offset - if (ctx->offset + primitive->display.fixed_point.from_sibling_field.byte_offset >= ctx->buffer.len) { + if (ctx->offset + primitive->display.fixed_point.from_sibling_field.byte_offset >= + ctx->buffer.len) { return parser_unexpected_buffer_end; } len_to_push += primitive->display.fixed_point.from_sibling_field.byte_offset + 1; @@ -239,7 +242,8 @@ parser_error_t schema_display_struct(parser_context_t *ctx, parser_tx_t *txObj) MEMZERO(&named_field, sizeof(named_field_t)); CHECK_ERROR(read_named_field(&struct_type.named_fields, &named_field)); - bool show_field = should_show_field(&named_field.value, named_field.silent, named_field.is_expert, ui_expert_mode); + bool show_field = + should_show_field(&named_field.value, named_field.silent, named_field.is_expert, ui_expert_mode); bool remove_title = false; if (show_field) { diff --git a/app/src/ui_item_buffer.c b/app/src/ui_item_buffer.c index 181e3d0..2794a83 100644 --- a/app/src/ui_item_buffer.c +++ b/app/src/ui_item_buffer.c @@ -281,7 +281,8 @@ parser_error_t get_item_buffer_range_length(item_buffer_t *buffer, uint8_t index return parser_ok; } -parser_error_t get_item_buffer_range(item_buffer_t *buffer, uint8_t index_start, uint8_t index_end, item_buffer_t *output) { +parser_error_t get_item_buffer_range(item_buffer_t *buffer, uint8_t index_start, uint8_t index_end, + item_buffer_t *output) { CHECK_INPUT(buffer); CHECK_INPUT(output); diff --git a/app/src/ui_item_buffer.h b/app/src/ui_item_buffer.h index c08ec45..de8e01f 100644 --- a/app/src/ui_item_buffer.h +++ b/app/src/ui_item_buffer.h @@ -28,6 +28,7 @@ parser_error_t get_item_buffer_content(item_buffer_t *buffer, uint8_t index, cha parser_error_t get_item_buffer_content_length(item_buffer_t *buffer, uint8_t index, size_t *length); parser_error_t get_item_buffer_range_length(item_buffer_t *buffer, uint8_t index_start, uint8_t index_end, size_t *total_length); -parser_error_t get_item_buffer_range(item_buffer_t *buffer, uint8_t index_start, uint8_t index_end, item_buffer_t *output); +parser_error_t get_item_buffer_range(item_buffer_t *buffer, uint8_t index_start, uint8_t index_end, + item_buffer_t *output); parser_error_t remove_first_separator(item_buffer_t *buffer, char *output, uint16_t output_len); parser_error_t remove_last_separator(item_buffer_t *buffer, char *output, uint16_t output_len); \ No newline at end of file diff --git a/app/src/ui_item_manager.c b/app/src/ui_item_manager.c index 2f1ac44..a4974ab 100644 --- a/app/src/ui_item_manager.c +++ b/app/src/ui_item_manager.c @@ -96,7 +96,8 @@ parser_error_t create_item_title(uint16_t index_start, uint16_t index_end, char for (uint16_t i = index_start; i < index_end; i++) { uint16_t output_str_len = strlen(output); - CHECK_ERROR(get_item_buffer_content(&item_title_buffer, i, output + output_str_len, output_len - output_str_len)); + CHECK_ERROR( + get_item_buffer_content(&item_title_buffer, i, output + output_str_len, output_len - output_str_len)); if (i < index_end - 1) { strncat(output, SEPARATOR_TITLE_DISPLAY, strlen(SEPARATOR_TITLE_DISPLAY)); } diff --git a/cmake/Hunter/config.cmake b/cmake/Hunter/config.cmake index 13447cb..d9cd376 100644 --- a/cmake/Hunter/config.cmake +++ b/cmake/Hunter/config.cmake @@ -1,3 +1,2 @@ -hunter_config(jsoncpp VERSION 1.9.5-b1) hunter_config(fmt VERSION 10.1.1) hunter_config(GTest VERSION 1.14.0) diff --git a/cmake/HunterGate.cmake b/cmake/HunterGate.cmake index 17c6d38..b597ea5 100644 --- a/cmake/HunterGate.cmake +++ b/cmake/HunterGate.cmake @@ -25,7 +25,7 @@ # This is a gate file to Hunter package manager. # Include this file using `include` command and add package you need, example: # -# cmake_minimum_required(VERSION 3.5) +# cmake_minimum_required(VERSION 3.10) # # include("cmake/HunterGate.cmake") # HunterGate( @@ -45,10 +45,10 @@ option(HUNTER_ENABLED "Enable Hunter package manager support" ON) if(HUNTER_ENABLED) - if(CMAKE_VERSION VERSION_LESS "3.5") + if(CMAKE_VERSION VERSION_LESS "3.10") message( FATAL_ERROR - "At least CMake version 3.5 required for Hunter dependency management." + "At least CMake version 3.10 required for Hunter dependency management." " Update CMake or set HUNTER_ENABLED to OFF." ) endif() @@ -253,7 +253,7 @@ function(hunter_gate_download dir) file( WRITE "${cmakelists}" - "cmake_minimum_required(VERSION 3.5)\n" + "cmake_minimum_required(VERSION 3.10)\n" "if(POLICY CMP0114)\n" " cmake_policy(SET CMP0114 NEW)\n" "endif()\n" diff --git a/docs/APDUSPEC.md b/docs/APDUSPEC.md index a88cfe9..ded5529 100644 --- a/docs/APDUSPEC.md +++ b/docs/APDUSPEC.md @@ -44,7 +44,7 @@ The general structure of commands and responses is as follows: ## Command definition -### GET_VERSION +### INS_GET_VERSION #### Command @@ -58,14 +58,15 @@ The general structure of commands and responses is as follows: #### Response -| Field | Type | Content | Note | -| ------- | -------- | ---------------- | ------------------------------- | -| TEST | byte (1) | Test Mode | 0xFF means test mode is enabled | -| MAJOR | byte (2) | Version Major | 0..65535 | -| MINOR | byte (2) | Version Minor | 0..65535 | -| PATCH | byte (2) | Version Patch | 0..65535 | -| LOCKED | byte (1) | Device is locked | | -| SW1-SW2 | byte (2) | Return code | see list of return codes | +| Field | Type | Content | Note | +| --------- | -------- | ---------------- | --------------------------------- | +| TEST | byte (1) | Test Mode | `0xFF` means test mode is enabled | +| MAJOR | byte (2) | Version Major | `0..65535` | +| MINOR | byte (2) | Version Minor | `0..65535` | +| PATCH | byte (2) | Version Patch | `0..65535` | +| LOCKED | byte (1) | Device is locked | | +| TARGET_ID | byte (4) | Target ID | | +| SW1-SW2 | byte (2) | Return code | See list of return codes | --- diff --git a/tests/parser_impl.cpp b/tests/parser_impl.cpp index 82ee977..fa15c0c 100644 --- a/tests/parser_impl.cpp +++ b/tests/parser_impl.cpp @@ -33,145 +33,281 @@ TEST(SCALE, ReadMetadata) { parser_tx_t tx_obj = {0}; parser_error_t err; uint8_t buffer[12000]; - auto bufferLen = parseHexString( - buffer, sizeof(buffer), - "6c000000010b0000005472616e73616374696f6e00000005000000090000007369676e617475726500000001000000000000000000000007000" - "0007075625f6b65790000000200000000000000000000000c00000072756e74696d655f63616c6c0000000300000000000000000000000a0000" - "0067656e65726174696f6e000001000801000000000700000064657461696c73000000690000000000000000000000000001100000004564323" - "53531395369676e617475726500000001000000070000006d73675f736967000001014000000000000000000000000000000001100000004564" - "32353531395075626c69634b657900000001000000070000007075625f6b65790000010120000000000000000000000000000000000b0000005" - "2756e74696d6543616c6c0c0000000400000042616e6b0000010004000000000000001100000053657175656e63657252656769737472790100" - "010016000000000000000b00000056616c7565536574746572020001001d00000000000000120000004174746573746572496e63656e7469766" - "5730300010025000000000000001000000050726f766572496e63656e7469766573040001002a00000000000000080000004163636f756e7473" - "050001002e000000000000000a000000556e697175656e6573730600010033000000000000000a000000436861696e537461746507000100350" - "00000000000000b000000426c6f6253746f72616765080001003600000000000000090000005061796d61737465720900010037000000000000" - "000300000045766d0a00010051000000000000000d0000004163636573735061747465726e0b000100540000000000000001000002000000010" - "000000005000000000000000000000000000000000b00000043616c6c4d657373616765050000000b000000437265617465546f6b656e000001" - "000600000000000000080000005472616e73666572010001001000000000000000040000004275726e020001001300000000000000040000004" - "d696e7403000100140000000000000006000000467265657a65040001001500000000000000000000012a0000005f5f536f765669727475616c" - "57616c6c65745f43616c6c4d6573736167655f437265617465546f6b656e000000060000000a000000746f6b656e5f6e616d650000010500000" - "0000e000000746f6b656e5f646563696d616c730000000700000000000000000000000f000000696e697469616c5f62616c616e636500000008" - "00000000000000000000000f0000006d696e745f746f5f616464726573730000000900000000000000000000000600000061646d696e7300000" - "00e00000000000000000000000a000000737570706c795f6361700000000f000000000000000000000000000301000501020000000100000001" - "0009010000000000000000000c0000004d756c74694164647265737302000000080000005374616e64617264000001000a00000000000000020" - "00000566d010001000c000000000000000100000200000001000000000b000000000000000000000000000000020000000100000001011c0000" - "00000000000303000000736f760000000000000000000200000001000000000d000000000000000000000000000000020000000100000001011" - "400000000000000000000000000000000000d0009000000000000000300080000000000000001270000005f5f536f765669727475616c57616c" - "6c65745f43616c6c4d6573736167655f5472616e73666572011a0000005472616e7366657220746f2061646472657373207b7d207b7d2e01070" - "000007c7b546f7d7b7d000200000002000000746f00000009000000000000000000000005000000636f696e7300000011000000000000000000" - "0000010100000000000000000105000000436f696e7301170000007b7d20636f696e73206f6620746f6b656e204944207b7d01140000007b416" - "d6f756e747c7d7b546f6b656e2049447c7d010200000006000000616d6f756e740000010009020101000000000000001f000000000000000000" - "000008000000746f6b656e5f696400000012000000000000000000000000000200000001000000010120000000000000000306000000746f6b6" - "56e5f0109000000746f6b656e5f696473000000000000000001230000005f5f536f765669727475616c57616c6c65745f43616c6c4d65737361" - "67655f4275726e0000000100000005000000636f696e73000000110000000000000000000000000001230000005f5f536f765669727475616c5" - "7616c6c65745f43616c6c4d6573736167655f4d696e740000000200000005000000636f696e730000001100000000000000000000000f000000" - "6d696e745f746f5f61646472657373000000090000000000000000000000000001250000005f5f536f765669727475616c57616c6c65745f436" - "16c6c4d6573736167655f467265657a650000000100000008000000746f6b656e5f696400000012000000000000000000000000000200000001" - "0000000017000000000000000000000000000000000b00000043616c6c4d6573736167650400000008000000526567697374657200000100180" - "0000000000000070000004465706f736974010001001a0000000000000012000000496e6974696174655769746864726177616c020001001b00" - "000000000000080000005769746864726177030001001c0000000000000000000001270000005f5f536f765669727475616c57616c6c65745f4" - "3616c6c4d6573736167655f5265676973746572000000020000000a00000064615f616464726573730000001900000000000000000000000600" - "0000616d6f756e74000000080000000000000000000000000002000000010000000101200000000000000000000000000000000000012600000" - "05f5f536f765669727475616c57616c6c65745f43616c6c4d6573736167655f4465706f736974000000020000000a00000064615f6164647265" - "737300000019000000000000000000000006000000616d6f756e74000000080000000000000000000000000001310000005f5f536f765669727" - "475616c57616c6c65745f43616c6c4d6573736167655f496e6974696174655769746864726177616c000000010000000a00000064615f616464" - "72657373000000190000000000000000000000000001270000005f5f536f765669727475616c57616c6c65745f43616c6c4d6573736167655f5" - "769746864726177000000010000000a00000064615f6164647265737300000019000000000000000000000000000200000001000000001e0000" - "00000000000000000000000000000b00000043616c6c4d657373616765030000000800000053657456616c7565000001001f000000000000000" - "d0000005365744d616e7956616c7565730100010023000000000000001700000041737365727456697369626c65536c6f744e756d6265720200" - "0100240000000000000000000001270000005f5f536f765669727475616c57616c6c65745f43616c6c4d6573736167655f53657456616c75650" - "00000020000000500000076616c7565000001000701000000000300000067617300000020000000000000000000000000000300210000000000" - "0000020000000100000000220000000000000000000000000000000c02000000000000000100080102000000010000000102000000000000000" - "0000001360000005f5f536f765669727475616c57616c6c65745f43616c6c4d6573736167655f41737365727456697369626c65536c6f744e75" - "6d626572000000010000001c00000065787065637465645f76697369626c655f736c6f745f6e756d62657200000100080100000000000002000" - "000010000000026000000000000000000000000000000000b00000043616c6c4d65737361676506000000100000005265676973746572417474" - "657374657200000100270000000000000011000000426567696e4578697441747465737465720100000c0000004578697441747465737465720" - "200001200000052656769737465724368616c6c656e6765720300010028000000000000000e000000457869744368616c6c656e676572040000" - "0f0000004465706f736974417474657374657205000100290000000000000000000002000000010000000008000000000000000000000000000" - "0000200000001000000000800000000000000000000000000000002000000010000000008000000000000000000000000000000020000000100" - "0000002b000000000000000000000000000000000b00000043616c6c4d65737361676503000000080000005265676973746572000001002c000" - "00000000000070000004465706f736974010001002d000000000000000400000045786974020000000000020000000100000000080000000000" - "00000000000000000000020000000100000000080000000000000000000000000000000200000001000000002f0000000000000000000000000" - "00000000b00000043616c6c4d6573736167650100000012000000496e7365727443726564656e7469616c496400000100300000000000000000" - "0000020000000100000000310000000000000000000000000000000200000001000000003200000000000000000000000000000002000000010" - "00000010120000000000000000000000000000000000002000000010000000034000000000000000000000000000000000f0000004e6f74496e" - "7374616e746961626c6500000000000000020000000100000000340000000000000000000000000000000200000001000000003400000000000" - "000000000000000000002000000010000000038000000000000000000000000000000000b00000043616c6c4d65737361676503000000110000" - "0052656769737465725061796d6173746572000001003900000000000000140000005365745061796572466f7253657175656e6365720100010" - "046000000000000000c000000557064617465506f6c69637902000100470000000000000000000001300000005f5f536f765669727475616c57" - "616c6c65745f43616c6c4d6573736167655f52656769737465725061796d61737465720000000100000006000000706f6c6963790000003a000" - "0000000000000000000010300000000000000010200000000000000011a0000005061796d6173746572506f6c696379496e697469616c697a65" - "72000000040000001400000064656661756c745f70617965655f706f6c6963790000003b0000000000000000000000060000007061796565730" - "0000041000000000000000000000013000000617574686f72697a65645f75706461746572730000000e00000000000000000000001500000061" - "7574686f72697a65645f73657175656e636572730000004300000000000000000000000000000b0000005061796565506f6c696379020000000" - "5000000416c6c6f77000001003c000000000000000400000044656e7901000000000001240000005f5f536f765669727475616c57616c6c6574" - "5f5061796565506f6c6963795f416c6c6f7700000004000000070000006d61785f6665650000000f00000000000000000000000900000067617" - "35f6c696d69740000002000000000000000000000000d0000006d61785f6761735f70726963650000003d000000000000000000000011000000" - "7472616e73616374696f6e5f6c696d6974000000400000000000000000000000000003003e00000000000000010800000047617350726963650" - "00000010000000500000076616c75650000003f000000000000000000000000000c020000000000000000080000000000000003010008010d00" - "42000000000000000200000002000000000900000000000000000000000000003b0000000000000000000000000000000014000000417574686" - "f72697a656453657175656e636572730200000003000000416c6c00000004000000536f6d650100010044000000000000000000000200000001" - "00000000450000000000000000000000000000000d00190000000000000001330000005f5f536f765669727475616c57616c6c65745f43616c6" - "c4d6573736167655f5365745061796572466f7253657175656e6365720000000100000005000000706179657200000009000000000000000000" - "00000000012b0000005f5f536f765669727475616c57616c6c65745f43616c6c4d6573736167655f557064617465506f6c69637900000002000" - "000050000007061796572000000090000000000000000000000060000007570646174650000004800000000000000000000000000010c000000" - "506f6c696379557064617465000000060000001000000073657175656e6365725f7570646174650000004900000000000000000000000f00000" - "075706461746572735f746f5f6164640000004e00000000000000000000001200000075706461746572735f746f5f72656d6f76650000004e00" - "000000000000000000001500000070617965655f706f6c69636965735f746f5f7365740000004f0000000000000000000000180000007061796" - "5655f706f6c69636965735f746f5f64656c6574650000004e00000000000000000000000e00000064656661756c745f706f6c69637900000050" - "0000000000000000000000000003004a00000000000000001200000053657175656e6365725365745570646174650200000008000000416c6c6" - "f77416c6c00000006000000557064617465010001004b000000000000000000000200000001000000004c000000000000000000000000000000" - "0116000000416c6c6f77656453657175656e6365725570646174650000000200000006000000746f5f6164640000004d0000000000000000000" - "00009000000746f5f72656d6f76650000004d000000000000000000000000000300450000000000000003000e00000000000000030041000000" - "0000000003003b0000000000000002000000010000000052000000000000000000000000000000010b00000043616c6c4d65737361676500000" - "00100000003000000726c7000000053000000000000000000000000000111000000526c7045766d5472616e73616374696f6e00000001000000" - "03000000726c7000000102000000000000000002000000010000000055000000000000000000000000000000001500000041636365737350617" - "47465726e4d657373616765730e0000000a000000577269746543656c6c730000010056000000000000000b0000005772697465437573746f6d" - "010001005700000000000000090000005265616443656c6c7302000100590000000000000009000000486173684279746573030001005a00000" - "0000000000a00000048617368437573746f6d040001005b000000000000000e00000053746f72655369676e6174757265050001005c00000000" - "0000000f0000005665726966795369676e617475726506000015000000566572696679437573746f6d5369676e6174757265070001005d00000" - "0000000001500000053746f726553657269616c697a6564537472696e67080001005e0000000000000018000000446573657269616c697a6542" - "797465734173537472696e6709000017000000446573657269616c697a65437573746f6d537472696e670a0001005f000000000000000b00000" - "044656c65746543656c6c730b000100600000000000000007000000536574486f6f6b0c00010061000000000000000b00000055706461746541" - "646d696e0d000100680000000000000000000001330000005f5f536f765669727475616c57616c6c65745f4163636573735061747465726e4d6" - "57373616765735f577269746543656c6c730000000300000005000000626567696e00000100080100000000090000006e756d5f63656c6c7300" - "00010008010000000009000000646174615f73697a6500000100070100000000000001340000005f5f536f765669727475616c57616c6c65745" - "f4163636573735061747465726e4d657373616765735f5772697465437573746f6d0000000200000005000000626567696e0000010008010000" - "000007000000636f6e74656e7400000058000000000000000000000000000d010501320000005f5f536f765669727475616c57616c6c65745f4" - "163636573735061747465726e4d657373616765735f5265616443656c6c730000000200000005000000626567696e0000010008010000000009" - "0000006e756d5f63656c6c7300000100080100000000000001320000005f5f536f765669727475616c57616c6c65745f4163636573735061747" - "465726e4d657373616765735f486173684279746573000000020000000600000066696c6c6572000001000501000000000400000073697a6500" - "000100070100000000000001330000005f5f536f765669727475616c57616c6c65745f4163636573735061747465726e4d657373616765735f4" - "8617368437573746f6d0000000100000005000000696e70757400000102000000000000000001370000005f5f536f765669727475616c57616c" - "6c65745f4163636573735061747465726e4d657373616765735f53746f72655369676e617475726500000003000000040000007369676e00000" - "0010000000000000000000000070000007075625f6b6579000000020000000000000000000000070000006d6573736167650000010500000000" - "0000013e0000005f5f536f765669727475616c57616c6c65745f4163636573735061747465726e4d657373616765735f5665726966794375737" - "46f6d5369676e617475726500000003000000040000007369676e000000010000000000000000000000070000007075625f6b65790000000200" - "00000000000000000000070000006d65737361676500000105000000000000013e0000005f5f536f765669727475616c57616c6c65745f41636" - "36573735061747465726e4d657373616765735f53746f726553657269616c697a6564537472696e670000000100000005000000696e70757400" - "000102000000000000000001400000005f5f536f765669727475616c57616c6c65745f4163636573735061747465726e4d657373616765735f4" - "46573657269616c697a65437573746f6d537472696e670000000100000005000000696e70757400000102000000000000000001340000005f5f" - "536f765669727475616c57616c6c65745f4163636573735061747465726e4d657373616765735f44656c65746543656c6c73000000020000000" - "5000000626567696e00000100080100000000090000006e756d5f63656c6c7300000100080100000000000001300000005f5f536f7656697274" - "75616c57616c6c65745f4163636573735061747465726e4d657373616765735f536574486f6f6b0000000200000003000000707265000000620" - "00000000000000000000004000000706f73740000006200000000000000000000000000030063000000000000000d006400000000000000000b" - "000000486f6f6b73436f6e666967030000000400000052656164000001006500000000000000050000005772697465010001006600000000000" - "0000600000044656c65746502000100670000000000000000000001230000005f5f536f765669727475616c57616c6c65745f486f6f6b73436f" - "6e6669675f526561640000000200000005000000626567696e000001000801000000000400000073697a6500000100080100000000000001240" - "000005f5f536f765669727475616c57616c6c65745f486f6f6b73436f6e6669675f57726974650000000300000005000000626567696e000001" - "000801000000000400000073697a650000010008010000000009000000646174615f73697a6500000100070100000000000001250000005f5f5" - "36f765669727475616c57616c6c65745f486f6f6b73436f6e6669675f44656c6574650000000200000005000000626567696e00000100080100" - "0000000400000073697a6500000100080100000000000001340000005f5f536f765669727475616c57616c6c65745f416363657373506174746" - "5726e4d657373616765735f55706461746541646d696e00000001000000090000006e65775f61646d696e000000090000000000000000000000" - "00000109000000547844657461696c730001370000007b4d6178205072696f72697479204665657c7d7c7b4d6178204665657c7d7c7b4761732" - "04c696d69747c7d7c7b436861696e2049447c7d0004000000150000006d61785f7072696f726974795f6665655f626970730001006a00000000" - "00000000000000070000006d61785f666565000000080000000000000000000000090000006761735f6c696d697400010020000000000000000" - "000000008000000636861696e5f696400010100080100000000000002000000010000000100080100000000000000000113000000556e736967" - "6e65645472616e73616374696f6e0001120000007b7d7c7b47656e65726174696f6e7d7c7b7d00030000000c00000072756e74696d655f63616" - "c6c0000000300000000000000000000000a00000067656e65726174696f6e000101000801000000000700000064657461696c73000000690000" - "00000000000000000000000400000000000000000000006b0000000000000003000000000000000b00000000000000e11000000000000009000" - "00054657374436861696e060100000009000000746f6b656e5f6964730100000020000000171717171717171717171717171717171717171717" - "17171717171717171717060900000054657374546f6b656e77f986b27d5c6e676fdb865f44833b5fe97f5cccafaf5b4733c21ba027f8b725"); + auto bufferLen = parseHexString(buffer, sizeof(buffer), + "6c000000010b0000005472616e73616374696f6e00000005000000090000007369676e617475726500" + "000001000000000000000000000007000" + "0007075625f6b65790000000200000000000000000000000c00000072756e74696d655f63616c6c000" + "0000300000000000000000000000a0000" + "0067656e65726174696f6e000001000801000000000700000064657461696c73000000690000000000" + "000000000000000001100000004564323" + "53531395369676e617475726500000001000000070000006d73675f736967000001014000000000000" + "000000000000000000001100000004564" + "32353531395075626c69634b657900000001000000070000007075625f6b6579000001012000000000" + "0000000000000000000000000b0000005" + "2756e74696d6543616c6c0c0000000400000042616e6b0000010004000000000000001100000053657" + "175656e63657252656769737472790100" + "010016000000000000000b00000056616c7565536574746572020001001d0000000000000012000000" + "4174746573746572496e63656e7469766" + "5730300010025000000000000001000000050726f766572496e63656e7469766573040001002a00000" + "000000000080000004163636f756e7473" + "050001002e000000000000000a000000556e697175656e6573730600010033000000000000000a0000" + "00436861696e537461746507000100350" + "00000000000000b000000426c6f6253746f72616765080001003600000000000000090000005061796" + "d61737465720900010037000000000000" + "000300000045766d0a00010051000000000000000d0000004163636573735061747465726e0b000100" + "540000000000000001000002000000010" + "000000005000000000000000000000000000000000b00000043616c6c4d657373616765050000000b0" + "00000437265617465546f6b656e000001" + "000600000000000000080000005472616e73666572010001001000000000000000040000004275726e" + "020001001300000000000000040000004" + "d696e7403000100140000000000000006000000467265657a650400010015000000000000000000000" + "12a0000005f5f536f765669727475616c" + "57616c6c65745f43616c6c4d6573736167655f437265617465546f6b656e000000060000000a000000" + "746f6b656e5f6e616d650000010500000" + "0000e000000746f6b656e5f646563696d616c730000000700000000000000000000000f000000696e6" + "97469616c5f62616c616e636500000008" + "00000000000000000000000f0000006d696e745f746f5f616464726573730000000900000000000000" + "000000000600000061646d696e7300000" + "00e00000000000000000000000a000000737570706c795f6361700000000f000000000000000000000" + "000000301000501020000000100000001" + "0009010000000000000000000c0000004d756c74694164647265737302000000080000005374616e64" + "617264000001000a00000000000000020" + "00000566d010001000c000000000000000100000200000001000000000b00000000000000000000000" + "0000000020000000100000001011c0000" + "00000000000303000000736f760000000000000000000200000001000000000d000000000000000000" + "000000000000020000000100000001011" + "400000000000000000000000000000000000d000900000000000000030008000000000000000127000" + "0005f5f536f765669727475616c57616c" + "6c65745f43616c6c4d6573736167655f5472616e73666572011a0000005472616e7366657220746f20" + "61646472657373207b7d207b7d2e01070" + "000007c7b546f7d7b7d000200000002000000746f00000009000000000000000000000005000000636" + "f696e7300000011000000000000000000" + "0000010100000000000000000105000000436f696e7301170000007b7d20636f696e73206f6620746f" + "6b656e204944207b7d01140000007b416" + "d6f756e747c7d7b546f6b656e2049447c7d010200000006000000616d6f756e7400000100090201010" + "00000000000001f000000000000000000" + "000008000000746f6b656e5f6964000000120000000000000000000000000002000000010000000101" + "20000000000000000306000000746f6b6" + "56e5f0109000000746f6b656e5f696473000000000000000001230000005f5f536f765669727475616" + "c57616c6c65745f43616c6c4d65737361" + "67655f4275726e0000000100000005000000636f696e73000000110000000000000000000000000001" + "230000005f5f536f765669727475616c5" + "7616c6c65745f43616c6c4d6573736167655f4d696e740000000200000005000000636f696e7300000" + "01100000000000000000000000f000000" + "6d696e745f746f5f61646472657373000000090000000000000000000000000001250000005f5f536f" + "765669727475616c57616c6c65745f436" + "16c6c4d6573736167655f467265657a650000000100000008000000746f6b656e5f696400000012000" + "000000000000000000000000200000001" + "0000000017000000000000000000000000000000000b00000043616c6c4d6573736167650400000008" + "000000526567697374657200000100180" + "0000000000000070000004465706f736974010001001a0000000000000012000000496e69746961746" + "55769746864726177616c020001001b00" + "000000000000080000005769746864726177030001001c0000000000000000000001270000005f5f53" + "6f765669727475616c57616c6c65745f4" + "3616c6c4d6573736167655f5265676973746572000000020000000a00000064615f616464726573730" + "000001900000000000000000000000600" + "0000616d6f756e74000000080000000000000000000000000002000000010000000101200000000000" + "000000000000000000000000012600000" + "05f5f536f765669727475616c57616c6c65745f43616c6c4d6573736167655f4465706f73697400000" + "0020000000a00000064615f6164647265" + "737300000019000000000000000000000006000000616d6f756e740000000800000000000000000000" + "00000001310000005f5f536f765669727" + "475616c57616c6c65745f43616c6c4d6573736167655f496e6974696174655769746864726177616c0" + "00000010000000a00000064615f616464" + "72657373000000190000000000000000000000000001270000005f5f536f765669727475616c57616c" + "6c65745f43616c6c4d6573736167655f5" + "769746864726177000000010000000a00000064615f616464726573730000001900000000000000000" + "0000000000200000001000000001e0000" + "00000000000000000000000000000b00000043616c6c4d657373616765030000000800000053657456" + "616c7565000001001f000000000000000" + "d0000005365744d616e7956616c7565730100010023000000000000001700000041737365727456697" + "369626c65536c6f744e756d6265720200" + "0100240000000000000000000001270000005f5f536f765669727475616c57616c6c65745f43616c6c" + "4d6573736167655f53657456616c75650" + "00000020000000500000076616c7565000001000701000000000300000067617300000020000000000" + "000000000000000000300210000000000" + "0000020000000100000000220000000000000000000000000000000c02000000000000000100080102" + "000000010000000102000000000000000" + "0000001360000005f5f536f765669727475616c57616c6c65745f43616c6c4d6573736167655f41737" + "365727456697369626c65536c6f744e75" + "6d626572000000010000001c00000065787065637465645f76697369626c655f736c6f745f6e756d62" + "657200000100080100000000000002000" + "000010000000026000000000000000000000000000000000b00000043616c6c4d65737361676506000" + "000100000005265676973746572417474" + "657374657200000100270000000000000011000000426567696e457869744174746573746572010000" + "0c0000004578697441747465737465720" + "200001200000052656769737465724368616c6c656e6765720300010028000000000000000e0000004" + "57869744368616c6c656e676572040000" + "0f0000004465706f736974417474657374657205000100290000000000000000000002000000010000" + "000008000000000000000000000000000" + "0000200000001000000000800000000000000000000000000000002000000010000000008000000000" + "000000000000000000000020000000100" + "0000002b000000000000000000000000000000000b00000043616c6c4d657373616765030000000800" + "00005265676973746572000001002c000" + "00000000000070000004465706f736974010001002d000000000000000400000045786974020000000" + "000020000000100000000080000000000" + "0000000000000000000002000000010000000008000000000000000000000000000000020000000100" + "0000002f0000000000000000000000000" + "00000000b00000043616c6c4d6573736167650100000012000000496e7365727443726564656e74696" + "16c496400000100300000000000000000" + "0000020000000100000000310000000000000000000000000000000200000001000000003200000000" + "000000000000000000000002000000010" + "0000001012000000000000000000000000000000000000200000001000000003400000000000000000" + "0000000000000000f0000004e6f74496e" + "7374616e746961626c6500000000000000020000000100000000340000000000000000000000000000" + "000200000001000000003400000000000" + "000000000000000000002000000010000000038000000000000000000000000000000000b000000436" + "16c6c4d65737361676503000000110000" + "0052656769737465725061796d61737465720000010039000000000000001400000053657450617965" + "72466f7253657175656e6365720100010" + "046000000000000000c000000557064617465506f6c696379020001004700000000000000000000013" + "00000005f5f536f765669727475616c57" + "616c6c65745f43616c6c4d6573736167655f52656769737465725061796d6173746572000000010000" + "0006000000706f6c6963790000003a000" + "0000000000000000000010300000000000000010200000000000000011a0000005061796d617374657" + "2506f6c696379496e697469616c697a65" + "72000000040000001400000064656661756c745f70617965655f706f6c6963790000003b0000000000" + "000000000000060000007061796565730" + "0000041000000000000000000000013000000617574686f72697a65645f75706461746572730000000" + "e00000000000000000000001500000061" + "7574686f72697a65645f73657175656e636572730000004300000000000000000000000000000b0000" + "005061796565506f6c696379020000000" + "5000000416c6c6f77000001003c000000000000000400000044656e7901000000000001240000005f5" + "f536f765669727475616c57616c6c6574" + "5f5061796565506f6c6963795f416c6c6f7700000004000000070000006d61785f6665650000000f00" + "000000000000000000000900000067617" + "35f6c696d69740000002000000000000000000000000d0000006d61785f6761735f707269636500000" + "03d000000000000000000000011000000" + "7472616e73616374696f6e5f6c696d6974000000400000000000000000000000000003003e00000000" + "000000010800000047617350726963650" + "00000010000000500000076616c75650000003f000000000000000000000000000c020000000000000" + "000080000000000000003010008010d00" + "42000000000000000200000002000000000900000000000000000000000000003b0000000000000000" + "000000000000000014000000417574686" + "f72697a656453657175656e636572730200000003000000416c6c00000004000000536f6d650100010" + "044000000000000000000000200000001" + "00000000450000000000000000000000000000000d00190000000000000001330000005f5f536f7656" + "69727475616c57616c6c65745f43616c6" + "c4d6573736167655f5365745061796572466f7253657175656e6365720000000100000005000000706" + "179657200000009000000000000000000" + "00000000012b0000005f5f536f765669727475616c57616c6c65745f43616c6c4d6573736167655f55" + "7064617465506f6c69637900000002000" + "0000500000070617965720000000900000000000000000000000600000075706461746500000048000" + "00000000000000000000000010c000000" + "506f6c696379557064617465000000060000001000000073657175656e6365725f7570646174650000" + "004900000000000000000000000f00000" + "075706461746572735f746f5f6164640000004e0000000000000000000000120000007570646174657" + "2735f746f5f72656d6f76650000004e00" + "000000000000000000001500000070617965655f706f6c69636965735f746f5f7365740000004f0000" + "000000000000000000180000007061796" + "5655f706f6c69636965735f746f5f64656c6574650000004e00000000000000000000000e000000646" + "56661756c745f706f6c69637900000050" + "0000000000000000000000000003004a00000000000000001200000053657175656e63657253657455" + "70646174650200000008000000416c6c6" + "f77416c6c00000006000000557064617465010001004b0000000000000000000002000000010000000" + "04c000000000000000000000000000000" + "0116000000416c6c6f77656453657175656e6365725570646174650000000200000006000000746f5f" + "6164640000004d0000000000000000000" + "00009000000746f5f72656d6f76650000004d000000000000000000000000000300450000000000000" + "003000e00000000000000030041000000" + "0000000003003b0000000000000002000000010000000052000000000000000000000000000000010b" + "00000043616c6c4d65737361676500000" + "00100000003000000726c7000000053000000000000000000000000000111000000526c7045766d547" + "2616e73616374696f6e00000001000000" + "03000000726c7000000102000000000000000002000000010000000055000000000000000000000000" + "000000001500000041636365737350617" + "47465726e4d657373616765730e0000000a000000577269746543656c6c73000001005600000000000" + "0000b0000005772697465437573746f6d" + "010001005700000000000000090000005265616443656c6c7302000100590000000000000009000000" + "486173684279746573030001005a00000" + "0000000000a00000048617368437573746f6d040001005b000000000000000e00000053746f7265536" + "9676e6174757265050001005c00000000" + "0000000f0000005665726966795369676e617475726506000015000000566572696679437573746f6d" + "5369676e6174757265070001005d00000" + "0000000001500000053746f726553657269616c697a6564537472696e67080001005e0000000000000" + "018000000446573657269616c697a6542" + "797465734173537472696e6709000017000000446573657269616c697a65437573746f6d537472696e" + "670a0001005f000000000000000b00000" + "044656c65746543656c6c730b000100600000000000000007000000536574486f6f6b0c00010061000" + "000000000000b00000055706461746541" + "646d696e0d000100680000000000000000000001330000005f5f536f765669727475616c57616c6c65" + "745f4163636573735061747465726e4d6" + "57373616765735f577269746543656c6c730000000300000005000000626567696e000001000801000" + "00000090000006e756d5f63656c6c7300" + "00010008010000000009000000646174615f73697a6500000100070100000000000001340000005f5f" + "536f765669727475616c57616c6c65745" + "f4163636573735061747465726e4d657373616765735f5772697465437573746f6d000000020000000" + "5000000626567696e0000010008010000" + "000007000000636f6e74656e7400000058000000000000000000000000000d010501320000005f5f53" + "6f765669727475616c57616c6c65745f4" + "163636573735061747465726e4d657373616765735f5265616443656c6c73000000020000000500000" + "0626567696e0000010008010000000009" + "0000006e756d5f63656c6c7300000100080100000000000001320000005f5f536f765669727475616c" + "57616c6c65745f4163636573735061747" + "465726e4d657373616765735f486173684279746573000000020000000600000066696c6c657200000" + "1000501000000000400000073697a6500" + "000100070100000000000001330000005f5f536f765669727475616c57616c6c65745f416363657373" + "5061747465726e4d657373616765735f4" + "8617368437573746f6d0000000100000005000000696e7075740000010200000000000000000137000" + "0005f5f536f765669727475616c57616c" + "6c65745f4163636573735061747465726e4d657373616765735f53746f72655369676e617475726500" + "000003000000040000007369676e00000" + "0010000000000000000000000070000007075625f6b657900000002000000000000000000000007000" + "0006d6573736167650000010500000000" + "0000013e0000005f5f536f765669727475616c57616c6c65745f4163636573735061747465726e4d65" + "7373616765735f5665726966794375737" + "46f6d5369676e617475726500000003000000040000007369676e00000001000000000000000000000" + "0070000007075625f6b65790000000200" + "00000000000000000000070000006d65737361676500000105000000000000013e0000005f5f536f76" + "5669727475616c57616c6c65745f41636" + "36573735061747465726e4d657373616765735f53746f726553657269616c697a6564537472696e670" + "000000100000005000000696e70757400" + "000102000000000000000001400000005f5f536f765669727475616c57616c6c65745f416363657373" + "5061747465726e4d657373616765735f4" + "46573657269616c697a65437573746f6d537472696e670000000100000005000000696e70757400000" + "102000000000000000001340000005f5f" + "536f765669727475616c57616c6c65745f4163636573735061747465726e4d657373616765735f4465" + "6c65746543656c6c73000000020000000" + "5000000626567696e00000100080100000000090000006e756d5f63656c6c730000010008010000000" + "0000001300000005f5f536f7656697274" + "75616c57616c6c65745f4163636573735061747465726e4d657373616765735f536574486f6f6b0000" + "000200000003000000707265000000620" + "00000000000000000000004000000706f7374000000620000000000000000000000000003006300000" + "0000000000d006400000000000000000b" + "000000486f6f6b73436f6e666967030000000400000052656164000001006500000000000000050000" + "005772697465010001006600000000000" + "0000600000044656c65746502000100670000000000000000000001230000005f5f536f76566972747" + "5616c57616c6c65745f486f6f6b73436f" + "6e6669675f526561640000000200000005000000626567696e00000100080100000000040000007369" + "7a6500000100080100000000000001240" + "000005f5f536f765669727475616c57616c6c65745f486f6f6b73436f6e6669675f577269746500000" + "00300000005000000626567696e000001" + "000801000000000400000073697a650000010008010000000009000000646174615f73697a65000001" + "00070100000000000001250000005f5f5" + "36f765669727475616c57616c6c65745f486f6f6b73436f6e6669675f44656c6574650000000200000" + "005000000626567696e00000100080100" + "0000000400000073697a6500000100080100000000000001340000005f5f536f765669727475616c57" + "616c6c65745f416363657373506174746" + "5726e4d657373616765735f55706461746541646d696e00000001000000090000006e65775f61646d6" + "96e000000090000000000000000000000" + "00000109000000547844657461696c730001370000007b4d6178205072696f72697479204665657c7d" + "7c7b4d6178204665657c7d7c7b4761732" + "04c696d69747c7d7c7b436861696e2049447c7d0004000000150000006d61785f7072696f726974795" + "f6665655f626970730001006a00000000" + "00000000000000070000006d61785f666565000000080000000000000000000000090000006761735f" + "6c696d697400010020000000000000000" + "000000008000000636861696e5f6964000101000801000000000000020000000100000001000801000" + "00000000000000113000000556e736967" + "6e65645472616e73616374696f6e0001120000007b7d7c7b47656e65726174696f6e7d7c7b7d000300" + "00000c00000072756e74696d655f63616" + "c6c0000000300000000000000000000000a00000067656e65726174696f6e000101000801000000000" + "700000064657461696c73000000690000" + "00000000000000000000000400000000000000000000006b0000000000000003000000000000000b00" + "000000000000e11000000000000009000" + "00054657374436861696e060100000009000000746f6b656e5f6964730100000020000000171717171" + "717171717171717171717171717171717" + "17171717171717171717060900000054657374546f6b656e77f986b27d5c6e676fdb865f44833b5fe9" + "7f5cccafaf5b4733c21ba027f8b725"); ctx.buffer.ptr = buffer; ctx.buffer.len = bufferLen; @@ -187,51 +323,83 @@ TEST(SCALE, MultiProofTest) { uint8_t buffer[12000]; // leave data - auto bufferLen = parseHexString( - buffer, sizeof(buffer), - "1000000059010000000b00000052756e74696d6543616c6c0c0000000400000042616e6b0000010004000000000000001100000053657175656" - "e63657252656769737472790100010016000000000000000b00000056616c7565536574746572020001001d0000000000000012000000417474" - "6573746572496e63656e74697665730300010025000000000000001000000050726f766572496e63656e7469766573040001002a00000000000" - "000080000004163636f756e7473050001002e000000000000000a000000556e697175656e6573730600010033000000000000000a0000004368" - "61696e53746174650700010035000000000000000b000000426c6f6253746f72616765080001003600000000000000090000005061796d61737" - "465720900010037000000000000000300000045766d0a00010051000000000000000d0000004163636573735061747465726e0b000100540000" - "0000000000010000190000000200000001000000000500000000000000000000000000000088000000000b00000043616c6c4d6573736167650" - "50000000b000000437265617465546f6b656e000001000600000000000000080000005472616e73666572010001001000000000000000040000" - "004275726e020001001300000000000000040000004d696e7403000100140000000000000006000000467265657a65040001001500000000000" - "00000000014000000020000000100000001000901000000000000000042000000000c0000004d756c7469416464726573730200000008000000" - "5374616e64617264000001000a0000000000000002000000566d010001000c00000000000000010000190000000200000001000000000b00000" - "000000000000000000000000023000000020000000100000001011c000000000000000303000000736f76000000000000000000930000000127" - "0000005f5f536f765669727475616c57616c6c65745f43616c6c4d6573736167655f5472616e73666572011a0000005472616e7366657220746" - "f2061646472657373207b7d207b7d2e01070000007c7b546f7d7b7d000200000002000000746f00000009000000000000000000000005000000" - "636f696e7300000011000000000000000000000001010000000000000000860000000105000000436f696e7301170000007b7d20636f696e732" - "06f6620746f6b656e204944207b7d01140000007b416d6f756e747c7d7b546f6b656e2049447c7d010200000006000000616d6f756e74000001" - "0009020101000000000000001f000000000000000000000008000000746f6b656e5f69640000001200000000000000000000000000330000000" - "200000001000000010120000000000000000306000000746f6b656e5f0109000000746f6b656e5f69647300000000000000000a000000030021" - "0000000000000019000000020000000100000000220000000000000000000000000000000d0000000c020000000000000001000801c60000000" - "109000000547844657461696c730001370000007b4d6178205072696f72697479204665657c7d7c7b4d6178204665657c7d7c7b476173204c69" - "6d69747c7d7c7b436861696e2049447c7d0004000000150000006d61785f7072696f726974795f6665655f626970730001006a0000000000000" - "000000000070000006d61785f666565000000080000000000000000000000090000006761735f6c696d69740001002000000000000000000000" - "0008000000636861696e5f696400010100080100000000000014000000020000000100000001000801000000000000000088000000011300000" - "0556e7369676e65645472616e73616374696f6e0001120000007b7d7c7b47656e65726174696f6e7d7c7b7d00030000000c00000072756e7469" - "6d655f63616c6c0000000300000000000000000000000a00000067656e65726174696f6e000101000801000000000700000064657461696c730" - "000006900000000000000000000000000"); + auto bufferLen = parseHexString(buffer, sizeof(buffer), + "1000000059010000000b00000052756e74696d6543616c6c0c0000000400000042616e6b0000010004" + "000000000000001100000053657175656" + "e63657252656769737472790100010016000000000000000b00000056616c756553657474657202000" + "1001d0000000000000012000000417474" + "6573746572496e63656e74697665730300010025000000000000001000000050726f766572496e6365" + "6e7469766573040001002a00000000000" + "000080000004163636f756e7473050001002e000000000000000a000000556e697175656e657373060" + "0010033000000000000000a0000004368" + "61696e53746174650700010035000000000000000b000000426c6f6253746f72616765080001003600" + "000000000000090000005061796d61737" + "465720900010037000000000000000300000045766d0a00010051000000000000000d0000004163636" + "573735061747465726e0b000100540000" + "0000000000010000190000000200000001000000000500000000000000000000000000000088000000" + "000b00000043616c6c4d6573736167650" + "50000000b000000437265617465546f6b656e000001000600000000000000080000005472616e73666" + "572010001001000000000000000040000" + "004275726e020001001300000000000000040000004d696e7403000100140000000000000006000000" + "467265657a65040001001500000000000" + "00000000014000000020000000100000001000901000000000000000042000000000c0000004d756c7" + "469416464726573730200000008000000" + "5374616e64617264000001000a0000000000000002000000566d010001000c00000000000000010000" + "190000000200000001000000000b00000" + "000000000000000000000000023000000020000000100000001011c000000000000000303000000736" + "f76000000000000000000930000000127" + "0000005f5f536f765669727475616c57616c6c65745f43616c6c4d6573736167655f5472616e736665" + "72011a0000005472616e7366657220746" + "f2061646472657373207b7d207b7d2e01070000007c7b546f7d7b7d000200000002000000746f00000" + "009000000000000000000000005000000" + "636f696e7300000011000000000000000000000001010000000000000000860000000105000000436f" + "696e7301170000007b7d20636f696e732" + "06f6620746f6b656e204944207b7d01140000007b416d6f756e747c7d7b546f6b656e2049447c7d010" + "200000006000000616d6f756e74000001" + "0009020101000000000000001f000000000000000000000008000000746f6b656e5f69640000001200" + "000000000000000000000000330000000" + "200000001000000010120000000000000000306000000746f6b656e5f0109000000746f6b656e5f696" + "47300000000000000000a000000030021" + "0000000000000019000000020000000100000000220000000000000000000000000000000d0000000c" + "020000000000000001000801c60000000" + "109000000547844657461696c730001370000007b4d6178205072696f72697479204665657c7d7c7b4" + "d6178204665657c7d7c7b476173204c69" + "6d69747c7d7c7b436861696e2049447c7d0004000000150000006d61785f7072696f726974795f6665" + "655f626970730001006a0000000000000" + "000000000070000006d61785f666565000000080000000000000000000000090000006761735f6c696" + "d69740001002000000000000000000000" + "0008000000636861696e5f696400010100080100000000000014000000020000000100000001000801" + "000000000000000088000000011300000" + "0556e7369676e65645472616e73616374696f6e0001120000007b7d7c7b47656e65726174696f6e7d7" + "c7b7d00030000000c00000072756e7469" + "6d655f63616c6c0000000300000000000000000000000a00000067656e65726174696f6e0001010008" + "01000000000700000064657461696c730" + "000006900000000000000000000000000"); // leaves_index - bufferLen += parseHexString(buffer + bufferLen, sizeof(buffer), - "10000000030000000000000004000000000000000500000000000000080000000000000009000000000000000a0" - "00000000000000b0000000000000010000000000000001100000000000000120000000000000020000000000000" - "002100000000000000220000000000000069000000000000006a000000000000006b00000000000000"); + bufferLen += + parseHexString(buffer + bufferLen, sizeof(buffer), + "10000000030000000000000004000000000000000500000000000000080000000000000009000000000000000a0" + "00000000000000b0000000000000010000000000000001100000000000000120000000000000020000000000000" + "002100000000000000220000000000000069000000000000006a000000000000006b00000000000000"); // lemmas bufferLen += parseHexString( buffer + bufferLen, sizeof(buffer), - "0e00000077acc7048b564d54cfb2cf87279320144ab1a3fd7d71c84c0912051d08ebf36bdf0ff86a776897f89216f36f60dc259efadc0fe9691" - "6b464bb0da54ccefd6c4a2c65338f3d4530a8df68c748139d75f43900873871b57da86e605a7ea2c195d2e02cecb6e76e86aa450de420490f1e" - "1c882e3cf23e9863df984884e4c48592302313aec76ea72f21d539d0ed27a1fa9431af9d270b3834b4a2d270e04495e06e339800d039914b263" - "0ac0e2ec7302447a84e7d27b0fa14c0afaf0beb979534159aa898b4dfa154a4bb5fd9a9cc75f9f8627d691fe4207dfd3621276e43f1d0e92c1a" - "96629574b47179a89ce11de505fc1f972b986eb3216ecdcbea928260316362f0db9c5a1c9552c49c574fd68ced31216afcf50ee00e4037b14f7" - "b815178825370d5c58a70ac1bac18a37025400bd9a5c1d8d635b9c02fe561324965c9b325fba7cdd8412a830cdb48bad5d88e1fcefc60d3fcbb" - "6cf8a95a20322e72b49e5284cd0a4c2cf32bc3a719948f3db013f6c0f33854cab1a02d61d6755bb541611faa801c77d4ab726b3400e77f090db" + "0e00000077acc7048b564d54cfb2cf87279320144ab1a3fd7d71c84c0912051d08ebf36bdf0ff86a776897f89216f36f60dc259efadc0f" + "e9691" + "6b464bb0da54ccefd6c4a2c65338f3d4530a8df68c748139d75f43900873871b57da86e605a7ea2c195d2e02cecb6e76e86aa450de4204" + "90f1e" + "1c882e3cf23e9863df984884e4c48592302313aec76ea72f21d539d0ed27a1fa9431af9d270b3834b4a2d270e04495e06e339800d03991" + "4b263" + "0ac0e2ec7302447a84e7d27b0fa14c0afaf0beb979534159aa898b4dfa154a4bb5fd9a9cc75f9f8627d691fe4207dfd3621276e43f1d0e" + "92c1a" + "96629574b47179a89ce11de505fc1f972b986eb3216ecdcbea928260316362f0db9c5a1c9552c49c574fd68ced31216afcf50ee00e4037" + "b14f7" + "b815178825370d5c58a70ac1bac18a37025400bd9a5c1d8d635b9c02fe561324965c9b325fba7cdd8412a830cdb48bad5d88e1fcefc60d" + "3fcbb" + "6cf8a95a20322e72b49e5284cd0a4c2cf32bc3a719948f3db013f6c0f33854cab1a02d61d6755bb541611faa801c77d4ab726b3400e77f" + "090db" "c1b39ea47027845b39f9e7dd5ad22fc78b5ed27560feb925637a3a176e3c9e1d357504d186d5fe6140abff97bcb464bcca2"); // tree_size @@ -253,10 +421,10 @@ TEST(SCALE, MultiProofTest) { "0400000000000000000000006b0000000000000003000000000000000b00000000000000"); // chain_data - bufferLen += - parseHexString(buffer + bufferLen, sizeof(buffer), - "e1100000000000000900000054657374436861696e060100000009000000746f6b656e5f6964730100000020000000171717" - "17171717171717171717171717171717171717171717171717171717060900000054657374546f6b656e"); + bufferLen += parseHexString( + buffer + bufferLen, sizeof(buffer), + "e1100000000000000900000054657374436861696e060100000009000000746f6b656e5f6964730100000020000000171717" + "17171717171717171717171717171717171717171717171717171717060900000054657374546f6b656e"); // extra_data_hash bufferLen += parseHexString(buffer + bufferLen, sizeof(buffer), @@ -276,7 +444,8 @@ TEST(SCALE, MultiProofTest) { EXPECT_EQ(err, parser_ok) << parser_getErrorDescription(err); uint8_t expected_hash[CX_SHA256_SIZE] = {0}; - parseHexString(expected_hash, sizeof(expected_hash), "a43850ba5603f89c05080e14ff868fec09f35fbfaa3c28ad76258fbac95d7432"); + parseHexString(expected_hash, sizeof(expected_hash), + "a43850ba5603f89c05080e14ff868fec09f35fbfaa3c28ad76258fbac95d7432"); EXPECT_EQ(memcmp(tx_obj.schema.chain_hash.ptr, expected_hash, CX_SHA256_SIZE), 0) << "Chain hash mismatch"; } diff --git a/tests/ui_tests.cpp b/tests/ui_tests.cpp index b6217d0..c806fa3 100644 --- a/tests/ui_tests.cpp +++ b/tests/ui_tests.cpp @@ -15,10 +15,10 @@ ********************************************************************************/ #include -#include #include #include +#include #include "app_mode.h" #include "gmock/gmock.h" @@ -61,8 +61,7 @@ class JsonTestsA : public ::testing::TestWithParam { std::vector GetJsonTestCases(std::string jsonFile) { auto answer = std::vector(); - Json::CharReaderBuilder builder; - Json::Value obj; + nlohmann::json obj; std::string fullPathJsonFile = std::string(TESTVECTORS_DIR) + jsonFile; @@ -72,27 +71,28 @@ std::vector GetJsonTestCases(std::string jsonFile) { } // Retrieve all test cases - JSONCPP_STRING errs; - Json::parseFromStream(builder, inFile, &obj, &errs); + obj = nlohmann::json::parse(inFile); std::cout << "Number of testcases: " << obj.size() << std::endl; for (int i = 0; i < obj.size(); i++) { auto outputs = std::vector(); for (auto s : obj[i]["output"]) { - outputs.push_back(s.asString()); + outputs.push_back(s.get()); } auto outputs_expert = std::vector(); for (auto s : obj[i]["output_expert"]) { - outputs_expert.push_back(s.asString()); + outputs_expert.push_back(s.get()); } - answer.push_back( - testcase_t{obj[i]["index"].asUInt64(), obj[i]["name"].asString(), obj[i]["transaction_blob"].asString(), - obj[i]["leaves_data"].asString(), obj[i]["leaves_index"].asString(), obj[i]["lemmas"].asString(), - obj[i]["tree_size"].asString(), obj[i]["root_hash"].asString(), obj[i]["root_type_index"].asString(), - obj[i]["chain_data"].asString(), obj[i]["extra_data_hash"].asString(), - obj[i]["chain_hash"].asString(), outputs, outputs_expert}); + answer.push_back(testcase_t{ + obj[i]["index"].get(), std::string("test_") + std::to_string(obj[i]["index"].get()), + obj[i]["transaction_blob"].get(), obj[i]["leaves_data"].get(), + obj[i]["leaves_index"].get(), obj[i]["lemmas"].get(), + obj[i]["tree_size"].get(), obj[i]["root_hash"].get(), + obj[i]["root_type_index"].get(), obj[i]["chain_data"].get(), + obj[i]["extra_data_hash"].get(), obj[i]["chain_hash"].get(), outputs, + outputs_expert}); } return answer; diff --git a/tests_zemu/package.json b/tests_zemu/package.json index 4284aaf..7eda6cf 100644 --- a/tests_zemu/package.json +++ b/tests_zemu/package.json @@ -23,35 +23,37 @@ "try": "node try.mjs", "upgrade": "bunx npm-check-updates -i" }, + "resolutions": { + "axios": "^1.10.0", + "glob": "^11.0.3" + }, "dependencies": { - "@zondax/ledger-sovereign": "^0.0.2", - "@zondax/zemu": "^0.55.0" + "@zondax/ledger-sovereign": "^0.0.3", + "@zondax/zemu": "^0.55.3" }, "devDependencies": { - "@ledgerhq/hw-transport-node-hid": "^6.29.5", - "@ledgerhq/logs": "^6.12.0", + "@ledgerhq/hw-transport-node-hid": "^6.29.8", "@noble/curves": "^1.8.1", - "@trivago/prettier-plugin-sort-imports": "^5.2.2", - "@types/jest": "^29.5.14", + "@types/jest": "^30.0.0", "@types/ledgerhq__hw-transport": "^4.21.8", - "@typescript-eslint/eslint-plugin": "^8.27.0", - "@typescript-eslint/parser": "^8.27.0", + "@types/node": "^24.0.4", + "@typescript-eslint/eslint-plugin": "^8.35.0", + "@typescript-eslint/parser": "^8.35.0", "blakejs": "^1.2.1", "crypto-js": "4.2.0", - "eslint": "^9.22.0", - "eslint-config-prettier": "^10.1.1", - "eslint-plugin-import": "^2.31.0", - "eslint-plugin-jest": "^28.11.0", - "eslint-plugin-prettier": "^5.2.3", - "eslint-plugin-promise": "^7.2.1", + "eslint": "^9.29.0", + "eslint-config-prettier": "^10.1.5", + "eslint-plugin-import": "^2.32.0", + "eslint-plugin-jest": "^28.8.0", + "eslint-plugin-prettier": "^5.5.0", "eslint-plugin-tsdoc": "^0.4.0", "eslint-plugin-unused-imports": "^4.1.4", - "jest": "29.7.0", + "jest": "^30.0.2", "jssha": "^3.3.1", - "prettier": "^3.5.3", - "sort-package-json": "^3.0.0", - "ts-jest": "^29.2.6", + "prettier": "^3.6.0", + "sort-package-json": "^3.3.0", + "ts-jest": "^29.4.0", "ts-node": "^10.9.2", - "typescript": "^5.8.2" + "typescript": "^5.8.3" } } diff --git a/tests_zemu/snapshots/fl-blind_sign/00001.png b/tests_zemu/snapshots/fl-blind_sign/00001.png deleted file mode 100644 index 6929578..0000000 Binary files a/tests_zemu/snapshots/fl-blind_sign/00001.png and /dev/null differ diff --git a/tests_zemu/snapshots/fl-blind_sign/00002.png b/tests_zemu/snapshots/fl-blind_sign/00002.png deleted file mode 100644 index 40b955b..0000000 Binary files a/tests_zemu/snapshots/fl-blind_sign/00002.png and /dev/null differ diff --git a/tests_zemu/snapshots/fl-blind_sign/00000.png b/tests_zemu/snapshots/fl-sign_bank_transfer/00000.png similarity index 100% rename from tests_zemu/snapshots/fl-blind_sign/00000.png rename to tests_zemu/snapshots/fl-sign_bank_transfer/00000.png diff --git a/tests_zemu/snapshots/fl-sign_bank_transfer/00001.png b/tests_zemu/snapshots/fl-sign_bank_transfer/00001.png new file mode 100644 index 0000000..3989a4e Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_bank_transfer/00001.png differ diff --git a/tests_zemu/snapshots/fl-sign_bank_transfer/00002.png b/tests_zemu/snapshots/fl-sign_bank_transfer/00002.png new file mode 100644 index 0000000..72f4ccf Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_bank_transfer/00002.png differ diff --git a/tests_zemu/snapshots/fl-blind_sign/00003.png b/tests_zemu/snapshots/fl-sign_bank_transfer/00003.png similarity index 100% rename from tests_zemu/snapshots/fl-blind_sign/00003.png rename to tests_zemu/snapshots/fl-sign_bank_transfer/00003.png diff --git a/tests_zemu/snapshots/fl-blind_sign/00004.png b/tests_zemu/snapshots/fl-sign_bank_transfer/00004.png similarity index 100% rename from tests_zemu/snapshots/fl-blind_sign/00004.png rename to tests_zemu/snapshots/fl-sign_bank_transfer/00004.png diff --git a/tests_zemu/snapshots/fl-sign_paymaster_register/00000.png b/tests_zemu/snapshots/fl-sign_paymaster_register/00000.png new file mode 100644 index 0000000..fa37c00 Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_paymaster_register/00000.png differ diff --git a/tests_zemu/snapshots/fl-sign_paymaster_register/00001.png b/tests_zemu/snapshots/fl-sign_paymaster_register/00001.png new file mode 100644 index 0000000..118dba3 Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_paymaster_register/00001.png differ diff --git a/tests_zemu/snapshots/fl-sign_paymaster_register/00002.png b/tests_zemu/snapshots/fl-sign_paymaster_register/00002.png new file mode 100644 index 0000000..cdad743 Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_paymaster_register/00002.png differ diff --git a/tests_zemu/snapshots/fl-sign_paymaster_register/00003.png b/tests_zemu/snapshots/fl-sign_paymaster_register/00003.png new file mode 100644 index 0000000..32d4f0a Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_paymaster_register/00003.png differ diff --git a/tests_zemu/snapshots/fl-sign_paymaster_register/00004.png b/tests_zemu/snapshots/fl-sign_paymaster_register/00004.png new file mode 100644 index 0000000..0a314c1 Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_paymaster_register/00004.png differ diff --git a/tests_zemu/snapshots/fl-sign_paymaster_register/00005.png b/tests_zemu/snapshots/fl-sign_paymaster_register/00005.png new file mode 100644 index 0000000..9672e21 Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_paymaster_register/00005.png differ diff --git a/tests_zemu/snapshots/fl-sign_paymaster_register/00006.png b/tests_zemu/snapshots/fl-sign_paymaster_register/00006.png new file mode 100644 index 0000000..fb2bd6e Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_paymaster_register/00006.png differ diff --git a/tests_zemu/snapshots/fl-sign_paymaster_register/00007.png b/tests_zemu/snapshots/fl-sign_paymaster_register/00007.png new file mode 100644 index 0000000..d01f066 Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_paymaster_register/00007.png differ diff --git a/tests_zemu/snapshots/fl-sign_paymaster_register/00008.png b/tests_zemu/snapshots/fl-sign_paymaster_register/00008.png new file mode 100644 index 0000000..c7a49e7 Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_paymaster_register/00008.png differ diff --git a/tests_zemu/snapshots/fl-sign_paymaster_register/00009.png b/tests_zemu/snapshots/fl-sign_paymaster_register/00009.png new file mode 100644 index 0000000..9c02d99 Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_paymaster_register/00009.png differ diff --git a/tests_zemu/snapshots/sp-blind_sign/00001.png b/tests_zemu/snapshots/sp-blind_sign/00001.png deleted file mode 100644 index 75af822..0000000 Binary files a/tests_zemu/snapshots/sp-blind_sign/00001.png and /dev/null differ diff --git a/tests_zemu/snapshots/sp-blind_sign/00002.png b/tests_zemu/snapshots/sp-blind_sign/00002.png deleted file mode 100644 index 00dc028..0000000 Binary files a/tests_zemu/snapshots/sp-blind_sign/00002.png and /dev/null differ diff --git a/tests_zemu/snapshots/sp-blind_sign/00003.png b/tests_zemu/snapshots/sp-blind_sign/00003.png deleted file mode 100644 index d9bf037..0000000 Binary files a/tests_zemu/snapshots/sp-blind_sign/00003.png and /dev/null differ diff --git a/tests_zemu/snapshots/sp-blind_sign/00004.png b/tests_zemu/snapshots/sp-blind_sign/00004.png deleted file mode 100644 index 07dd619..0000000 Binary files a/tests_zemu/snapshots/sp-blind_sign/00004.png and /dev/null differ diff --git a/tests_zemu/snapshots/sp-blind_sign/00005.png b/tests_zemu/snapshots/sp-blind_sign/00005.png deleted file mode 100644 index 967bc33..0000000 Binary files a/tests_zemu/snapshots/sp-blind_sign/00005.png and /dev/null differ diff --git a/tests_zemu/snapshots/sp-blind_sign/00000.png b/tests_zemu/snapshots/sp-sign_bank_transfer/00000.png similarity index 100% rename from tests_zemu/snapshots/sp-blind_sign/00000.png rename to tests_zemu/snapshots/sp-sign_bank_transfer/00000.png diff --git a/tests_zemu/snapshots/sp-sign_bank_transfer/00001.png b/tests_zemu/snapshots/sp-sign_bank_transfer/00001.png new file mode 100644 index 0000000..78529ca Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_bank_transfer/00001.png differ diff --git a/tests_zemu/snapshots/sp-sign_bank_transfer/00002.png b/tests_zemu/snapshots/sp-sign_bank_transfer/00002.png new file mode 100644 index 0000000..c7aaa53 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_bank_transfer/00002.png differ diff --git a/tests_zemu/snapshots/sp-sign_bank_transfer/00003.png b/tests_zemu/snapshots/sp-sign_bank_transfer/00003.png new file mode 100644 index 0000000..b398890 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_bank_transfer/00003.png differ diff --git a/tests_zemu/snapshots/sp-sign_bank_transfer/00004.png b/tests_zemu/snapshots/sp-sign_bank_transfer/00004.png new file mode 100644 index 0000000..0f61b4d Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_bank_transfer/00004.png differ diff --git a/tests_zemu/snapshots/sp-sign_bank_transfer/00005.png b/tests_zemu/snapshots/sp-sign_bank_transfer/00005.png new file mode 100644 index 0000000..5ae22f9 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_bank_transfer/00005.png differ diff --git a/tests_zemu/snapshots/sp-sign_bank_transfer/00006.png b/tests_zemu/snapshots/sp-sign_bank_transfer/00006.png new file mode 100644 index 0000000..b468ee6 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_bank_transfer/00006.png differ diff --git a/tests_zemu/snapshots/sp-sign_bank_transfer/00007.png b/tests_zemu/snapshots/sp-sign_bank_transfer/00007.png new file mode 100644 index 0000000..dba281e Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_bank_transfer/00007.png differ diff --git a/tests_zemu/snapshots/sp-blind_sign/00006.png b/tests_zemu/snapshots/sp-sign_bank_transfer/00008.png similarity index 100% rename from tests_zemu/snapshots/sp-blind_sign/00006.png rename to tests_zemu/snapshots/sp-sign_bank_transfer/00008.png diff --git a/tests_zemu/snapshots/sp-blind_sign/00007.png b/tests_zemu/snapshots/sp-sign_bank_transfer/00009.png similarity index 100% rename from tests_zemu/snapshots/sp-blind_sign/00007.png rename to tests_zemu/snapshots/sp-sign_bank_transfer/00009.png diff --git a/tests_zemu/snapshots/x-blind_sign/00000.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00000.png similarity index 100% rename from tests_zemu/snapshots/x-blind_sign/00000.png rename to tests_zemu/snapshots/sp-sign_paymaster_register/00000.png diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00001.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00001.png new file mode 100644 index 0000000..d5a1a93 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00001.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00002.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00002.png new file mode 100644 index 0000000..5da4c8b Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00002.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00003.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00003.png new file mode 100644 index 0000000..a326c62 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00003.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00004.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00004.png new file mode 100644 index 0000000..a2d59de Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00004.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00005.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00005.png new file mode 100644 index 0000000..765dc4a Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00005.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00006.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00006.png new file mode 100644 index 0000000..bbea04f Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00006.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00007.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00007.png new file mode 100644 index 0000000..629c35d Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00007.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00008.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00008.png new file mode 100644 index 0000000..e0acb9b Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00008.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00009.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00009.png new file mode 100644 index 0000000..5863f99 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00009.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00010.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00010.png new file mode 100644 index 0000000..a9c84e5 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00010.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00011.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00011.png new file mode 100644 index 0000000..280b067 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00011.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00012.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00012.png new file mode 100644 index 0000000..892af89 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00012.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00013.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00013.png new file mode 100644 index 0000000..27f8afd Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00013.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00014.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00014.png new file mode 100644 index 0000000..f9d2166 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00014.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00015.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00015.png new file mode 100644 index 0000000..27f8afd Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00015.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00016.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00016.png new file mode 100644 index 0000000..99d1791 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00016.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00017.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00017.png new file mode 100644 index 0000000..6c2600a Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00017.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00018.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00018.png new file mode 100644 index 0000000..8f655dc Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00018.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00019.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00019.png new file mode 100644 index 0000000..326af2e Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00019.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00020.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00020.png new file mode 100644 index 0000000..daf378c Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00020.png differ diff --git a/tests_zemu/snapshots/sp-sign_paymaster_register/00021.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00021.png new file mode 100644 index 0000000..dba281e Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_paymaster_register/00021.png differ diff --git a/tests_zemu/snapshots/x-blind_sign/00006.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00022.png similarity index 100% rename from tests_zemu/snapshots/x-blind_sign/00006.png rename to tests_zemu/snapshots/sp-sign_paymaster_register/00022.png diff --git a/tests_zemu/snapshots/x-blind_sign/00007.png b/tests_zemu/snapshots/sp-sign_paymaster_register/00023.png similarity index 100% rename from tests_zemu/snapshots/x-blind_sign/00007.png rename to tests_zemu/snapshots/sp-sign_paymaster_register/00023.png diff --git a/tests_zemu/snapshots/st-blind_sign/00001.png b/tests_zemu/snapshots/st-blind_sign/00001.png deleted file mode 100644 index d4cfddd..0000000 Binary files a/tests_zemu/snapshots/st-blind_sign/00001.png and /dev/null differ diff --git a/tests_zemu/snapshots/st-blind_sign/00002.png b/tests_zemu/snapshots/st-blind_sign/00002.png deleted file mode 100644 index 58c2300..0000000 Binary files a/tests_zemu/snapshots/st-blind_sign/00002.png and /dev/null differ diff --git a/tests_zemu/snapshots/st-blind_sign/00000.png b/tests_zemu/snapshots/st-sign_bank_transfer/00000.png similarity index 100% rename from tests_zemu/snapshots/st-blind_sign/00000.png rename to tests_zemu/snapshots/st-sign_bank_transfer/00000.png diff --git a/tests_zemu/snapshots/st-sign_bank_transfer/00001.png b/tests_zemu/snapshots/st-sign_bank_transfer/00001.png new file mode 100644 index 0000000..6daeef0 Binary files /dev/null and b/tests_zemu/snapshots/st-sign_bank_transfer/00001.png differ diff --git a/tests_zemu/snapshots/st-sign_bank_transfer/00002.png b/tests_zemu/snapshots/st-sign_bank_transfer/00002.png new file mode 100644 index 0000000..687cd5d Binary files /dev/null and b/tests_zemu/snapshots/st-sign_bank_transfer/00002.png differ diff --git a/tests_zemu/snapshots/st-blind_sign/00003.png b/tests_zemu/snapshots/st-sign_bank_transfer/00003.png similarity index 100% rename from tests_zemu/snapshots/st-blind_sign/00003.png rename to tests_zemu/snapshots/st-sign_bank_transfer/00003.png diff --git a/tests_zemu/snapshots/st-blind_sign/00004.png b/tests_zemu/snapshots/st-sign_bank_transfer/00004.png similarity index 100% rename from tests_zemu/snapshots/st-blind_sign/00004.png rename to tests_zemu/snapshots/st-sign_bank_transfer/00004.png diff --git a/tests_zemu/snapshots/st-sign_paymaster_register/00000.png b/tests_zemu/snapshots/st-sign_paymaster_register/00000.png new file mode 100644 index 0000000..e3c33d5 Binary files /dev/null and b/tests_zemu/snapshots/st-sign_paymaster_register/00000.png differ diff --git a/tests_zemu/snapshots/st-sign_paymaster_register/00001.png b/tests_zemu/snapshots/st-sign_paymaster_register/00001.png new file mode 100644 index 0000000..b846af6 Binary files /dev/null and b/tests_zemu/snapshots/st-sign_paymaster_register/00001.png differ diff --git a/tests_zemu/snapshots/st-sign_paymaster_register/00002.png b/tests_zemu/snapshots/st-sign_paymaster_register/00002.png new file mode 100644 index 0000000..e022179 Binary files /dev/null and b/tests_zemu/snapshots/st-sign_paymaster_register/00002.png differ diff --git a/tests_zemu/snapshots/st-sign_paymaster_register/00003.png b/tests_zemu/snapshots/st-sign_paymaster_register/00003.png new file mode 100644 index 0000000..0dbeabb Binary files /dev/null and b/tests_zemu/snapshots/st-sign_paymaster_register/00003.png differ diff --git a/tests_zemu/snapshots/st-sign_paymaster_register/00004.png b/tests_zemu/snapshots/st-sign_paymaster_register/00004.png new file mode 100644 index 0000000..7862b35 Binary files /dev/null and b/tests_zemu/snapshots/st-sign_paymaster_register/00004.png differ diff --git a/tests_zemu/snapshots/st-sign_paymaster_register/00005.png b/tests_zemu/snapshots/st-sign_paymaster_register/00005.png new file mode 100644 index 0000000..7304def Binary files /dev/null and b/tests_zemu/snapshots/st-sign_paymaster_register/00005.png differ diff --git a/tests_zemu/snapshots/st-sign_paymaster_register/00006.png b/tests_zemu/snapshots/st-sign_paymaster_register/00006.png new file mode 100644 index 0000000..f98b8ad Binary files /dev/null and b/tests_zemu/snapshots/st-sign_paymaster_register/00006.png differ diff --git a/tests_zemu/snapshots/st-sign_paymaster_register/00007.png b/tests_zemu/snapshots/st-sign_paymaster_register/00007.png new file mode 100644 index 0000000..067d7cc Binary files /dev/null and b/tests_zemu/snapshots/st-sign_paymaster_register/00007.png differ diff --git a/tests_zemu/snapshots/x-blind_sign/00001.png b/tests_zemu/snapshots/x-blind_sign/00001.png deleted file mode 100644 index 75af822..0000000 Binary files a/tests_zemu/snapshots/x-blind_sign/00001.png and /dev/null differ diff --git a/tests_zemu/snapshots/x-blind_sign/00002.png b/tests_zemu/snapshots/x-blind_sign/00002.png deleted file mode 100644 index 00dc028..0000000 Binary files a/tests_zemu/snapshots/x-blind_sign/00002.png and /dev/null differ diff --git a/tests_zemu/snapshots/x-blind_sign/00003.png b/tests_zemu/snapshots/x-blind_sign/00003.png deleted file mode 100644 index d9bf037..0000000 Binary files a/tests_zemu/snapshots/x-blind_sign/00003.png and /dev/null differ diff --git a/tests_zemu/snapshots/x-blind_sign/00004.png b/tests_zemu/snapshots/x-blind_sign/00004.png deleted file mode 100644 index 07dd619..0000000 Binary files a/tests_zemu/snapshots/x-blind_sign/00004.png and /dev/null differ diff --git a/tests_zemu/snapshots/x-blind_sign/00005.png b/tests_zemu/snapshots/x-blind_sign/00005.png deleted file mode 100644 index 967bc33..0000000 Binary files a/tests_zemu/snapshots/x-blind_sign/00005.png and /dev/null differ diff --git a/tests_zemu/snapshots/x-sign_bank_transfer/00000.png b/tests_zemu/snapshots/x-sign_bank_transfer/00000.png new file mode 100644 index 0000000..6797254 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_bank_transfer/00000.png differ diff --git a/tests_zemu/snapshots/x-sign_bank_transfer/00001.png b/tests_zemu/snapshots/x-sign_bank_transfer/00001.png new file mode 100644 index 0000000..78529ca Binary files /dev/null and b/tests_zemu/snapshots/x-sign_bank_transfer/00001.png differ diff --git a/tests_zemu/snapshots/x-sign_bank_transfer/00002.png b/tests_zemu/snapshots/x-sign_bank_transfer/00002.png new file mode 100644 index 0000000..c7aaa53 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_bank_transfer/00002.png differ diff --git a/tests_zemu/snapshots/x-sign_bank_transfer/00003.png b/tests_zemu/snapshots/x-sign_bank_transfer/00003.png new file mode 100644 index 0000000..b398890 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_bank_transfer/00003.png differ diff --git a/tests_zemu/snapshots/x-sign_bank_transfer/00004.png b/tests_zemu/snapshots/x-sign_bank_transfer/00004.png new file mode 100644 index 0000000..0f61b4d Binary files /dev/null and b/tests_zemu/snapshots/x-sign_bank_transfer/00004.png differ diff --git a/tests_zemu/snapshots/x-sign_bank_transfer/00005.png b/tests_zemu/snapshots/x-sign_bank_transfer/00005.png new file mode 100644 index 0000000..5ae22f9 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_bank_transfer/00005.png differ diff --git a/tests_zemu/snapshots/x-sign_bank_transfer/00006.png b/tests_zemu/snapshots/x-sign_bank_transfer/00006.png new file mode 100644 index 0000000..b468ee6 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_bank_transfer/00006.png differ diff --git a/tests_zemu/snapshots/x-sign_bank_transfer/00007.png b/tests_zemu/snapshots/x-sign_bank_transfer/00007.png new file mode 100644 index 0000000..dba281e Binary files /dev/null and b/tests_zemu/snapshots/x-sign_bank_transfer/00007.png differ diff --git a/tests_zemu/snapshots/x-sign_bank_transfer/00008.png b/tests_zemu/snapshots/x-sign_bank_transfer/00008.png new file mode 100644 index 0000000..1e4be69 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_bank_transfer/00008.png differ diff --git a/tests_zemu/snapshots/x-sign_bank_transfer/00009.png b/tests_zemu/snapshots/x-sign_bank_transfer/00009.png new file mode 100644 index 0000000..f279fad Binary files /dev/null and b/tests_zemu/snapshots/x-sign_bank_transfer/00009.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00000.png b/tests_zemu/snapshots/x-sign_paymaster_register/00000.png new file mode 100644 index 0000000..6797254 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00000.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00001.png b/tests_zemu/snapshots/x-sign_paymaster_register/00001.png new file mode 100644 index 0000000..d5a1a93 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00001.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00002.png b/tests_zemu/snapshots/x-sign_paymaster_register/00002.png new file mode 100644 index 0000000..5da4c8b Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00002.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00003.png b/tests_zemu/snapshots/x-sign_paymaster_register/00003.png new file mode 100644 index 0000000..a326c62 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00003.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00004.png b/tests_zemu/snapshots/x-sign_paymaster_register/00004.png new file mode 100644 index 0000000..a2d59de Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00004.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00005.png b/tests_zemu/snapshots/x-sign_paymaster_register/00005.png new file mode 100644 index 0000000..765dc4a Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00005.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00006.png b/tests_zemu/snapshots/x-sign_paymaster_register/00006.png new file mode 100644 index 0000000..bbea04f Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00006.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00007.png b/tests_zemu/snapshots/x-sign_paymaster_register/00007.png new file mode 100644 index 0000000..629c35d Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00007.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00008.png b/tests_zemu/snapshots/x-sign_paymaster_register/00008.png new file mode 100644 index 0000000..e0acb9b Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00008.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00009.png b/tests_zemu/snapshots/x-sign_paymaster_register/00009.png new file mode 100644 index 0000000..5863f99 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00009.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00010.png b/tests_zemu/snapshots/x-sign_paymaster_register/00010.png new file mode 100644 index 0000000..a9c84e5 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00010.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00011.png b/tests_zemu/snapshots/x-sign_paymaster_register/00011.png new file mode 100644 index 0000000..280b067 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00011.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00012.png b/tests_zemu/snapshots/x-sign_paymaster_register/00012.png new file mode 100644 index 0000000..892af89 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00012.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00013.png b/tests_zemu/snapshots/x-sign_paymaster_register/00013.png new file mode 100644 index 0000000..27f8afd Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00013.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00014.png b/tests_zemu/snapshots/x-sign_paymaster_register/00014.png new file mode 100644 index 0000000..f9d2166 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00014.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00015.png b/tests_zemu/snapshots/x-sign_paymaster_register/00015.png new file mode 100644 index 0000000..27f8afd Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00015.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00016.png b/tests_zemu/snapshots/x-sign_paymaster_register/00016.png new file mode 100644 index 0000000..99d1791 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00016.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00017.png b/tests_zemu/snapshots/x-sign_paymaster_register/00017.png new file mode 100644 index 0000000..6c2600a Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00017.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00018.png b/tests_zemu/snapshots/x-sign_paymaster_register/00018.png new file mode 100644 index 0000000..8f655dc Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00018.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00019.png b/tests_zemu/snapshots/x-sign_paymaster_register/00019.png new file mode 100644 index 0000000..326af2e Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00019.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00020.png b/tests_zemu/snapshots/x-sign_paymaster_register/00020.png new file mode 100644 index 0000000..daf378c Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00020.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00021.png b/tests_zemu/snapshots/x-sign_paymaster_register/00021.png new file mode 100644 index 0000000..dba281e Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00021.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00022.png b/tests_zemu/snapshots/x-sign_paymaster_register/00022.png new file mode 100644 index 0000000..1e4be69 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00022.png differ diff --git a/tests_zemu/snapshots/x-sign_paymaster_register/00023.png b/tests_zemu/snapshots/x-sign_paymaster_register/00023.png new file mode 100644 index 0000000..f279fad Binary files /dev/null and b/tests_zemu/snapshots/x-sign_paymaster_register/00023.png differ diff --git a/tests_zemu/tests/standard.test.ts b/tests_zemu/tests/standard.test.ts index be897d3..f7f4dce 100644 --- a/tests_zemu/tests/standard.test.ts +++ b/tests_zemu/tests/standard.test.ts @@ -136,33 +136,4 @@ describe('Standard', function () { await sim.close() } }) - - // TODO: remove this test case - // test.concurrent.each(models)('blind sign', async function (m) { - // const sim = new Zemu(m.path) - // try { - // await sim.start({ ...defaultOptions, model: m.name }) - // const app = new SovereignApp(sim.getTransport()) - - // const txBlob = Buffer.from(txBlobExample, 'hex') - // const responseAddr = await app.getAddressAndPubKey(PATH, false) - // const pubKey = responseAddr.pubkey - - // // do not wait here.. we need to navigate - // const signatureRequest = app.sign(PATH, txBlob) - - // // Wait until we are not in the main menu - // await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) - // await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-blind_sign`) - - // const signatureResponse = await signatureRequest - // console.log('Signature:', signatureResponse.signature.toString('hex')) - - // // Now verify the signature - // const valid = ed25519.verify(signatureResponse.signature, txBlob, pubKey) - // expect(valid).toEqual(true) - // } finally { - // await sim.close() - // } - // }) }) diff --git a/tests_zemu/tests/testscases/transactions.ts b/tests_zemu/tests/testscases/transactions.ts new file mode 100644 index 0000000..38a673e --- /dev/null +++ b/tests_zemu/tests/testscases/transactions.ts @@ -0,0 +1,70 @@ +import { PATH } from '../common' + +export const TRANSACTIONS_TEST_CASES = [ + { + name: 'bank_transfer', + path: PATH, + transaction: Buffer.from( + '0001000b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b1027000000000000000000000000000017171717171717171717171717171717171717171717171717171717171717060000000000000000000000000000000000e876481700000000000000000000000100ca9a3b0000000000ca9a3b00000000e110000000000000', + 'hex', + ), + schema: { + merkleProof: { + leavesData: Buffer.from( + '1000000059010000000b00000052756e74696d6543616c6c0c0000000400000042616e6b0000010004000000000000001100000053657175656e63657252656769737472790100010016000000000000000b00000056616c7565536574746572020001001d00000000000000120000004174746573746572496e63656e74697665730300010025000000000000001000000050726f766572496e63656e7469766573040001002a00000000000000080000004163636f756e7473050001002e000000000000000a000000556e697175656e6573730600010033000000000000000a000000436861696e53746174650700010035000000000000000b000000426c6f6253746f72616765080001003600000000000000090000005061796d61737465720900010037000000000000000300000045766d0a00010051000000000000000d0000004163636573735061747465726e0b0001005400000000000000010000190000000200000001000000000500000000000000000000000000000088000000000b00000043616c6c4d657373616765050000000b000000437265617465546f6b656e000001000600000000000000080000005472616e73666572010001001000000000000000040000004275726e020001001300000000000000040000004d696e7403000100140000000000000006000000467265657a6504000100150000000000000000000014000000020000000100000001000901000000000000000042000000000c0000004d756c74694164647265737302000000080000005374616e64617264000001000a0000000000000002000000566d010001000c00000000000000010000190000000200000001000000000b00000000000000000000000000000023000000020000000100000001011c000000000000000303000000736f760000000000000000009300000001270000005f5f536f765669727475616c57616c6c65745f43616c6c4d6573736167655f5472616e73666572011a0000005472616e7366657220746f2061646472657373207b7d207b7d2e01070000007c7b546f7d7b7d000200000002000000746f00000009000000000000000000000005000000636f696e7300000011000000000000000000000001010000000000000000860000000105000000436f696e7301170000007b7d20636f696e73206f6620746f6b656e204944207b7d01140000007b416d6f756e747c7d7b546f6b656e2049447c7d010200000006000000616d6f756e740000010009020101000000000000001f000000000000000000000008000000746f6b656e5f69640000001200000000000000000000000000330000000200000001000000010120000000000000000306000000746f6b656e5f0109000000746f6b656e5f69647300000000000000000a0000000300210000000000000019000000020000000100000000220000000000000000000000000000000d0000000c020000000000000001000801c60000000109000000547844657461696c730001370000007b4d6178205072696f72697479204665657c7d7c7b4d6178204665657c7d7c7b476173204c696d69747c7d7c7b436861696e2049447c7d0004000000150000006d61785f7072696f726974795f6665655f626970730001006a0000000000000000000000070000006d61785f666565000000080000000000000000000000090000006761735f6c696d697400010020000000000000000000000008000000636861696e5f6964000101000801000000000000140000000200000001000000010008010000000000000000880000000113000000556e7369676e65645472616e73616374696f6e0001120000007b7d7c7b47656e65726174696f6e7d7c7b7d00030000000c00000072756e74696d655f63616c6c0000000300000000000000000000000a00000067656e65726174696f6e000101000801000000000700000064657461696c730000006900000000000000000000000000', + 'hex', + ), + leavesIndices: Buffer.from( + '10000000030000000000000004000000000000000500000000000000080000000000000009000000000000000a000000000000000b0000000000000010000000000000001100000000000000120000000000000020000000000000002100000000000000220000000000000069000000000000006a000000000000006b00000000000000', + 'hex', + ), + lemmas: Buffer.from( + '0e00000077acc7048b564d54cfb2cf87279320144ab1a3fd7d71c84c0912051d08ebf36bdf0ff86a776897f89216f36f60dc259efadc0fe96916b464bb0da54ccefd6c4a2c65338f3d4530a8df68c748139d75f43900873871b57da86e605a7ea2c195d2e02cecb6e76e86aa450de420490f1e1c882e3cf23e9863df984884e4c48592302313aec76ea72f21d539d0ed27a1fa9431af9d270b3834b4a2d270e04495e06e339800d039914b2630ac0e2ec7302447a84e7d27b0fa14c0afaf0beb979534159aa898b4dfa154a4bb5fd9a9cc75f9f8627d691fe4207dfd3621276e43f1d0e92c1a96629574b47179a89ce11de505fc1f972b986eb3216ecdcbea928260316362f0db9c5a1c9552c49c574fd68ced31216afcf50ee00e4037b14f7b815178825370d5c58a70ac1bac18a37025400bd9a5c1d8d635b9c02fe561324965c9b325fba7cdd8412a830cdb48bad5d88e1fcefc60d3fcbb6cf8a95a20322e72b49e5284cd0a4c2cf32bc3a719948f3db013f6c0f33854cab1a02d61d6755bb541611faa801c77d4ab726b3400e77f090dbc1b39ea47027845b39f9e7dd5ad22fc78b5ed27560feb925637a3a176e3c9e1d357504d186d5fe6140abff97bcb464bcca2', + 'hex', + ), + treeSize: Buffer.from('6c00000000000000', 'hex'), + rootHash: Buffer.from('f55d28d6582a2e492b325f097e1ebcc0a19eca8f506fb5a7c3473067d48f06f8', 'hex'), + }, + chainData: Buffer.from( + 'e1100000000000000900000054657374436861696e060100000009000000746f6b656e5f696473010000002000000017171717171717171717171717171717171717171717171717171717171717060900000054657374546f6b656e', + 'hex', + ), + rootTypeIndices: Buffer.from('0400000000000000000000006b0000000000000003000000000000000b00000000000000', 'hex'), + extraDataHash: Buffer.from('77f986b27d5c6e676fdb865f44833b5fe97f5cccafaf5b4733c21ba027f8b725', 'hex'), + chainHash: Buffer.from('a43850ba5603f89c05080e14ff868fec09f35fbfaa3c28ad76258fbac95d7432', 'hex'), + }, + }, + { + name: 'paymaster_register', + path: PATH, + transaction: Buffer.from( + '09000001102700000000000000000000000000000001d0070000000000000000000000000000d007000000000000000000000000000001320000000000000001000000000b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0101000000000b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b000000000000000000000000000000000000e876481700000000000000000000000100ca9a3b0000000000ca9a3b00000000e110000000000000', + 'hex', + ), + schema: { + merkleProof: { + leavesData: Buffer.from( + '1a00000059010000000b00000052756e74696d6543616c6c0c0000000400000042616e6b0000010004000000000000001100000053657175656e63657252656769737472790100010016000000000000000b00000056616c7565536574746572020001001d00000000000000120000004174746573746572496e63656e74697665730300010025000000000000001000000050726f766572496e63656e7469766573040001002a00000000000000080000004163636f756e7473050001002e000000000000000a000000556e697175656e6573730600010033000000000000000a000000436861696e53746174650700010035000000000000000b000000426c6f6253746f72616765080001003600000000000000090000005061796d61737465720900010037000000000000000300000045766d0a00010051000000000000000d0000004163636573735061747465726e0b000100540000000000000001000014000000020000000100000001000901000000000000000042000000000c0000004d756c74694164647265737302000000080000005374616e64617264000001000a0000000000000002000000566d010001000c00000000000000010000190000000200000001000000000b00000000000000000000000000000023000000020000000100000001011c000000000000000303000000736f760000000000000000000a0000000d0009000000000000000a000000030008000000000000000a0000000300210000000000000019000000020000000100000000220000000000000000000000000000000d0000000c020000000000000001000801190000000200000001000000003800000000000000000000000000000078000000000b00000043616c6c4d657373616765030000001100000052656769737465725061796d6173746572000001003900000000000000140000005365745061796572466f7253657175656e6365720100010046000000000000000c000000557064617465506f6c6963790200010047000000000000000000006700000001300000005f5f536f765669727475616c57616c6c65745f43616c6c4d6573736167655f52656769737465725061796d61737465720000000100000006000000706f6c6963790000003a0000000000000000000000010300000000000000010200000000000000b6000000011a0000005061796d6173746572506f6c696379496e697469616c697a6572000000040000001400000064656661756c745f70617965655f706f6c6963790000003b00000000000000000000000600000070617965657300000041000000000000000000000013000000617574686f72697a65645f75706461746572730000000e000000000000000000000015000000617574686f72697a65645f73657175656e63657273000000430000000000000000000000000037000000000b0000005061796565506f6c6963790200000005000000416c6c6f77000001003c000000000000000400000044656e79010000000000ac00000001240000005f5f536f765669727475616c57616c6c65745f5061796565506f6c6963795f416c6c6f7700000004000000070000006d61785f6665650000000f0000000000000000000000090000006761735f6c696d69740000002000000000000000000000000d0000006d61785f6761735f70726963650000003d0000000000000000000000110000007472616e73616374696f6e5f6c696d697400000040000000000000000000000000000a00000003003e000000000000002e00000001080000004761735072696365000000010000000500000076616c75650000003f00000000000000000000000000120000000c02000000000000000008000000000000000500000003010008010a0000000d004200000000000000280000000200000002000000000900000000000000000000000000003b0000000000000000000000000000003e0000000014000000417574686f72697a656453657175656e636572730200000003000000416c6c00000004000000536f6d65010001004400000000000000000000c60000000109000000547844657461696c730001370000007b4d6178205072696f72697479204665657c7d7c7b4d6178204665657c7d7c7b476173204c696d69747c7d7c7b436861696e2049447c7d0004000000150000006d61785f7072696f726974795f6665655f626970730001006a0000000000000000000000070000006d61785f666565000000080000000000000000000000090000006761735f6c696d697400010020000000000000000000000008000000636861696e5f6964000101000801000000000000140000000200000001000000010008010000000000000000880000000113000000556e7369676e65645472616e73616374696f6e0001120000007b7d7c7b47656e65726174696f6e7d7c7b7d00030000000c00000072756e74696d655f63616c6c0000000300000000000000000000000a00000067656e65726174696f6e000101000801000000000700000064657461696c730000006900000000000000000000000000', + 'hex', + ), + leavesIndices: Buffer.from( + '1a0000000300000000000000080000000000000009000000000000000a000000000000000b000000000000000e000000000000000f000000000000002000000000000000210000000000000022000000000000003700000000000000380000000000000039000000000000003a000000000000003b000000000000003c000000000000003d000000000000003e000000000000003f00000000000000400000000000000041000000000000004200000000000000430000000000000069000000000000006a000000000000006b00000000000000', + 'hex', + ), + lemmas: Buffer.from( + '1000000077acc7048b564d54cfb2cf87279320144ab1a3fd7d71c84c0912051d08ebf36bdf0ff86a776897f89216f36f60dc259efadc0fe96916b464bb0da54ccefd6c4aaed068171d4b762ffb6832ef09b312fa307c6e63842a3ed345f296fe4fdd6b784221aacf4fa025bc5f03c16582f9e4ab4fc1479ce11af5927610c450f8461c11b720318bc1aeeb37557487d8e3029d63c310b136487d5862e3b7e7953137d9222c1a96629574b47179a89ce11de505fc1f972b986eb3216ecdcbea928260316362f0db9c5a1c9552c49c574fd68ced31216afcf50ee00e4037b14f7b815178825370d5c58a70ac1bac18a37025400bd9a5c1d8d635b9c02fe561324965c9b325cdeccaa748532eb8c46e2031d355ecd8cd8f49b58540130e8c31312935e1a084114fe6c3a9666ee00ee9f54a171cbcaf9c3d8261acf90902c3cde82a5adf692aa4b4add2c0c43f06ca66475693198153cdb81c8e72dc6096eea71699db04d3934a5ce1176c12b475dd37f6520dc546f61a0fb2a68915590abbdedba9eed5c427ae0d79269b40e78557292c4691beb4d0f1186cd7b77423d9d232d88156a860fe6b6158f4d25b73e714c58dd1ce65723c71311c19d637103647d7d2e4228292ffaa801c77d4ab726b3400e77f090dbc1b39ea47027845b39f9e7dd5ad22fc78b5ed27560feb925637a3a176e3c9e1d357504d186d5fe6140abff97bcb464bcca2', + 'hex', + ), + treeSize: Buffer.from('6c00000000000000', 'hex'), + rootHash: Buffer.from('f55d28d6582a2e492b325f097e1ebcc0a19eca8f506fb5a7c3473067d48f06f8', 'hex'), + }, + chainData: Buffer.from( + 'e1100000000000000900000054657374436861696e060100000009000000746f6b656e5f696473010000002000000017171717171717171717171717171717171717171717171717171717171717060900000054657374546f6b656e', + 'hex', + ), + rootTypeIndices: Buffer.from('0400000000000000000000006b0000000000000003000000000000000b00000000000000', 'hex'), + extraDataHash: Buffer.from('77f986b27d5c6e676fdb865f44833b5fe97f5cccafaf5b4733c21ba027f8b725', 'hex'), + chainHash: Buffer.from('a43850ba5603f89c05080e14ff868fec09f35fbfaa3c28ad76258fbac95d7432', 'hex'), + }, + }, +] diff --git a/tests_zemu/tests/transactions.test.ts b/tests_zemu/tests/transactions.test.ts new file mode 100644 index 0000000..c4d584e --- /dev/null +++ b/tests_zemu/tests/transactions.test.ts @@ -0,0 +1,60 @@ +/** ****************************************************************************** + * (c) 2018 - 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************* */ + +import Zemu from '@zondax/zemu' +import { SovereignApp } from '@zondax/ledger-sovereign' +import { defaultOptions, models } from './common' +import { ed25519 } from '@noble/curves/ed25519' + +jest.setTimeout(60000) + +import { TRANSACTIONS_TEST_CASES } from './testscases/transactions' + +jest.setTimeout(60000) + +describe.each(TRANSACTIONS_TEST_CASES)('Tx', function (data) { + test.concurrent.each(models)('sign transaction', async function (m) { + const sim = new Zemu(m.path) + try { + await sim.start({ ...defaultOptions, model: m.name }) + const app = new SovereignApp(sim.getTransport()) + + const txBlob = data.transaction + const schema = data.schema + const responseAddr = await app.getAddressAndPubKey(data.path, false) + const pubKey = responseAddr.pubkey + + // do not wait here.. we need to navigate + const signatureRequest = app.sign(data.path, txBlob, schema) + + // Wait until we are not in the main menu + await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) + await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_${data.name}`) + + const signatureResponse = await signatureRequest + console.log(signatureResponse.signature.toString('hex')) + + const chainHash = data.schema.chainHash + const txBlobWithChainHash = Buffer.concat([txBlob, chainHash]) + + // Now verify the signature + const valid = ed25519.verify(signatureResponse.signature, txBlobWithChainHash, pubKey) + expect(valid).toEqual(true) + } finally { + await sim.close() + } + }) +}) diff --git a/tests_zemu/try.mjs b/tests_zemu/try.mjs index 72a0762..e216bd0 100644 --- a/tests_zemu/try.mjs +++ b/tests_zemu/try.mjs @@ -3,8 +3,36 @@ import { SovereignApp } from '@zondax/ledger-sovereign' import { ed25519 } from '@noble/curves/ed25519' const PATH = "m/44'/1551'/0'" -const BLOB = - 'e227ae01b445203f7fd92dd6e206f9de27713ba00c95f46dce5068b68f895b30cac0b4f2a74d6aa05d07b6a83cda6ef19b50e8c26e5653d80156ab1053f3fec3d161388122a7cc6ecfd790e833d127231785b0fdc337bb8e' + +const transaction = Buffer.from( + '0001000b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b1027000000000000000000000000000017171717171717171717171717171717171717171717171717171717171717060000000000000000000000000000000000e876481700000000000000000000000100ca9a3b0000000000ca9a3b00000000e110000000000000', + 'hex', +) +const schema = { + merkleProof: { + leavesData: Buffer.from( + '1000000059010000000b00000052756e74696d6543616c6c0c0000000400000042616e6b0000010004000000000000001100000053657175656e63657252656769737472790100010016000000000000000b00000056616c7565536574746572020001001d00000000000000120000004174746573746572496e63656e74697665730300010025000000000000001000000050726f766572496e63656e7469766573040001002a00000000000000080000004163636f756e7473050001002e000000000000000a000000556e697175656e6573730600010033000000000000000a000000436861696e53746174650700010035000000000000000b000000426c6f6253746f72616765080001003600000000000000090000005061796d61737465720900010037000000000000000300000045766d0a00010051000000000000000d0000004163636573735061747465726e0b0001005400000000000000010000190000000200000001000000000500000000000000000000000000000088000000000b00000043616c6c4d657373616765050000000b000000437265617465546f6b656e000001000600000000000000080000005472616e73666572010001001000000000000000040000004275726e020001001300000000000000040000004d696e7403000100140000000000000006000000467265657a6504000100150000000000000000000014000000020000000100000001000901000000000000000042000000000c0000004d756c74694164647265737302000000080000005374616e64617264000001000a0000000000000002000000566d010001000c00000000000000010000190000000200000001000000000b00000000000000000000000000000023000000020000000100000001011c000000000000000303000000736f760000000000000000009300000001270000005f5f536f765669727475616c57616c6c65745f43616c6c4d6573736167655f5472616e73666572011a0000005472616e7366657220746f2061646472657373207b7d207b7d2e01070000007c7b546f7d7b7d000200000002000000746f00000009000000000000000000000005000000636f696e7300000011000000000000000000000001010000000000000000860000000105000000436f696e7301170000007b7d20636f696e73206f6620746f6b656e204944207b7d01140000007b416d6f756e747c7d7b546f6b656e2049447c7d010200000006000000616d6f756e740000010009020101000000000000001f000000000000000000000008000000746f6b656e5f69640000001200000000000000000000000000330000000200000001000000010120000000000000000306000000746f6b656e5f0109000000746f6b656e5f69647300000000000000000a0000000300210000000000000019000000020000000100000000220000000000000000000000000000000d0000000c020000000000000001000801c60000000109000000547844657461696c730001370000007b4d6178205072696f72697479204665657c7d7c7b4d6178204665657c7d7c7b476173204c696d69747c7d7c7b436861696e2049447c7d0004000000150000006d61785f7072696f726974795f6665655f626970730001006a0000000000000000000000070000006d61785f666565000000080000000000000000000000090000006761735f6c696d697400010020000000000000000000000008000000636861696e5f6964000101000801000000000000140000000200000001000000010008010000000000000000880000000113000000556e7369676e65645472616e73616374696f6e0001120000007b7d7c7b47656e65726174696f6e7d7c7b7d00030000000c00000072756e74696d655f63616c6c0000000300000000000000000000000a00000067656e65726174696f6e000101000801000000000700000064657461696c730000006900000000000000000000000000', + 'hex', + ), + leavesIndices: Buffer.from( + '10000000030000000000000004000000000000000500000000000000080000000000000009000000000000000a000000000000000b0000000000000010000000000000001100000000000000120000000000000020000000000000002100000000000000220000000000000069000000000000006a000000000000006b00000000000000', + 'hex', + ), + lemmas: Buffer.from( + '0e00000077acc7048b564d54cfb2cf87279320144ab1a3fd7d71c84c0912051d08ebf36bdf0ff86a776897f89216f36f60dc259efadc0fe96916b464bb0da54ccefd6c4a2c65338f3d4530a8df68c748139d75f43900873871b57da86e605a7ea2c195d2e02cecb6e76e86aa450de420490f1e1c882e3cf23e9863df984884e4c48592302313aec76ea72f21d539d0ed27a1fa9431af9d270b3834b4a2d270e04495e06e339800d039914b2630ac0e2ec7302447a84e7d27b0fa14c0afaf0beb979534159aa898b4dfa154a4bb5fd9a9cc75f9f8627d691fe4207dfd3621276e43f1d0e92c1a96629574b47179a89ce11de505fc1f972b986eb3216ecdcbea928260316362f0db9c5a1c9552c49c574fd68ced31216afcf50ee00e4037b14f7b815178825370d5c58a70ac1bac18a37025400bd9a5c1d8d635b9c02fe561324965c9b325fba7cdd8412a830cdb48bad5d88e1fcefc60d3fcbb6cf8a95a20322e72b49e5284cd0a4c2cf32bc3a719948f3db013f6c0f33854cab1a02d61d6755bb541611faa801c77d4ab726b3400e77f090dbc1b39ea47027845b39f9e7dd5ad22fc78b5ed27560feb925637a3a176e3c9e1d357504d186d5fe6140abff97bcb464bcca2', + 'hex', + ), + treeSize: Buffer.from('6c00000000000000', 'hex'), + rootHash: Buffer.from('f55d28d6582a2e492b325f097e1ebcc0a19eca8f506fb5a7c3473067d48f06f8', 'hex'), + }, + chainData: Buffer.from( + 'e1100000000000000900000054657374436861696e060100000009000000746f6b656e5f696473010000002000000017171717171717171717171717171717171717171717171717171717171717060900000054657374546f6b656e', + 'hex', + ), + rootTypeIndices: Buffer.from('0400000000000000000000006b0000000000000003000000000000000b00000000000000', 'hex'), + extraDataHash: Buffer.from('77f986b27d5c6e676fdb865f44833b5fe97f5cccafaf5b4733c21ba027f8b725', 'hex'), + chainHash: Buffer.from('a43850ba5603f89c05080e14ff868fec09f35fbfaa3c28ad76258fbac95d7432', 'hex'), +} async function showAddress(app) { let resp = await app.deviceInfo() @@ -18,17 +46,19 @@ async function showAddress(app) { console.log('Address: ' + address.toString('hex')) } -async function sign(app, action) { - const messageToSign = Buffer.from(action, 'hex') +async function sign(app) { try { const responseAddr = await app.getAddressAndPubKey(PATH, false) const pubKey = responseAddr.pubkey - const signatureRequest = app.sign(PATH, messageToSign) + const signatureRequest = app.sign(PATH, transaction, schema) const signatureResponse = await signatureRequest console.log('Signature:', signatureResponse.signature.toString('hex')) - const valid = ed25519.verify(signatureResponse.signature, messageToSign, pubKey) + const chainHash = schema.chainHash + const txBlobWithChainHash = Buffer.concat([transaction, chainHash]) + + const valid = ed25519.verify(signatureResponse.signature, txBlobWithChainHash, pubKey) if (valid) { console.log('Valid signature') } else { @@ -46,7 +76,7 @@ async function main() { // Enable/disable(uncommenting) to try this features on a real device await showAddress(app) - await sign(app, BLOB) + await sign(app) } ;(async () => {