Skip to content

Commit a647c36

Browse files
Merge pull request #412 from LedgerHQ/feature/apa/ens
Domain names support
2 parents 45c049f + 8decdc9 commit a647c36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1438
-334
lines changed

.github/workflows/ci-workflow.yml

Lines changed: 13 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -166,111 +166,18 @@ jobs:
166166
# =====================================================
167167

168168
build_ragger_elfs:
169-
name: Building binaries for Ragger tests
170-
runs-on: ubuntu-latest
171-
container:
172-
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest
173-
174-
steps:
175-
- name: Clone
176-
uses: actions/checkout@v3
177-
178-
- name: Build test binaries
179-
run: |
180-
make -j BOLOS_SDK=$NANOS_SDK CAL_CI_KEY=1
181-
mv bin/app.elf app-nanos.elf
182-
make clean
183-
make -j BOLOS_SDK=$NANOX_SDK CAL_CI_KEY=1
184-
mv bin/app.elf app-nanox.elf
185-
make clean
186-
make -j BOLOS_SDK=$NANOSP_SDK CAL_CI_KEY=1
187-
mv bin/app.elf app-nanosp.elf
188-
189-
- name: Upload app binaries
190-
uses: actions/upload-artifact@v3
191-
with:
192-
name: ragger_elfs
193-
path: ./app-*.elf
194-
195-
create_ragger_env:
196-
name: Cache Ragger environment
197-
runs-on: ubuntu-latest
198-
199-
steps:
200-
- name: Clone
201-
uses: actions/checkout@v3
202-
203-
- name: APT update
204-
run: |
205-
sudo apt update
206-
207-
- name: Create virtual env with dependencies
208-
run: |
209-
cd tests/ragger
210-
python3 -m venv ./venv
211-
. ./venv/bin/activate
212-
pip3 install --extra-index-url https://test.pypi.org/simple/ -r requirements.txt
213-
# Used for the cache key
214-
echo "py_deps=$(pip freeze | md5sum | cut -d' ' -f1)" >> $GITHUB_ENV
215-
216-
- name: Download QEMU
217-
run: |
218-
sudo apt install --download-only -y qemu-user-static
219-
mkdir -p tests/ragger/packages
220-
cp /var/cache/apt/archives/*.deb tests/ragger/packages/
221-
# Used for the cache key
222-
echo "deb_deps=$(find /var/cache/apt/archives/ -maxdepth 0 -type f -name '*.deb' | md5sum | cut -d' ' -f 1)" >> $GITHUB_ENV
223-
224-
- name: Set up cache
225-
uses: actions/cache@v3
226-
with:
227-
key: ${{ runner.os }}-raggenv-${{ env.py_deps }}-${{ env.deb_deps }}
228-
path: |
229-
tests/ragger/venv/
230-
tests/ragger/packages/
231-
outputs:
232-
py_deps: ${{ env.py_deps }}
233-
deb_deps: ${{ env.deb_deps }}
234-
169+
name: Build app for Ragger tests
170+
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
171+
with:
172+
upload_app_binaries_artifact: "ragger_elfs"
173+
flags: "DEBUG=1 CAL_CI_KEY=1 DOMAIN_NAME_TEST_KEY=1"
174+
run_for_devices: '["nanos", "nanox", "nanosp"]'
235175

236176
jobs-ragger-tests:
237-
name: Ragger tests
238-
strategy:
239-
matrix:
240-
model: ["nanos", "nanox", "nanosp"]
241-
needs: [build_ragger_elfs, create_ragger_env]
242-
runs-on: ubuntu-latest
243-
244-
steps:
245-
- name: Clone
246-
uses: actions/checkout@v3
247-
248-
- name: Download previously built artifacts
249-
uses: actions/download-artifact@v3
250-
with:
251-
name: ragger_elfs
252-
path: tmp/
253-
254-
- name: Put them where they belong
255-
run: |
256-
mkdir -p tests/ragger/elfs
257-
find tmp/ -type f -name '*.elf' -exec cp {} tests/ragger/elfs/ \;
258-
259-
- name: Get cached environment
260-
uses: actions/cache@v3
261-
with:
262-
key: ${{ runner.os }}-raggenv-${{ needs.create_ragger_env.outputs.py_deps }}-${{ needs.create_ragger_env.outputs.deb_deps }}
263-
path: |
264-
tests/ragger/venv/
265-
tests/ragger/packages/
266-
267-
- name: Install QEMU
268-
run: |
269-
sudo mv tests/ragger/packages/*.deb /var/cache/apt/archives/
270-
sudo apt install -y qemu-user-static
271-
272-
- name: Run tests
273-
run: |
274-
cd tests/ragger
275-
. ./venv/bin/activate
276-
pytest --path ./elfs --model ${{ matrix.model }} -s -v --tb=short
177+
name: Run Ragger tests
178+
needs: build_ragger_elfs
179+
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_ragger_tests.yml@v1
180+
with:
181+
download_app_binaries_artifact: "ragger_elfs"
182+
test_dir: tests/ragger
183+
run_for_devices: '["nanos", "nanox", "nanosp"]'

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [1.10.2](https://github.com/ledgerhq/app-ethereum/compare/1.10.1...1.10.2) - 2022-02-09
8+
## [1.10.2](https://github.com/ledgerhq/app-ethereum/compare/1.10.1...1.10.2) - 2023-XX-XX
99

1010
### Added
1111

@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2222
- (network) Velas EVM
2323
- (network) Boba Network
2424
- (network) Energi
25+
- Domain names support (LNX / LNS+)
2526

2627
### Changed
2728

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ APP_LOAD_PARAMS += --path "1517992542'/1101353413'"
3535
APPVERSION_M=1
3636
APPVERSION_N=10
3737
APPVERSION_P=2
38-
APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
38+
APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)-dev
3939
APP_LOAD_FLAGS= --appFlags 0xa40 --dep Ethereum:$(APPVERSION)
4040

4141
###########################
@@ -157,6 +157,15 @@ ifneq ($(CAL_CI_KEY),0)
157157
DEFINES += HAVE_CAL_CI_KEY
158158
endif
159159

160+
# ENS
161+
ifneq ($(TARGET_NAME),TARGET_NANOS)
162+
DEFINES += HAVE_DOMAIN_NAME
163+
DOMAIN_NAME_TEST_KEY:=0
164+
ifneq ($(DOMAIN_NAME_TEST_KEY),0)
165+
DEFINES += HAVE_DOMAIN_NAME_TEST_KEY
166+
endif
167+
endif
168+
160169
# Enabling debug PRINTF
161170
DEBUG:=0
162171
ifneq ($(DEBUG),0)

doc/ethapp.adoc

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ Application version 1.9.19 - 2022-05-17
3838
- Add EIP712 STRUCT DEFINITION & EIP712 STRUCT IMPLEMENTATION
3939
- Update to SIGN ETH EIP712
4040

41+
### 1.10.2
42+
- Add domain names support
43+
4144
## About
4245

4346
This application describes the APDU messages interface to communicate with the Ethereum application.
@@ -881,6 +884,82 @@ _Output data_
881884
None
882885

883886

887+
### GET CHALLENGE
888+
889+
#### Description
890+
891+
Sends a random 32-bit long value. Can prevent replay of signed payloads when the challenge
892+
is included in said payload.
893+
894+
#### Coding
895+
896+
_Command_
897+
898+
[width="80%"]
899+
|=============================================================
900+
| *CLA* | *INS* | *P1* | *P2* | *LC*
901+
| E0 | 20 | 00 | 00 | 00
902+
|=============================================================
903+
904+
_Input data_
905+
906+
None
907+
908+
_Output data_
909+
910+
[width="80%"]
911+
|===========================================
912+
| *Description* | *Length*
913+
| Challenge value (BE) | 4
914+
|===========================================
915+
916+
917+
### PROVIDE DOMAIN NAME
918+
919+
#### Description
920+
921+
This command provides a domain name (like ENS) to be displayed during transactions in place of the address it is associated to.
922+
It shall be run just before a transaction involving the associated address that would be displayed on the device.
923+
924+
The signature is computed on the TLV payload (minus the signature obviously).
925+
926+
#### Coding
927+
928+
_Command_
929+
930+
[width="80%"]
931+
|==============================================================
932+
| *CLA* | *INS* | *P1* | *P2* | *LC*
933+
| E0 | 22 | 01 : first chunk
934+
935+
00 : following chunk
936+
| 00 | 00
937+
|==============================================================
938+
939+
_Input data_
940+
941+
##### If P1 == first chunk
942+
943+
[width="80%"]
944+
|==========================================
945+
| *Description* | *Length (byte)*
946+
| Payload length | 2
947+
| TLV payload | variable
948+
|==========================================
949+
950+
##### If P1 == following chunk
951+
952+
[width="80%"]
953+
|==========================================
954+
| *Description* | *Length (byte)*
955+
| TLV payload | variable
956+
|==========================================
957+
958+
_Output data_
959+
960+
None
961+
962+
884963
## Transport protocol
885964

886965
### General transport description

src/apdu_constants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#define INS_EIP712_STRUCT_DEF 0x1A
2525
#define INS_EIP712_STRUCT_IMPL 0x1C
2626
#define INS_EIP712_FILTERING 0x1E
27+
#define INS_ENS_GET_CHALLENGE 0x20
28+
#define INS_ENS_PROVIDE_INFO 0x22
2729
#define P1_CONFIRM 0x01
2830
#define P1_NON_CONFIRM 0x00
2931
#define P2_NO_CHAINCODE 0x00

src/main.c

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "handle_get_printable_amount.h"
3030
#include "handle_check_address.h"
3131
#include "commands_712.h"
32+
#include "challenge.h"
33+
#include "domain_name.h"
3234

3335
#ifdef HAVE_STARKWARE
3436
#include "stark_crypto.h"
@@ -749,6 +751,19 @@ void handleApdu(unsigned int *flags, unsigned int *tx) {
749751
break;
750752
#endif // HAVE_EIP712_FULL_SUPPORT
751753

754+
#ifdef HAVE_DOMAIN_NAME
755+
case INS_ENS_GET_CHALLENGE:
756+
handle_get_challenge();
757+
break;
758+
759+
case INS_ENS_PROVIDE_INFO:
760+
handle_provide_domain_name(G_io_apdu_buffer[OFFSET_P1],
761+
G_io_apdu_buffer[OFFSET_P2],
762+
G_io_apdu_buffer + OFFSET_CDATA,
763+
G_io_apdu_buffer[OFFSET_LC]);
764+
break;
765+
#endif // HAVE_DOMAIN_NAME
766+
752767
#if 0
753768
case 0xFF: // return to dashboard
754769
goto return_to_dashboard;
@@ -954,19 +969,22 @@ void coin_main(chain_config_t *coin_config) {
954969
G_io_app.plane_mode = os_setting_get(OS_SETTING_PLANEMODE, NULL, 0);
955970
#endif // TARGET_NANOX
956971

957-
if (N_storage.initialized != 0x01) {
972+
if (!N_storage.initialized) {
958973
internalStorage_t storage;
959974
#ifdef HAVE_ALLOW_DATA
960-
storage.dataAllowed = 0x01;
975+
storage.dataAllowed = true;
961976
#else
962-
storage.dataAllowed = 0x00;
977+
storage.dataAllowed = false;
963978
#endif
964-
storage.contractDetails = 0x00;
965-
storage.displayNonce = 0x00;
979+
storage.contractDetails = false;
980+
storage.displayNonce = false;
966981
#ifdef HAVE_EIP712_FULL_SUPPORT
967-
storage.verbose_eip712 = 0x00;
982+
storage.verbose_eip712 = false;
983+
#endif
984+
#ifdef HAVE_DOMAIN_NAME
985+
storage.verbose_domain_name = false;
968986
#endif
969-
storage.initialized = 0x01;
987+
storage.initialized = true;
970988
nvm_write((void *) &N_storage, (void *) &storage, sizeof(internalStorage_t));
971989
}
972990

@@ -980,6 +998,11 @@ void coin_main(chain_config_t *coin_config) {
980998
BLE_power(1, "Nano X");
981999
#endif // HAVE_BLE
9821000

1001+
#ifdef HAVE_DOMAIN_NAME
1002+
// to prevent it from having a fixed value at boot
1003+
roll_challenge();
1004+
#endif // HAVE_DOMAIN_NAME
1005+
9831006
app_main();
9841007
}
9851008
CATCH(EXCEPTION_IO_RESET) {

src/shared_context.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ typedef struct bip32_path_t {
2424
} bip32_path_t;
2525

2626
typedef struct internalStorage_t {
27-
unsigned char dataAllowed;
28-
unsigned char contractDetails;
29-
unsigned char displayNonce;
27+
bool dataAllowed;
28+
bool contractDetails;
29+
bool displayNonce;
3030
#ifdef HAVE_EIP712_FULL_SUPPORT
3131
bool verbose_eip712;
3232
#endif // HAVE_EIP712_FULL_SUPPORT
33-
uint8_t initialized;
33+
#ifdef HAVE_DOMAIN_NAME
34+
bool verbose_domain_name;
35+
#endif // HAVE_DOMAIN_NAME
36+
bool initialized;
3437
} internalStorage_t;
3538

3639
#ifdef HAVE_STARKWARE

src_bagl/ui_domain_name.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifdef HAVE_DOMAIN_NAME
2+
3+
#include "ux.h"
4+
#include "domain_name.h"
5+
6+
//////////////////////////////////////////////////////////////////////
7+
// clang-format off
8+
UX_STEP_NOCB(
9+
ux_domain_name_step,
10+
bnnn_paging,
11+
{
12+
.title = "Domain",
13+
.text = g_domain_name
14+
});
15+
// clang-format on
16+
17+
#endif // HAVE_DOMAIN_NAME

src_bagl/ui_domain_name.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifdef HAVE_DOMAIN_NAME
2+
3+
#ifndef UI_DOMAIN_NAME_H_
4+
#define UI_DOMAIN_NAME_H_
5+
6+
#include "ux.h"
7+
8+
extern const ux_flow_step_t ux_domain_name_step;
9+
10+
#endif // UI_DOMAIN_NAME_H_
11+
12+
#endif // HAVE_DOMAIN_NAME

0 commit comments

Comments
 (0)