diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index a141a2d..2bbff60 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -19,8 +19,8 @@ Describe your issue in as much detail as possible here.
## Steps to reproduce
-* Tell us how to reproduce this issue
-* Where the issue is, if you know
+* Tell us how to reproduce this issue
+* Where the issue is, if you know
* Which commands triggered the issue, if any
## Expected behaviour
@@ -37,4 +37,5 @@ Please paste any logs here that demonstrate the issue, if they exist
## Proposed solution
-If you have an idea of how to fix this issue, please write it down here, so we can begin discussing it
\ No newline at end of file
+If you have an idea of how to fix this issue, please write it down here,
+so we can begin discussing it
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index 031ba33..af1481d 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -1,6 +1,6 @@
---
name: Feature report
-about: Suggest an idea for this project
+about: Suggest an idea for this project
title: 'Add [Subject of the issue]'
labels: 'enhancement'
assignees: ''
diff --git a/.github/ISSUE_TEMPLATE/network_request.md b/.github/ISSUE_TEMPLATE/network_request.md
index 369f21e..ee5115a 100644
--- a/.github/ISSUE_TEMPLATE/network_request.md
+++ b/.github/ISSUE_TEMPLATE/network_request.md
@@ -1,6 +1,6 @@
---
name: Network request
-about: Request of new chain or network
+about: Request of new chain or network
title: 'Add {NameChain} network ({SYMBOL})'
labels: 'enhancement, chain/network'
assignees: ''
@@ -8,12 +8,13 @@ assignees: ''
---
## Description
-- [ ] Symbol:
-- [ ] ChainId:
-- [ ] Website:
-- [ ] Block-Explorer:
-- [ ] [slip-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md) type:
+
+- [ ] Symbol:
+- [ ] ChainId:
+- [ ] Website:
+- [ ] Block-Explorer:
+- [ ] [slip-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md) type:
## Additional comments
-Please post additional comments in this section if you have them, otherwise delete it.
\ No newline at end of file
+Please post additional comments in this section if you have them, otherwise delete it.
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 4024641..b17d695 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -1,6 +1,6 @@
## Description
-Please provide a detailed description of what was done in this PR.
+Please provide a detailed description of what was done in this PR.
(And mentioned if linked to an issue [docs](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue))
## Changes include
@@ -18,4 +18,4 @@ Please complete this section if any breaking changes have been made, otherwise d
## Additional comments
-Please post additional comments in this section if you have them, otherwise delete it.
\ No newline at end of file
+Please post additional comments in this section if you have them, otherwise delete it.
diff --git a/.github/workflows/auto-author-assign.yml b/.github/workflows/auto-author-assign.yml
deleted file mode 100644
index 82adf17..0000000
--- a/.github/workflows/auto-author-assign.yml
+++ /dev/null
@@ -1,15 +0,0 @@
----
-name: 'Auto Author Assign'
-
-on:
- pull_request_target:
- types: [opened, reopened]
-
-permissions:
- pull-requests: write
-
-jobs:
- assign-author:
- runs-on: ubuntu-latest
- steps:
- - uses: toshimaru/auto-author-assign@v1.6.1
diff --git a/.github/workflows/build_and_functional_tests.yml b/.github/workflows/build_and_functional_tests.yml
new file mode 100644
index 0000000..e0d280a
--- /dev/null
+++ b/.github/workflows/build_and_functional_tests.yml
@@ -0,0 +1,33 @@
+name: Build and run functional tests using ragger through reusable workflow
+
+# This workflow will build the app and then run functional tests using the Ragger framework upon Speculos emulation.
+# It calls a reusable workflow developed by Ledger's internal developer team to build the application and upload the
+# resulting binaries.
+# It then calls another reusable workflow to run the Ragger tests on the compiled application binary.
+#
+# While this workflow is optional, having functional testing on your application is mandatory and this workflow and
+# tooling environment is meant to be easy to use and adapt after forking your application
+
+on:
+ workflow_dispatch:
+ push:
+ branches:
+ - master
+ - main
+ - develop
+ pull_request:
+
+jobs:
+ build_application:
+ name: Build application using the reusable workflow
+ uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
+ with:
+ upload_app_binaries_artifact: "ragger_elfs"
+ flags: "DEBUG=1 CAL_TEST_KEY=1 DOMAIN_NAME_TEST_KEY=1 SET_PLUGIN_TEST_KEY=1 NFT_TEST_KEY=1"
+
+ ragger_tests:
+ name: Run ragger tests using the reusable workflow
+ needs: build_application
+ uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_ragger_tests.yml@v1
+ with:
+ download_app_binaries_artifact: "ragger_elfs"
diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml
index b785a7e..29cf364 100644
--- a/.github/workflows/ci-workflow.yml
+++ b/.github/workflows/ci-workflow.yml
@@ -1,5 +1,5 @@
---
-name: Tests
+name: Tests (Speculos and Zemu)
on:
workflow_dispatch:
@@ -22,7 +22,7 @@ jobs:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: Build testing binaries
run: |
@@ -30,7 +30,7 @@ jobs:
cd tests/zemu/ && ./build_local_test_elfs.sh
- name: Upload app binaries
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: e2e_zemu_elfs
path: ./tests/zemu/elfs/
@@ -41,16 +41,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- - name: Test
- run: |
- id
- echo $HOME
- echo $DISPLAY
-
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- - run: sudo apt-get update -y && sudo apt-get install -y libusb-1.0.0 libudev-dev
+ - name: Install additional tools
+ run: sudo apt-get update -y && sudo apt-get install -y libusb-1.0.0 libudev-dev
- name: Install NodeJS
uses: actions/setup-node@v3
@@ -67,12 +62,12 @@ jobs:
run: mkdir tests/zemu/elfs
- name: Download app binaries
- uses: actions/download-artifact@v3
+ uses: actions/download-artifact@v4
with:
path: tmp/
- name: Gather elfs
- run: cp `find tmp/e2e_zemu_elfs/ -name "*.elf"` tests/zemu/elfs/
+ run: cp tmp/e2e_zemu_elfs/*.elf tests/zemu/elfs/
- name: Run zemu tests
run: cd tests/zemu/ && yarn test
@@ -89,7 +84,7 @@ jobs:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: Build testing binaries
run: |
@@ -99,7 +94,7 @@ jobs:
make clean && make -j DEBUG=1 NFT_STAGING_KEY=1 BOLOS_SDK=$NANOSP_SDK && mv bin/app.elf tests/speculos/elfs/nanosp.elf
- name: Upload app binaries
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: e2e_speculos_elfs
path: ./tests/speculos/elfs
@@ -117,18 +112,18 @@ jobs:
steps:
- name: Clone
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Create tmp folder for artifacts
run: mkdir tests/speculos/elfs
- name: Download app binaries
- uses: actions/download-artifact@v3
+ uses: actions/download-artifact@v4
with:
path: tmp/
- name: Gather elfs
- run: cp `find tmp/e2e_speculos_elfs/ -name "*.elf"` tests/speculos/elfs/
+ run: cp tmp/e2e_speculos_elfs/*.elf tests/speculos/elfs/
- name: Install dependencies
run: |
@@ -140,62 +135,3 @@ jobs:
run: |
cd tests/speculos
pytest --model ${{ matrix.model }} --path ./elfs/${{ matrix.model }}.elf --display headless
-
-
- # =====================================================
- # RAGGER TESTS
- # =====================================================
-
- build_ragger_elfs:
- name: Build app for Ragger tests
- uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
- with:
- upload_app_binaries_artifact: "ragger_elfs"
- flags: "DEBUG=1 CAL_TEST_KEY=1 DOMAIN_NAME_TEST_KEY=1 SET_PLUGIN_TEST_KEY=1 NFT_TEST_KEY=1"
-
- jobs-ragger-tests:
- name: Run Ragger tests
- needs: build_ragger_elfs
- uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_ragger_tests.yml@v1
- with:
- download_app_binaries_artifact: "ragger_elfs"
-
- # =====================================================
- # STATIC ANALYSIS
- # =====================================================
-
- # Static analysis on the main ETH chain is covered by the guidelines enforcer
- scan-build:
- name: Clang Static Analyzer on altcoin
- runs-on: ubuntu-latest
- container:
- image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
- strategy:
- fail-fast: false
- matrix:
- device: ["nanos", "nanos2", "nanox", "stax"]
-
- steps:
- - name: Clone
- uses: actions/checkout@v3
- with:
- submodules: recursive
-
- - name: Build with Clang Static Analyzer
- run: |
- eval "BOLOS_SDK=\$$(echo ${{ matrix.device }} | tr [:lower:] [:upper:])_SDK" && \
- echo "BOLOS_SDK value will be: ${BOLOS_SDK}" && \
- make -j ENABLE_SDK_WERROR=1 BOLOS_SDK=${BOLOS_SDK} CHAIN=polygon scan-build
-
- - uses: actions/upload-artifact@v3
- if: failure()
- with:
- name: scan-build
- path: scan-build
-
- - name: Upload scan result
- if: failure()
- uses: actions/upload-artifact@v3
- with:
- name: scan-build
- path: scan-build
diff --git a/.github/workflows/codeql_checks.yml b/.github/workflows/codeql_checks.yml
new file mode 100644
index 0000000..fb95064
--- /dev/null
+++ b/.github/workflows/codeql_checks.yml
@@ -0,0 +1,44 @@
+name: "CodeQL"
+
+on:
+ workflow_dispatch:
+ push:
+ branches:
+ - master
+ - main
+ - develop
+ pull_request:
+ # Excluded path: add the paths you want to ignore instead of deleting the workflow
+ paths-ignore:
+ - '.github/workflows/*.yml'
+ - 'tests/*'
+
+jobs:
+ analyse:
+ name: Analyse
+ strategy:
+ matrix:
+ sdk: [ "$NANOS_SDK", "$NANOX_SDK", "$NANOSP_SDK", "$STAX_SDK" ]
+ #'cpp' covers C and C++
+ language: [ 'cpp' ]
+ runs-on: ubuntu-latest
+ container:
+ image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-legacy:latest
+
+ steps:
+ - name: Clone
+ uses: actions/checkout@v4
+
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v3
+ with:
+ languages: ${{ matrix.language }}
+ queries: security-and-quality
+
+ # CodeQL will create the database during the compilation
+ - name: Build
+ run: |
+ make BOLOS_SDK=${{ matrix.sdk }}
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v3
diff --git a/.github/workflows/guidelines_enforcer.yml b/.github/workflows/guidelines_enforcer.yml
new file mode 100644
index 0000000..fdaf9f2
--- /dev/null
+++ b/.github/workflows/guidelines_enforcer.yml
@@ -0,0 +1,23 @@
+name: Ensure compliance with Ledger guidelines
+
+# This workflow is mandatory in all applications
+# It calls a reusable workflow guidelines_enforcer developed by Ledger's internal developer team.
+# The successful completion of the reusable workflow is a mandatory step for an app to be available on the Ledger
+# application store.
+#
+# More information on the guidelines can be found in the repository:
+# LedgerHQ/ledger-app-workflows/
+
+on:
+ workflow_dispatch:
+ push:
+ branches:
+ - master
+ - main
+ - develop
+ pull_request:
+
+jobs:
+ guidelines_enforcer:
+ name: Call Ledger guidelines_enforcer
+ uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_guidelines_enforcer.yml@v1
diff --git a/.github/workflows/pr_on_all_plugins.yml b/.github/workflows/pr_on_all_plugins.yml
index 3db1bbe..7618cdd 100644
--- a/.github/workflows/pr_on_all_plugins.yml
+++ b/.github/workflows/pr_on_all_plugins.yml
@@ -39,7 +39,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout SDK repository
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
repository: LedgerHQ/ethereum-plugin-sdk
ref: develop
@@ -96,7 +96,7 @@ jobs:
steps:
- name: Checkout plugin repository
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
repository: LedgerHQ/${{ matrix.repo }}
submodules: recursive
@@ -144,7 +144,7 @@ jobs:
gh label create 'auto' --color 'b4a8d1' --description 'Automatically created'
fi
- - name: Create pull request and commment on SDK issue
+ - name: Create pull request and comment on SDK issue
run: |
# Github limits the number of possible PR being opened in a given time window.
# The limits are 20 creation per minute and 150 per hour.
diff --git a/.github/workflows/python-client.yml b/.github/workflows/python-client.yml
index 248c804..2c8745b 100644
--- a/.github/workflows/python-client.yml
+++ b/.github/workflows/python-client.yml
@@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- run: pip install flake8 flake8-pyproject
- name: Flake8 lint Python code
run: (cd client && flake8 src/)
@@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- run: pip install mypy
- name: Mypy type checking
run: (cd client && mypy src/)
@@ -45,7 +45,7 @@ jobs:
steps:
- name: Clone
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
fetch-depth: 0
diff --git a/.github/workflows/sdk-generation.yml b/.github/workflows/sdk-generation.yml
index 363c89b..afefb30 100644
--- a/.github/workflows/sdk-generation.yml
+++ b/.github/workflows/sdk-generation.yml
@@ -15,7 +15,7 @@ jobs:
steps:
- name: Clone
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
# by default the action uses fetch-depth = 1, which creates
# shallow repositories from which we can't push
diff --git a/.gitignore b/.gitignore
index 49c5a99..6b3139a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,13 +1,10 @@
# Compilation of Ledger's app
-src/glyphs.c
-src/glyphs.h
bin/
debug/
-dep/
-obj/
build/
# Python
+venv/
*.pyc
__version__.py
@@ -19,4 +16,4 @@ tests/elfs/*
tests/snapshots-tmp
.vscode
-.idea
\ No newline at end of file
+.idea
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fb41e35..8b9ce8a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -211,7 +211,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
-- Provide network ticker to plugins (especialy helpful for Paraswap plugin)
+- Provide network ticker to plugins (especially helpful for Paraswap plugin)
- Polygon variant
## [1.9.10](https://github.com/ledgerhq/app-ethereum/compare/1.9.9...1.9.10) - 2021-10-08
diff --git a/Makefile b/Makefile
index d3572f8..a7a2ef2 100644
--- a/Makefile
+++ b/Makefile
@@ -34,13 +34,13 @@ APP_LOAD_PARAMS += --path "1517992542'/1101353413'"
APPVERSION_M = 1
APPVERSION_N = 11
-APPVERSION_P = 0
+APPVERSION_P = 1
APPVERSION = $(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)-dev
APP_LOAD_FLAGS = --appFlags 0xa40 --dep Ethereum:$(APPVERSION)
-###########################
-# Set Chain environnement #
-###########################
+#########################
+# Set Chain environment #
+#########################
ifeq ($(CHAIN),)
CHAIN = ethereum
diff --git a/README.md b/README.md
index 637e3d3..7a71b1a 100644
--- a/README.md
+++ b/README.md
@@ -31,18 +31,17 @@
- [Running all tests](#running-all-tests)
- [With Makefile](#with-makefile)
- [With yarn](#with-yarn)
- - [Running a specific tests](#running-a-specific-tests)
+ - [Running a specific test](#running-a-specific-test)
- [Adding tests](#adding-tests)
- [Zemu](#zemu)
- [Update binaries](#update-binaries)
- [Contributing](#contributing)
-
## About the project
-Ethereum wallet application framework for Nano S, Nano S Plus and Nano X.
+Ethereum wallet application framework for Nano S, Nano S Plus and Nano X.
Ledger Blue is not maintained anymore, but the app can still be compiled for this target using the branch [`blue-final-release`](https://github.com/LedgerHQ/app-ethereum/tree/blue-final-release).
## Documentation
@@ -53,8 +52,9 @@ To compile it and load it on a device, please check out our [developer portal](h
### Plugins
-We have the concept of plugins in the ETH app.
-Find the documentations here:
+We have the concept of plugins in the ETH app.
+Find the documentations here:
+
- [Blog Ethereum plugins](https://blog.ledger.com/ethereum-plugins/)
- [Ethereum application Plugins : Technical Specifications](https://github.com/LedgerHQ/app-ethereum/blob/master/doc/ethapp_plugins.asc)
- [Plugin guide](https://hackmd.io/300Ukv5gSbCbVcp3cZuwRQ)
@@ -68,48 +68,55 @@ Testing is done via the open-source framework [zemu](https://github.com/Zondax/z
- [nodeJS == 16](https://github.com/nvm-sh/nvm)
- [yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable)
-- [build environnement](https://github.com/LedgerHQ/ledger-app-builder/blob/master/Dockerfile)
+- [build environment](https://github.com/LedgerHQ/ledger-app-builder/blob/master/Dockerfile)
-#### Build the applications required by the test suite
+#### Build the applications required by the test suite
1. Add your BOLOS SDKs path to:
- - `NANOS_SDK` and `NANOX_SDK`
+
+ `NANOS_SDK` and `NANOX_SDK`
2. Go to the `tests` folder and run `./build_local_test_elfs.sh`
- - ```sh
- cd tests
- # This helper script will build the applications required by the test suite and move them at the right place.
- yarn install
- ./build_local_test_elfs.sh
- ```
+
+ ```sh
+ cd tests
+ # This helper script will build the applications required by the test suite and move them at the right place.
+ yarn install
+ ./build_local_test_elfs.sh
+ ```
### Running all tests
+
#### With Makefile
1. Then you can install and run tests by simply running on the `root` of the repo:
- - ```sh
- make test
- ```
- - This will run `make install_tests` and `make run_tests`
+
+ ```sh
+ make test
+ # This will run `make install_tests` and `make run_tests`
+ ```
#### With yarn
1. Go to the `tests` folder and run:
- - ```sh
- yarn test
- ```
-### Running a specific tests
+ ```sh
+ yarn test
+ ```
-1. Go to the `tests` folder and run:
- - ```sh
- yarn jest --runInBand --detectOpenHandles {YourTestFile}
- ```
-2. For example with the `send test`:
- - ```sh
- yarn jest --runInBand --detectOpenHandles src/send.test.js
- ```
+### Running a specific test
+1. Go to the `tests` folder and run:
+
+ ```sh
+ yarn jest --runInBand --detectOpenHandles {YourTestFile}
+ ```
+
+2. For example with the `send test`:
+
+ ```sh
+ yarn jest --runInBand --detectOpenHandles src/send.test.js
+ ```
### Adding tests
@@ -128,7 +135,7 @@ Finally make sure you adapt the expected signature!
#### Update binaries
-Don't forget to update the binaries in the test folder. To do so, compile with those environement variables:
+Don't forget to update the binaries in the test folder. To do so, compile with those environment variables:
```sh
make DEBUG=1 ALLOW_DATA=1
@@ -142,10 +149,9 @@ cp bin/app.elf tests/elfs/ethereum_nanos.elf
Repeat the operation for a binary compiled with nanoX SDK and change for `ethereum_nanox.elf`.
-
## Contributing
-Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
+Contributions are what makes the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag `enhancement`.
diff --git a/client/pyproject.toml b/client/pyproject.toml
index 3a91961..e68d1a3 100644
--- a/client/pyproject.toml
+++ b/client/pyproject.toml
@@ -48,4 +48,4 @@ Home = "https://github.com/LedgerHQ/app-ethereum"
ignore_missing_imports = true
[tool.flake8]
-max-line-length = 120
\ No newline at end of file
+max-line-length = 120
diff --git a/doc/eth_contract_support_embedded.adoc b/doc/eth_contract_support_embedded.adoc
index 36a582c..629f994 100644
--- a/doc/eth_contract_support_embedded.adoc
+++ b/doc/eth_contract_support_embedded.adoc
@@ -12,7 +12,7 @@ This document described how a specific device UI for a smart contract can be add
## Standard support
-The applications already includes dedicated UI support for those specific contract calls :
+The application already includes dedicated UI support for those specific contract calls :
* ERC 20 approve(address, uint256) - implementation in *src_features/erc20_approval*
* ERC 20 transfer(address, uint256) - implementation in *src_features/signTx*
@@ -45,4 +45,3 @@ A UI implementation might want to convert an ERC 20 token contract address to a
2 tickers can be temporarily provisioned to the application by using the PROVIDE ERC 20 TOKEN INFORMATION APDU, described in *src_features/provideErc20TokenInformation* - the UI can then iterate on the provisioned tickers to display relevant information to the user
The same mechanism will be extended to support well known contract addresses in the future
-
diff --git a/doc/ethapp.adoc b/doc/ethapp.adoc
index 6fba964..10637a0 100644
--- a/doc/ethapp.adoc
+++ b/doc/ethapp.adoc
@@ -801,7 +801,7 @@ None
This command provides a trusted way of deciding what information from the JSON data to show and replace some values by more meaningful ones.
-This mode can be overriden by the in-app setting to fully clear-sign EIP-712 messages.
+This mode can be overridden by the in-app setting to fully clear-sign EIP-712 messages.
For the signatures :
diff --git a/examples/signMessageEIP711v0.py b/examples/signMessageEIP711v0.py
index 97b8ef1..cbe6595 100755
--- a/examples/signMessageEIP711v0.py
+++ b/examples/signMessageEIP711v0.py
@@ -59,7 +59,7 @@ if args.path == None:
domainHash = binascii.unhexlify(args.domainHash)
messageHash = binascii.unhexlify(args.messageHash)
-encodedTx = domainHash + messageHash
+encodedTx = domainHash + messageHash
donglePath = parse_bip32_path(args.path)
apdu = bytearray.fromhex("e00c0000")
diff --git a/glyphs/stax_chain_10507_64px.gif b/glyphs/stax_chain_10507_64px.gif
index 287008f..4cabc80 100644
Binary files a/glyphs/stax_chain_10507_64px.gif and b/glyphs/stax_chain_10507_64px.gif differ
diff --git a/glyphs/stax_chain_1907_64px.gif b/glyphs/stax_chain_1907_64px.gif
index 543f164..f2ddefc 100644
Binary files a/glyphs/stax_chain_1907_64px.gif and b/glyphs/stax_chain_1907_64px.gif differ
diff --git a/glyphs/stax_chain_40_64px.gif b/glyphs/stax_chain_40_64px.gif
index 151d58d..f245b1b 100644
Binary files a/glyphs/stax_chain_40_64px.gif and b/glyphs/stax_chain_40_64px.gif differ
diff --git a/glyphs/stax_chain_42220_64px.gif b/glyphs/stax_chain_42220_64px.gif
index 2b1370c..12216a6 100644
Binary files a/glyphs/stax_chain_42220_64px.gif and b/glyphs/stax_chain_42220_64px.gif differ
diff --git a/glyphs/stax_chain_44787_64px.gif b/glyphs/stax_chain_44787_64px.gif
index 2b1370c..12216a6 100644
Binary files a/glyphs/stax_chain_44787_64px.gif and b/glyphs/stax_chain_44787_64px.gif differ
diff --git a/glyphs/stax_chain_4_64px.gif b/glyphs/stax_chain_4_64px.gif
index 503a95f..4503aa9 100644
Binary files a/glyphs/stax_chain_4_64px.gif and b/glyphs/stax_chain_4_64px.gif differ
diff --git a/glyphs/stax_chain_62320_64px.gif b/glyphs/stax_chain_62320_64px.gif
index 2b1370c..12216a6 100644
Binary files a/glyphs/stax_chain_62320_64px.gif and b/glyphs/stax_chain_62320_64px.gif differ
diff --git a/icons/nanos_app_chain_14.gif b/icons/nanos_app_chain_14.gif
index e90dc8a..b96842b 100644
Binary files a/icons/nanos_app_chain_14.gif and b/icons/nanos_app_chain_14.gif differ
diff --git a/icons/nanos_app_chain_16.gif b/icons/nanos_app_chain_16.gif
index 584b1dc..f837534 100644
Binary files a/icons/nanos_app_chain_16.gif and b/icons/nanos_app_chain_16.gif differ
diff --git a/icons/nanos_app_chain_19.gif b/icons/nanos_app_chain_19.gif
index 302030b..6af1721 100644
Binary files a/icons/nanos_app_chain_19.gif and b/icons/nanos_app_chain_19.gif differ
diff --git a/icons/nanos_app_chain_20531811.gif b/icons/nanos_app_chain_20531811.gif
index 367ccf4..8f94d1d 100644
Binary files a/icons/nanos_app_chain_20531811.gif and b/icons/nanos_app_chain_20531811.gif differ
diff --git a/icons/nanos_app_chain_20531812.gif b/icons/nanos_app_chain_20531812.gif
index 367ccf4..8f94d1d 100644
Binary files a/icons/nanos_app_chain_20531812.gif and b/icons/nanos_app_chain_20531812.gif differ
diff --git a/icons/nanos_app_chain_246.gif b/icons/nanos_app_chain_246.gif
new file mode 100644
index 0000000..e2b44ca
Binary files /dev/null and b/icons/nanos_app_chain_246.gif differ
diff --git a/icons/nanos_app_chain_269.gif b/icons/nanos_app_chain_269.gif
index 1785934..958c660 100644
Binary files a/icons/nanos_app_chain_269.gif and b/icons/nanos_app_chain_269.gif differ
diff --git a/icons/nanos_app_chain_50.gif b/icons/nanos_app_chain_50.gif
index cccda60..f9d105a 100644
Binary files a/icons/nanos_app_chain_50.gif and b/icons/nanos_app_chain_50.gif differ
diff --git a/icons/nanos_app_chain_51.gif b/icons/nanos_app_chain_51.gif
index cccda60..f9d105a 100644
Binary files a/icons/nanos_app_chain_51.gif and b/icons/nanos_app_chain_51.gif differ
diff --git a/icons/nanos_app_chain_7341.gif b/icons/nanos_app_chain_7341.gif
index 3a07de0..b96efa1 100644
Binary files a/icons/nanos_app_chain_7341.gif and b/icons/nanos_app_chain_7341.gif differ
diff --git a/icons/nanos_app_chain_846000.gif b/icons/nanos_app_chain_846000.gif
index ad64f0f..1fbb57a 100644
Binary files a/icons/nanos_app_chain_846000.gif and b/icons/nanos_app_chain_846000.gif differ
diff --git a/icons/nanox_app_chain_19.gif b/icons/nanox_app_chain_19.gif
index 1361a68..cd3f798 100644
Binary files a/icons/nanox_app_chain_19.gif and b/icons/nanox_app_chain_19.gif differ
diff --git a/icons/nanox_app_chain_20531811.gif b/icons/nanox_app_chain_20531811.gif
index 596fa38..36a8eb7 100644
Binary files a/icons/nanox_app_chain_20531811.gif and b/icons/nanox_app_chain_20531811.gif differ
diff --git a/icons/nanox_app_chain_20531812.gif b/icons/nanox_app_chain_20531812.gif
index 596fa38..36a8eb7 100644
Binary files a/icons/nanox_app_chain_20531812.gif and b/icons/nanox_app_chain_20531812.gif differ
diff --git a/icons/nanox_app_chain_246.gif b/icons/nanox_app_chain_246.gif
new file mode 100644
index 0000000..cf87519
Binary files /dev/null and b/icons/nanox_app_chain_246.gif differ
diff --git a/icons/nanox_app_chain_7341.gif b/icons/nanox_app_chain_7341.gif
index fd1cb06..bab9850 100644
Binary files a/icons/nanox_app_chain_7341.gif and b/icons/nanox_app_chain_7341.gif differ
diff --git a/icons/nanox_app_chain_846000.gif b/icons/nanox_app_chain_846000.gif
index d36d209..dfc1f23 100644
Binary files a/icons/nanox_app_chain_846000.gif and b/icons/nanox_app_chain_846000.gif differ
diff --git a/makefile_conf/chain/akroma.mk b/makefile_conf/chain/akroma.mk
index 68c935f..0426bdb 100644
--- a/makefile_conf/chain/akroma.mk
+++ b/makefile_conf/chain/akroma.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/200625'"
TICKER = "AKA"
CHAIN_ID = 200625
-APPNAME = "Akroma"
\ No newline at end of file
+APPNAME = "Akroma"
diff --git a/makefile_conf/chain/artis_sigma1.mk b/makefile_conf/chain/artis_sigma1.mk
index 766bd32..1539ccc 100644
--- a/makefile_conf/chain/artis_sigma1.mk
+++ b/makefile_conf/chain/artis_sigma1.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/246529'"
TICKER = "ATS"
CHAIN_ID = 246529
-APPNAME = "ARTIS sigma1"
\ No newline at end of file
+APPNAME = "ARTIS sigma1"
diff --git a/makefile_conf/chain/artis_tau1.mk b/makefile_conf/chain/artis_tau1.mk
index dd0d981..720f506 100644
--- a/makefile_conf/chain/artis_tau1.mk
+++ b/makefile_conf/chain/artis_tau1.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/246785'"
TICKER = "ATS"
CHAIN_ID = 246785
-APPNAME = "ARTIS tau1"
\ No newline at end of file
+APPNAME = "ARTIS tau1"
diff --git a/makefile_conf/chain/atheios.mk b/makefile_conf/chain/atheios.mk
index e7e9ef5..77a73d7 100644
--- a/makefile_conf/chain/atheios.mk
+++ b/makefile_conf/chain/atheios.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/1620'"
TICKER = "ATH"
CHAIN_ID = 1620
-APPNAME = "Atheios"
\ No newline at end of file
+APPNAME = "Atheios"
diff --git a/makefile_conf/chain/bsc.mk b/makefile_conf/chain/bsc.mk
index dc70e0b..e3c9f6a 100644
--- a/makefile_conf/chain/bsc.mk
+++ b/makefile_conf/chain/bsc.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "BNB"
CHAIN_ID = 56
-APPNAME = "Binance Smart Chain"
\ No newline at end of file
+APPNAME = "Binance Smart Chain"
diff --git a/makefile_conf/chain/bttc.mk b/makefile_conf/chain/bttc.mk
index 9e82b67..6451337 100644
--- a/makefile_conf/chain/bttc.mk
+++ b/makefile_conf/chain/bttc.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "BTT"
CHAIN_ID = 199
-APPNAME = "BTTC"
\ No newline at end of file
+APPNAME = "BTTC"
diff --git a/makefile_conf/chain/callisto.mk b/makefile_conf/chain/callisto.mk
index 1147dc9..5919f3f 100644
--- a/makefile_conf/chain/callisto.mk
+++ b/makefile_conf/chain/callisto.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/820'"
TICKER = "CLO"
CHAIN_ID = 820
-APPNAME = "Callisto"
\ No newline at end of file
+APPNAME = "Callisto"
diff --git a/makefile_conf/chain/conflux_espace.mk b/makefile_conf/chain/conflux_espace.mk
index 6efc293..8bc8c9a 100644
--- a/makefile_conf/chain/conflux_espace.mk
+++ b/makefile_conf/chain/conflux_espace.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "CFX"
CHAIN_ID = 1030
-APPNAME = "Conflux eSpace"
\ No newline at end of file
+APPNAME = "Conflux eSpace"
diff --git a/makefile_conf/chain/cube.mk b/makefile_conf/chain/cube.mk
index 7ac424c..614036d 100644
--- a/makefile_conf/chain/cube.mk
+++ b/makefile_conf/chain/cube.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "CUBE"
CHAIN_ID = 1818
-APPNAME = "Cube"
\ No newline at end of file
+APPNAME = "Cube"
diff --git a/makefile_conf/chain/dexon.mk b/makefile_conf/chain/dexon.mk
index c892e35..7cd36b7 100644
--- a/makefile_conf/chain/dexon.mk
+++ b/makefile_conf/chain/dexon.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/237'"
TICKER = "DXN"
CHAIN_ID = 237
-APPNAME = "DEXON"
\ No newline at end of file
+APPNAME = "DEXON"
diff --git a/makefile_conf/chain/ellaism.mk b/makefile_conf/chain/ellaism.mk
index 1bd5589..27df5db 100644
--- a/makefile_conf/chain/ellaism.mk
+++ b/makefile_conf/chain/ellaism.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/163'"
TICKER = "ELLA"
CHAIN_ID = 64
-APPNAME = "Ellaism"
\ No newline at end of file
+APPNAME = "Ellaism"
diff --git a/makefile_conf/chain/ether1.mk b/makefile_conf/chain/ether1.mk
index 9efc015..1885586 100644
--- a/makefile_conf/chain/ether1.mk
+++ b/makefile_conf/chain/ether1.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/1313114'"
TICKER = "ETHO"
CHAIN_ID = 1313114
-APPNAME = "Ether-1"
\ No newline at end of file
+APPNAME = "Ether-1"
diff --git a/makefile_conf/chain/ethereum_classic.mk b/makefile_conf/chain/ethereum_classic.mk
index ac44b6a..5cc1760 100644
--- a/makefile_conf/chain/ethereum_classic.mk
+++ b/makefile_conf/chain/ethereum_classic.mk
@@ -2,4 +2,4 @@
APP_LOAD_PARAMS += --path "44'/61'" --path "44'/60'"
TICKER = "ETC"
CHAIN_ID = 61
-APPNAME = "Ethereum Classic"
\ No newline at end of file
+APPNAME = "Ethereum Classic"
diff --git a/makefile_conf/chain/ethergem.mk b/makefile_conf/chain/ethergem.mk
index 6c81976..09d3855 100644
--- a/makefile_conf/chain/ethergem.mk
+++ b/makefile_conf/chain/ethergem.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/1987'"
TICKER = "EGEM"
CHAIN_ID = 1987
-APPNAME = "EtherGem"
\ No newline at end of file
+APPNAME = "EtherGem"
diff --git a/makefile_conf/chain/ethersocial.mk b/makefile_conf/chain/ethersocial.mk
index bbf512c..95e153c 100644
--- a/makefile_conf/chain/ethersocial.mk
+++ b/makefile_conf/chain/ethersocial.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/31102'"
TICKER = "ESN"
CHAIN_ID = 31102
-APPNAME = "Ethersocial"
\ No newline at end of file
+APPNAME = "Ethersocial"
diff --git a/makefile_conf/chain/expanse.mk b/makefile_conf/chain/expanse.mk
index f2ee995..737ec43 100644
--- a/makefile_conf/chain/expanse.mk
+++ b/makefile_conf/chain/expanse.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/40'"
TICKER = "EXP"
CHAIN_ID = 2
-APPNAME = "Expanse"
\ No newline at end of file
+APPNAME = "Expanse"
diff --git a/makefile_conf/chain/flare.mk b/makefile_conf/chain/flare.mk
index 36339ee..e8ecf3b 100644
--- a/makefile_conf/chain/flare.mk
+++ b/makefile_conf/chain/flare.mk
@@ -6,4 +6,4 @@ CHAIN_ID = 14
APP_LOAD_PARAMS += --tlvraw 9F:01
DEFINES += HAVE_PENDING_REVIEW_SCREEN
-APPNAME = "Flare"
\ No newline at end of file
+APPNAME = "Flare"
diff --git a/makefile_conf/chain/flare_coston.mk b/makefile_conf/chain/flare_coston.mk
index 0d6bddf..f8f5ed2 100644
--- a/makefile_conf/chain/flare_coston.mk
+++ b/makefile_conf/chain/flare_coston.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
TICKER = "FLR"
CHAIN_ID = 16
-APPNAME = "Flare Coston"
\ No newline at end of file
+APPNAME = "Flare Coston"
diff --git a/makefile_conf/chain/gochain.mk b/makefile_conf/chain/gochain.mk
index 180b2fd..b24e64e 100644
--- a/makefile_conf/chain/gochain.mk
+++ b/makefile_conf/chain/gochain.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/6060'"
TICKER = "GO"
CHAIN_ID = 60
-APPNAME = "GoChain"
\ No newline at end of file
+APPNAME = "GoChain"
diff --git a/makefile_conf/chain/hpb.mk b/makefile_conf/chain/hpb.mk
index 60fb3c1..03fc005 100644
--- a/makefile_conf/chain/hpb.mk
+++ b/makefile_conf/chain/hpb.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/269'"
TICKER = "HPB"
CHAIN_ID = 269
-APPNAME = "HPB"
\ No newline at end of file
+APPNAME = "HPB"
diff --git a/makefile_conf/chain/kardiachain.mk b/makefile_conf/chain/kardiachain.mk
index cc76d38..8ee40be 100644
--- a/makefile_conf/chain/kardiachain.mk
+++ b/makefile_conf/chain/kardiachain.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "KAI"
CHAIN_ID = 24
-APPNAME = "KardiaChain"
\ No newline at end of file
+APPNAME = "KardiaChain"
diff --git a/makefile_conf/chain/meter.mk b/makefile_conf/chain/meter.mk
index 2a74120..cb4554b 100644
--- a/makefile_conf/chain/meter.mk
+++ b/makefile_conf/chain/meter.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "MTR"
CHAIN_ID = 82
-APPNAME = "Meter"
\ No newline at end of file
+APPNAME = "Meter"
diff --git a/makefile_conf/chain/mix.mk b/makefile_conf/chain/mix.mk
index c180cc9..6d96ce7 100644
--- a/makefile_conf/chain/mix.mk
+++ b/makefile_conf/chain/mix.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/76'"
TICKER = "MIX"
CHAIN_ID = 76
-APPNAME = "Mix"
\ No newline at end of file
+APPNAME = "Mix"
diff --git a/makefile_conf/chain/moonbeam.mk b/makefile_conf/chain/moonbeam.mk
index 5822f8f..963ee63 100644
--- a/makefile_conf/chain/moonbeam.mk
+++ b/makefile_conf/chain/moonbeam.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" --path "44'/1284'"
TICKER = "GLMR"
CHAIN_ID = 1284
-APPNAME = "Moonbeam"
\ No newline at end of file
+APPNAME = "Moonbeam"
diff --git a/makefile_conf/chain/moonriver.mk b/makefile_conf/chain/moonriver.mk
index 4413715..5c9391e 100644
--- a/makefile_conf/chain/moonriver.mk
+++ b/makefile_conf/chain/moonriver.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" --path "44'/1285'"
TICKER = "MOVR"
CHAIN_ID = 1285
-APPNAME = "Moonriver"
\ No newline at end of file
+APPNAME = "Moonriver"
diff --git a/makefile_conf/chain/musicoin.mk b/makefile_conf/chain/musicoin.mk
index 188bebb..0c530d7 100644
--- a/makefile_conf/chain/musicoin.mk
+++ b/makefile_conf/chain/musicoin.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/184'"
TICKER = "MUSIC"
CHAIN_ID = 7762959
-APPNAME = "Musicoin"
\ No newline at end of file
+APPNAME = "Musicoin"
diff --git a/makefile_conf/chain/okc.mk b/makefile_conf/chain/okc.mk
index 6ed8042..9fdd4aa 100644
--- a/makefile_conf/chain/okc.mk
+++ b/makefile_conf/chain/okc.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "OKT"
CHAIN_ID = 66
-APPNAME = "OKXChain"
\ No newline at end of file
+APPNAME = "OKXChain"
diff --git a/makefile_conf/chain/pirl.mk b/makefile_conf/chain/pirl.mk
index 3f30261..fec941e 100644
--- a/makefile_conf/chain/pirl.mk
+++ b/makefile_conf/chain/pirl.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/164'"
TICKER = "PIRL"
CHAIN_ID = 3125659152
-APPNAME = "Pirl"
\ No newline at end of file
+APPNAME = "Pirl"
diff --git a/makefile_conf/chain/poa.mk b/makefile_conf/chain/poa.mk
index c415c26..dd9f32e 100644
--- a/makefile_conf/chain/poa.mk
+++ b/makefile_conf/chain/poa.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "POA"
CHAIN_ID = 99
-APPNAME = "POA"
\ No newline at end of file
+APPNAME = "POA"
diff --git a/makefile_conf/chain/polygon.mk b/makefile_conf/chain/polygon.mk
index 9bdf2dc..0348401 100644
--- a/makefile_conf/chain/polygon.mk
+++ b/makefile_conf/chain/polygon.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "MATIC"
CHAIN_ID = 137
-APPNAME = "Polygon"
\ No newline at end of file
+APPNAME = "Polygon"
diff --git a/makefile_conf/chain/reosc.mk b/makefile_conf/chain/reosc.mk
index 9f9cedf..662e8a2 100644
--- a/makefile_conf/chain/reosc.mk
+++ b/makefile_conf/chain/reosc.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/2894'"
TICKER = "REOSC"
CHAIN_ID = 2894
-APPNAME = "REOSC"
\ No newline at end of file
+APPNAME = "REOSC"
diff --git a/makefile_conf/chain/rsk.mk b/makefile_conf/chain/rsk.mk
index dad8f56..bdbef87 100644
--- a/makefile_conf/chain/rsk.mk
+++ b/makefile_conf/chain/rsk.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/137'" --path "44'/00'"
TICKER = "RBTC"
CHAIN_ID = 30
-APPNAME = "RSK"
\ No newline at end of file
+APPNAME = "RSK"
diff --git a/makefile_conf/chain/rsk_testnet.mk b/makefile_conf/chain/rsk_testnet.mk
index 2142f7c..8caa3a7 100644
--- a/makefile_conf/chain/rsk_testnet.mk
+++ b/makefile_conf/chain/rsk_testnet.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/37310'"
TICKER = "RBTC"
CHAIN_ID = 31
-APPNAME = "RSK Test"
\ No newline at end of file
+APPNAME = "RSK Test"
diff --git a/makefile_conf/chain/shyft.mk b/makefile_conf/chain/shyft.mk
index b578933..71ead2b 100644
--- a/makefile_conf/chain/shyft.mk
+++ b/makefile_conf/chain/shyft.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "SHFT"
CHAIN_ID = 7341
-APPNAME = "Shyft"
\ No newline at end of file
+APPNAME = "Shyft"
diff --git a/makefile_conf/chain/songbird.mk b/makefile_conf/chain/songbird.mk
index bc11a41..4c767ee 100644
--- a/makefile_conf/chain/songbird.mk
+++ b/makefile_conf/chain/songbird.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
TICKER = "SGB"
CHAIN_ID = 19
-APPNAME = "Songbird"
\ No newline at end of file
+APPNAME = "Songbird"
diff --git a/makefile_conf/chain/tecracoin.mk b/makefile_conf/chain/tecracoin.mk
index eabc826..87a94ff 100644
--- a/makefile_conf/chain/tecracoin.mk
+++ b/makefile_conf/chain/tecracoin.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
TICKER = "TCR"
CHAIN_ID = 20531812
-APPNAME = "TecraCoin"
\ No newline at end of file
+APPNAME = "TecraCoin"
diff --git a/makefile_conf/chain/tecratestnet.mk b/makefile_conf/chain/tecratestnet.mk
index d97ab81..1be7c06 100644
--- a/makefile_conf/chain/tecratestnet.mk
+++ b/makefile_conf/chain/tecratestnet.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
TICKER = "TCR"
CHAIN_ID = 20531811
-APPNAME = "TecraTestnet"
\ No newline at end of file
+APPNAME = "TecraTestnet"
diff --git a/makefile_conf/chain/thundercore.mk b/makefile_conf/chain/thundercore.mk
index a7a4ddd..ea63c1a 100644
--- a/makefile_conf/chain/thundercore.mk
+++ b/makefile_conf/chain/thundercore.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/1001'"
TICKER = "TT"
CHAIN_ID = 108
-APPNAME = "ThunderCore"
\ No newline at end of file
+APPNAME = "ThunderCore"
diff --git a/makefile_conf/chain/tomochain.mk b/makefile_conf/chain/tomochain.mk
index 9538308..19e2f4b 100644
--- a/makefile_conf/chain/tomochain.mk
+++ b/makefile_conf/chain/tomochain.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/889'"
TICKER = "TOMO"
CHAIN_ID = 88
-APPNAME = "TomoChain"
\ No newline at end of file
+APPNAME = "TomoChain"
diff --git a/makefile_conf/chain/ubiq.mk b/makefile_conf/chain/ubiq.mk
index 62a4ba1..840d304 100644
--- a/makefile_conf/chain/ubiq.mk
+++ b/makefile_conf/chain/ubiq.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/108'"
TICKER = "UBQ"
CHAIN_ID = 8
-APPNAME = "Ubiq"
\ No newline at end of file
+APPNAME = "Ubiq"
diff --git a/makefile_conf/chain/volta.mk b/makefile_conf/chain/volta.mk
index 28f7c56..9230cbc 100644
--- a/makefile_conf/chain/volta.mk
+++ b/makefile_conf/chain/volta.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/73799'" --path "44'/60'"
TICKER = "VOLTA"
CHAIN_ID = 73799
-APPNAME = "Volta"
\ No newline at end of file
+APPNAME = "Volta"
diff --git a/makefile_conf/chain/webchain.mk b/makefile_conf/chain/webchain.mk
index 3a7da24..f2bb364 100644
--- a/makefile_conf/chain/webchain.mk
+++ b/makefile_conf/chain/webchain.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/227'"
TICKER = "WEB"
CHAIN_ID = 24484
-APPNAME = "Webchain"
\ No newline at end of file
+APPNAME = "Webchain"
diff --git a/makefile_conf/chain/wethio.mk b/makefile_conf/chain/wethio.mk
index fc491df..11b29d7 100644
--- a/makefile_conf/chain/wethio.mk
+++ b/makefile_conf/chain/wethio.mk
@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/77777'"
TICKER = "ZYN"
CHAIN_ID = 78
-APPNAME = "Wethio"
\ No newline at end of file
+APPNAME = "Wethio"
diff --git a/src/apdu_constants.h b/src/apdu_constants.h
index 07e41a3..4b628bd 100644
--- a/src/apdu_constants.h
+++ b/src/apdu_constants.h
@@ -44,6 +44,7 @@
#define APDU_RESPONSE_INVALID_P1_P2 0x6b00
#define APDU_RESPONSE_CONDITION_NOT_SATISFIED 0x6985
#define APDU_RESPONSE_REF_DATA_NOT_FOUND 0x6a88
+#define APDU_RESPONSE_UNKNOWN 0x6f00
enum { OFFSET_CLA = 0, OFFSET_INS, OFFSET_P1, OFFSET_P2, OFFSET_LC, OFFSET_CDATA };
diff --git a/src/ethUstream.c b/src/ethUstream.c
index 3273c65..3737dc2 100644
--- a/src/ethUstream.c
+++ b/src/ethUstream.c
@@ -36,7 +36,7 @@ void initTx(txContext_t *context,
context->customProcessor = customProcessor;
context->extra = extra;
context->currentField = RLP_NONE + 1;
- cx_keccak_init(context->sha3, 256);
+ CX_ASSERT(cx_keccak_init_no_throw(context->sha3, 256));
}
uint8_t readTxByte(txContext_t *context) {
@@ -52,7 +52,7 @@ uint8_t readTxByte(txContext_t *context) {
context->currentFieldPos++;
}
if (!(context->processingField && context->fieldSingleByte)) {
- cx_hash((cx_hash_t *) context->sha3, 0, &data, 1, NULL, 0);
+ CX_ASSERT(cx_hash_no_throw((cx_hash_t *) context->sha3, 0, &data, 1, NULL, 0));
}
return data;
}
@@ -66,7 +66,8 @@ void copyTxData(txContext_t *context, uint8_t *out, uint32_t length) {
memmove(out, context->workBuffer, length);
}
if (!(context->processingField && context->fieldSingleByte)) {
- cx_hash((cx_hash_t *) context->sha3, 0, context->workBuffer, length, NULL, 0);
+ CX_ASSERT(
+ cx_hash_no_throw((cx_hash_t *) context->sha3, 0, context->workBuffer, length, NULL, 0));
}
context->workBuffer += length;
context->commandLength -= length;
@@ -517,7 +518,7 @@ static parserStatus_e processTxInternal(txContext_t *context) {
PRINTF("parsing is done\n");
return USTREAM_FINISHED;
}
- // Old style transaction (pre EIP-155). Transations could just skip `v,r,s` so we needed to
+ // Old style transaction (pre EIP-155). Transactions could just skip `v,r,s` so we needed to
// cut parsing here. commandLength == 0 could happen in two cases :
// 1. We are in an old style transaction : just return `USTREAM_FINISHED`.
// 2. We are at the end of an APDU in a multi-apdu process. This would make us return
diff --git a/src/handle_check_address.c b/src/handle_check_address.c
index 45c8586..fd0d79e 100644
--- a/src/handle_check_address.c
+++ b/src/handle_check_address.c
@@ -1,7 +1,9 @@
#include "handle_check_address.h"
+#include "apdu_constants.h"
#include "os.h"
#include "shared_context.h"
#include "string.h"
+#include "lib_standard_app/crypto_helpers.h"
#define ZERO(x) explicit_bzero(&x, sizeof(x))
@@ -17,18 +19,9 @@ void handle_check_address(check_address_parameters_t* params, chain_config_t* ch
const uint8_t* bip32_path_ptr = params->address_parameters;
uint8_t bip32PathLength = *(bip32_path_ptr++);
- cx_sha3_t local_sha3;
-
- // Common memory is used for locals that are not used concurrently
- union group1 {
- uint32_t bip32Path[MAX_BIP32_PATH];
- cx_ecfp_private_key_t privateKey;
- char address[51];
- } locals_union1;
- union group2 {
- uint8_t privateKeyData[64];
- cx_ecfp_public_key_t publicKey;
- } locals_union2;
+ uint32_t bip32Path[MAX_BIP32_PATH];
+ char address[51];
+ uint8_t raw_pubkey[65];
if ((bip32PathLength < 0x01) || (bip32PathLength > MAX_BIP32_PATH) ||
(bip32PathLength * 4 != params->address_parameters_length - 1)) {
@@ -36,58 +29,30 @@ void handle_check_address(check_address_parameters_t* params, chain_config_t* ch
return;
}
for (uint8_t i = 0; i < bip32PathLength; i++) {
- locals_union1.bip32Path[i] = U4BE(bip32_path_ptr, 0);
+ bip32Path[i] = U4BE(bip32_path_ptr, 0);
bip32_path_ptr += 4;
}
- if (os_derive_bip32_no_throw(CX_CURVE_256K1,
- locals_union1.bip32Path,
- bip32PathLength,
- locals_union2.privateKeyData,
- NULL) != CX_OK) {
- ZERO(locals_union1);
- ZERO(locals_union2);
- return;
+
+ if (bip32_derive_get_pubkey_256(CX_CURVE_256K1,
+ bip32Path,
+ bip32PathLength,
+ raw_pubkey,
+ NULL,
+ CX_SHA512) != CX_OK) {
+ THROW(APDU_RESPONSE_UNKNOWN);
}
- ZERO(locals_union1);
- if (cx_ecfp_init_private_key_no_throw(CX_CURVE_256K1,
- locals_union2.privateKeyData,
- 32,
- &locals_union1.privateKey) != CX_OK) {
- ZERO(locals_union1);
- ZERO(locals_union2);
- return;
- }
- ZERO(locals_union2);
- if (cx_ecfp_generate_pair_no_throw(CX_CURVE_256K1,
- &locals_union2.publicKey,
- &locals_union1.privateKey,
- 1) != CX_OK) {
- ZERO(locals_union1);
- ZERO(locals_union2);
- return;
- }
- ZERO(locals_union1);
- if (!getEthAddressStringFromKey(&locals_union2.publicKey,
- locals_union1.address,
- &local_sha3,
- chain_config->chainId)) {
- ZERO(locals_union1);
- ZERO(locals_union2);
- return;
- }
- ZERO(locals_union2);
+ getEthAddressStringFromRawKey((const uint8_t*) raw_pubkey, address, chain_config->chainId);
uint8_t offset_0x = 0;
if (memcmp(params->address_to_check, "0x", 2) == 0) {
offset_0x = 2;
}
- if (strcmp(locals_union1.address, params->address_to_check + offset_0x) != 0) {
+ if (strcmp(address, params->address_to_check + offset_0x) != 0) {
PRINTF("Addresses don't match\n");
} else {
PRINTF("Addresses match\n");
params->result = 1;
}
- ZERO(locals_union1);
}
diff --git a/src/handle_swap_sign_transaction.c b/src/handle_swap_sign_transaction.c
index fc7167a..22b3ac1 100644
--- a/src/handle_swap_sign_transaction.c
+++ b/src/handle_swap_sign_transaction.c
@@ -113,4 +113,6 @@ void __attribute__((noreturn)) handle_swap_sign_transaction(chain_config_t* conf
BLE_power(1, NULL);
#endif // HAVE_BLE
app_main();
+ // Failsafe
+ os_sched_exit(-1);
}
diff --git a/src/hash_bytes.c b/src/hash_bytes.c
index e6b6437..4d3eab4 100644
--- a/src/hash_bytes.c
+++ b/src/hash_bytes.c
@@ -8,7 +8,7 @@
* @param[in] hash_ctx pointer to the hashing context
*/
void hash_nbytes(const uint8_t *bytes_ptr, size_t n, cx_hash_t *hash_ctx) {
- cx_hash(hash_ctx, 0, bytes_ptr, n, NULL, 0);
+ CX_ASSERT(cx_hash_no_throw(hash_ctx, 0, bytes_ptr, n, NULL, 0));
}
/**
diff --git a/src/main.c b/src/main.c
index 4f5ce6d..24d2f63 100644
--- a/src/main.c
+++ b/src/main.c
@@ -31,6 +31,7 @@
#include "commands_712.h"
#include "challenge.h"
#include "domain_name.h"
+#include "lib_standard_app/crypto_helpers.h"
unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];
@@ -88,28 +89,6 @@ void io_seproxyhal_send_status(uint32_t sw) {
io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, 2);
}
-void format_signature_out(const uint8_t *signature) {
- memset(G_io_apdu_buffer + 1, 0x00, 64);
- uint8_t offset = 1;
- uint8_t xoffset = 4; // point to r value
- // copy r
- uint8_t xlength = signature[xoffset - 1];
- if (xlength == 33) {
- xlength = 32;
- xoffset++;
- }
- memmove(G_io_apdu_buffer + offset + 32 - xlength, signature + xoffset, xlength);
- offset += 32;
- xoffset += xlength + 2; // move over rvalue and TagLEn
- // copy s value
- xlength = signature[xoffset - 1];
- if (xlength == 33) {
- xlength = 32;
- xoffset++;
- }
- memmove(G_io_apdu_buffer + offset + 32 - xlength, signature + xoffset, xlength);
-}
-
unsigned short io_exchange_al(unsigned char channel, unsigned short tx_len) {
switch (channel & ~(IO_FLAGS)) {
case CHANNEL_KEYBOARD:
@@ -162,11 +141,17 @@ void handleGetWalletId(volatile unsigned int *tx) {
unsigned char t[64];
cx_ecfp_256_private_key_t priv;
cx_ecfp_256_public_key_t pub;
- // seed => priv key
- os_perso_derive_node_bip32(CX_CURVE_256K1, U_os_perso_seed_cookie, 2, t, NULL);
+ // seed => pubkey
+ CX_ASSERT(bip32_derive_with_seed_init_privkey_256(HDW_NORMAL,
+ CX_CURVE_256K1,
+ U_os_perso_seed_cookie,
+ 2,
+ &priv,
+ NULL,
+ NULL,
+ 0));
// priv key => pubkey
- cx_ecdsa_init_private_key(CX_CURVE_256K1, t, 32, &priv);
- cx_ecfp_generate_pair(CX_CURVE_256K1, &pub, &priv, 1);
+ CX_ASSERT(cx_ecfp_generate_pair_no_throw(CX_CURVE_256K1, &pub, &priv, 1));
// pubkey -> sha512
cx_hash_sha512(pub.W, sizeof(pub.W), t, sizeof(t));
// ! cookie !
@@ -427,7 +412,7 @@ void handleApdu(unsigned int *flags, unsigned int *tx) {
// If we are in swap mode and have validated a TX, we send it and immediately quit
if (quit_now) {
if (io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, *tx) == 0) {
- // In case of success, the apdu is sent immediatly and eth exits
+ // In case of success, the apdu is sent immediately and eth exits
// Reaching this code means we encountered an error
finalize_exchange_sign_transaction(false);
} else {
@@ -508,9 +493,6 @@ void app_main(void) {
}
END_TRY;
}
-
- // return_to_dashboard:
- return;
}
// override point, but nothing more to do
diff --git a/src/network.c b/src/network.c
index 1563c32..f16832f 100644
--- a/src/network.c
+++ b/src/network.c
@@ -13,7 +13,7 @@ typedef struct network_info_s {
static const char *unknown_ticker = "???";
-// Mappping of chain ids to networks.
+// Mapping of chain ids to networks.
static const network_info_t NETWORK_MAPPING[] = {
{.chain_id = 1, .name = "Ethereum", .ticker = "ETH"},
{.chain_id = 3, .name = "Ropsten", .ticker = "ETH"},
@@ -153,7 +153,7 @@ const char *get_displayable_ticker(const uint64_t *chain_id, const chain_config_
}
/**
- * Checks wether the app can support the given chain ID
+ * Checks whether the app can support the given chain ID
*
* - If the given chain ID is the same as the app's one
* - If both chain IDs are present in the array of Ethereum-compatible networks
diff --git a/src/plugins.c b/src/plugins.c
index 42c17a9..0256979 100644
--- a/src/plugins.c
+++ b/src/plugins.c
@@ -37,4 +37,4 @@ void plugin_ui_get_item(void) {
sizeof(strings.common.fullAddress),
strings.common.fullAmount,
sizeof(strings.common.fullAmount));
-}
\ No newline at end of file
+}
diff --git a/src/plugins.h b/src/plugins.h
index 1ccc123..df406c0 100644
--- a/src/plugins.h
+++ b/src/plugins.h
@@ -8,4 +8,4 @@ void plugin_ui_get_item_internal(uint8_t *title_buffer,
uint8_t *msg_buffer,
size_t msg_buffer_size);
-#endif // _PLUGIN_H_
\ No newline at end of file
+#endif // _PLUGIN_H_
diff --git a/src/swap_utils.c b/src/swap_utils.c
index 8a5db86..7774b75 100644
--- a/src/swap_utils.c
+++ b/src/swap_utils.c
@@ -53,7 +53,6 @@ bool parse_swap_config(const uint8_t *config,
if ((config_len - offset) >= sizeof(*chain_id)) {
PRINTF("Chain ID from the swap subconfig = 0x%.*h\n", sizeof(*chain_id), &config[offset]);
*chain_id = u64_from_BE(config + offset, sizeof(*chain_id));
- offset += sizeof(*chain_id);
}
return true;
}
diff --git a/src/ui_callbacks.h b/src/ui_callbacks.h
index 3063400..da70478 100644
--- a/src/ui_callbacks.h
+++ b/src/ui_callbacks.h
@@ -25,7 +25,6 @@ unsigned int io_seproxyhal_touch_privacy_cancel(const bagl_element_t *e);
void ui_warning_contract_data(void);
void io_seproxyhal_send_status(uint32_t sw);
-void format_signature_out(const uint8_t *signature);
void finalizeParsing(bool direct);
extraInfo_t *getKnownToken(uint8_t *contractAddress);
diff --git a/src/uint256.c b/src/uint256.c
index 8829c90..fb6d236 100644
--- a/src/uint256.c
+++ b/src/uint256.c
@@ -175,7 +175,7 @@ void mul256(const uint256_t *const number1,
write_u64_be(num1 + i * sizeof(uint64_t), number1->elements[i / 2].elements[i % 2]);
write_u64_be(num2 + i * sizeof(uint64_t), number2->elements[i / 2].elements[i % 2]);
}
- cx_math_mult(result, num1, num2, sizeof(num1));
+ CX_ASSERT(cx_math_mult_no_throw(result, num1, num2, sizeof(num1)));
for (uint8_t i = 0; i < 4; i++) {
read_u64_be(result + 32 + i * sizeof(uint64_t), &target->elements[i / 2].elements[i % 2]);
}
diff --git a/src_bagl/ui_flow_performPrivacyOperation.c b/src_bagl/ui_flow_performPrivacyOperation.c
index 5c181ef..8c870c0 100644
--- a/src_bagl/ui_flow_performPrivacyOperation.c
+++ b/src_bagl/ui_flow_performPrivacyOperation.c
@@ -3,7 +3,7 @@
// clang-format off
UX_STEP_NOCB(
- ux_display_privacy_public_key_flow_1_step,
+ ux_display_privacy_public_key_flow_1_step,
pnn,
{
&C_icon_eye,
@@ -11,21 +11,21 @@ UX_STEP_NOCB(
"privacy key",
});
UX_STEP_NOCB(
- ux_display_privacy_public_key_flow_2_step,
+ ux_display_privacy_public_key_flow_2_step,
bnnn_paging,
{
.title = "Address",
.text = strings.common.fullAddress,
});
UX_STEP_NOCB(
- ux_display_privacy_public_key_flow_3_step,
+ ux_display_privacy_public_key_flow_3_step,
bnnn_paging,
{
.title = "Key",
.text = strings.common.fullAmount,
});
UX_STEP_CB(
- ux_display_privacy_public_key_flow_4_step,
+ ux_display_privacy_public_key_flow_4_step,
pb,
io_seproxyhal_touch_privacy_ok(NULL),
{
@@ -33,7 +33,7 @@ UX_STEP_CB(
"Approve",
});
UX_STEP_CB(
- ux_display_privacy_public_key_flow_5_step,
+ ux_display_privacy_public_key_flow_5_step,
pb,
io_seproxyhal_touch_privacy_cancel(NULL),
{
diff --git a/src_bagl/ui_plugin.c b/src_bagl/ui_plugin.c
index c3743fa..e493bd9 100644
--- a/src_bagl/ui_plugin.c
+++ b/src_bagl/ui_plugin.c
@@ -46,4 +46,4 @@ void display_next_plugin_item(bool entering) {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src_common/common_utils.c b/src_common/common_utils.c
index 84a424e..240f2f2 100644
--- a/src_common/common_utils.c
+++ b/src_common/common_utils.c
@@ -20,6 +20,8 @@
#include "asset_info.h"
#include "common_utils.h"
+#include "lcx_ecfp.h"
+#include "lcx_sha3.h"
void array_hexstr(char *strbuf, const void *bin, unsigned int len) {
while (len--) {
@@ -214,55 +216,23 @@ bool amountToString(const uint8_t *amount,
return true;
}
-bool getEthAddressFromKey(cx_ecfp_public_key_t *publicKey, uint8_t *out, cx_sha3_t *sha3Context) {
- uint8_t hashAddress[INT256_LENGTH];
-
- if (cx_keccak_init_no_throw(sha3Context, 256) != CX_OK) {
- return false;
- }
-
- if (cx_hash_no_throw((cx_hash_t *) sha3Context,
- CX_LAST,
- publicKey->W + 1,
- 64,
- hashAddress,
- 32) != CX_OK) {
- return false;
- }
-
- memmove(out, hashAddress + 12, 20);
- return true;
+void getEthAddressFromRawKey(const uint8_t raw_pubkey[static 65],
+ uint8_t out[static ADDRESS_LENGTH]) {
+ uint8_t hashAddress[CX_KECCAK_256_SIZE];
+ CX_ASSERT(cx_keccak_256_hash(raw_pubkey + 1, 64, hashAddress));
+ memmove(out, hashAddress + 12, ADDRESS_LENGTH);
}
-bool getEthAddressStringFromKey(cx_ecfp_public_key_t *publicKey,
- char *out,
- cx_sha3_t *sha3Context,
- uint64_t chainId) {
- uint8_t hashAddress[INT256_LENGTH];
-
- if (cx_keccak_init_no_throw(sha3Context, 256) != CX_OK) {
- return false;
- }
-
- if (cx_hash_no_throw((cx_hash_t *) sha3Context,
- CX_LAST,
- publicKey->W + 1,
- 64,
- hashAddress,
- 32) != CX_OK) {
- return false;
- }
-
- if (!getEthAddressStringFromBinary(hashAddress + 12, out, sha3Context, chainId)) {
- return false;
- }
-
- return true;
+void getEthAddressStringFromRawKey(const uint8_t raw_pubkey[static 65],
+ char out[static ADDRESS_LENGTH * 2],
+ uint64_t chainId) {
+ uint8_t hashAddress[CX_KECCAK_256_SIZE];
+ CX_ASSERT(cx_keccak_256_hash(raw_pubkey + 1, 64, hashAddress));
+ getEthAddressStringFromBinary(hashAddress + 12, out, chainId);
}
bool getEthAddressStringFromBinary(uint8_t *address,
- char *out,
- cx_sha3_t *sha3Context,
+ char out[static ADDRESS_LENGTH * 2],
uint64_t chainId) {
// save some precious stack space
union locals_union {
@@ -292,18 +262,10 @@ bool getEthAddressStringFromBinary(uint8_t *address,
locals_union.tmp[offset + 2 * i] = HEXDIGITS[(digit >> 4) & 0x0f];
locals_union.tmp[offset + 2 * i + 1] = HEXDIGITS[digit & 0x0f];
}
- if (cx_keccak_init_no_throw(sha3Context, 256) != CX_OK) {
+ if (cx_keccak_256_hash(locals_union.tmp, offset + 40, locals_union.hashChecksum) != CX_OK) {
return false;
}
- if (cx_hash_no_throw((cx_hash_t *) sha3Context,
- CX_LAST,
- locals_union.tmp,
- offset + 40,
- locals_union.hashChecksum,
- 32) != CX_OK) {
- return false;
- }
for (i = 0; i < 40; i++) {
uint8_t digit = address[i / 2];
if ((i % 2) == 0) {
@@ -329,20 +291,15 @@ bool getEthAddressStringFromBinary(uint8_t *address,
/* Fills the `out` buffer with the lowercase string representation of the pubkey passed in as binary
format by `in`. (eg: uint8_t*:0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB ->
-char*:"0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB\0" )
-`sha3` context doesn't have have to be initialized prior to call.*/
-bool getEthDisplayableAddress(uint8_t *in,
- char *out,
- size_t out_len,
- cx_sha3_t *sha3,
- uint64_t chainId) {
+char*:"0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB\0" ).*/
+bool getEthDisplayableAddress(uint8_t *in, char *out, size_t out_len, uint64_t chainId) {
if (out_len < 43) {
strlcpy(out, "ERROR", out_len);
return false;
}
out[0] = '0';
out[1] = 'x';
- if (!getEthAddressStringFromBinary(in, out + 2, sha3, chainId)) {
+ if (!getEthAddressStringFromBinary(in, out + 2, chainId)) {
strlcpy(out, "ERROR", out_len);
return false;
}
diff --git a/src_common/common_utils.h b/src_common/common_utils.h
index fd198d9..2a7566f 100644
--- a/src_common/common_utils.h
+++ b/src_common/common_utils.h
@@ -56,23 +56,45 @@ bool adjustDecimals(const char *src,
size_t targetLength,
uint8_t decimals);
-bool getEthAddressFromKey(cx_ecfp_public_key_t *publicKey, uint8_t *out, cx_sha3_t *sha3Context);
+void getEthAddressFromRawKey(const uint8_t raw_pubkey[static 65],
+ uint8_t out[static ADDRESS_LENGTH]);
-bool getEthAddressStringFromKey(cx_ecfp_public_key_t *publicKey,
- char *out,
- cx_sha3_t *sha3Context,
- uint64_t chainId);
-
-bool getEthAddressStringFromBinary(uint8_t *address,
- char *out,
- cx_sha3_t *sha3Context,
+void getEthAddressStringFromRawKey(const uint8_t raw_pubkey[static 65],
+ char out[static ADDRESS_LENGTH * 2],
uint64_t chainId);
-bool getEthDisplayableAddress(uint8_t *in,
- char *out,
- size_t out_len,
- cx_sha3_t *sha3,
- uint64_t chainId);
+/**
+ * @deprecated
+ * See #getEthAddressFromRawKey
+ */
+DEPRECATED static inline bool getEthAddressFromKey(cx_ecfp_public_key_t *publicKey,
+ uint8_t *out,
+ cx_sha3_t *sha3Context) {
+ UNUSED(sha3Context);
+
+ getEthAddressFromRawKey(publicKey->W, out);
+ return true;
+}
+
+/**
+ * @deprecated
+ * See #getEthAddressFromRawKey
+ */
+DEPRECATED static inline bool getEthAddressStringFromKey(cx_ecfp_public_key_t *publicKey,
+ uint8_t *out,
+ cx_sha3_t *sha3Context,
+ uint64_t chainId) {
+ UNUSED(sha3Context);
+
+ getEthAddressStringFromRawKey(publicKey->W, (char *) out, chainId);
+ return true;
+}
+
+bool getEthAddressStringFromBinary(uint8_t *address,
+ char out[static ADDRESS_LENGTH * 2],
+ uint64_t chainId);
+
+bool getEthDisplayableAddress(uint8_t *in, char *out, size_t out_len, uint64_t chainId);
static __attribute__((no_instrument_function)) inline int allzeroes(const void *buf, size_t n) {
uint8_t *p = (uint8_t *) buf;
diff --git a/src_common/eth_plugin_interface.h b/src_common/eth_plugin_interface.h
index 9821836..6d872f5 100644
--- a/src_common/eth_plugin_interface.h
+++ b/src_common/eth_plugin_interface.h
@@ -90,7 +90,7 @@ typedef struct ethPluginSharedRO_s {
// Plugin-only memory allocated by the Ethereum application and used by the plugin.
#define PLUGIN_CONTEXT_SIZE (5 * INT256_LENGTH)
-// It is recommended to cast the raw uin8_t array to a structure meaningfull for your plugin
+// It is recommended to cast the raw uin8_t array to a structure meaningful for your plugin
// Helper to check that the actual plugin context structure is not bigger than the allocated memory
#define ASSERT_SIZEOF_PLUGIN_CONTEXT(s) \
_Static_assert(sizeof(s) <= PLUGIN_CONTEXT_SIZE, "Plugin context structure is too big.")
diff --git a/src_features/getEth2PublicKey/cmd_getEth2PublicKey.c b/src_features/getEth2PublicKey/cmd_getEth2PublicKey.c
index b1b38d5..8ba2bb9 100644
--- a/src_features/getEth2PublicKey/cmd_getEth2PublicKey.c
+++ b/src_features/getEth2PublicKey/cmd_getEth2PublicKey.c
@@ -13,27 +13,35 @@ static const uint8_t BLS12_381_FIELD_MODULUS[] = {
0x1e, 0xab, 0xff, 0xfe, 0xb1, 0x53, 0xff, 0xff, 0xb9, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xaa, 0xab};
void getEth2PublicKey(uint32_t *bip32Path, uint8_t bip32PathLength, uint8_t *out) {
- uint8_t privateKeyData[INT256_LENGTH];
+ uint8_t privateKeyData[64];
cx_ecfp_256_extended_private_key_t privateKey;
cx_ecfp_384_public_key_t publicKey;
uint8_t yFlag = 0;
uint8_t tmp[96];
+ int diff;
io_seproxyhal_io_heartbeat();
- os_perso_derive_eip2333(CX_CURVE_BLS12_381_G1, bip32Path, bip32PathLength, privateKeyData);
+ CX_ASSERT(os_derive_eip2333_no_throw(CX_CURVE_BLS12_381_G1,
+ bip32Path,
+ bip32PathLength,
+ privateKeyData));
io_seproxyhal_io_heartbeat();
memset(tmp, 0, 48);
memmove(tmp + 16, privateKeyData, 32);
- cx_ecfp_init_private_key(CX_CURVE_BLS12_381_G1, tmp, 48, (cx_ecfp_private_key_t *) &privateKey);
- cx_ecfp_generate_pair(CX_CURVE_BLS12_381_G1,
- (cx_ecfp_public_key_t *) &publicKey,
- (cx_ecfp_private_key_t *) &privateKey,
- 1);
+ CX_ASSERT(cx_ecfp_init_private_key_no_throw(CX_CURVE_BLS12_381_G1,
+ tmp,
+ 48,
+ (cx_ecfp_private_key_t *) &privateKey));
+ CX_ASSERT(cx_ecfp_generate_pair_no_throw(CX_CURVE_BLS12_381_G1,
+ (cx_ecfp_public_key_t *) &publicKey,
+ (cx_ecfp_private_key_t *) &privateKey,
+ 1));
explicit_bzero(tmp, 96);
explicit_bzero((void *) &privateKey, sizeof(cx_ecfp_256_extended_private_key_t));
tmp[47] = 2;
- cx_math_mult(tmp, publicKey.W + 1 + 48, tmp, 48);
- if (cx_math_cmp(tmp + 48, BLS12_381_FIELD_MODULUS, 48) > 0) {
+ CX_ASSERT(cx_math_mult_no_throw(tmp, publicKey.W + 1 + 48, tmp, 48));
+ CX_ASSERT(cx_math_cmp_no_throw(tmp + 48, BLS12_381_FIELD_MODULUS, 48, &diff));
+ if (diff > 0) {
yFlag = 0x20;
}
publicKey.W[1] &= 0x1f;
diff --git a/src_features/getPublicKey/cmd_getPublicKey.c b/src_features/getPublicKey/cmd_getPublicKey.c
index c30addc..dbc84bb 100644
--- a/src_features/getPublicKey/cmd_getPublicKey.c
+++ b/src_features/getPublicKey/cmd_getPublicKey.c
@@ -4,6 +4,7 @@
#include "feature_getPublicKey.h"
#include "common_ui.h"
#include "os_io_seproxyhal.h"
+#include "lib_standard_app/crypto_helpers.h"
void handleGetPublicKey(uint8_t p1,
uint8_t p2,
@@ -11,9 +12,7 @@ void handleGetPublicKey(uint8_t p1,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx) {
- uint8_t privateKeyData[INT256_LENGTH];
bip32_path_t bip32;
- cx_ecfp_private_key_t privateKey;
if (!G_called_from_swap) {
reset_app_context();
@@ -35,25 +34,18 @@ void handleGetPublicKey(uint8_t p1,
}
tmpCtx.publicKeyContext.getChaincode = (p2 == P2_CHAINCODE);
- io_seproxyhal_io_heartbeat();
- os_perso_derive_node_bip32(
- CX_CURVE_256K1,
- bip32.path,
- bip32.length,
- privateKeyData,
- (tmpCtx.publicKeyContext.getChaincode ? tmpCtx.publicKeyContext.chainCode : NULL));
- cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey);
- io_seproxyhal_io_heartbeat();
- cx_ecfp_generate_pair(CX_CURVE_256K1, &tmpCtx.publicKeyContext.publicKey, &privateKey, 1);
- explicit_bzero(&privateKey, sizeof(privateKey));
- explicit_bzero(privateKeyData, sizeof(privateKeyData));
- io_seproxyhal_io_heartbeat();
- if (!getEthAddressStringFromKey(&tmpCtx.publicKeyContext.publicKey,
- tmpCtx.publicKeyContext.address,
- &global_sha3,
- chainConfig->chainId)) {
- THROW(CX_INVALID_PARAMETER);
+ if (bip32_derive_get_pubkey_256(
+ CX_CURVE_256K1,
+ bip32.path,
+ bip32.length,
+ tmpCtx.publicKeyContext.publicKey.W,
+ (tmpCtx.publicKeyContext.getChaincode ? tmpCtx.publicKeyContext.chainCode : NULL),
+ CX_SHA512) != CX_OK) {
+ THROW(APDU_RESPONSE_UNKNOWN);
}
+ getEthAddressStringFromRawKey(tmpCtx.publicKeyContext.publicKey.W,
+ tmpCtx.publicKeyContext.address,
+ chainConfig->chainId);
uint64_t chain_id = chainConfig->chainId;
if (dataLength >= sizeof(chain_id)) {
diff --git a/src_features/performPrivacyOperation/cmd_performPrivacyOperation.c b/src_features/performPrivacyOperation/cmd_performPrivacyOperation.c
index c1f0369..c0120f0 100644
--- a/src_features/performPrivacyOperation/cmd_performPrivacyOperation.c
+++ b/src_features/performPrivacyOperation/cmd_performPrivacyOperation.c
@@ -28,7 +28,7 @@ void handlePerformPrivacyOperation(uint8_t p1,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx) {
- uint8_t privateKeyData[INT256_LENGTH];
+ uint8_t privateKeyData[64];
uint8_t privateKeyDataSwapped[INT256_LENGTH];
bip32_path_t bip32;
cx_err_t status = CX_OK;
@@ -53,27 +53,30 @@ void handlePerformPrivacyOperation(uint8_t p1,
cx_ecfp_private_key_t privateKey;
- os_perso_derive_node_bip32(
+ CX_ASSERT(os_derive_bip32_no_throw(
CX_CURVE_256K1,
bip32.path,
bip32.length,
privateKeyData,
- (tmpCtx.publicKeyContext.getChaincode ? tmpCtx.publicKeyContext.chainCode : NULL));
- cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey);
- cx_ecfp_generate_pair(CX_CURVE_256K1, &tmpCtx.publicKeyContext.publicKey, &privateKey, 1);
- if (!getEthAddressStringFromKey(&tmpCtx.publicKeyContext.publicKey,
- tmpCtx.publicKeyContext.address,
- &global_sha3,
- chainConfig->chainId)) {
- THROW(CX_INVALID_PARAMETER);
- }
+ (tmpCtx.publicKeyContext.getChaincode ? tmpCtx.publicKeyContext.chainCode : NULL)));
+ CX_ASSERT(cx_ecfp_init_private_key_no_throw(CX_CURVE_256K1, privateKeyData, 32, &privateKey));
+ CX_ASSERT(cx_ecfp_generate_pair_no_throw(CX_CURVE_256K1,
+ &tmpCtx.publicKeyContext.publicKey,
+ &privateKey,
+ 1));
+ getEthAddressStringFromRawKey((const uint8_t *) &tmpCtx.publicKeyContext.publicKey.W,
+ tmpCtx.publicKeyContext.address,
+ chainConfig->chainId);
if (p2 == P2_PUBLIC_ENCRYPTION_KEY) {
decodeScalar(privateKeyData, privateKeyDataSwapped);
- cx_ecfp_init_private_key(CX_CURVE_Curve25519, privateKeyDataSwapped, 32, &privateKey);
- cx_ecfp_generate_pair(CX_CURVE_Curve25519,
- &tmpCtx.publicKeyContext.publicKey,
- &privateKey,
- 1);
+ CX_ASSERT(cx_ecfp_init_private_key_no_throw(CX_CURVE_Curve25519,
+ privateKeyDataSwapped,
+ 32,
+ &privateKey));
+ CX_ASSERT(cx_ecfp_generate_pair_no_throw(CX_CURVE_Curve25519,
+ &tmpCtx.publicKeyContext.publicKey,
+ &privateKey,
+ 1));
explicit_bzero(privateKeyDataSwapped, sizeof(privateKeyDataSwapped));
} else {
memmove(tmpCtx.publicKeyContext.publicKey.W + 1, dataBuffer, 32);
diff --git a/src_features/provideDomainName/cmd_provide_domain_name.c b/src_features/provideDomainName/cmd_provide_domain_name.c
index 3ec5b39..cfcdc0d 100644
--- a/src_features/provideDomainName/cmd_provide_domain_name.c
+++ b/src_features/provideDomainName/cmd_provide_domain_name.c
@@ -365,36 +365,38 @@ static bool handle_address(const s_tlv_data *data,
static bool verify_signature(const s_sig_ctx *sig_ctx) {
uint8_t hash[INT256_LENGTH];
cx_ecfp_public_key_t verif_key;
+ cx_err_t error = CX_INTERNAL_ERROR;
- cx_hash((cx_hash_t *) &sig_ctx->hash_ctx, CX_LAST, NULL, 0, hash, INT256_LENGTH);
+ CX_CHECK(
+ cx_hash_no_throw((cx_hash_t *) &sig_ctx->hash_ctx, CX_LAST, NULL, 0, hash, INT256_LENGTH));
switch (sig_ctx->key_id) {
#ifdef HAVE_DOMAIN_NAME_TEST_KEY
case KEY_ID_TEST:
#else
case KEY_ID_PROD:
#endif
- cx_ecfp_init_public_key(CX_CURVE_256K1,
- DOMAIN_NAME_PUB_KEY,
- sizeof(DOMAIN_NAME_PUB_KEY),
- &verif_key);
+ CX_CHECK(cx_ecfp_init_public_key_no_throw(CX_CURVE_256K1,
+ DOMAIN_NAME_PUB_KEY,
+ sizeof(DOMAIN_NAME_PUB_KEY),
+ &verif_key));
break;
default:
PRINTF("Error: Unknown metadata key ID %u\n", sig_ctx->key_id);
return false;
}
- if (!cx_ecdsa_verify(&verif_key,
- CX_LAST,
- CX_SHA256,
- hash,
- sizeof(hash),
- sig_ctx->input_sig,
- sig_ctx->input_sig_size)) {
+ if (!cx_ecdsa_verify_no_throw(&verif_key,
+ hash,
+ sizeof(hash),
+ sig_ctx->input_sig,
+ sig_ctx->input_sig_size)) {
PRINTF("Domain name signature verification failed!\n");
#ifndef HAVE_BYPASS_SIGNATURES
return false;
#endif
}
return true;
+end:
+ return false;
}
/**
@@ -442,7 +444,7 @@ static bool check_found_tlv_tags(s_tlv_handler *handlers, int handler_count) {
// prevent missing or duplicated tags
for (int idx = 0; idx < handler_count; ++idx) {
if (handlers[idx].found != 1) {
- PRINTF("Found %u occurence(s) of tag 0x%x in TLV!\n",
+ PRINTF("Found %u occurrence(s) of tag 0x%x in TLV!\n",
handlers[idx].found,
handlers[idx].tag);
return false;
diff --git a/src_features/provideErc20TokenInformation/cmd_provideTokenInfo.c b/src_features/provideErc20TokenInformation/cmd_provideTokenInfo.c
index 00665ad..94bf4e2 100644
--- a/src_features/provideErc20TokenInformation/cmd_provideTokenInfo.c
+++ b/src_features/provideErc20TokenInformation/cmd_provideTokenInfo.c
@@ -168,18 +168,14 @@ void handleProvideErc20TokenInformation(uint8_t p1,
}
if (index < NUM_TOKENS_EXTRA) {
PRINTF("Descriptor whitelisted\n");
- } else {
- cx_ecfp_init_public_key(CX_CURVE_256K1,
- LEDGER_SIGNATURE_PUBLIC_KEY,
- sizeof(LEDGER_SIGNATURE_PUBLIC_KEY),
- &tokenKey);
- if (!cx_ecdsa_verify(&tokenKey,
- CX_LAST,
- CX_SHA256,
- hash,
- 32,
- workBuffer + offset,
- dataLength)) {
+ } else
+#endif
+ {
+ CX_ASSERT(cx_ecfp_init_public_key_no_throw(CX_CURVE_256K1,
+ LEDGER_SIGNATURE_PUBLIC_KEY,
+ sizeof(LEDGER_SIGNATURE_PUBLIC_KEY),
+ &tokenKey));
+ if (!cx_ecdsa_verify_no_throw(&tokenKey, hash, 32, workBuffer + offset, dataLength)) {
#ifndef HAVE_BYPASS_SIGNATURES
PRINTF("Invalid token signature\n");
THROW(0x6A80);
@@ -187,26 +183,6 @@ void handleProvideErc20TokenInformation(uint8_t p1,
}
}
-#else
-
- cx_ecfp_init_public_key(CX_CURVE_256K1,
- LEDGER_SIGNATURE_PUBLIC_KEY,
- sizeof(LEDGER_SIGNATURE_PUBLIC_KEY),
- &tokenKey);
- if (!cx_ecdsa_verify(&tokenKey,
- CX_LAST,
- CX_SHA256,
- hash,
- 32,
- workBuffer + offset,
- dataLength)) {
-#ifndef HAVE_BYPASS_SIGNATURES
- PRINTF("Invalid token signature\n");
- THROW(0x6A80);
-#endif
- }
-#endif
-
tmpCtx.transactionContext.tokenSet[tmpCtx.transactionContext.currentItemIndex] = 1;
THROW(0x9000);
}
diff --git a/src_features/provideNFTInformation/cmd_provideNFTInfo.c b/src_features/provideNFTInformation/cmd_provideNFTInfo.c
index e59c77b..a9685ce 100644
--- a/src_features/provideNFTInformation/cmd_provideNFTInfo.c
+++ b/src_features/provideNFTInformation/cmd_provideNFTInfo.c
@@ -69,7 +69,7 @@ void handleProvideNFTInformation(uint8_t p1,
PRINTF("Data too small for headers: expected at least %d, got %d\n",
HEADER_SIZE,
dataLength);
- THROW(0x6A80);
+ THROW(APDU_RESPONSE_INVALID_DATA);
}
uint8_t type = workBuffer[offset];
@@ -78,7 +78,7 @@ void handleProvideNFTInformation(uint8_t p1,
break;
default:
PRINTF("Unsupported type %d\n", type);
- THROW(0x6a80);
+ THROW(APDU_RESPONSE_INVALID_DATA);
break;
}
offset += TYPE_SIZE;
@@ -89,7 +89,7 @@ void handleProvideNFTInformation(uint8_t p1,
break;
default:
PRINTF("Unsupported version %d\n", version);
- THROW(0x6a80);
+ THROW(APDU_RESPONSE_INVALID_DATA);
break;
}
offset += VERSION_SIZE;
@@ -104,14 +104,14 @@ void handleProvideNFTInformation(uint8_t p1,
PRINTF("Data too small for payload: expected at least %d, got %d\n",
payloadSize,
dataLength);
- THROW(0x6A80);
+ THROW(APDU_RESPONSE_INVALID_DATA);
}
if (collectionNameLength > COLLECTION_NAME_MAX_LEN) {
PRINTF("CollectionName too big: expected max %d, got %d\n",
COLLECTION_NAME_MAX_LEN,
collectionNameLength);
- THROW(0x6A80);
+ THROW(APDU_RESPONSE_INVALID_DATA);
}
// Safe because we've checked the size before.
@@ -151,7 +151,7 @@ void handleProvideNFTInformation(uint8_t p1,
break;
default:
PRINTF("KeyID %d not supported\n", keyId);
- THROW(0x6A80);
+ THROW(APDU_RESPONSE_INVALID_DATA);
break;
}
PRINTF("RawKey: %.*H\n", rawKeyLen, rawKey);
@@ -159,20 +159,10 @@ void handleProvideNFTInformation(uint8_t p1,
uint8_t algorithmId = workBuffer[offset];
PRINTF("Algorithm: %d\n", algorithmId);
- cx_curve_t curve;
- verificationAlgo *verificationFn;
- cx_md_t hashId;
- switch (algorithmId) {
- case ALGORITHM_ID_1:
- curve = CX_CURVE_256K1;
- verificationFn = (verificationAlgo *) cx_ecdsa_verify;
- hashId = CX_SHA256;
- break;
- default:
- PRINTF("Incorrect algorithmId %d\n", algorithmId);
- THROW(0x6a80);
- break;
+ if (algorithmId != ALGORITHM_ID_1) {
+ PRINTF("Incorrect algorithmId %d\n", algorithmId);
+ THROW(APDU_RESPONSE_INVALID_DATA);
}
offset += ALGORITHM_ID_SIZE;
PRINTF("hashing: %.*H\n", payloadSize, workBuffer);
@@ -180,36 +170,34 @@ void handleProvideNFTInformation(uint8_t p1,
if (dataLength < payloadSize + SIGNATURE_LENGTH_SIZE) {
PRINTF("Data too short to hold signature length\n");
- THROW(0x6a80);
+ THROW(APDU_RESPONSE_INVALID_DATA);
}
uint8_t signatureLen = workBuffer[offset];
- PRINTF("Sigature len: %d\n", signatureLen);
+ PRINTF("Signature len: %d\n", signatureLen);
if (signatureLen < MIN_DER_SIG_SIZE || signatureLen > MAX_DER_SIG_SIZE) {
PRINTF("SignatureLen too big or too small. Must be between %d and %d, got %d\n",
MIN_DER_SIG_SIZE,
MAX_DER_SIG_SIZE,
signatureLen);
- THROW(0x6a80);
+ THROW(APDU_RESPONSE_INVALID_DATA);
}
offset += SIGNATURE_LENGTH_SIZE;
if (dataLength < payloadSize + SIGNATURE_LENGTH_SIZE + signatureLen) {
PRINTF("Signature could not fit in data\n");
- THROW(0x6a80);
+ THROW(APDU_RESPONSE_INVALID_DATA);
}
- cx_ecfp_init_public_key(curve, rawKey, rawKeyLen, &nftKey);
- if (!verificationFn(&nftKey,
- CX_LAST,
- hashId,
- hash,
- sizeof(hash),
- (uint8_t *) workBuffer + offset,
- signatureLen)) {
+ CX_ASSERT(cx_ecfp_init_public_key_no_throw(CX_CURVE_256K1, rawKey, rawKeyLen, &nftKey));
+ if (!cx_ecdsa_verify_no_throw(&nftKey,
+ hash,
+ sizeof(hash),
+ (uint8_t *) workBuffer + offset,
+ signatureLen)) {
#ifndef HAVE_BYPASS_SIGNATURES
PRINTF("Invalid NFT signature\n");
- THROW(0x6A80);
+ THROW(APDU_RESPONSE_INVALID_DATA);
#endif
}
diff --git a/src_features/setExternalPlugin/cmd_setExternalPlugin.c b/src_features/setExternalPlugin/cmd_setExternalPlugin.c
index 13d1faf..a2ddd71 100644
--- a/src_features/setExternalPlugin/cmd_setExternalPlugin.c
+++ b/src_features/setExternalPlugin/cmd_setExternalPlugin.c
@@ -37,17 +37,15 @@ void handleSetExternalPlugin(uint8_t p1,
// check Ledger's signature over the payload
cx_hash_sha256(workBuffer, payload_size, hash, sizeof(hash));
- cx_ecfp_init_public_key(CX_CURVE_256K1,
- LEDGER_SIGNATURE_PUBLIC_KEY,
- sizeof(LEDGER_SIGNATURE_PUBLIC_KEY),
- &tokenKey);
- if (!cx_ecdsa_verify(&tokenKey,
- CX_LAST,
- CX_SHA256,
- hash,
- sizeof(hash),
- workBuffer + payload_size,
- dataLength - payload_size)) {
+ CX_ASSERT(cx_ecfp_init_public_key_no_throw(CX_CURVE_256K1,
+ LEDGER_SIGNATURE_PUBLIC_KEY,
+ sizeof(LEDGER_SIGNATURE_PUBLIC_KEY),
+ &tokenKey));
+ if (!cx_ecdsa_verify_no_throw(&tokenKey,
+ hash,
+ sizeof(hash),
+ workBuffer + payload_size,
+ dataLength - payload_size)) {
#ifndef HAVE_BYPASS_SIGNATURES
PRINTF("Invalid plugin signature %.*H\n",
dataLength - payload_size,
diff --git a/src_features/setPlugin/cmd_setPlugin.c b/src_features/setPlugin/cmd_setPlugin.c
index d4eb522..d083d9b 100644
--- a/src_features/setPlugin/cmd_setPlugin.c
+++ b/src_features/setPlugin/cmd_setPlugin.c
@@ -58,7 +58,7 @@ typedef bool verificationAlgo(const cx_ecfp_public_key_t *,
// Returns the plugin type of a given plugin name.
// If the plugin name is not a specific known internal plugin, this function default return value is
-// `EXERNAL`.
+// `EXTERNAL`.
static pluginType_t getPluginType(char *pluginName, uint8_t pluginNameLength) {
if (pluginNameLength == sizeof(ERC721_STR) - 1 &&
strncmp(pluginName, ERC721_STR, pluginNameLength) == 0) {
@@ -189,20 +189,10 @@ void handleSetPlugin(uint8_t p1,
uint8_t algorithmId = workBuffer[offset];
PRINTF("Algorithm: %d\n", algorithmId);
- cx_curve_t curve;
- verificationAlgo *verificationFn;
- cx_md_t hashId;
- switch (algorithmId) {
- case ECC_SECG_P256K1__ECDSA_SHA_256:
- curve = CX_CURVE_256K1;
- verificationFn = (verificationAlgo *) cx_ecdsa_verify;
- hashId = CX_SHA256;
- break;
- default:
- PRINTF("Incorrect algorithmId %d\n", algorithmId);
- THROW(0x6a80);
- break;
+ if (algorithmId != ECC_SECG_P256K1__ECDSA_SHA_256) {
+ PRINTF("Incorrect algorithmId %d\n", algorithmId);
+ THROW(0x6a80);
}
offset += ALGORITHM_ID_SIZE;
PRINTF("hashing: %.*H\n", payloadSize, workBuffer);
@@ -229,14 +219,12 @@ void handleSetPlugin(uint8_t p1,
THROW(0x6a80);
}
- cx_ecfp_init_public_key(curve, rawKey, rawKeyLen, &pluginKey);
- if (!verificationFn(&pluginKey,
- CX_LAST,
- hashId,
- hash,
- sizeof(hash),
- (unsigned char *) (workBuffer + offset),
- signatureLen)) {
+ CX_ASSERT(cx_ecfp_init_public_key_no_throw(CX_CURVE_256K1, rawKey, rawKeyLen, &pluginKey));
+ if (!cx_ecdsa_verify_no_throw(&pluginKey,
+ hash,
+ sizeof(hash),
+ (unsigned char *) (workBuffer + offset),
+ signatureLen)) {
#ifndef HAVE_BYPASS_SIGNATURES
PRINTF("Invalid NFT signature\n");
THROW(0x6A80);
diff --git a/src_features/signMessage/cmd_signMessage.c b/src_features/signMessage/cmd_signMessage.c
index 6280ca0..14ea72d 100644
--- a/src_features/signMessage/cmd_signMessage.c
+++ b/src_features/signMessage/cmd_signMessage.c
@@ -92,6 +92,8 @@ static void reset_ui_buffer(void) {
* @return pointer to the start of the start of the message; \ref NULL if it failed
*/
static const uint8_t *first_apdu_data(const uint8_t *data, uint8_t *length) {
+ cx_err_t error = CX_INTERNAL_ERROR;
+
if (appState != APP_STATE_IDLE) {
apdu_reply(APDU_RESPONSE_CONDITION_NOT_SATISFIED);
}
@@ -113,22 +115,29 @@ static const uint8_t *first_apdu_data(const uint8_t *data, uint8_t *length) {
*length -= sizeof(uint32_t);
// Initialize message header + length
- cx_keccak_init(&global_sha3, 256);
- cx_hash((cx_hash_t *) &global_sha3, 0, (uint8_t *) SIGN_MAGIC, sizeof(SIGN_MAGIC) - 1, NULL, 0);
+ CX_CHECK(cx_keccak_init_no_throw(&global_sha3, 256));
+ CX_CHECK(cx_hash_no_throw((cx_hash_t *) &global_sha3,
+ 0,
+ (uint8_t *) SIGN_MAGIC,
+ sizeof(SIGN_MAGIC) - 1,
+ NULL,
+ 0));
snprintf(strings.tmp.tmp2,
sizeof(strings.tmp.tmp2),
"%u",
tmpCtx.messageSigningContext.remainingLength);
- cx_hash((cx_hash_t *) &global_sha3,
- 0,
- (uint8_t *) strings.tmp.tmp2,
- strlen(strings.tmp.tmp2),
- NULL,
- 0);
+ CX_CHECK(cx_hash_no_throw((cx_hash_t *) &global_sha3,
+ 0,
+ (uint8_t *) strings.tmp.tmp2,
+ strlen(strings.tmp.tmp2),
+ NULL,
+ 0));
reset_ui_buffer();
states.sign_state = STATE_191_HASH_DISPLAY;
states.ui_started = false;
return data;
+end:
+ return NULL;
}
/**
@@ -139,6 +148,8 @@ static const uint8_t *first_apdu_data(const uint8_t *data, uint8_t *length) {
* @return whether it was successful or not
*/
static bool feed_hash(const uint8_t *const data, const uint8_t length) {
+ cx_err_t error = CX_INTERNAL_ERROR;
+
if (length > tmpCtx.messageSigningContext.remainingLength) {
PRINTF("Error: Length mismatch ! (%u > %u)!\n",
length,
@@ -146,17 +157,19 @@ static bool feed_hash(const uint8_t *const data, const uint8_t length) {
apdu_reply(APDU_RESPONSE_INVALID_DATA);
return false;
}
- cx_hash((cx_hash_t *) &global_sha3, 0, data, length, NULL, 0);
+ CX_CHECK(cx_hash_no_throw((cx_hash_t *) &global_sha3, 0, data, length, NULL, 0));
if ((tmpCtx.messageSigningContext.remainingLength -= length) == 0) {
// Finalize hash
- cx_hash((cx_hash_t *) &global_sha3,
- CX_LAST,
- NULL,
- 0,
- tmpCtx.messageSigningContext.hash,
- 32);
+ CX_CHECK(cx_hash_no_throw((cx_hash_t *) &global_sha3,
+ CX_LAST,
+ NULL,
+ 0,
+ tmpCtx.messageSigningContext.hash,
+ 32));
}
return true;
+end:
+ return false;
}
/**
diff --git a/src_features/signMessage/ui_common_signMessage.c b/src_features/signMessage/ui_common_signMessage.c
index eb6707d..4bc7da9 100644
--- a/src_features/signMessage/ui_common_signMessage.c
+++ b/src_features/signMessage/ui_common_signMessage.c
@@ -1,31 +1,23 @@
#include "os_io_seproxyhal.h"
+#include "apdu_constants.h"
+#include "lib_standard_app/crypto_helpers.h"
#include "common_ui.h"
unsigned int io_seproxyhal_touch_signMessage_ok(void) {
- uint8_t privateKeyData[INT256_LENGTH];
- uint8_t signature[100];
- cx_ecfp_private_key_t privateKey;
uint32_t tx = 0;
- io_seproxyhal_io_heartbeat();
- os_perso_derive_node_bip32(CX_CURVE_256K1,
- tmpCtx.messageSigningContext.bip32.path,
- tmpCtx.messageSigningContext.bip32.length,
- privateKeyData,
- NULL);
- io_seproxyhal_io_heartbeat();
- cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey);
- explicit_bzero(privateKeyData, sizeof(privateKeyData));
unsigned int info = 0;
- io_seproxyhal_io_heartbeat();
- cx_ecdsa_sign(&privateKey,
- CX_RND_RFC6979 | CX_LAST,
- CX_SHA256,
- tmpCtx.messageSigningContext.hash,
- sizeof(tmpCtx.messageSigningContext.hash),
- signature,
- sizeof(signature),
- &info);
- explicit_bzero(&privateKey, sizeof(privateKey));
+ if (bip32_derive_ecdsa_sign_rs_hash_256(CX_CURVE_256K1,
+ tmpCtx.messageSigningContext.bip32.path,
+ tmpCtx.messageSigningContext.bip32.length,
+ CX_RND_RFC6979 | CX_LAST,
+ CX_SHA256,
+ tmpCtx.messageSigningContext.hash,
+ sizeof(tmpCtx.messageSigningContext.hash),
+ G_io_apdu_buffer + 1,
+ G_io_apdu_buffer + 1 + 32,
+ &info) != CX_OK) {
+ THROW(APDU_RESPONSE_UNKNOWN);
+ }
G_io_apdu_buffer[0] = 27;
if (info & CX_ECCINFO_PARITY_ODD) {
G_io_apdu_buffer[0]++;
@@ -33,7 +25,6 @@ unsigned int io_seproxyhal_touch_signMessage_ok(void) {
if (info & CX_ECCINFO_xGTn) {
G_io_apdu_buffer[0] += 2;
}
- format_signature_out(signature);
tx = 65;
G_io_apdu_buffer[tx++] = 0x90;
G_io_apdu_buffer[tx++] = 0x00;
diff --git a/src_features/signMessageEIP712/field_hash.c b/src_features/signMessageEIP712/field_hash.c
index af89be8..0ea583c 100644
--- a/src_features/signMessageEIP712/field_hash.c
+++ b/src_features/signMessageEIP712/field_hash.c
@@ -52,6 +52,7 @@ static const uint8_t *field_hash_prepare(const void *const field_ptr,
const uint8_t *data,
uint8_t *data_length) {
e_type field_type;
+ cx_err_t error = CX_INTERNAL_ERROR;
field_type = struct_field_type(field_ptr);
fh->remaining_size = __builtin_bswap16(*(uint16_t *) &data[0]); // network byte order
@@ -59,10 +60,12 @@ static const uint8_t *field_hash_prepare(const void *const field_ptr,
*data_length -= sizeof(uint16_t);
fh->state = FHS_WAITING_FOR_MORE;
if (IS_DYN(field_type)) {
- cx_keccak_init(&global_sha3, 256); // init hash
+ CX_CHECK(cx_keccak_init_no_throw(&global_sha3, 256));
ui_712_new_field(field_ptr, data, *data_length);
}
return data;
+end:
+ return NULL;
}
/**
@@ -120,14 +123,22 @@ static const uint8_t *field_hash_finalize_static(const void *const field_ptr,
*/
static uint8_t *field_hash_finalize_dynamic(void) {
uint8_t *value;
+ cx_err_t error = CX_INTERNAL_ERROR;
if ((value = mem_alloc(KECCAK256_HASH_BYTESIZE)) == NULL) {
apdu_response_code = APDU_RESPONSE_INSUFFICIENT_MEMORY;
return NULL;
}
// copy hash into memory
- cx_hash((cx_hash_t *) &global_sha3, CX_LAST, NULL, 0, value, KECCAK256_HASH_BYTESIZE);
+ CX_CHECK(cx_hash_no_throw((cx_hash_t *) &global_sha3,
+ CX_LAST,
+ NULL,
+ 0,
+ value,
+ KECCAK256_HASH_BYTESIZE));
return value;
+end:
+ return NULL;
}
/**
@@ -162,7 +173,7 @@ static void field_hash_feed_parent(e_type field_type, const uint8_t *const hash)
* @param[in] field_ptr pointer to the struct field definition
* @param[in] data the field value
* @param[in] data_length the value length
- * @return whether an error occured or not
+ * @return whether an error occurred or not
*/
static bool field_hash_domain_special_fields(const void *const field_ptr,
const uint8_t *const data,
@@ -191,7 +202,7 @@ static bool field_hash_domain_special_fields(const void *const field_ptr,
* @param[in] field_ptr pointer to the struct field definition
* @param[in] data the field value
* @param[in] data_length the value length
- * @return whether an error occured or not
+ * @return whether an error occurred or not
*/
static bool field_hash_finalize(const void *const field_ptr,
const uint8_t *const data,
diff --git a/src_features/signMessageEIP712/filtering.c b/src_features/signMessageEIP712/filtering.c
index ff45a6e..1a24d61 100644
--- a/src_features/signMessageEIP712/filtering.c
+++ b/src_features/signMessageEIP712/filtering.c
@@ -63,6 +63,7 @@ static bool verify_filtering_signature(uint8_t dname_length,
cx_ecfp_public_key_t verifying_key;
cx_sha256_t hash_ctx;
uint64_t chain_id;
+ cx_err_t error = CX_INTERNAL_ERROR;
cx_sha256_init(&hash_ctx);
@@ -105,13 +106,13 @@ static bool verify_filtering_signature(uint8_t dname_length,
hash_nbytes((uint8_t *) dname, sizeof(char) * dname_length, (cx_hash_t *) &hash_ctx);
// Finalize hash
- cx_hash((cx_hash_t *) &hash_ctx, CX_LAST, NULL, 0, hash, INT256_LENGTH);
+ CX_CHECK(cx_hash_no_throw((cx_hash_t *) &hash_ctx, CX_LAST, NULL, 0, hash, INT256_LENGTH));
- cx_ecfp_init_public_key(CX_CURVE_256K1,
- LEDGER_SIGNATURE_PUBLIC_KEY,
- sizeof(LEDGER_SIGNATURE_PUBLIC_KEY),
- &verifying_key);
- if (!cx_ecdsa_verify(&verifying_key, CX_LAST, CX_SHA256, hash, sizeof(hash), sig, sig_length)) {
+ CX_CHECK(cx_ecfp_init_public_key_no_throw(CX_CURVE_256K1,
+ LEDGER_SIGNATURE_PUBLIC_KEY,
+ sizeof(LEDGER_SIGNATURE_PUBLIC_KEY),
+ &verifying_key));
+ if (!cx_ecdsa_verify_no_throw(&verifying_key, hash, sizeof(hash), sig, sig_length)) {
#ifndef HAVE_BYPASS_SIGNATURES
PRINTF("Invalid EIP-712 filtering signature\n");
apdu_response_code = APDU_RESPONSE_INVALID_DATA;
@@ -119,6 +120,8 @@ static bool verify_filtering_signature(uint8_t dname_length,
#endif
}
return true;
+end:
+ return false;
}
/**
diff --git a/src_features/signMessageEIP712/path.c b/src_features/signMessageEIP712/path.c
index 3c823c9..8a5d05d 100644
--- a/src_features/signMessageEIP712/path.c
+++ b/src_features/signMessageEIP712/path.c
@@ -115,7 +115,7 @@ const void *path_get_field(void) {
/**
* Go down (add) a depth level.
*
- * @return whether the push was succesful
+ * @return whether the push was successful
*/
static bool path_depth_list_push(void) {
if (path_struct == NULL) {
@@ -147,13 +147,17 @@ static cx_sha3_t *get_last_hash_ctx(void) {
static bool finalize_hash_depth(uint8_t *hash) {
const cx_sha3_t *hash_ctx;
size_t hashed_bytes;
+ cx_err_t error = CX_INTERNAL_ERROR;
hash_ctx = get_last_hash_ctx();
hashed_bytes = hash_ctx->blen;
// finalize hash
- cx_hash((cx_hash_t *) hash_ctx, CX_LAST, NULL, 0, hash, KECCAK256_HASH_BYTESIZE);
+ CX_CHECK(
+ cx_hash_no_throw((cx_hash_t *) hash_ctx, CX_LAST, NULL, 0, hash, KECCAK256_HASH_BYTESIZE));
mem_dealloc(sizeof(*hash_ctx)); // remove hash context
return hashed_bytes > 0;
+end:
+ return false;
}
/**
@@ -166,7 +170,7 @@ static void feed_last_hash_depth(const uint8_t *const hash) {
hash_ctx = get_last_hash_ctx();
// continue progressive hash with the array hash
- cx_hash((cx_hash_t *) hash_ctx, 0, hash, KECCAK256_HASH_BYTESIZE, NULL, 0);
+ CX_ASSERT(cx_hash_no_throw((cx_hash_t *) hash_ctx, 0, hash, KECCAK256_HASH_BYTESIZE, NULL, 0));
}
/**
@@ -177,15 +181,18 @@ static void feed_last_hash_depth(const uint8_t *const hash) {
*/
static bool push_new_hash_depth(bool init) {
cx_sha3_t *hash_ctx;
+ cx_err_t error = CX_INTERNAL_ERROR;
// allocate new hash context
if ((hash_ctx = MEM_ALLOC_AND_ALIGN_TYPE(*hash_ctx)) == NULL) {
return false;
}
if (init) {
- cx_keccak_init(hash_ctx, 256); // initialize it
+ CX_CHECK(cx_keccak_init_no_throw(hash_ctx, 256));
}
return true;
+end:
+ return false;
}
/**
@@ -294,7 +301,6 @@ static bool path_update(void) {
if ((field_ptr = get_field(NULL)) == NULL) {
return false;
}
- struct_ptr = path_struct->root_struct;
while (struct_field_type(field_ptr) == TYPE_CUSTOM) {
typename = get_struct_field_typename(field_ptr, &typename_len);
if ((struct_ptr = get_structn(typename, typename_len)) == NULL) {
@@ -432,6 +438,7 @@ bool path_new_array_depth(const uint8_t *const data, uint8_t length) {
bool is_custom;
uint8_t array_size;
uint8_t array_depth_count_bak;
+ cx_err_t error = CX_INTERNAL_ERROR;
if (path_struct == NULL) {
apdu_response_code = APDU_RESPONSE_CONDITION_NOT_SATISFIED;
@@ -479,9 +486,9 @@ bool path_new_array_depth(const uint8_t *const data, uint8_t length) {
if (array_size > 0) {
memcpy(hash_ctx, old_ctx, sizeof(*old_ctx));
} else {
- cx_keccak_init(hash_ctx, 256);
+ CX_CHECK(cx_keccak_init_no_throw(hash_ctx, 256));
}
- cx_keccak_init(old_ctx, 256); // init hash
+ CX_CHECK(cx_keccak_init_no_throw(old_ctx, 256));
}
if (array_size == 0) {
do {
@@ -490,6 +497,8 @@ bool path_new_array_depth(const uint8_t *const data, uint8_t length) {
}
return true;
+end:
+ return false;
}
/**
diff --git a/src_features/signMessageEIP712/schema_hash.c b/src_features/signMessageEIP712/schema_hash.c
index e47c2ee..5b8e1bf 100644
--- a/src_features/signMessageEIP712/schema_hash.c
+++ b/src_features/signMessageEIP712/schema_hash.c
@@ -27,6 +27,7 @@ bool compute_schema_hash(void) {
const char *name;
uint8_t name_length;
cx_sha224_t hash_ctx;
+ cx_err_t error = CX_INTERNAL_ERROR;
cx_sha224_init(&hash_ctx);
@@ -61,13 +62,15 @@ bool compute_schema_hash(void) {
hash_byte('}', (cx_hash_t *) &hash_ctx);
// copy hash into context struct
- cx_hash((cx_hash_t *) &hash_ctx,
- CX_LAST,
- NULL,
- 0,
- eip712_context->schema_hash,
- sizeof(eip712_context->schema_hash));
+ CX_CHECK(cx_hash_no_throw((cx_hash_t *) &hash_ctx,
+ CX_LAST,
+ NULL,
+ 0,
+ eip712_context->schema_hash,
+ sizeof(eip712_context->schema_hash)));
return true;
+end:
+ return false;
}
#endif // HAVE_EIP712_FULL_SUPPORT
diff --git a/src_features/signMessageEIP712/type_hash.c b/src_features/signMessageEIP712/type_hash.c
index 7b9515f..f37e208 100644
--- a/src_features/signMessageEIP712/type_hash.c
+++ b/src_features/signMessageEIP712/type_hash.c
@@ -51,7 +51,7 @@ static bool encode_and_hash_type(const void *const struct_ptr) {
struct_name = get_struct_name(struct_ptr, &struct_name_length);
hash_nbytes((uint8_t *) struct_name, struct_name_length, (cx_hash_t *) &global_sha3);
- // opening struct parenthese
+ // opening struct parentheses
hash_byte('(', (cx_hash_t *) &global_sha3);
field_ptr = get_struct_fields_array(struct_ptr, &fields_count);
@@ -67,7 +67,7 @@ static bool encode_and_hash_type(const void *const struct_ptr) {
field_ptr = get_next_struct_field(field_ptr);
}
- // closing struct parenthese
+ // closing struct parentheses
hash_byte(')', (cx_hash_t *) &global_sha3);
return true;
@@ -107,7 +107,7 @@ static void sort_dependencies(uint8_t deps_count, const void **deps) {
/**
* Find all the dependencies from a given structure
*
- * @param[out] deps_count count of how many struct dependencie pointers
+ * @param[out] deps_count count of how many struct dependency pointers
* @param[in] first_dep pointer to the first dependency pointer
* @param[in] struct_ptr pointer to the struct we are getting the dependencies of
* @return pointer to the first found dependency, \ref NULL otherwise
@@ -171,8 +171,9 @@ bool type_hash(const char *const struct_name, const uint8_t struct_name_length,
uint8_t deps_count = 0;
const void **deps;
void *mem_loc_bak = mem_alloc(0);
+ cx_err_t error = CX_INTERNAL_ERROR;
- cx_keccak_init(&global_sha3, 256); // init hash
+ CX_CHECK(cx_keccak_init_no_throw(&global_sha3, 256));
deps = get_struct_dependencies(&deps_count, NULL, struct_ptr);
if ((deps_count > 0) && (deps == NULL)) {
return false;
@@ -191,8 +192,15 @@ bool type_hash(const char *const struct_name, const uint8_t struct_name_length,
mem_dealloc(mem_alloc(0) - mem_loc_bak);
// copy hash into memory
- cx_hash((cx_hash_t *) &global_sha3, CX_LAST, NULL, 0, hash_buf, KECCAK256_HASH_BYTESIZE);
+ CX_CHECK(cx_hash_no_throw((cx_hash_t *) &global_sha3,
+ CX_LAST,
+ NULL,
+ 0,
+ hash_buf,
+ KECCAK256_HASH_BYTESIZE));
return true;
+end:
+ return false;
}
#endif // HAVE_EIP712_FULL_SUPPORT
diff --git a/src_features/signMessageEIP712/typed_data.c b/src_features/signMessageEIP712/typed_data.c
index a410ccf..e5f75b7 100644
--- a/src_features/signMessageEIP712/typed_data.c
+++ b/src_features/signMessageEIP712/typed_data.c
@@ -58,7 +58,7 @@ static const uint8_t *field_skip_typedesc(const uint8_t *field_ptr, const uint8_
* @return pointer to the data right after
*/
static const uint8_t *field_skip_typename(const uint8_t *field_ptr, const uint8_t *ptr) {
- uint8_t size;
+ uint8_t size = 0;
if (struct_field_type(field_ptr) == TYPE_CUSTOM) {
get_string_in_mem(ptr, &size);
@@ -89,7 +89,7 @@ static const uint8_t *field_skip_typesize(const uint8_t *field_ptr, const uint8_
* @return pointer to the data right after
*/
static const uint8_t *field_skip_array_levels(const uint8_t *field_ptr, const uint8_t *ptr) {
- uint8_t size;
+ uint8_t size = 0;
if (struct_field_is_array(field_ptr)) {
ptr = get_array_in_mem(ptr, &size);
@@ -108,11 +108,12 @@ static const uint8_t *field_skip_array_levels(const uint8_t *field_ptr, const ui
* @return pointer to the data right after
*/
static const uint8_t *field_skip_keyname(const uint8_t *field_ptr, const uint8_t *ptr) {
- uint8_t size;
+ uint8_t size = 0;
+ uint8_t *new_ptr;
(void) field_ptr;
- ptr = get_array_in_mem(ptr, &size);
- return ptr + size;
+ new_ptr = (uint8_t *) get_array_in_mem(ptr, &size);
+ return (const uint8_t *) (new_ptr + size);
}
/**
@@ -416,7 +417,7 @@ const uint8_t *get_structs_array(uint8_t *const length) {
* @return pointer to struct
*/
const uint8_t *get_structn(const char *const name, const uint8_t length) {
- uint8_t structs_count;
+ uint8_t structs_count = 0;
const uint8_t *struct_ptr;
const char *struct_name;
uint8_t name_length;
diff --git a/src_features/signMessageEIP712/ui_logic.c b/src_features/signMessageEIP712/ui_logic.c
index 5a169e9..88951d7 100644
--- a/src_features/signMessageEIP712/ui_logic.c
+++ b/src_features/signMessageEIP712/ui_logic.c
@@ -48,7 +48,7 @@ static bool ui_712_field_shown(void) {
* @param[in] src_length source buffer size
* @param[in] dst destination buffer
* @param[in] dst_length destination buffer length
- * @param[in] explicit_trunc if truncation should be explicitely shown
+ * @param[in] explicit_trunc if truncation should be explicitly shown
*/
static void ui_712_set_buf(const char *const src,
size_t src_length,
@@ -194,7 +194,7 @@ static void ui_712_format_str(const uint8_t *const data, uint8_t length) {
static const char *get_address_token_ticker(const uint8_t *addr) {
tokenDefinition_t *token;
- // Loop over the received token informations
+ // Loop over the received token information
for (uint8_t token_idx = 0; token_idx < MAX_ITEMS; ++token_idx) {
if (tmpCtx.transactionContext.tokenSet[token_idx] == 1) {
token = &tmpCtx.transactionContext.extraInfo[token_idx].token;
@@ -247,7 +247,6 @@ static bool ui_712_format_addr(const uint8_t *const data, uint8_t length) {
if (!getEthDisplayableAddress((uint8_t *) data,
strings.tmp.tmp,
sizeof(strings.tmp.tmp),
- &global_sha3,
chainConfig->chainId)) {
THROW(APDU_RESPONSE_ERROR_NO_INFO);
}
@@ -292,7 +291,7 @@ static void ui_712_format_bytes(const uint8_t *const data, uint8_t length) {
// x2 for each byte value is represented by 2 ASCII characters
if ((2 + (length * 2)) > (sizeof(strings.tmp.tmp) - 1)) {
strings.tmp.tmp[sizeof(strings.tmp.tmp) - 1 - 3] = '\0';
- strcat(strings.tmp.tmp, "...");
+ strlcat(strings.tmp.tmp, "...", sizeof(strings.tmp.tmp));
}
}
}
diff --git a/src_features/signMessageEIP712_common/common_712.c b/src_features/signMessageEIP712_common/common_712.c
index 084a528..e45e30c 100644
--- a/src_features/signMessageEIP712_common/common_712.c
+++ b/src_features/signMessageEIP712_common/common_712.c
@@ -1,5 +1,7 @@
#include "shared_context.h"
+#include "apdu_constants.h"
#include "os_io_seproxyhal.h"
+#include "lib_standard_app/crypto_helpers.h"
#include "ui_callbacks.h"
#include "common_712.h"
#include "ui_callbacks.h"
@@ -8,54 +10,45 @@
static const uint8_t EIP_712_MAGIC[] = {0x19, 0x01};
unsigned int ui_712_approve_cb(void) {
- uint8_t privateKeyData[INT256_LENGTH];
uint8_t hash[INT256_LENGTH];
- uint8_t signature[100];
- cx_ecfp_private_key_t privateKey;
uint32_t tx = 0;
io_seproxyhal_io_heartbeat();
- cx_keccak_init(&global_sha3, 256);
- cx_hash((cx_hash_t *) &global_sha3,
- 0,
- (uint8_t *) EIP_712_MAGIC,
- sizeof(EIP_712_MAGIC),
- NULL,
- 0);
- cx_hash((cx_hash_t *) &global_sha3,
- 0,
- tmpCtx.messageSigningContext712.domainHash,
- sizeof(tmpCtx.messageSigningContext712.domainHash),
- NULL,
- 0);
- cx_hash((cx_hash_t *) &global_sha3,
- CX_LAST,
- tmpCtx.messageSigningContext712.messageHash,
- sizeof(tmpCtx.messageSigningContext712.messageHash),
- hash,
- sizeof(hash));
+ CX_ASSERT(cx_keccak_init_no_throw(&global_sha3, 256));
+ CX_ASSERT(cx_hash_no_throw((cx_hash_t *) &global_sha3,
+ 0,
+ (uint8_t *) EIP_712_MAGIC,
+ sizeof(EIP_712_MAGIC),
+ NULL,
+ 0));
+ CX_ASSERT(cx_hash_no_throw((cx_hash_t *) &global_sha3,
+ 0,
+ tmpCtx.messageSigningContext712.domainHash,
+ sizeof(tmpCtx.messageSigningContext712.domainHash),
+ NULL,
+ 0));
+ CX_ASSERT(cx_hash_no_throw((cx_hash_t *) &global_sha3,
+ CX_LAST,
+ tmpCtx.messageSigningContext712.messageHash,
+ sizeof(tmpCtx.messageSigningContext712.messageHash),
+ hash,
+ sizeof(hash)));
PRINTF("EIP712 Domain hash 0x%.*h\n", 32, tmpCtx.messageSigningContext712.domainHash);
PRINTF("EIP712 Message hash 0x%.*h\n", 32, tmpCtx.messageSigningContext712.messageHash);
- io_seproxyhal_io_heartbeat();
- os_perso_derive_node_bip32(CX_CURVE_256K1,
- tmpCtx.messageSigningContext712.bip32.path,
- tmpCtx.messageSigningContext712.bip32.length,
- privateKeyData,
- NULL);
- io_seproxyhal_io_heartbeat();
- cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey);
- explicit_bzero(privateKeyData, sizeof(privateKeyData));
+
unsigned int info = 0;
- io_seproxyhal_io_heartbeat();
- cx_ecdsa_sign(&privateKey,
- CX_RND_RFC6979 | CX_LAST,
- CX_SHA256,
- hash,
- sizeof(hash),
- signature,
- sizeof(signature),
- &info);
- explicit_bzero(&privateKey, sizeof(privateKey));
+ if (bip32_derive_ecdsa_sign_rs_hash_256(CX_CURVE_256K1,
+ tmpCtx.messageSigningContext712.bip32.path,
+ tmpCtx.messageSigningContext712.bip32.length,
+ CX_RND_RFC6979 | CX_LAST,
+ CX_SHA256,
+ hash,
+ sizeof(hash),
+ G_io_apdu_buffer + 1,
+ G_io_apdu_buffer + 1 + 32,
+ &info) != CX_OK) {
+ THROW(APDU_RESPONSE_UNKNOWN);
+ }
G_io_apdu_buffer[0] = 27;
if (info & CX_ECCINFO_PARITY_ODD) {
G_io_apdu_buffer[0]++;
@@ -63,7 +56,6 @@ unsigned int ui_712_approve_cb(void) {
if (info & CX_ECCINFO_xGTn) {
G_io_apdu_buffer[0] += 2;
}
- format_signature_out(signature);
tx = 65;
G_io_apdu_buffer[tx++] = 0x90;
G_io_apdu_buffer[tx++] = 0x00;
diff --git a/src_features/signTx/cmd_signTx.c b/src_features/signTx/cmd_signTx.c
index 0eb1d1c..8a84538 100644
--- a/src_features/signTx/cmd_signTx.c
+++ b/src_features/signTx/cmd_signTx.c
@@ -43,7 +43,7 @@ void handleSign(uint8_t p1,
if (txType >= MIN_TX_TYPE && txType <= MAX_TX_TYPE) {
// Enumerate through all supported txTypes here...
if (txType == EIP2930 || txType == EIP1559) {
- cx_hash((cx_hash_t *) &global_sha3, 0, workBuffer, 1, NULL, 0);
+ CX_ASSERT(cx_hash_no_throw((cx_hash_t *) &global_sha3, 0, workBuffer, 1, NULL, 0));
txContext.txType = txType;
workBuffer++;
dataLength--;
diff --git a/src_features/signTx/logic_signTx.c b/src_features/signTx/logic_signTx.c
index bdacd76..20c1375 100644
--- a/src_features/signTx/logic_signTx.c
+++ b/src_features/signTx/logic_signTx.c
@@ -8,6 +8,7 @@
#include "common_ui.h"
#include "ui_callbacks.h"
#include "apdu_constants.h"
+#include "lib_standard_app/crypto_helpers.h"
#define ERR_SILENT_MODE_CHECK_FAILED 0x6001
@@ -184,10 +185,9 @@ static void address_to_string(uint8_t *in,
size_t in_len,
char *out,
size_t out_len,
- cx_sha3_t *sha3,
uint64_t chainId) {
if (in_len != 0) {
- if (!getEthDisplayableAddress(in, out, out_len, sha3, chainId)) {
+ if (!getEthDisplayableAddress(in, out, out_len, chainId)) {
THROW(APDU_RESPONSE_ERROR_NO_INFO);
}
} else {
@@ -279,29 +279,24 @@ static void get_network_as_string(char *out, size_t out_size) {
}
static void get_public_key(uint8_t *out, uint8_t outLength) {
- uint8_t privateKeyData[INT256_LENGTH] = {0};
- cx_ecfp_private_key_t privateKey = {0};
- cx_ecfp_public_key_t publicKey = {0};
+ uint8_t raw_pubkey[65];
if (outLength < ADDRESS_LENGTH) {
return;
}
-
- os_perso_derive_node_bip32(CX_CURVE_256K1,
- tmpCtx.transactionContext.bip32.path,
- tmpCtx.transactionContext.bip32.length,
- privateKeyData,
- NULL);
- cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey);
- cx_ecfp_generate_pair(CX_CURVE_256K1, &publicKey, &privateKey, 1);
- explicit_bzero(&privateKey, sizeof(privateKey));
- explicit_bzero(privateKeyData, sizeof(privateKeyData));
- if (!getEthAddressFromKey(&publicKey, out, &global_sha3)) {
- THROW(CX_INVALID_PARAMETER);
+ if (bip32_derive_get_pubkey_256(CX_CURVE_256K1,
+ tmpCtx.transactionContext.bip32.path,
+ tmpCtx.transactionContext.bip32.length,
+ raw_pubkey,
+ NULL,
+ CX_SHA512) != CX_OK) {
+ THROW(APDU_RESPONSE_UNKNOWN);
}
+
+ getEthAddressFromRawKey(raw_pubkey, out);
}
-/* Local implmentation of strncasecmp, workaround of the segfaulting base implem
+/* Local implementation of strncasecmp, workaround of the segfaulting base implem
* Remove once strncasecmp is fixed
*/
static int strcasecmp_workaround(const char *str1, const char *str2) {
@@ -322,6 +317,7 @@ __attribute__((noinline)) static bool finalize_parsing_helper(bool direct, bool
uint64_t chain_id = get_tx_chain_id();
const char *ticker = get_displayable_ticker(&chain_id, chainConfig);
ethPluginFinalize_t pluginFinalize;
+ cx_err_t error = CX_INTERNAL_ERROR;
// Verify the chain
if (chainConfig->chainId != ETHEREUM_MAINNET_CHAINID) {
@@ -337,12 +333,12 @@ __attribute__((noinline)) static bool finalize_parsing_helper(bool direct, bool
}
}
// Store the hash
- cx_hash((cx_hash_t *) &global_sha3,
- CX_LAST,
- tmpCtx.transactionContext.hash,
- 0,
- tmpCtx.transactionContext.hash,
- 32);
+ CX_CHECK(cx_hash_no_throw((cx_hash_t *) &global_sha3,
+ CX_LAST,
+ tmpCtx.transactionContext.hash,
+ 0,
+ tmpCtx.transactionContext.hash,
+ 32));
// Finalize the plugin handling
if (dataContext.tokenContext.pluginStatus >= ETH_PLUGIN_RESULT_SUCCESSFUL) {
@@ -460,7 +456,6 @@ __attribute__((noinline)) static bool finalize_parsing_helper(bool direct, bool
tmpContent.txContent.destinationLength,
displayBuffer,
sizeof(displayBuffer),
- &global_sha3,
chainConfig->chainId);
if (G_called_from_swap) {
// Ensure the values are the same that the ones that have been previously validated
@@ -529,6 +524,8 @@ __attribute__((noinline)) static bool finalize_parsing_helper(bool direct, bool
get_network_as_string(strings.common.network_name, sizeof(strings.common.network_name));
PRINTF("Network: %s\n", strings.common.network_name);
return true;
+end:
+ return false;
}
void finalizeParsing(bool direct) {
diff --git a/src_nbgl/ui_get_eth2_public_key.c b/src_nbgl/ui_get_eth2_public_key.c
index 9f388df..3f6a3e7 100644
--- a/src_nbgl/ui_get_eth2_public_key.c
+++ b/src_nbgl/ui_get_eth2_public_key.c
@@ -27,4 +27,4 @@ static void buildScreen(void) {
void ui_display_public_eth2(void) {
buildScreen();
-}
\ No newline at end of file
+}
diff --git a/src_nbgl/ui_sign_712.c b/src_nbgl/ui_sign_712.c
index ad4f07f..c612fcf 100644
--- a/src_nbgl/ui_sign_712.c
+++ b/src_nbgl/ui_sign_712.c
@@ -48,18 +48,10 @@ static bool display_review_page(uint8_t page, nbgl_pageContent_t *content) {
break;
case 1:
- switch (ui_712_next_field()) {
- case EIP712_NO_MORE_FIELD:
- ui_712_switch_to_sign();
- ret = true;
- break;
- case EIP712_FIELD_INCOMING:
- case EIP712_FIELD_LATER:
- default:
- break;
+ if (ui_712_next_field() == EIP712_NO_MORE_FIELD) {
+ ui_712_switch_to_sign();
}
__attribute__((fallthrough));
-
default:
ret = false;
break;
diff --git a/src_plugins/erc1155/erc1155_ui.c b/src_plugins/erc1155/erc1155_ui.c
index a31dd96..1e9d451 100644
--- a/src_plugins/erc1155/erc1155_ui.c
+++ b/src_plugins/erc1155/erc1155_ui.c
@@ -17,7 +17,6 @@ static void set_approval_for_all_ui(ethQueryContractUI_t *msg, erc1155_context_t
if (!getEthDisplayableAddress(context->address,
msg->msg,
msg->msgLength,
- &global_sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
@@ -31,7 +30,6 @@ static void set_approval_for_all_ui(ethQueryContractUI_t *msg, erc1155_context_t
if (!getEthDisplayableAddress(msg->item1->nft.contractAddress,
msg->msg,
msg->msgLength,
- &global_sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
@@ -50,7 +48,6 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *contex
if (!getEthDisplayableAddress(context->address,
msg->msg,
msg->msgLength,
- &global_sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
@@ -64,7 +61,6 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *contex
if (!getEthDisplayableAddress(msg->item1->nft.contractAddress,
msg->msg,
msg->msgLength,
- &global_sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
@@ -100,7 +96,6 @@ static void set_batch_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *
if (!getEthDisplayableAddress(context->address,
msg->msg,
msg->msgLength,
- &global_sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
@@ -114,7 +109,6 @@ static void set_batch_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *
if (!getEthDisplayableAddress(msg->item1->nft.contractAddress,
msg->msg,
msg->msgLength,
- &global_sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
diff --git a/src_plugins/erc20/erc20_plugin.c b/src_plugins/erc20/erc20_plugin.c
index e5b1ba0..c104974 100644
--- a/src_plugins/erc20/erc20_plugin.c
+++ b/src_plugins/erc20/erc20_plugin.c
@@ -204,7 +204,6 @@ void erc20_plugin_call(int message, void *parameters) {
if (!getEthDisplayableAddress(context->destinationAddress,
msg->msg,
msg->msgLength,
- msg->pluginSharedRW->sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
diff --git a/src_plugins/erc721/erc721_ui.c b/src_plugins/erc721/erc721_ui.c
index e948087..1c0facd 100644
--- a/src_plugins/erc721/erc721_ui.c
+++ b/src_plugins/erc721/erc721_ui.c
@@ -13,7 +13,6 @@ static void set_approval_ui(ethQueryContractUI_t *msg, erc721_context_t *context
if (!getEthDisplayableAddress(context->address,
msg->msg,
msg->msgLength,
- &global_sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
@@ -27,7 +26,6 @@ static void set_approval_ui(ethQueryContractUI_t *msg, erc721_context_t *context
if (!getEthDisplayableAddress(msg->item1->nft.contractAddress,
msg->msg,
msg->msgLength,
- &global_sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
@@ -59,7 +57,6 @@ static void set_approval_for_all_ui(ethQueryContractUI_t *msg, erc721_context_t
if (!getEthDisplayableAddress(context->address,
msg->msg,
msg->msgLength,
- &global_sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
@@ -73,7 +70,6 @@ static void set_approval_for_all_ui(ethQueryContractUI_t *msg, erc721_context_t
if (!getEthDisplayableAddress(msg->item1->nft.contractAddress,
msg->msg,
msg->msgLength,
- &global_sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
@@ -92,7 +88,6 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc721_context_t *context
if (!getEthDisplayableAddress(context->address,
msg->msg,
msg->msgLength,
- &global_sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
@@ -106,7 +101,6 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc721_context_t *context
if (!getEthDisplayableAddress(msg->item1->nft.contractAddress,
msg->msg,
msg->msgLength,
- &global_sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
}
diff --git a/src_plugins/eth2/eth2_plugin.c b/src_plugins/eth2/eth2_plugin.c
index 588199e..c18462a 100644
--- a/src_plugins/eth2/eth2_plugin.c
+++ b/src_plugins/eth2/eth2_plugin.c
@@ -119,7 +119,6 @@ void eth2_plugin_call(int message, void *parameters) {
if (!getEthDisplayableAddress((uint8_t *) context->deposit_address,
tmp,
sizeof(tmp),
- msg->pluginSharedRW->sha3,
chainConfig->chainId)) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
return;
diff --git a/tests/speculos/.gitignore b/tests/speculos/.gitignore
index 94026aa..a6d415f 100644
--- a/tests/speculos/.gitignore
+++ b/tests/speculos/.gitignore
@@ -22,4 +22,4 @@ pytestdebug.log
.mypy_cache
.coverage
.coverage.*
-coverage.xml
\ No newline at end of file
+coverage.xml
diff --git a/tests/speculos/README.md b/tests/speculos/README.md
index 68d1468..3cc7fd3 100644
--- a/tests/speculos/README.md
+++ b/tests/speculos/README.md
@@ -8,6 +8,7 @@ These tests are implemented in Python with the `SpeculosClient` interface which
- [pip](https://pip.pypa.io/en/stable/installation/)
### Dependencies
+
Python dependencies are listed in [requirements.txt](requirements.txt)
```shell
@@ -19,6 +20,7 @@ python3 -m pip install -r requirements.txt
### Compilation app
Go to the root of the repository:
+
```sh
make DEBUG=1 NFT_TESTING_KEY=1 BOLOS_SDK=$NANOX_SDK
mv bin/app.elf tests/speculos/.elf
@@ -26,12 +28,13 @@ mv bin/app.elf tests/speculos/.elf
Given the requirements are installed, just do (by default command):
-```
+```shell
cd tests/speculos/
pytest
```
### Custom options
+
- **--model:** "nanos", "nanox", "nanosp" | default: "nanos"
- **--display:** "qt", "headless" | default: "qt"
- **--path:** the path of the binary app | default: path of makefile compilation
@@ -39,6 +42,7 @@ pytest
## Example
With `nanox` binary app:
+
```sh
# the --path is variable to where you put your binary
diff --git a/tests/speculos/docs/README.md b/tests/speculos/docs/README.md
index eb6df71..8a10e58 100644
--- a/tests/speculos/docs/README.md
+++ b/tests/speculos/docs/README.md
@@ -32,6 +32,7 @@
## Ethereum_client
### Ethereum_cmd_builder
+
```py
def chunked(size, source)
@@ -49,6 +50,7 @@ class EthereumCommandBuilder:
```
### Ethereum_cmd
+
```py
class EthereumCommand:
# Sending apdu and parsing the response in the right form
@@ -61,16 +63,14 @@ class EthereumCommand:
def simple_sign_tx(self, bip32_path: str, transaction: Transaction, result: List = list()) -> None:
def sign_eip712(self, bip32_path: str, transaction: EIP712, result: List = list()) -> None:
def personal_sign_tx(self, bip32_path: str, transaction: PersonalTransaction, result: List = list()) -> None:
-
-
# Allows to send an apdu without return of speculos
def send_apdu(self, apdu: bytes) -> bytes:
# Allows to send an apdu with return of speculos
def send_apdu_context(self, apdu: bytes, result: List = list()) -> bytes:
-
```
### Utils
+
```py
def save_screenshot(cmd, path: str):
def compare_screenshot(cmd, path: str):
@@ -80,21 +80,23 @@ def packed_bip32_path_from_string(path: str) -> bytes:
def write_varint(n: int) -> bytes:
def read_varint(buf: BytesIO, prefix: Optional[bytes] = None) -> int:
def read(buf: BytesIO, size: int) -> bytes:
-def read_uint(buf: BytesIO,
+def read_uint(buf: BytesIO, bit_len: int, byteorder: Literal['big', 'little'] = 'little') -> int:
```
## Tests new apdu
-If a new instruction is programmed it will be necessary to create 2 new functions.
-one in `ethereum_cmd_builder` :
+If a new instruction is programmed it will be necessary to create 2 new functions.
+one in `ethereum_cmd_builder`:
+
- Creation of the raw apdu you can find some examples in this same file
-
-and one in `ethereum_cmd`:
+
+and one in `ethereum_cmd`:
+
- Send the apdu to speculos and parse the answer in a `list` named result you can find some examples in this same file
## Example for write new tests
-To send several apdu and get the return
+To send several apdu and get the return
```py
FIRST = bytes.fromhex("{YourAPDU}")
@@ -130,4 +132,3 @@ def test_some_error(cmd):
pass
assert error.args[0] == '0x6a80'
```
-
diff --git a/tests/speculos/ethereum_client/ethereum_cmd.py b/tests/speculos/ethereum_client/ethereum_cmd.py
index a13a817..8c575af 100644
--- a/tests/speculos/ethereum_client/ethereum_cmd.py
+++ b/tests/speculos/ethereum_client/ethereum_cmd.py
@@ -22,7 +22,7 @@ class EthereumCommand:
self.builder = EthereumCommandBuilder(debug=debug)
self.debug = debug
self.model = model
-
+
def get_configuration(self) -> Tuple[int, int, int, int]:
try:
response = self.client._apdu_exchange(
@@ -46,7 +46,7 @@ class EthereumCommand:
self.client._apdu_exchange(
self.builder.set_plugin(plugin=plugin)
)
-
+
except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_SET_PLUGIN)
@@ -79,7 +79,7 @@ class EthereumCommand:
data=chunk[5:]) as exchange:
yield exchange
response: bytes = exchange.receive()
-
+
except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_GET_PUBLIC_KEY)
@@ -94,17 +94,17 @@ class EthereumCommand:
uncompressed_addr_len: bytes = response[offset:offset + pub_key_len]
offset += pub_key_len
-
+
eth_addr_len: int = response[offset]
offset += 1
-
+
eth_addr: bytes = response[offset:offset + eth_addr_len]
offset += eth_addr_len
chain_code: bytes = response[offset:]
assert len(response) == 1 + pub_key_len + 1 + eth_addr_len + 32 # 32 -> chain_code_len
-
+
result.append(uncompressed_addr_len)
result.append(eth_addr)
result.append(chain_code)
@@ -120,7 +120,7 @@ class EthereumCommand:
data=chunk[5:]) as exchange:
yield exchange
response: bytes = exchange.receive()
-
+
except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_PERFORM_PRIVACY_OPERATION)
@@ -146,7 +146,7 @@ class EthereumCommand:
data=apdu[5:]) as exchange:
yield exchange
result.append(exchange.receive())
-
+
except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_SIGN_TX)
@@ -162,14 +162,14 @@ class EthereumCommand:
data=chunk[5:]) as exchange:
yield exchange
response: bytes = exchange.receive()
-
+
except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_SIGN_TX)
# response = V (1) || R (32) || S (32)
assert len(response) == 65
v, r, s = parse_sign_response(response)
-
+
result.append(v)
result.append(r)
result.append(s)
@@ -185,14 +185,14 @@ class EthereumCommand:
data=chunk[5:]) as exchange:
yield exchange
response: bytes = exchange.receive()
-
+
except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_SIGN_EIP712)
# response = V (1) || R (32) || S (32)
assert len(response) == 65
v, r, s = parse_sign_response(response)
-
+
result.append(v)
result.append(r)
result.append(s)
@@ -211,16 +211,13 @@ class EthereumCommand:
response: bytes = exchange.receive()
else:
self.send_apdu(apdu)
-
+
except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_SIGN_TX)
# response = V (1) || R (32) || S (32)
v, r, s = parse_sign_response(response)
-
+
result.append(v)
result.append(r)
result.append(s)
-
-
-
diff --git a/tests/speculos/ethereum_client/ethereum_cmd_builder.py b/tests/speculos/ethereum_client/ethereum_cmd_builder.py
index f2f721e..dd516d4 100644
--- a/tests/speculos/ethereum_client/ethereum_cmd_builder.py
+++ b/tests/speculos/ethereum_client/ethereum_cmd_builder.py
@@ -156,7 +156,7 @@ class EthereumCommandBuilder:
"""
cdata = packed_bip32_path_from_string(bip32_path)
-
+
return self.serialize(cla=self.CLA,
ins=InsType.INS_GET_PUBLIC_KEY,
p1=0x01 if display else 0x00,
@@ -171,11 +171,11 @@ class EthereumCommandBuilder:
bip32_path : str
String representation of BIP32 path.
Third party public key on Curve25519 : 32 bytes
- Optionnal if returning the shared secret
-
+ Optional if returning the shared secret
+
"""
cdata = packed_bip32_path_from_string(bip32_path)
-
+
return self.serialize(cla=self.CLA,
ins=InsType.INS_PERFORM_PRIVACY_OPERATION,
p1=0x01 if display else 0x00,
@@ -200,7 +200,7 @@ class EthereumCommandBuilder:
"""
cdata = packed_bip32_path_from_string(bip32_path)
-
+
tx: bytes = transaction.serialize()
cdata = cdata + tx
@@ -230,7 +230,7 @@ class EthereumCommandBuilder:
"""
cdata = packed_bip32_path_from_string(bip32_path)
-
+
tx: bytes = transaction.serialize()
cdata = cdata + tx
@@ -259,12 +259,12 @@ class EthereumCommandBuilder:
"""
cdata = packed_bip32_path_from_string(bip32_path)
-
+
tx: bytes = transaction.serialize()
cdata = cdata + tx
last_chunk = len(cdata) // MAX_APDU_LEN
-
+
# The generator allows to send apdu frames because we can't send an apdu > 255
for i, (chunk) in enumerate(chunked(MAX_APDU_LEN, cdata)):
if i == 0 and i == last_chunk:
@@ -290,4 +290,4 @@ class EthereumCommandBuilder:
ins=InsType.INS_SIGN_PERSONAL_TX,
p1=0x80,
p2=0x00,
- cdata=chunk)
\ No newline at end of file
+ cdata=chunk)
diff --git a/tests/speculos/ethereum_client/plugin.py b/tests/speculos/ethereum_client/plugin.py
index 9274fde..88e7892 100644
--- a/tests/speculos/ethereum_client/plugin.py
+++ b/tests/speculos/ethereum_client/plugin.py
@@ -10,7 +10,7 @@ class ERC20Information:
self.nb_decimals: int = nb_decimals
self.chainID: int = chainID
self.sign: bytes = bytes.fromhex(sign)
-
+
def serialize(self) -> bytes:
return b"".join([
write_varint(len(self.erc20_ticker)),
@@ -67,4 +67,4 @@ class Plugin:
write_varint(len(self.sign)),
self.sign,
- ])
\ No newline at end of file
+ ])
diff --git a/tests/speculos/ethereum_client/transaction.py b/tests/speculos/ethereum_client/transaction.py
index 4c9fe23..64b261b 100644
--- a/tests/speculos/ethereum_client/transaction.py
+++ b/tests/speculos/ethereum_client/transaction.py
@@ -88,9 +88,9 @@ class EIP712:
def __init__(self, domain_hash: str, msg_hash: str) -> None:
self.domain_hash = bytes.fromhex(domain_hash)
self.msg_hash = bytes.fromhex(msg_hash)
-
+
def serialize(self) -> bytes:
return b"".join([
self.domain_hash,
self.msg_hash
- ])
\ No newline at end of file
+ ])
diff --git a/tests/speculos/ethereum_client/utils.py b/tests/speculos/ethereum_client/utils.py
index be3cdde..de03b78 100644
--- a/tests/speculos/ethereum_client/utils.py
+++ b/tests/speculos/ethereum_client/utils.py
@@ -54,7 +54,7 @@ def bip32_path_from_string(path: str) -> List[bytes]:
def packed_bip32_path_from_string(path: str) -> bytes:
bip32_paths = bip32_path_from_string(path)
-
+
return b"".join([
len(bip32_paths).to_bytes(1, byteorder="big"),
*bip32_paths
@@ -98,7 +98,7 @@ def read(buf: BytesIO, size: int) -> bytes:
b: bytes = buf.read(size)
if len(b) < size:
- raise ValueError(f"Cant read {size} bytes in buffer!")
+ raise ValueError(f"Can't read {size} bytes in buffer!")
return b
diff --git a/tests/speculos/old_test_eip191.py b/tests/speculos/old_test_eip191.py
index d24ad0b..423bd23 100644
--- a/tests/speculos/old_test_eip191.py
+++ b/tests/speculos/old_test_eip191.py
@@ -16,7 +16,7 @@ def test_personal_sign_metamask(cmd):
with cmd.personal_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5)
-
+
if cmd.model == "nanos":
# Sign message
compare_screenshot(cmd, f"screenshots/eip191/{PATH_IMG[cmd.model]}/personal_sign_metamask/00000.png")
@@ -49,7 +49,7 @@ def test_personal_sign_metamask(cmd):
assert v == 0x1c # 28
assert r.hex() == "916099cf0d9c21911c85f0770a47a9696a8189e78c259cf099749748c507baae"
assert s.hex() == "0d72234bc0ac2e94c5f7a5f4f9cd8610a52be4ea55515a85b9703f1bb158415c"
-
+
def test_personal_sign_reject(cmd):
result: list = []
@@ -109,7 +109,7 @@ def test_personal_sign_non_ascii(cmd):
with cmd.personal_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5)
-
+
if cmd.model == "nanos":
# Sign message
compare_screenshot(cmd, f"screenshots/eip191/{PATH_IMG[cmd.model]}/personal_sign_non_ascii/00000.png")
@@ -159,7 +159,7 @@ def test_personal_sign_opensea(cmd):
with cmd.personal_sign_tx(bip32_path, transaction, result) as ex:
sleep(0.5)
-
+
if cmd.model == "nanos":
# Sign message
compare_screenshot(cmd, f"screenshots/eip191/{PATH_IMG[cmd.model]}/personal_sign_opensea/00000.png")
diff --git a/tests/speculos/test_configuration_cmd.py b/tests/speculos/test_configuration_cmd.py
index af56756..d8213f7 100644
--- a/tests/speculos/test_configuration_cmd.py
+++ b/tests/speculos/test_configuration_cmd.py
@@ -1,3 +1,3 @@
def test_configuration(cmd):
- assert cmd.get_configuration() == (2, 1, 11, 0)
+ assert cmd.get_configuration() == (2, 1, 11, 1)
diff --git a/tests/speculos/test_eip1559.py b/tests/speculos/test_eip1559.py
index f834df3..62cb43a 100644
--- a/tests/speculos/test_eip1559.py
+++ b/tests/speculos/test_eip1559.py
@@ -9,7 +9,7 @@ def test_sign_eip_1559(cmd):
with cmd.send_apdu_context(apdu_sign_eip_1559, result) as ex:
sleep(0.5)
-
+
if cmd.model == "nanos":
# Review transaction
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00000.png")
@@ -47,7 +47,7 @@ def test_sign_eip_1559(cmd):
# Address
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00002.png")
cmd.client.press_and_release('right')
-
+
# Max Fees
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00003.png")
cmd.client.press_and_release('right')
diff --git a/tests/speculos/test_eip712.py b/tests/speculos/test_eip712.py
index 6a72aa4..161e6ee 100644
--- a/tests/speculos/test_eip712.py
+++ b/tests/speculos/test_eip712.py
@@ -176,4 +176,4 @@ def test_sign_eip_712_bad_msg(cmd):
with cmd.sign_eip712(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
pass
- assert error.args[0] == '0x6a80'
\ No newline at end of file
+ assert error.args[0] == '0x6a80'
diff --git a/tests/speculos/test_erc1155.py b/tests/speculos/test_erc1155.py
index b0692ec..f3948a4 100644
--- a/tests/speculos/test_erc1155.py
+++ b/tests/speculos/test_erc1155.py
@@ -38,7 +38,7 @@ def test_transfer_erc1155(cmd):
if cmd.model == "nanox" or cmd.model == "nanosp":
cmd.set_plugin(plugin=PLUGIN)
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
-
+
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
@@ -46,8 +46,8 @@ def test_transfer_erc1155(cmd):
# Review transaction
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00000.png")
cmd.client.press_and_release('right')
-
- # NFT Transfert
+
+ # NFT Transfer
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00001.png")
cmd.client.press_and_release('right')
@@ -98,7 +98,7 @@ def test_transfer_erc1155_without_nft_provide_info(cmd):
cmd.set_plugin(plugin=PLUGIN)
-
+
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
@@ -114,7 +114,7 @@ def test_transfer_erc1155_without_set_plugin(cmd):
with pytest.raises(ethereum_client.exception.errors.DenyError) as error:
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
-
+
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
@@ -161,7 +161,7 @@ def test_transfer_batch_erc1155(cmd):
if cmd.model == "nanox" or cmd.model == "nanosp":
cmd.set_plugin(plugin=PLUGIN_BATCH)
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION_BATCH)
-
+
cmd.send_apdu(SIGN_FIRST_BATCH)
cmd.send_apdu(SIGN_MORE_1_BATCH)
cmd.send_apdu(SIGN_MORE_2_BATCH)
diff --git a/tests/speculos/test_erc20information.py b/tests/speculos/test_erc20information.py
index 9af2c7b..de01c63 100644
--- a/tests/speculos/test_erc20information.py
+++ b/tests/speculos/test_erc20information.py
@@ -28,4 +28,4 @@ def test_provide_erc20_token_error(cmd):
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
cmd.provide_erc20_token_information(info=erc20_info)
- assert error.args[0] == '0x6a80'
\ No newline at end of file
+ assert error.args[0] == '0x6a80'
diff --git a/tests/speculos/test_erc721.py b/tests/speculos/test_erc721.py
index 8652501..c492f65 100644
--- a/tests/speculos/test_erc721.py
+++ b/tests/speculos/test_erc721.py
@@ -38,7 +38,7 @@ def test_transfer_erc721(cmd):
if cmd.model == "nanox" or cmd.model == "nanosp":
cmd.set_plugin(plugin=PLUGIN)
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
-
+
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
@@ -46,7 +46,7 @@ def test_transfer_erc721(cmd):
# Review transaction
compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00000.png")
cmd.client.press_and_release('right')
-
+
# NFT Transfer
compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00001.png")
cmd.client.press_and_release('right')
@@ -97,7 +97,7 @@ def test_transfer_erc721_without_nft_provide_info(cmd):
pass
assert error.args[0] == '0x6a80'
-
+
def test_transfer_erc721_without_set_plugin(cmd):
@@ -106,10 +106,10 @@ def test_transfer_erc721_without_set_plugin(cmd):
if cmd.model == "nanox" or cmd.model == "nanosp":
with pytest.raises(ethereum_client.exception.errors.DenyError) as error:
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
-
+
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
pass
-
- assert error.args[0] == '0x6985'
\ No newline at end of file
+
+ assert error.args[0] == '0x6985'
diff --git a/tests/speculos/test_pubkey_cmd.py b/tests/speculos/test_pubkey_cmd.py
index 17f1d78..451bbf9 100644
--- a/tests/speculos/test_pubkey_cmd.py
+++ b/tests/speculos/test_pubkey_cmd.py
@@ -92,11 +92,11 @@ def test_reject_get_public_key(cmd):
# Approve
compare_screenshot(cmd, f"screenshots/pubkey/{PATH_IMG[cmd.model]}/reject_get_public_key/00004.png")
cmd.client.press_and_release('right')
-
+
# Reject
compare_screenshot(cmd, f"screenshots/pubkey/{PATH_IMG[cmd.model]}/reject_get_public_key/00005.png")
cmd.client.press_and_release('both')
-
+
if cmd.model == "nanox" or cmd.model == "nanosp":
# Verify address
compare_screenshot(cmd, f"screenshots/pubkey/{PATH_IMG[cmd.model]}/reject_get_public_key/00000.png")
diff --git a/tests/speculos/test_sign_cmd.py b/tests/speculos/test_sign_cmd.py
index 90879ac..5da7ef6 100644
--- a/tests/speculos/test_sign_cmd.py
+++ b/tests/speculos/test_sign_cmd.py
@@ -27,7 +27,7 @@ def test_sign_simple(cmd):
with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5)
-
+
if cmd.model == "nanos":
# Review transaction
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/simple/00000.png")
@@ -87,7 +87,7 @@ def test_sign_simple(cmd):
def test_sign_reject(cmd):
result: list = []
-
+
# Ether coin type
bip32_path="44'/60'/1'/0/0"
@@ -134,7 +134,7 @@ def test_sign_reject(cmd):
# Accept and send
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/reject/00008.png")
cmd.client.press_and_release('right')
-
+
# Reject
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/reject/00009.png")
cmd.client.press_and_release('both')
@@ -169,7 +169,7 @@ def test_sign_reject(cmd):
def test_sign_limit_nonce(cmd):
result: list = []
-
+
# Ether coin type
bip32_path="44'/60'/1'/0/0"
@@ -246,7 +246,7 @@ def test_sign_limit_nonce(cmd):
def test_sign_error_transaction_type(cmd):
result: list = []
-
+
# Ether coin type
bip32_path="44'/60'/1'/0/0"
@@ -311,7 +311,7 @@ def test_sign_nonce_display(cmd):
with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5)
-
+
if cmd.model == "nanos":
# Review transaction
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/nonce_display/00000.png")
@@ -413,7 +413,7 @@ def test_sign_blind_simple(cmd):
with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5)
-
+
if cmd.model == "nanos":
# Review transaction
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/blind_simple/00000.png")
@@ -546,7 +546,7 @@ def test_sign_blind_and_nonce_display(cmd):
with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5)
-
+
if cmd.model == "nanos":
# Review transaction
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/blind_and_nonce_display/00000.png")
diff --git a/tests/unit/.gitignore b/tests/unit/.gitignore
index 2cbee4e..c77e954 100644
--- a/tests/unit/.gitignore
+++ b/tests/unit/.gitignore
@@ -19,4 +19,4 @@ build/
# Coverage file
coverage.info
-coverage
\ No newline at end of file
+coverage
diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt
index 93605b2..3683680 100644
--- a/tests/unit/CMakeLists.txt
+++ b/tests/unit/CMakeLists.txt
@@ -62,4 +62,4 @@ add_library(demo SHARED ./demo_tu.c)
target_link_libraries(test_demo PUBLIC cmocka gcov demo)
-add_test(test_demo test_demo)
\ No newline at end of file
+add_test(test_demo test_demo)
diff --git a/tests/unit/Makefile b/tests/unit/Makefile
index 71d8a14..91d1bfd 100644
--- a/tests/unit/Makefile
+++ b/tests/unit/Makefile
@@ -39,4 +39,4 @@ clean:
@if [ -d coverage ]; then $(ECHO) -e "${RED}[ RM ]${RESET}" coverage && $(RM) -r coverage ; fi;
@if [ -f coverage.info ]; then $(ECHO) -e "${RED}[ RM ]${RESET}" coverage.info && $(RM) -r coverage.info ; fi;
-.PHONY: all coverage clean
\ No newline at end of file
+.PHONY: all coverage clean
diff --git a/tests/unit/README.md b/tests/unit/README.md
index 68a98f2..bb2ab7f 100644
--- a/tests/unit/README.md
+++ b/tests/unit/README.md
@@ -1,7 +1,7 @@
# Unit tests
-It is important to unit test your functions.
-This also allows you to document how your functions work.
+It is important to unit test your functions.
+This also allows you to document how your functions work.
We use the library [**cmocka**](https://cmocka.org/#features)
## Requirement
@@ -9,11 +9,12 @@ We use the library [**cmocka**](https://cmocka.org/#features)
- [CMake >= 3.10](https://cmake.org/download/)
- [lcov >= 1.14](http://ltp.sourceforge.net/coverage/lcov.php)
-Don't worry, you don't necessarily need to install the `cmocka library` because the **cmakelist automatically fetches** the library
+Don't worry, you don't necessarily need to install the `cmocka library`
+because the **cmakelist automatically fetches** the library
## Add new test
-Create new file into `tests` folder and follow [this initiation](https://cmocka.org/talks/cmocka_unit_testing_and_mocking.pdf)
+Create new file into `tests` folder and follow [this initiation](https://cmocka.org/talks/cmocka_unit_testing_and_mocking.pdf)
Now go to the `CMakeLists.txt` file and add your test with the specific file you want to test.
@@ -27,12 +28,15 @@ The `default rules` of makefile will compile the tests and run them.
make
```
-The `coverage rule` will launch the default rules and generate the coverage and you will be **automatically redirected** to the generated .html
+The `coverage rule` will launch the default rules and generate the coverage
+and you will be **automatically redirected** to the generated .html
+
```sh
make coverage
```
The `clean rule` will delete the folders and files generated
+
```sh
make clean
-```
\ No newline at end of file
+```
diff --git a/tests/unit/demo_tu.c b/tests/unit/demo_tu.c
index c4f450c..1287e7c 100644
--- a/tests/unit/demo_tu.c
+++ b/tests/unit/demo_tu.c
@@ -9,4 +9,4 @@ int local_strchr_demo(char *string, char ch) {
}
}
return -1;
-}
\ No newline at end of file
+}
diff --git a/tests/unit/tests/demo.c b/tests/unit/tests/demo.c
index 1da227d..cdc9d9a 100644
--- a/tests/unit/tests/demo.c
+++ b/tests/unit/tests/demo.c
@@ -15,4 +15,4 @@ int main(void) {
cmocka_unit_test(null_test_success),
};
return cmocka_run_group_tests(tests, NULL, NULL);
-}
\ No newline at end of file
+}
diff --git a/tests/zemu/.gitignore b/tests/zemu/.gitignore
index 826d3f0..fedc352 100644
--- a/tests/zemu/.gitignore
+++ b/tests/zemu/.gitignore
@@ -1,4 +1,4 @@
/node_modules
/snapshots-tmp
/elfs
-/lib
\ No newline at end of file
+/lib
diff --git a/tests/zemu/Makefile b/tests/zemu/Makefile
index 82d7706..0ff9a84 100644
--- a/tests/zemu/Makefile
+++ b/tests/zemu/Makefile
@@ -5,4 +5,4 @@ all:
yarn install
yarn test
-.PHONY: all
\ No newline at end of file
+.PHONY: all
diff --git a/tests/zemu/globalsetup.js b/tests/zemu/globalsetup.js
index e835233..ce41bc6 100644
--- a/tests/zemu/globalsetup.js
+++ b/tests/zemu/globalsetup.js
@@ -14,4 +14,4 @@ module.exports = async () => {
await Zemu.checkAndPullImage();
await Zemu.stopAllEmuContainers();
fsExtra.emptyDirSync("snapshots/tmp")
-};
\ No newline at end of file
+};
diff --git a/tests/zemu/jest.config.js b/tests/zemu/jest.config.js
index af09403..63b6051 100644
--- a/tests/zemu/jest.config.js
+++ b/tests/zemu/jest.config.js
@@ -34,6 +34,6 @@ module.exports = {
// Path of the file where tests can be """decorated"""
setupFilesAfterEnv: ['/setupTests.js'],
- // Stop immediatly when a test fail
+ // Stop immediately when a test fail
bail: true,
};
diff --git a/tests/zemu/jest.js b/tests/zemu/jest.js
index 521ecbe..c5156ab 100644
--- a/tests/zemu/jest.js
+++ b/tests/zemu/jest.js
@@ -19,4 +19,4 @@ export const sim_options_x = {
export const Resolve = require("path").resolve;
export const NANOS_ELF_PATH = Resolve("elfs/ethereum_nanos.elf");
-export const NANOX_ELF_PATH = Resolve("elfs/ethereum_nanox.elf");
\ No newline at end of file
+export const NANOX_ELF_PATH = Resolve("elfs/ethereum_nanox.elf");
diff --git a/tests/zemu/setupTests.js b/tests/zemu/setupTests.js
index cbd0230..a9a9f82 100644
--- a/tests/zemu/setupTests.js
+++ b/tests/zemu/setupTests.js
@@ -16,4 +16,4 @@ expect.extend({
}
}
},
- });
\ No newline at end of file
+ });