Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

support full 32bit chain_id, cast (uint64_t)v #386

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
7 changes: 2 additions & 5 deletions firmware/ethereum.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
#include "memzero.h"
#include "messages.pb.h"

/* maximum supported chain id. v must fit in an uint32_t. */
#define MAX_CHAIN_ID 2147483630

static bool ethereum_signing = false;
static uint32_t data_total, data_left;
static EthereumTxRequest msg_tx_request;
Expand Down Expand Up @@ -203,7 +200,7 @@ static void send_signature(void)

msg_tx_request.has_signature_v = true;
if (chain_id) {
msg_tx_request.signature_v = v + 2 * chain_id + 35;
msg_tx_request.signature_v = (uint64_t)v + 2 * chain_id + 35;
} else {
msg_tx_request.signature_v = v + 27;
}
Expand Down Expand Up @@ -461,7 +458,7 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node)

/* eip-155 chain id */
if (msg->has_chain_id) {
if (msg->chain_id < 1 || msg->chain_id > MAX_CHAIN_ID) {
if (msg->chain_id < 1) {
fsm_sendFailure(Failure_FailureType_Failure_DataError, _("Chain Id out of bounds"));
ethereum_signing_abort();
return;
Expand Down