Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stax/flex support #19

Merged
merged 56 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
5cc906e
Remove nanos
steel97 Oct 8, 2024
4faa896
NBGL
steel97 Oct 8, 2024
df02421
More UI
steel97 Oct 9, 2024
d544f01
Cleanup
steel97 Oct 9, 2024
e5285ab
Lint
steel97 Oct 9, 2024
483d757
Attempt to fix lint workflow
steel97 Oct 9, 2024
8ecbe68
Workflow fix attempt
steel97 Oct 9, 2024
0357e13
Fix
steel97 Oct 9, 2024
33b892c
Removed SDK parameter from speculos run
steel97 Oct 9, 2024
9f203a6
Fix
steel97 Oct 9, 2024
5d69e8a
Added flex and stax to test
steel97 Oct 9, 2024
9559fc1
Sign tx initial work
steel97 Oct 10, 2024
9bd5077
Application id test
steel97 Oct 10, 2024
bf83d8e
Tx sign flow
steel97 Oct 10, 2024
9802ad5
Fixed NanoSP
steel97 Oct 10, 2024
35d7f6e
Fix tests
steel97 Oct 10, 2024
9c6f953
UI fixes, token/amount display
steel97 Oct 13, 2024
1b0ff7b
Revert
steel97 Oct 13, 2024
f864aeb
Lint
steel97 Oct 13, 2024
e71fc09
Removed unused code, workflow improvements
steel97 Oct 13, 2024
2559664
Fix attempt (enable clang analyzer for nanosp/stax)
steel97 Oct 13, 2024
a0339ae
Fix warnings
steel97 Oct 13, 2024
ccb3ccb
Cleanup includes, minor refactoring
steel97 Oct 13, 2024
92c5dc9
Application display where required
steel97 Oct 13, 2024
ee9d671
Bump version
steel97 Oct 13, 2024
7cad844
Cut buffer to required memory size
steel97 Oct 13, 2024
5030da6
Revert unit-tests formatting
steel97 Oct 14, 2024
52cf579
Fixed icon size
steel97 Oct 14, 2024
23e2b9e
Removed unused code
steel97 Oct 14, 2024
c61262c
Updated changelog
steel97 Oct 14, 2024
2c6117c
Cleanup
steel97 Oct 14, 2024
68cd1d9
Update CHANGELOG.md
steel97 Oct 16, 2024
b2696bf
Fix changelog
steel97 Oct 16, 2024
a194cd8
Set TOKEN_MAX_COUNT to 100
steel97 Oct 16, 2024
c9af358
Updated UI to support more tokens
steel97 Oct 16, 2024
41d03a9
Add required app permissions
steel97 Oct 16, 2024
5b0ce37
Revert permissions
steel97 Oct 16, 2024
83dd516
Dynamic UI allocation
steel97 Oct 16, 2024
7422510
Fix tx fee display
steel97 Oct 16, 2024
2362b65
Remove TARGET_NANOS check
steel97 Oct 17, 2024
42c5b01
Unify bagl/nbgl shared code
steel97 Oct 17, 2024
e84fade
Remove is_ui_nbgl_busy from state
steel97 Oct 17, 2024
7f336f5
Show bip32 path on da ui
steel97 Oct 17, 2024
dace382
Move ui_stx_display_output_state and ui_stx_display_tx_state to stx_…
steel97 Oct 17, 2024
ae5646c
Do not show application id if it's zero
steel97 Oct 18, 2024
46aac69
Rework da_ui (single screen)
steel97 Oct 18, 2024
7ca5ca9
Fix
steel97 Oct 18, 2024
22ffb41
Reject/confirm notification UI
steel97 Oct 18, 2024
b1f4350
Change review status type
steel97 Oct 18, 2024
c84b1b8
Change sign tx icon to app logo
steel97 Oct 18, 2024
7903614
Reworked streaming ui to allow back button in certain cases
steel97 Oct 18, 2024
e19d4b4
CLang warning fix
steel97 Oct 18, 2024
ce1b6e1
Lint
steel97 Oct 18, 2024
b31060f
Fix: do not show app id if it's zero (bagl)
steel97 Oct 18, 2024
e2766d7
Fix test
steel97 Oct 18, 2024
fd44e8b
Fixed pk display on da/epk screens
steel97 Oct 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ on: [push, pull_request]

jobs:
job_build_nano_debug:
name: Build application for NanoS, X and S+
name: Build application for NanoS+, X, Stax, Flex
runs-on: ubuntu-latest
strategy:
matrix:
include:
- SDK: "$NANOS_SDK"
artifact: ergo-app-debug-nanos
- SDK: "$NANOX_SDK"
artifact: ergo-app-debug-nanox
- SDK: "$NANOSP_SDK"
artifact: ergo-app-debug-nanosp
- SDK: "$STAX_SDK"
artifact: ergo-app-debug-stax
- SDK: "$FLEX_SDK"
artifact: ergo-app-debug-flex

container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest
Expand Down Expand Up @@ -102,6 +104,11 @@ jobs:
job_scan_build:
name: Clang Static Analyzer
runs-on: ubuntu-latest
strategy:
matrix:
include:
- SDK: "$NANOSP_SDK"
- SDK: "$STAX_SDK"

container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest
Expand All @@ -112,6 +119,7 @@ jobs:

- name: Build with Clang Static Analyzer
run: |
export BOLOS_SDK=${{ matrix.SDK }}
make clean
scan-build --use-cc=clang -analyze-headers -enable-checker security -enable-checker unix -enable-checker valist -o scan-build --status-bugs make default

Expand All @@ -128,12 +136,10 @@ jobs:
strategy:
matrix:
include:
- model: nanos
SDK: "2.1"
# - model: nanox
# SDK: "2.0.2"
# - model: nanosp
# SDK: "1.0.4"
- model: nanox
- model: nanosp
#- model: stax
#- model: flex

needs: job_build_nano_debug
runs-on: ubuntu-latest
Expand Down Expand Up @@ -161,13 +167,13 @@ jobs:
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt-get install -qy nodejs
export SEED=`cat tests/seed.txt`
nohup bash -c "python /speculos/speculos.py bin/app.elf --apdu-port 9999 --api-port 5000 --display headless --model=${{ matrix.model }} --sdk=${{ matrix.SDK }} --seed \"${SEED}\"" > speculos.log 2<&1 &
nohup bash -c "python /speculos/speculos.py bin/app.elf --apdu-port 9999 --api-port 5000 --display headless --model=${{ matrix.model }} --seed \"${SEED}\"" > speculos.log 2<&1 &
cd tests && npm install
until `nc -w5 -z -v 127.0.0.1 9999`; do sleep 1; done;
npm --model=${{matrix.model}} --port=5000 run test

- name: Upload Speculos log
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: speculos-${{matrix.model}}-log
path: speculos.log
2 changes: 1 addition & 1 deletion .github/workflows/lint-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: actions/checkout@v4

- name: Lint
uses: DoozyX/clang-format-lint-action@v0.12
uses: DoozyX/clang-format-lint-action@v0.18.2
with:
source: './src'
extensions: 'h,c'
Expand Down
14 changes: 8 additions & 6 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
{
"env": {
"BOLOS_SDK": "~/.ledger/nanos-sdk",
"BOLOS_SDK": "~/.ledger/nanosplus-sdk",
"ARM_GCC": "~/.ledger/gcc-arm-none-eabi-13.2-2023.10"
},
"configurations": [
{
"name": "Nano S",
"name": "Nano S+",
"includePath": [
"${workspaceFolder}/src",
"${workspaceFolder}/build/nanos/gen_src",
"${workspaceFolder}/build/stax/gen_src",
"${env:ARM_GCC}/arm-none-eabi/include/*",
"${env:ARM_GCC}/lib/gcc/arm-none-eabi/13.2.1/include/*",
"${env:BOLOS_SDK}/include/*",
"${env:BOLOS_SDK}/lib_ux/include/*",
"${env:BOLOS_SDK}/lib_nbgl/include/*",
"${env:BOLOS_SDK}/lib_cxng/include/*",
"${env:BOLOS_SDK}/lib_standard_app/*"
],
"defines": [
"TARGET_NANOS",
"TARGET_NANOS2",
"OS_IO_SEPROXYHAL",
"HAVE_BAGL",
"HAVE_NBGL",
"HAVE_SE_TOUCH",
"HAVE_ECC",
"HAVE_ECC_WEIERSTRASS",
"HAVE_SECP_CURVES",
Expand Down Expand Up @@ -50,7 +52,7 @@
"PRINTF=screen_printf",
"_DEFAULT_SOURCE"
],
"compilerPath": "${env:ARM_GCC}/bin/arm-none-eabi-gcc",
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-arm",
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.6] - 2024-06-10

- Added Stax/Flex
- Removed Nano S

## [0.0.5] - 2024-06-10

- Updated to the latest Ledger SDK
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ APPNAME = "Ergo"
# Application version
APPVERSION_M = 0
APPVERSION_N = 0
APPVERSION_P = 5
APPVERSION_P = 6
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

# Application source files
APP_SOURCE_PATH += src

# Application icons following guidelines:
# https://developers.ledger.com/docs/embedded-app/design-requirements/#device-icon
ICON_NANOS = icons/app_16px.gif
ICON_NANOX = icons/app_14px.gif
ICON_NANOSP = icons/app_14px.gif
#ICON_STAX = icons/app_32px.gif
ICON_STAX = icons/app_32px.gif
ICON_FLEX = icons/app_40px.gif

# Application allowed derivation curves.
# Possibles curves are: secp256k1, secp256r1, ed25519 and bls12381g1
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ledger Ergo Application

This is a Ergo application for the Ledger Nano S/X.
This is a Ergo application for the Ledger Nano S+/X/Stax/Flex.

## Prerequisite

Expand All @@ -15,7 +15,7 @@ BOLOS_ENV=/opt/bolos-devenv
and do the same with `BOLOS_SDK` environment variable

```
BOLOS_SDK=/opt/bolos-sdk/nanos-secure-sdk
BOLOS_SDK=/opt/bolos-sdk/nanosplus-secure-sdk
```

## Compilation
Expand All @@ -42,7 +42,7 @@ the process outputs HTML and LaTeX documentations in `doc/html` and `doc/latex`
The flow processed in [GitHub Actions](https://github.com/features/actions) is the following:

- Code formatting with [clang-format](http://clang.llvm.org/docs/ClangFormat.html)
- Compilation of the application for Ledger Nano S in [ledger-app-builder](https://github.com/LedgerHQ/ledger-app-builder)
- Compilation of the application for Ledger Nano S+ in [ledger-app-builder](https://github.com/LedgerHQ/ledger-app-builder)
- Unit tests of C functions with [cmocka](https://cmocka.org/) (see [unit-tests/](unit-tests/))
- End-to-end tests with [Speculos](https://github.com/LedgerHQ/speculos) emulator (see [tests/](tests/))
- Code coverage with [gcov](https://gcc.gnu.org/onlinedocs/gcc/Gcov.html)/[lcov](http://ltp.sourceforge.net/coverage/lcov.php) and upload to [codecov.io](https://about.codecov.io)
Expand Down
File renamed without changes
Binary file added glyphs/app_logo_64px.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/app_32px.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/app_40px.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ledger_app.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[app]
build_directory = "./"
sdk = "C"
devices = ["nanos", "nanox", "nanos+"]
devices = ["nanox", "nanos+", "stax", "flex"]

[tests]
unit_directory = "./unit-tests/"
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifdef HAVE_BAGL

#include <os.h>
#include <ux.h>
#include <glyphs.h>
Expand Down Expand Up @@ -48,4 +50,6 @@ int ui_display_access_token(uint32_t app_access_token, attest_input_ctx_t* conte
ui_display_screens(&screen);

return 0;
}
}

#endif
57 changes: 57 additions & 0 deletions src/commands/attestinput/ainpt_ui_nbgl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#ifdef HAVE_NBGL

#include <os.h>
#include <nbgl_use_case.h>
#include <string.h>
#include <glyphs.h>

#include "ainpt_ui.h"
#include "ainpt_response.h"
#include "../../context.h"
#include "../../common/macros_ext.h"
#include "../../helpers/response.h"
#include "../../ui/ui_application_id.h"
#include "../../ui/ui_menu.h"
#include "../../ui/ui_main.h"
#include "../../ui/display.h"

#define APPLICATION_ID_SUBLEN APPLICATION_ID_STR_LEN + 13
static char sub_message[APPLICATION_ID_SUBLEN];

void ui_action_attest_input(bool approved) {
set_flow_response(approved);
}

int ui_display_access_token(uint32_t app_access_token, attest_input_ctx_t* context) {
context->ui.app_token_value = app_access_token;

if (app_access_token != 0) {
ui_application_id_screen(app_access_token, context->ui.app_token);
memset(sub_message, 0, APPLICATION_ID_SUBLEN);
snprintf(sub_message, APPLICATION_ID_SUBLEN, "Application: 0x%08x", app_access_token);
}

nbgl_useCaseChoice(&VALIDATE_ICON,
"Confirm Attest Input",
sub_message,
"Confirm",
"Reject",
ui_action_attest_input);
bool approved = io_ui_process();

if (approved) {
app_set_connected_app_id(context->ui.app_token_value);
context->state = ATTEST_INPUT_STATE_APPROVED;
send_response_attested_input_session_id(context->session);

} else {
app_set_current_command(CMD_NONE);
res_deny();

ui_menu_main();
}

return 0;
}

#endif
9 changes: 8 additions & 1 deletion src/commands/deriveaddress/da_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <stdbool.h> // bool
#include "da_context.h"
#include "../../constants.h"
#include "../../context.h"
#include "../../helpers/response.h"

/**
* Display account on the device and ask confirmation to export.
Expand All @@ -16,4 +18,9 @@ int ui_display_address(derive_address_ctx_t* ctx,
uint32_t app_access_token,
uint32_t* bip32_path,
uint8_t bip32_path_len,
uint8_t raw_address[static P2PK_ADDRESS_LEN]);
uint8_t raw_address[static P2PK_ADDRESS_LEN]);

static inline int send_error(uint16_t err) {
app_set_current_command(CMD_NONE);
return res_error(err);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifdef HAVE_BAGL

#include <os.h>
#include <ux.h>
#include <glyphs.h>
Expand Down Expand Up @@ -49,11 +51,6 @@ static NOINLINE void ui_action_derive_address(bool approved, void* context) {
ui_menu_main();
}

static inline int send_error(uint16_t err) {
app_set_current_command(CMD_NONE);
return res_error(err);
}

// Display
int ui_display_address(derive_address_ctx_t* ctx,
bool send,
Expand Down Expand Up @@ -117,3 +114,5 @@ int ui_display_address(derive_address_ctx_t* ctx,

return 0;
}

#endif
Loading
Loading