diff --git a/firmware/ethereum.c b/firmware/ethereum.c index a7342391ad..8d6c78ec11 100644 --- a/firmware/ethereum.c +++ b/firmware/ethereum.c @@ -438,6 +438,8 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node) msg->to.size = 0; if (!msg->has_nonce) msg->nonce.size = 0; + if (!msg->has_prefix) + msg->prefix.size = 0; /* eip-155 chain id */ if (msg->has_chain_id) { @@ -512,6 +514,9 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node) layoutProgress("Signing", 0); + if (msg->has_prefix) { + rlp_length += rlp_calculate_length(msg->prefix.size, msg->prefix.bytes[0]); + } rlp_length += rlp_calculate_length(msg->nonce.size, msg->nonce.bytes[0]); rlp_length += rlp_calculate_length(msg->gas_price.size, msg->gas_price.bytes[0]); rlp_length += rlp_calculate_length(msg->gas_limit.size, msg->gas_limit.bytes[0]); @@ -529,6 +534,9 @@ void ethereum_signing_init(EthereumSignTx *msg, const HDNode *node) layoutProgress("Signing", 100); + if (msg->has_prefix) { + hash_rlp_field(msg->prefix.bytes, msg->prefix.size); + } hash_rlp_field(msg->nonce.bytes, msg->nonce.size); hash_rlp_field(msg->gas_price.bytes, msg->gas_price.size); hash_rlp_field(msg->gas_limit.bytes, msg->gas_limit.size); diff --git a/firmware/protob/messages.options b/firmware/protob/messages.options index 7138c65978..c538e5e99d 100644 --- a/firmware/protob/messages.options +++ b/firmware/protob/messages.options @@ -100,6 +100,7 @@ EthereumSignTx.gas_limit max_size:32 EthereumSignTx.to max_size:20 EthereumSignTx.value max_size:32 EthereumSignTx.data_initial_chunk max_size:1024 +EthereumSignTx.prefix max_size:32 EthereumTxRequest.signature_r max_size:32 EthereumTxRequest.signature_s max_size:32 diff --git a/firmware/protob/messages.pb.c b/firmware/protob/messages.pb.c index b2421129d4..5a55dbeb03 100644 --- a/firmware/protob/messages.pb.c +++ b/firmware/protob/messages.pb.c @@ -325,7 +325,7 @@ const pb_field_t TxAck_fields[2] = { PB_LAST_FIELD }; -const pb_field_t EthereumSignTx_fields[10] = { +const pb_field_t EthereumSignTx_fields[11] = { PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, EthereumSignTx, address_n, address_n, 0), PB_FIELD2( 2, BYTES , OPTIONAL, STATIC , OTHER, EthereumSignTx, nonce, address_n, 0), PB_FIELD2( 3, BYTES , OPTIONAL, STATIC , OTHER, EthereumSignTx, gas_price, nonce, 0), @@ -335,6 +335,7 @@ const pb_field_t EthereumSignTx_fields[10] = { PB_FIELD2( 7, BYTES , OPTIONAL, STATIC , OTHER, EthereumSignTx, data_initial_chunk, value, 0), PB_FIELD2( 8, UINT32 , OPTIONAL, STATIC , OTHER, EthereumSignTx, data_length, data_initial_chunk, 0), PB_FIELD2( 9, UINT32 , OPTIONAL, STATIC , OTHER, EthereumSignTx, chain_id, data_length, 0), + PB_FIELD2( 10, BYTES , OPTIONAL, STATIC , OTHER, EthereumSignTx, prefix, chain_id, 0), PB_LAST_FIELD }; diff --git a/firmware/protob/messages.pb.h b/firmware/protob/messages.pb.h index 0dad8391fc..d8470eb997 100644 --- a/firmware/protob/messages.pb.h +++ b/firmware/protob/messages.pb.h @@ -444,6 +444,11 @@ typedef struct { uint8_t bytes[1024]; } EthereumSignTx_data_initial_chunk_t; +typedef struct { + size_t size; + uint8_t bytes[32]; +} EthereumSignTx_prefix_t; + typedef struct _EthereumSignTx { size_t address_n_count; uint32_t address_n[8]; @@ -463,6 +468,8 @@ typedef struct _EthereumSignTx { uint32_t data_length; bool has_chain_id; uint32_t chain_id; + bool has_prefix; + EthereumSignTx_prefix_t prefix; } EthereumSignTx; typedef struct { @@ -872,7 +879,7 @@ extern const uint32_t SignTx_lock_time_default; #define SignTx_init_default {0, 0, false, "Bitcoin", false, 1u, false, 0u} #define TxRequest_init_default {false, (RequestType)0, false, TxRequestDetailsType_init_default, false, TxRequestSerializedType_init_default} #define TxAck_init_default {false, TransactionType_init_default} -#define EthereumSignTx_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, 0, false, 0} +#define EthereumSignTx_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, 0, false, 0, false, {0, {0}}} #define EthereumTxRequest_init_default {false, 0, false, 0, false, {0, {0}}, false, {0, {0}}} #define EthereumTxAck_init_default {false, {0, {0}}} #define SignIdentity_init_default {false, IdentityType_init_default, false, {0, {0}}, false, "", false, ""} @@ -936,7 +943,7 @@ extern const uint32_t SignTx_lock_time_default; #define SignTx_init_zero {0, 0, false, "", false, 0, false, 0} #define TxRequest_init_zero {false, (RequestType)0, false, TxRequestDetailsType_init_zero, false, TxRequestSerializedType_init_zero} #define TxAck_init_zero {false, TransactionType_init_zero} -#define EthereumSignTx_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, 0, false, 0} +#define EthereumSignTx_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, {0, {0}}, false, 0, false, 0, false, {0, {0}}} #define EthereumTxRequest_init_zero {false, 0, false, 0, false, {0, {0}}, false, {0, {0}}} #define EthereumTxAck_init_zero {false, {0, {0}}} #define SignIdentity_init_zero {false, IdentityType_init_zero, false, {0, {0}}, false, "", false, ""} @@ -1025,6 +1032,7 @@ extern const uint32_t SignTx_lock_time_default; #define EthereumSignTx_data_initial_chunk_tag 7 #define EthereumSignTx_data_length_tag 8 #define EthereumSignTx_chain_id_tag 9 +#define EthereumSignTx_prefix_tag 10 #define EthereumTxAck_data_chunk_tag 1 #define EthereumTxRequest_data_length_tag 1 #define EthereumTxRequest_signature_v_tag 2 @@ -1173,7 +1181,7 @@ extern const pb_field_t TxSize_fields[2]; extern const pb_field_t SignTx_fields[6]; extern const pb_field_t TxRequest_fields[4]; extern const pb_field_t TxAck_fields[2]; -extern const pb_field_t EthereumSignTx_fields[10]; +extern const pb_field_t EthereumSignTx_fields[11]; extern const pb_field_t EthereumTxRequest_fields[5]; extern const pb_field_t EthereumTxAck_fields[2]; extern const pb_field_t SignIdentity_fields[5]; @@ -1239,7 +1247,7 @@ extern const pb_field_t DebugLinkFlashErase_fields[2]; #define SignTx_size 43 #define TxRequest_size (18 + TxRequestDetailsType_size + TxRequestSerializedType_size) #define TxAck_size (6 + TransactionType_size) -#define EthereumSignTx_size 1245 +#define EthereumSignTx_size 1279 #define EthereumTxRequest_size 80 #define EthereumTxAck_size 1027 #define SignIdentity_size (558 + IdentityType_size) diff --git a/vendor/trezor-common b/vendor/trezor-common index dd1f7a2b0b..78da723c06 160000 --- a/vendor/trezor-common +++ b/vendor/trezor-common @@ -1 +1 @@ -Subproject commit dd1f7a2b0b44793734e286239f64ddb3d816058d +Subproject commit 78da723c063ae0aa76e06a517fe48d0013928cc4