Skip to content

Commit

Permalink
Merge pull request #58 from trilitech/ajinkyaraj-23@use_base58_from_sdk
Browse files Browse the repository at this point in the history
Use base58 encoding from ledger SDK
  • Loading branch information
ajinkyaraj-23 authored Mar 4, 2024
2 parents c4b3c35 + 9f524a4 commit 34d1c53
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 169 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ VARIANT_VALUES = tezos_baking
# OPTION

DISABLE_STANDARD_APP_SYNC_RAPDU = 1
DISABLE_STANDARD_APP_FILES = 1
DEFINES += HAVE_LEGACY_PID

ENABLE_BLUETOOTH = 1
ENABLE_NBGL_QRCODE = 1
Expand Down
2 changes: 1 addition & 1 deletion misra.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"script": "misra.py",
"args": [
"--rule-texts=misra.md",
"--suppress-rules 2.7,3.1,7.2,7.4,8.2,8.4,8.9,8.14,9.2,10.1,10.3,10.4,10.5,10.6,11.1,11.3,11.5,11.8,12.1,12.3,13.3,13.4,14.2,14.4,15.5,16.3,16.4,16.5,16.6,17.7,17.8,18.4,18.8,19.2,20.5,20.7,21.15,21.16"
"--suppress-rules 2.7,3.1,7.2,7.4,8.2,8.4,8.9,8.14,9.2,10.1,10.3,10.4,10.5,10.6,11.1,11.3,11.5,11.8,12.1,13.3,13.4,14.2,14.4,15.5,16.3,16.4,16.5,16.6,17.7,17.8,18.4,18.8,19.2,20.5,20.7,21.15,21.16"
]
}
1 change: 0 additions & 1 deletion src/apdu_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "apdu.h"
#include "baking_auth.h"
#include "base58_encoding.h"
#include "globals.h"
#include "keys.h"
#include "memory.h"
Expand Down
65 changes: 0 additions & 65 deletions src/base58_encoding.c

This file was deleted.

5 changes: 0 additions & 5 deletions src/base58_encoding.h

This file was deleted.

72 changes: 0 additions & 72 deletions src/boot.c

This file was deleted.

11 changes: 0 additions & 11 deletions src/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,12 @@

globals_t global;

// These are strange variables that the SDK relies on us to define but uses directly itself.
ux_state_t G_ux;
bolos_ux_params_t G_ux_params;

unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];

void clear_apdu_globals(void) {
memset(&global.apdu, 0, sizeof(global.apdu));
}

void init_globals(void) {
memset(&global, 0, sizeof(global));

memset(&G_ux, 0, sizeof(G_ux));
memset(&G_ux_params, 0, sizeof(G_ux_params));

memset(G_io_seproxyhal_spi_buffer, 0, sizeof(G_io_seproxyhal_spi_buffer));
}

// DO NOT TRY TO INIT THIS. This can only be written via an system call.
Expand Down
5 changes: 0 additions & 5 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ typedef struct {
bool is_blank_screen;
} dynamic_display;

void *stack_root;
apdu_handler handlers[INS_MAX + 1];
bip32_path_with_curve_t path_with_curve;

Expand Down Expand Up @@ -130,10 +129,6 @@ typedef struct {

extern globals_t global;

extern unsigned int app_stack_canary; // From SDK

extern unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];

extern nvram_data const N_data_real;
#define N_data (*(volatile nvram_data *) PIC(&N_data_real))

Expand Down
3 changes: 3 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include "memory.h"

__attribute__((noreturn)) void app_main(void) {
init_globals();
ui_initial_screen();

// TODO: Consider using static initialization of a const, instead of this
for (size_t i = 0; i < NUM_ELEMENTS(global.handlers); i++) {
global.handlers[i] = handle_apdu_error;
Expand Down
9 changes: 4 additions & 5 deletions src/to_string.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "to_string.h"

#include <base58.h>

#include "apdu.h"
#include "base58_encoding.h"
#include "keys.h"

#include <string.h>
Expand Down Expand Up @@ -107,8 +108,7 @@ void pkh_to_string(char *const buff,
memcpy(data.hash, hash, sizeof(data.hash));
compute_hash_checksum(data.checksum, &data, sizeof(data) - sizeof(data.checksum));

size_t out_size = buff_size;
if (!b58enc(buff, &out_size, &data, sizeof(data))) {
if (base58_encode((const uint8_t *) &data, sizeof(data), buff, buff_size) == -1) {
THROW(EXC_WRONG_LENGTH);
}
}
Expand All @@ -131,8 +131,7 @@ void chain_id_to_string(char *const buff, size_t const buff_size, chain_id_t con

compute_hash_checksum(data.checksum, &data, sizeof(data) - sizeof(data.checksum));

size_t out_size = buff_size;
if (!b58enc(buff, &out_size, &data, sizeof(data))) {
if (base58_encode((const uint8_t *) &data, sizeof(data), buff, buff_size) == -1) {
THROW(EXC_WRONG_LENGTH);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/ui_sign_bagl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "apdu.h"
#include "baking_auth.h"
#include "base58_encoding.h"
#include "globals.h"
#include "keys.h"
#include "memory.h"
Expand Down
1 change: 0 additions & 1 deletion src/ui_sign_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "apdu.h"
#include "baking_auth.h"
#include "base58_encoding.h"
#include "globals.h"
#include "keys.h"
#include "memory.h"
Expand Down

0 comments on commit 34d1c53

Please sign in to comment.