Merge pull request #551 from LedgerHQ/cev/B2CA-1247_guideline-enforcer
B2CA-1247: Fix deprecated warnings
7
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -19,8 +19,8 @@ Describe your issue in as much detail as possible here.
|
||||
|
||||
## Steps to reproduce
|
||||
|
||||
* Tell us how to reproduce this issue <br />
|
||||
* Where the issue is, if you know <br />
|
||||
* 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
|
||||
If you have an idea of how to fix this issue, please write it down here,
|
||||
so we can begin discussing it
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -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: ''
|
||||
|
||||
15
.github/ISSUE_TEMPLATE/network_request.md
vendored
@@ -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.
|
||||
Please post additional comments in this section if you have them, otherwise delete it.
|
||||
|
||||
4
.github/pull_request_template.md
vendored
@@ -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.
|
||||
Please post additional comments in this section if you have them, otherwise delete it.
|
||||
|
||||
15
.github/workflows/auto-author-assign.yml
vendored
@@ -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
|
||||
33
.github/workflows/build_and_functional_tests.yml
vendored
Normal file
@@ -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"
|
||||
90
.github/workflows/ci-workflow.yml
vendored
@@ -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
|
||||
|
||||
44
.github/workflows/codeql_checks.yml
vendored
Normal file
@@ -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
|
||||
23
.github/workflows/guidelines_enforcer.yml
vendored
Normal file
@@ -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
|
||||
6
.github/workflows/pr_on_all_plugins.yml
vendored
@@ -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.
|
||||
|
||||
6
.github/workflows/python-client.yml
vendored
@@ -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
|
||||
|
||||
|
||||
2
.github/workflows/sdk-generation.yml
vendored
@@ -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
|
||||
|
||||
7
.gitignore
vendored
@@ -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
|
||||
.idea
|
||||
|
||||
@@ -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
|
||||
|
||||
8
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
|
||||
|
||||
72
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)
|
||||
|
||||
|
||||
</details>
|
||||
|
||||
## 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`.
|
||||
|
||||
|
||||
@@ -48,4 +48,4 @@ Home = "https://github.com/LedgerHQ/app-ethereum"
|
||||
ignore_missing_imports = true
|
||||
|
||||
[tool.flake8]
|
||||
max-line-length = 120
|
||||
max-line-length = 120
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 :
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
Before Width: | Height: | Size: 718 B After Width: | Height: | Size: 748 B |
|
Before Width: | Height: | Size: 725 B After Width: | Height: | Size: 825 B |
|
Before Width: | Height: | Size: 880 B After Width: | Height: | Size: 910 B |
|
Before Width: | Height: | Size: 836 B After Width: | Height: | Size: 866 B |
|
Before Width: | Height: | Size: 836 B After Width: | Height: | Size: 866 B |
|
Before Width: | Height: | Size: 561 B After Width: | Height: | Size: 591 B |
|
Before Width: | Height: | Size: 836 B After Width: | Height: | Size: 866 B |
|
Before Width: | Height: | Size: 70 B After Width: | Height: | Size: 70 B |
|
Before Width: | Height: | Size: 73 B After Width: | Height: | Size: 73 B |
|
Before Width: | Height: | Size: 73 B After Width: | Height: | Size: 73 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
BIN
icons/nanos_app_chain_246.gif
Normal file
|
After Width: | Height: | Size: 114 B |
|
Before Width: | Height: | Size: 79 B After Width: | Height: | Size: 79 B |
|
Before Width: | Height: | Size: 67 B After Width: | Height: | Size: 67 B |
|
Before Width: | Height: | Size: 67 B After Width: | Height: | Size: 67 B |
|
Before Width: | Height: | Size: 73 B After Width: | Height: | Size: 73 B |
|
Before Width: | Height: | Size: 81 B After Width: | Height: | Size: 75 B |
|
Before Width: | Height: | Size: 57 B After Width: | Height: | Size: 65 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 98 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 98 B |
BIN
icons/nanox_app_chain_246.gif
Normal file
|
After Width: | Height: | Size: 106 B |
|
Before Width: | Height: | Size: 76 B After Width: | Height: | Size: 76 B |
|
Before Width: | Height: | Size: 78 B After Width: | Height: | Size: 78 B |
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/200625'"
|
||||
TICKER = "AKA"
|
||||
CHAIN_ID = 200625
|
||||
APPNAME = "Akroma"
|
||||
APPNAME = "Akroma"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/246529'"
|
||||
TICKER = "ATS"
|
||||
CHAIN_ID = 246529
|
||||
APPNAME = "ARTIS sigma1"
|
||||
APPNAME = "ARTIS sigma1"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/246785'"
|
||||
TICKER = "ATS"
|
||||
CHAIN_ID = 246785
|
||||
APPNAME = "ARTIS tau1"
|
||||
APPNAME = "ARTIS tau1"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/1620'"
|
||||
TICKER = "ATH"
|
||||
CHAIN_ID = 1620
|
||||
APPNAME = "Atheios"
|
||||
APPNAME = "Atheios"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
TICKER = "BNB"
|
||||
CHAIN_ID = 56
|
||||
APPNAME = "Binance Smart Chain"
|
||||
APPNAME = "Binance Smart Chain"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
TICKER = "BTT"
|
||||
CHAIN_ID = 199
|
||||
APPNAME = "BTTC"
|
||||
APPNAME = "BTTC"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/820'"
|
||||
TICKER = "CLO"
|
||||
CHAIN_ID = 820
|
||||
APPNAME = "Callisto"
|
||||
APPNAME = "Callisto"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
TICKER = "CFX"
|
||||
CHAIN_ID = 1030
|
||||
APPNAME = "Conflux eSpace"
|
||||
APPNAME = "Conflux eSpace"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
TICKER = "CUBE"
|
||||
CHAIN_ID = 1818
|
||||
APPNAME = "Cube"
|
||||
APPNAME = "Cube"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/237'"
|
||||
TICKER = "DXN"
|
||||
CHAIN_ID = 237
|
||||
APPNAME = "DEXON"
|
||||
APPNAME = "DEXON"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/163'"
|
||||
TICKER = "ELLA"
|
||||
CHAIN_ID = 64
|
||||
APPNAME = "Ellaism"
|
||||
APPNAME = "Ellaism"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/1313114'"
|
||||
TICKER = "ETHO"
|
||||
CHAIN_ID = 1313114
|
||||
APPNAME = "Ether-1"
|
||||
APPNAME = "Ether-1"
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/61'" --path "44'/60'"
|
||||
TICKER = "ETC"
|
||||
CHAIN_ID = 61
|
||||
APPNAME = "Ethereum Classic"
|
||||
APPNAME = "Ethereum Classic"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/1987'"
|
||||
TICKER = "EGEM"
|
||||
CHAIN_ID = 1987
|
||||
APPNAME = "EtherGem"
|
||||
APPNAME = "EtherGem"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/31102'"
|
||||
TICKER = "ESN"
|
||||
CHAIN_ID = 31102
|
||||
APPNAME = "Ethersocial"
|
||||
APPNAME = "Ethersocial"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/40'"
|
||||
TICKER = "EXP"
|
||||
CHAIN_ID = 2
|
||||
APPNAME = "Expanse"
|
||||
APPNAME = "Expanse"
|
||||
|
||||
@@ -6,4 +6,4 @@ CHAIN_ID = 14
|
||||
APP_LOAD_PARAMS += --tlvraw 9F:01
|
||||
DEFINES += HAVE_PENDING_REVIEW_SCREEN
|
||||
|
||||
APPNAME = "Flare"
|
||||
APPNAME = "Flare"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
|
||||
TICKER = "FLR"
|
||||
CHAIN_ID = 16
|
||||
APPNAME = "Flare Coston"
|
||||
APPNAME = "Flare Coston"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/6060'"
|
||||
TICKER = "GO"
|
||||
CHAIN_ID = 60
|
||||
APPNAME = "GoChain"
|
||||
APPNAME = "GoChain"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/269'"
|
||||
TICKER = "HPB"
|
||||
CHAIN_ID = 269
|
||||
APPNAME = "HPB"
|
||||
APPNAME = "HPB"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
TICKER = "KAI"
|
||||
CHAIN_ID = 24
|
||||
APPNAME = "KardiaChain"
|
||||
APPNAME = "KardiaChain"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
TICKER = "MTR"
|
||||
CHAIN_ID = 82
|
||||
APPNAME = "Meter"
|
||||
APPNAME = "Meter"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/76'"
|
||||
TICKER = "MIX"
|
||||
CHAIN_ID = 76
|
||||
APPNAME = "Mix"
|
||||
APPNAME = "Mix"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'" --path "44'/1284'"
|
||||
TICKER = "GLMR"
|
||||
CHAIN_ID = 1284
|
||||
APPNAME = "Moonbeam"
|
||||
APPNAME = "Moonbeam"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'" --path "44'/1285'"
|
||||
TICKER = "MOVR"
|
||||
CHAIN_ID = 1285
|
||||
APPNAME = "Moonriver"
|
||||
APPNAME = "Moonriver"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/184'"
|
||||
TICKER = "MUSIC"
|
||||
CHAIN_ID = 7762959
|
||||
APPNAME = "Musicoin"
|
||||
APPNAME = "Musicoin"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
TICKER = "OKT"
|
||||
CHAIN_ID = 66
|
||||
APPNAME = "OKXChain"
|
||||
APPNAME = "OKXChain"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/164'"
|
||||
TICKER = "PIRL"
|
||||
CHAIN_ID = 3125659152
|
||||
APPNAME = "Pirl"
|
||||
APPNAME = "Pirl"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
TICKER = "POA"
|
||||
CHAIN_ID = 99
|
||||
APPNAME = "POA"
|
||||
APPNAME = "POA"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
TICKER = "MATIC"
|
||||
CHAIN_ID = 137
|
||||
APPNAME = "Polygon"
|
||||
APPNAME = "Polygon"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/2894'"
|
||||
TICKER = "REOSC"
|
||||
CHAIN_ID = 2894
|
||||
APPNAME = "REOSC"
|
||||
APPNAME = "REOSC"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/137'" --path "44'/00'"
|
||||
TICKER = "RBTC"
|
||||
CHAIN_ID = 30
|
||||
APPNAME = "RSK"
|
||||
APPNAME = "RSK"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/37310'"
|
||||
TICKER = "RBTC"
|
||||
CHAIN_ID = 31
|
||||
APPNAME = "RSK Test"
|
||||
APPNAME = "RSK Test"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
TICKER = "SHFT"
|
||||
CHAIN_ID = 7341
|
||||
APPNAME = "Shyft"
|
||||
APPNAME = "Shyft"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
|
||||
TICKER = "SGB"
|
||||
CHAIN_ID = 19
|
||||
APPNAME = "Songbird"
|
||||
APPNAME = "Songbird"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
|
||||
TICKER = "TCR"
|
||||
CHAIN_ID = 20531812
|
||||
APPNAME = "TecraCoin"
|
||||
APPNAME = "TecraCoin"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
|
||||
TICKER = "TCR"
|
||||
CHAIN_ID = 20531811
|
||||
APPNAME = "TecraTestnet"
|
||||
APPNAME = "TecraTestnet"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/1001'"
|
||||
TICKER = "TT"
|
||||
CHAIN_ID = 108
|
||||
APPNAME = "ThunderCore"
|
||||
APPNAME = "ThunderCore"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/889'"
|
||||
TICKER = "TOMO"
|
||||
CHAIN_ID = 88
|
||||
APPNAME = "TomoChain"
|
||||
APPNAME = "TomoChain"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/108'"
|
||||
TICKER = "UBQ"
|
||||
CHAIN_ID = 8
|
||||
APPNAME = "Ubiq"
|
||||
APPNAME = "Ubiq"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/73799'" --path "44'/60'"
|
||||
TICKER = "VOLTA"
|
||||
CHAIN_ID = 73799
|
||||
APPNAME = "Volta"
|
||||
APPNAME = "Volta"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/227'"
|
||||
TICKER = "WEB"
|
||||
CHAIN_ID = 24484
|
||||
APPNAME = "Webchain"
|
||||
APPNAME = "Webchain"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/77777'"
|
||||
TICKER = "ZYN"
|
||||
CHAIN_ID = 78
|
||||
APPNAME = "Wethio"
|
||||
APPNAME = "Wethio"
|
||||
|
||||
@@ -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 };
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
42
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -37,4 +37,4 @@ void plugin_ui_get_item(void) {
|
||||
sizeof(strings.common.fullAddress),
|
||||
strings.common.fullAmount,
|
||||
sizeof(strings.common.fullAmount));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_
|
||||
#endif // _PLUGIN_H_
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
{
|
||||
|
||||