Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
0xPxt committed Sep 3, 2024
1 parent be8b7e8 commit 9ee800d
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 127 deletions.
4 changes: 1 addition & 3 deletions app/src/apdu_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
#include "app_main.h"
#include "coin.h"
#include "crypto.h"
#include "parser_txdef.h"
#include "tx.h"
#include "view.h"
#include "view_internal.h"
#include "zxmacros.h"
#include "parser_txdef.h"

static bool tx_initialized = false;

Expand Down Expand Up @@ -149,14 +149,12 @@ __Z_INLINE void handleSignHash(volatile uint32_t *flags, volatile uint32_t *tx,
*flags |= IO_ASYNCH_REPLY;
}


__Z_INLINE void handleSignTransaction(volatile uint32_t *flags, volatile uint32_t *tx, uint32_t rx) {
zemu_log("handleSignTransaction\n");
if (!process_chunk(tx, rx)) {
THROW(APDU_CODE_OK);
}


const char *error_msg = tx_parse(tx_type_transaction);
CHECK_APP_CANARY()
if (error_msg != NULL) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/common/tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include "coin.h"
#include "os.h"
#include "zxerror.h"
#include "parser_txdef.h"
#include "zxerror.h"

void tx_initialize();

Expand Down
5 changes: 3 additions & 2 deletions app/src/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include "coin.h"
#include "crypto_helper.h"
#include "cx.h"
#include "parser_txdef.h"
#include "zxformat.h"
#include "zxmacros.h"
#include "parser_txdef.h"

uint32_t hdPath[HDPATH_LEN_DEFAULT];

Expand Down Expand Up @@ -63,7 +63,8 @@ zxerr_t crypto_extractPublicKey(uint8_t *pubKey, uint16_t pubKeyLen) {
return error;
}

zxerr_t crypto_sign(uint8_t *signature, uint16_t signatureMaxlen, const uint8_t *message, uint16_t messageLen, tx_type_t tx_type) {
zxerr_t crypto_sign(uint8_t *signature, uint16_t signatureMaxlen, const uint8_t *message, uint16_t messageLen,
tx_type_t tx_type) {
if (signature == NULL || message == NULL || signatureMaxlen < ED25519_SIGNATURE_SIZE || messageLen == 0) {
return zxerr_invalid_crypto_settings;
}
Expand Down
5 changes: 3 additions & 2 deletions app/src/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ extern "C" {
#include <stdbool.h>

#include "coin.h"
#include "zxerror.h"
#include "parser_txdef.h"
#include "zxerror.h"

extern uint32_t hdPath[HDPATH_LEN_DEFAULT];

zxerr_t crypto_fillAddress(uint8_t *buffer, uint16_t bufferLen, uint16_t *addrResponseLen);

zxerr_t crypto_sign(uint8_t *signature, uint16_t signatureMaxlen, const uint8_t *message, uint16_t messageLen, tx_type_t tx_type);
zxerr_t crypto_sign(uint8_t *signature, uint16_t signatureMaxlen, const uint8_t *message, uint16_t messageLen,
tx_type_t tx_type);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/items.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ static items_error_t items_computeHash(tx_type_t tx_type) {
tx_hash_t *hash_obj = parser_getParserHashObj();
base64_encode(base64_hash, 44, (uint8_t *)hash_obj->tx, hash_obj->hash_len);
} else {
if (blake2b_hash((uint8_t *)parser_getParserJsonObj()->json.buffer, parser_getParserJsonObj()->json.bufferLen, hash) !=
zxerr_ok) {
if (blake2b_hash((uint8_t *)parser_getParserJsonObj()->json.buffer, parser_getParserJsonObj()->json.bufferLen,
hash) != zxerr_ok) {
return items_error;
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "items_defs.h"
#include "json_parser.h"
#include "parser_common.h"
#include "zxtypes.h"
#include "parser_txdef.h"
#include "zxtypes.h"

items_error_t items_initItems();
items_error_t items_storeItems(tx_type_t tx_type);
Expand Down
3 changes: 2 additions & 1 deletion app/src/items_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#define WARNING_TEXT \
"UNSAFE TRANSACTION. This transaction's code was not recognized and does not limit capabilities for all signers. " \
"Signing this transaction may make arbitrary actions on the chain including loss of all funds."
#define HASH_WARNING_TEXT "Blind Signing a Transaction Hash is a very unusual operation. Do not continue unless you know what you are doing"
#define HASH_WARNING_TEXT \
"Blind Signing a Transaction Hash is a very unusual operation. Do not continue unless you know what you are doing"
#define CAUTION_TEXT "'meta' field of transaction not recognized"
#define TX_TOO_LARGE_TEXT \
"Transaction too large for Ledger to display. PROCEED WITH GREAT CAUTION. Do you want to continue?"
Expand Down
20 changes: 8 additions & 12 deletions app/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,17 @@
tx_json_t tx_obj_json;
tx_hash_t tx_obj_hash;

char
char
#if defined(TARGET_NANOS)
// For nanos, jsonTemplate does not fit in RAM.
__attribute__((section(".text")))
// For nanos, jsonTemplate does not fit in RAM.
__attribute__((section(".text")))
#endif
jsonTemplate[1200] = {0};
jsonTemplate[1200] = {0};
uint16_t jsonTemplateLen;

char *parser_get_json_template_buffer() {
return jsonTemplate;
}
char *parser_get_json_template_buffer() { return jsonTemplate; }

uint16_t parser_get_json_template_buffer_len() {
return jsonTemplateLen;
}
uint16_t parser_get_json_template_buffer_len() { return jsonTemplateLen; }

parser_error_t parser_init_context(parser_context_t *ctx, const uint8_t *buffer, uint16_t bufferSize) {
ctx->offset = 0;
Expand Down Expand Up @@ -75,11 +71,11 @@ parser_error_t parser_parse(parser_context_t *ctx, const uint8_t *data, size_t d
} else if (tx_type == tx_type_transaction) {
parser_createJsonTemplate(ctx, jsonTemplate, sizeof(jsonTemplate), &jsonTemplateLen);
ctx->json = &tx_obj_json;
ctx->buffer = (const uint8_t *) jsonTemplate;
ctx->buffer = (const uint8_t *)jsonTemplate;
ctx->bufferLen = jsonTemplateLen;

CHECK_ERROR(_read_json_tx(ctx));
}
}

ITEMS_TO_PARSER_ERROR(items_initItems())
ITEMS_TO_PARSER_ERROR(items_storeItems(tx_type))
Expand Down
Loading

0 comments on commit 9ee800d

Please sign in to comment.