Skip to content

Commit 87b53e3

Browse files
authored
Remove msg prefix (#32)
* Remove prefix from sign_msg * Sign_msg snapshots * Bump Version * Upgrade ledger-mina dependency on zemu tests * Use standard Makefile * New Snapshots (qr disabled) * ragger tests snapshots * Fix ragger version
1 parent 025e2f0 commit 87b53e3

File tree

64 files changed

+56
-159
lines changed

Some content is hidden

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

64 files changed

+56
-159
lines changed

Makefile

Lines changed: 39 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,49 @@
1818
ifeq ($(BOLOS_SDK),)
1919
$(error Environment variable BOLOS_SDK is not set)
2020
endif
21-
include $(BOLOS_SDK)/Makefile.defines
2221

23-
APP_LOAD_PARAMS= --path "44'/12586'" --curve secp256k1 --appFlags 0x200 $(COMMON_LOAD_PARAMS)
22+
ifndef COIN
23+
COIN=mina
24+
endif
25+
26+
VARIANT_PARAM=COIN
27+
VARIANT_VALUES=$(COIN)
2428

2529
# Add and push a new git tag to update the app version
2630
GIT_DESCRIBE=$(shell git describe --tags --abbrev=8 --always --long --dirty 2>/dev/null)
2731
VERSION_TAG=$(shell echo $(GIT_DESCRIBE) | sed 's/^v//g')
2832
APPVERSION_M=1
2933
APPVERSION_N=4
30-
APPVERSION_P=3
34+
APPVERSION_P=4
3135
APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
3236
APPNAME = "Mina"
3337

34-
DEFINES += $(DEFINES_LIB) $(USER_DEFINES)
35-
36-
ifeq ($(TARGET_NAME),TARGET_NANOS)
37-
ICONNAME=icons/nanos_app_mina.gif
38-
else ifeq ($(TARGET_NAME),TARGET_STAX)
39-
ICONNAME=icons/stax_app_mina.gif
40-
else ifeq ($(TARGET_NAME),TARGET_FLEX)
41-
ICONNAME=icons/flex_app_mina.gif
42-
else
43-
ICONNAME=icons/nanox_app_mina.gif
44-
endif
38+
#APP_LOAD_PARAMS= --path "44'/12586'" --curve secp256k1 --appFlags 0x200 $(COMMON_LOAD_PARAMS)
39+
# Application allowed derivation curves.
40+
# Possibles curves are: secp256k1, secp256r1, ed25519 and bls12381g1
41+
# If your app needs it, you can specify multiple curves by using:
42+
# `CURVE_APP_LOAD_PARAMS = <curve1> <curve2>`
43+
CURVE_APP_LOAD_PARAMS = secp256k1
44+
45+
# Application allowed derivation paths.
46+
# You should request a specific path for your app.
47+
# This serve as an isolation mechanism.
48+
# Most application will have to request a path according to the BIP-0044
49+
# and SLIP-0044 standards.
50+
# If your app needs it, you can specify multiple path by using:
51+
# `PATH_APP_LOAD_PARAMS = "44'/1'" "45'/1'"`
52+
53+
APPPATH = "44'/12586'"
54+
$(info PATHS LIST = $(APPPATH))
55+
PATH_APP_LOAD_PARAMS = $(APPPATH)
56+
57+
# Application icons following guidelines:
58+
# https://developers.ledger.com/docs/embedded-app/design-requirements/#device-icon
59+
ICON_NANOS = icons/nanos_app_mina.gif
60+
ICON_NANOX = icons/nanox_app_mina.gif
61+
ICON_NANOSP = icons/nanox_app_mina.gif
62+
ICON_STAX = icons/stax_app_mina.gif
63+
ICON_FLEX = icons/flex_app_mina.gif
4564

4665
################
4766
# Default rule #
@@ -95,68 +114,12 @@ else
95114
NO_STACK_CANARY=1
96115
endif
97116

98-
DEFINES += APPNAME=\"$(APPNAME)\"
117+
# App-specific defines
99118
DEFINES += LEDGER_BUILD
100-
DEFINES += OS_IO_SEPROXYHAL
101-
DEFINES += HAVE_SPRINTF
102-
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=6 IO_HID_EP_LENGTH=64 HAVE_USB_APDU
103-
DEFINES += LEDGER_MAJOR_VERSION=$(APPVERSION_M) LEDGER_MINOR_VERSION=$(APPVERSION_N) LEDGER_PATCH_VERSION=$(APPVERSION_P)
104-
105-
# U2F
106-
DEFINES += HAVE_U2F HAVE_IO_U2F
107-
DEFINES += U2F_PROXY_MAGIC=\"BOIL\"
108-
DEFINES += USB_SEGMENT_SIZE=64
109-
DEFINES += BLE_SEGMENT_SIZE=32 #max MTU, min 20
110-
111-
WEBUSB_URL = www.ledgerwallet.com
112-
DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=$(shell echo -n $(WEBUSB_URL) | wc -c) WEBUSB_URL=$(shell echo -n $(WEBUSB_URL) | sed -e "s/./\\\'\0\\\',/g")
113-
114119
DEFINES += UNUSED\(x\)=\(void\)x
120+
DEFINES += APPNAME=\"$(APPNAME)\"
115121
DEFINES += APPVERSION=\"$(APPVERSION)\"
116122

117-
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_STAX TARGET_FLEX))
118-
DEFINES += HAVE_BLE BLE_COMMAND_TIMEOUT_MS=2000
119-
DEFINES += HAVE_BLE_APDU # basic ledger apdu transport over BLE
120-
endif
121-
122-
ifeq ($(TARGET_NAME),TARGET_NANOS)
123-
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
124-
else
125-
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300
126-
endif
127-
128-
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_STAX TARGET_FLEX))
129-
DEFINES += NBGL_QRCODE
130-
SDK_SOURCE_PATH += qrcode
131-
else
132-
DEFINES += HAVE_BAGL HAVE_UX_FLOW
133-
ifneq ($(TARGET_NAME),TARGET_NANOS)
134-
DEFINES += BUILD_NANOX
135-
DEFINES += HAVE_GLO096
136-
DEFINES += HAVE_BAGL BAGL_WIDTH=128 BAGL_HEIGHT=64
137-
DEFINES += HAVE_BAGL_ELLIPSIS # long label truncation feature
138-
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX
139-
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX
140-
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX
141-
endif
142-
endif
143-
144-
# Both nano S and X benefit from the flow.
145-
DEFINES += HAVE_UX_FLOW
146-
147-
# Enabling debug PRINTF
148-
DEBUG = 0
149-
ifneq ($(DEBUG),0)
150-
151-
ifeq ($(TARGET_NAME),TARGET_NANOS)
152-
DEFINES += HAVE_PRINTF PRINTF=screen_printf
153-
else
154-
DEFINES += HAVE_PRINTF PRINTF=mcu_usb_printf
155-
endif
156-
else
157-
DEFINES += PRINTF\(...\)=
158-
endif
159-
160123
ifneq ("$(MAKECMDGOALS)", "clean")
161124
ifneq ("$(MAKECMDGOALS)", "allclean")
162125
$(info )
@@ -181,46 +144,8 @@ $(error HAVE_ON_DEVICE_UNIT_TESTS should not be used for release builds);
181144
endif
182145
endif
183146

184-
##############
185-
# Compiler #
186-
##############
187-
ifneq ($(BOLOS_ENV),)
188-
$(info BOLOS_ENV=$(BOLOS_ENV))
189-
CLANGPATH := $(BOLOS_ENV)/clang-arm-fropi/bin/
190-
GCCPATH := $(BOLOS_ENV)/gcc-arm-none-eabi-10.3-2021.10/bin/
191-
else
192-
$(info BOLOS_ENV is not set: falling back to CLANGPATH and GCCPATH)
193-
endif
194-
ifeq ($(CLANGPATH),)
195-
$(info CLANGPATH is not set: clang will be used from PATH)
196-
endif
197-
ifeq ($(GCCPATH),)
198-
$(info GCCPATH is not set: arm-none-eabi-* will be used from PATH)
199-
endif
200-
201-
CC := $(CLANGPATH)clang
202-
203-
CFLAGS += -O3 -Os
204-
205-
AS := $(GCCPATH)arm-none-eabi-gcc
206-
207-
LD := $(GCCPATH)arm-none-eabi-gcc
208-
LDFLAGS += -O3 -Os
209-
LDLIBS += -lm -lgcc -lc
210-
211-
# import rules to compile glyphs(/pone)
212-
include $(BOLOS_SDK)/Makefile.glyphs
213-
214147
### variables processed by the common makefile.rules of the SDK to grab source files and include dirs
215148
APP_SOURCE_PATH += src
216-
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_u2f
217-
ifneq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_STAX TARGET_FLEX))
218-
SDK_SOURCE_PATH += lib_ux
219-
endif
220-
221-
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOX TARGET_STAX TARGET_FLEX))
222-
SDK_SOURCE_PATH += lib_blewbxx lib_blewbxx_impl
223-
endif
224149

225150
APP_LOAD_PARAMS_EVALUATED=$(shell printf '\\"%s\\" ' $(APP_LOAD_PARAMS))
226151
APP_DELETE_PARAMS_EVALUATED=$(shell printf '\\"%s\\" ' $(COMMON_DELETE_PARAMS))
@@ -254,6 +179,10 @@ read -p "Please unlock your Ledger device and exit any apps (press any key to co
254179
endef
255180
export RELEASE_DEPS
256181

182+
HAVE_APPLICATION_FLAG_BOLOS_SETTINGS = 1
183+
184+
include $(BOLOS_SDK)/Makefile.standard_app
185+
257186
side_release: all
258187
@# Must force clean like this because Ledger makefile always runs first
259188
@echo
@@ -304,18 +233,3 @@ side_release: all
304233
@rm -f install.sh
305234
@rm -f uninstall.sh
306235
@rm -f mina_ledger_wallet
307-
308-
load: all
309-
python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS)
310-
311-
load-offline: all
312-
python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS) --offline
313-
314-
delete:
315-
python3 -m ledgerblue.deleteApp $(COMMON_DELETE_PARAMS)
316-
317-
# import generic rules from the sdk
318-
include $(BOLOS_SDK)/Makefile.rules
319-
320-
listvariants:
321-
@echo VARIANTS COIN mina

src/crypto.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ bool sign(Signature *sig, const Keypair *kp, const ROInput *input, const uint8_t
749749
io_seproxyhal_io_heartbeat();
750750
}
751751
CATCH_OTHER(e) {
752+
UNUSED(e);
752753
error = true;
753754
}
754755
FINALLY {

src/globals.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#include "globals.h"
22
#include "menu.h"
33

4-
ux_state_t G_ux;
5-
bolos_ux_params_t G_ux_params;
6-
74
// display stepped screens
85
unsigned int ux_step;
96
unsigned int ux_step_count;

src/globals.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
#define P1_FIRST 0x00
88
#define P1_MORE 0x80
99

10-
extern ux_state_t ux;
10+
// Provided by the SDK
11+
extern ux_state_t G_ux;
1112
// display stepped screens
1213
extern unsigned int ux_step;
1314
extern unsigned int ux_step_count;

src/main.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include "test_crypto.h"
2323
#include "menu.h"
2424

25-
unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];
26-
2725
#define CLA 0xe0
2826
#define INS_GET_CONF 0x01
2927
#define INS_GET_ADDR 0x02
@@ -58,9 +56,9 @@ void handleApdu(volatile unsigned int *flags, volatile unsigned int *tx,
5856

5957
switch (G_io_apdu_buffer[OFFSET_INS]) {
6058
case INS_GET_CONF:
61-
G_io_apdu_buffer[0] = LEDGER_MAJOR_VERSION;
62-
G_io_apdu_buffer[1] = LEDGER_MINOR_VERSION;
63-
G_io_apdu_buffer[2] = LEDGER_PATCH_VERSION;
59+
G_io_apdu_buffer[0] = MAJOR_VERSION;
60+
G_io_apdu_buffer[1] = MINOR_VERSION;
61+
G_io_apdu_buffer[2] = PATCH_VERSION;
6462
*tx = 3;
6563
THROW(APDU_CODE_OK);
6664
break;

src/sign_msg.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ void handle_sign_msg(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint8_t dataLe
2020

2121
uint8_t msg_buffer[255] = {0};
2222

23-
const char prefix[] = PREFIX;
24-
25-
if (dataLength + strlen(prefix) > sizeof(msg_buffer)) {
23+
if (dataLength > sizeof(msg_buffer)) {
2624
THROW(INVALID_PARAMETER);
2725
}
2826

@@ -37,10 +35,9 @@ void handle_sign_msg(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint8_t dataLe
3735
THROW(INVALID_PARAMETER);
3836
}
3937

40-
memcpy(msg_buffer, prefix, strlen(prefix));
41-
memcpy(msg_buffer + strlen(prefix), dataBuffer + MSG_OFFSET, dataLength - (ACCOUNT_LENGTH + NETWORK_LENGTH));
38+
memcpy(msg_buffer, dataBuffer + MSG_OFFSET, dataLength - (ACCOUNT_LENGTH + NETWORK_LENGTH));
4239

43-
ui_sign_msg(msg_buffer, strlen(prefix) + dataLength - (ACCOUNT_LENGTH + NETWORK_LENGTH), network);
40+
ui_sign_msg(msg_buffer, dataLength - (ACCOUNT_LENGTH + NETWORK_LENGTH), network);
4441
*flags |= IO_ASYNCH_REPLY;
4542
}
4643

src/sign_msg.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#define NETWORK_OFFSET 4
99
#define MSG_OFFSET 5
1010

11-
#define PREFIX "Message : "
12-
1311
void handle_sign_msg(uint8_t p1, uint8_t p2, uint8_t *dataBuffer,
1412
uint8_t dataLength, volatile unsigned int *flags);
1513

src/sign_tx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void sign_transaction(tx_t* tx, ui_t* ui)
4949
}
5050
}
5151
CATCH_OTHER(e) {
52+
UNUSED(e);
5253
error = true;
5354
}
5455
FINALLY {

src/utils.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,9 @@ int b58_encode(const unsigned char *in, unsigned char length,
8282
*/
8383
#define MAX_DEC_INPUT_SIZE 164
8484

85-
uint8_t const BASE58_TABLE[] = {
86-
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, //
87-
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, //
88-
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, //
89-
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, //
90-
0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0xFF, 0xFF, //
91-
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, //
92-
0x10, 0xFF, 0x11, 0x12, 0x13, 0x14, 0x15, 0xFF, 0x16, 0x17, 0x18, 0x19, //
93-
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, //
94-
0xFF, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, //
95-
0xFF, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, //
96-
0x37, 0x38, 0x39, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF //
97-
};
85+
// Use the SDK's version
86+
#define BASE58_TABLE_SIZE 128
87+
extern uint8_t const BASE58_TABLE[BASE58_TABLE_SIZE];
9888

9989
int b58_decode(const char *in, size_t in_len, uint8_t *out, size_t out_len) {
10090
uint8_t tmp[MAX_DEC_INPUT_SIZE] = {0};

tests/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
base58
22
bip32
3-
ragger[tests,speculos]
3+
ragger[tests,speculos]==1.32.1
44
ledgerblue

0 commit comments

Comments
 (0)