From d4cc4a48b87224ce5a0e9d4897ea722a9173af4d Mon Sep 17 00:00:00 2001 From: Peter Banik Date: Fri, 21 Apr 2017 12:51:13 +0200 Subject: [PATCH 1/5] Added altcoin support to GetPublicKey (#161) --- firmware/coins-gen.py | 6 ++++++ firmware/coins.c | 16 ++++++++-------- firmware/fsm.c | 5 ++++- firmware/protob/messages.options | 1 + firmware/protob/messages.pb.c | 4 +++- firmware/protob/messages.pb.h | 12 ++++++++---- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/firmware/coins-gen.py b/firmware/coins-gen.py index d3109ec8d1..c7181d942e 100755 --- a/firmware/coins-gen.py +++ b/firmware/coins-gen.py @@ -30,6 +30,12 @@ for c in coins: 'true' if c['signed_message_header'] is not None else 'false', '"\\x%02x" "%s"' % (len(c['signed_message_header']), c['signed_message_header'].replace('\n', '\\n')) if c['signed_message_header'] is not None else 'NULL', + + 'true' if c['xpub_magic'] is not None else 'false', + '0x%s' % c['xpub_magic'] if c['xpub_magic'] is not None else '00000000', + + 'true' if c['xprv_magic'] is not None else 'false', + '0x%s' % c['xprv_magic'] if c['xprv_magic'] is not None else '00000000' ]) for j in range(len(fields[0])): diff --git a/firmware/coins.c b/firmware/coins.c index 094f2d5ed9..f26808e2bf 100644 --- a/firmware/coins.c +++ b/firmware/coins.c @@ -26,14 +26,14 @@ // filled CoinType Protobuf structure defined in https://github.com/trezor/trezor-common/blob/master/protob/types.proto#L133 // address types > 0xFF represent a two-byte prefix in big-endian order const CoinType coins[COINS_COUNT] = { - {true, "Bitcoin", true, "BTC", true, 0, true, 300000, true, 5, true, 6, true, 10, true, "\x18" "Bitcoin Signed Message:\n", }, - {true, "Testnet", true, "TEST", true, 111, true, 10000000, true, 196, true, 3, true, 40, true, "\x18" "Bitcoin Signed Message:\n", }, - {true, "Namecoin", true, "NMC", true, 52, true, 10000000, true, 5, false, 0, false, 0, true, "\x19" "Namecoin Signed Message:\n", }, - {true, "Litecoin", true, "LTC", true, 48, true, 1000000, true, 5, false, 0, false, 0, true, "\x19" "Litecoin Signed Message:\n", }, - {true, "Dogecoin", true, "DOGE", true, 30, true, 1000000000, true, 22, false, 0, false, 0, true, "\x19" "Dogecoin Signed Message:\n", }, - {true, "Dash", true, "DASH", true, 76, true, 100000, true, 16, false, 0, false, 0, true, "\x19" "DarkCoin Signed Message:\n", }, - {true, "Zcash", true, "ZEC", true, 7352, true, 1000000, true, 7357, false, 0, false, 0, true, "\x16" "Zcash Signed Message:\n", }, - {true, "Zcash Testnet", true, "TAZ", true, 7461, true, 10000000, true, 7354, false, 0, false, 0, true, "\x16" "Zcash Signed Message:\n", }, + {true, "Bitcoin", true, "BTC", true, 0, true, 300000, true, 5, true, 6, true, 10, true, "\x18" "Bitcoin Signed Message:\n", true, 0x0488b21e, true, 0x0488ade4, }, + {true, "Testnet", true, "TEST", true, 111, true, 10000000, true, 196, true, 3, true, 40, true, "\x18" "Bitcoin Signed Message:\n", true, 0x043587cf, true, 0x04358394, }, + {true, "Namecoin", true, "NMC", true, 52, true, 10000000, true, 5, false, 0, false, 0, true, "\x19" "Namecoin Signed Message:\n", true, 0x019da462, true, 0x019d9cfe, }, + {true, "Litecoin", true, "LTC", true, 48, true, 1000000, true, 5, false, 0, false, 0, true, "\x19" "Litecoin Signed Message:\n", true, 0x019da462, true, 0x019d9cfe, }, + {true, "Dogecoin", true, "DOGE", true, 30, true, 1000000000, true, 22, false, 0, false, 0, true, "\x19" "Dogecoin Signed Message:\n", true, 0x02facafd, true, 0x02fac398, }, + {true, "Dash", true, "DASH", true, 76, true, 100000, true, 16, false, 0, false, 0, true, "\x19" "DarkCoin Signed Message:\n", true, 0x02fe52cc, true, 0x02fe52f8, }, + {true, "Zcash", true, "ZEC", true, 7352, true, 1000000, true, 7357, false, 0, false, 0, true, "\x16" "Zcash Signed Message:\n", true, 0x0488b21e, true, 0x0488ade4, }, + {true, "Zcash Testnet", true, "TAZ", true, 7461, true, 10000000, true, 7354, false, 0, false, 0, true, "\x16" "Zcash Signed Message:\n", true, 0x043587cf, true, 0x04358394, }, }; const CoinType *coinByShortcut(const char *shortcut) diff --git a/firmware/fsm.c b/firmware/fsm.c index 3cea7f2331..0893d3f5bd 100644 --- a/firmware/fsm.c +++ b/firmware/fsm.c @@ -317,6 +317,9 @@ void fsm_msgGetPublicKey(GetPublicKey *msg) CHECK_PIN + const CoinType *coin = fsm_getCoin(msg->coin_name); + if (!coin) return; + const char *curve = SECP256K1_NAME; if (msg->has_ecdsa_curve_name) { curve = msg->ecdsa_curve_name; @@ -360,7 +363,7 @@ void fsm_msgGetPublicKey(GetPublicKey *msg) resp->node.public_key.bytes[0] = 0; } resp->has_xpub = true; - hdnode_serialize_public(node, fingerprint, resp->xpub, sizeof(resp->xpub)); + hdnode_serialize_public(node, fingerprint, resp->xpub, sizeof(resp->xpub), coin->xpub_magic); msg_write(MessageType_MessageType_PublicKey, resp); layoutHome(); } diff --git a/firmware/protob/messages.options b/firmware/protob/messages.options index 9164ce6dba..c0f88fc3ff 100644 --- a/firmware/protob/messages.options +++ b/firmware/protob/messages.options @@ -26,6 +26,7 @@ Entropy.entropy max_size:1024 GetPublicKey.address_n max_count:8 GetPublicKey.ecdsa_curve_name max_size:32 +GetPublicKey.coin_name max_size:17 PublicKey.xpub max_size:113 diff --git a/firmware/protob/messages.pb.c b/firmware/protob/messages.pb.c index 7011ece5d2..8e85255962 100644 --- a/firmware/protob/messages.pb.c +++ b/firmware/protob/messages.pb.c @@ -3,6 +3,7 @@ #include "messages.pb.h" +const char GetPublicKey_coin_name_default[17] = "Bitcoin"; const char GetAddress_coin_name_default[17] = "Bitcoin"; const InputScriptType GetAddress_script_type_default = InputScriptType_SPENDADDRESS; const char LoadDevice_language_default[17] = "english"; @@ -130,10 +131,11 @@ const pb_field_t Entropy_fields[2] = { PB_LAST_FIELD }; -const pb_field_t GetPublicKey_fields[4] = { +const pb_field_t GetPublicKey_fields[5] = { PB_FIELD2( 1, UINT32 , REPEATED, STATIC , FIRST, GetPublicKey, address_n, address_n, 0), PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, GetPublicKey, ecdsa_curve_name, address_n, 0), PB_FIELD2( 3, BOOL , OPTIONAL, STATIC , OTHER, GetPublicKey, show_display, ecdsa_curve_name, 0), + PB_FIELD2( 4, STRING , OPTIONAL, STATIC , OTHER, GetPublicKey, coin_name, show_display, &GetPublicKey_coin_name_default), PB_LAST_FIELD }; diff --git a/firmware/protob/messages.pb.h b/firmware/protob/messages.pb.h index f5b5893b61..ced5e9b6e1 100644 --- a/firmware/protob/messages.pb.h +++ b/firmware/protob/messages.pb.h @@ -598,6 +598,8 @@ typedef struct _GetPublicKey { char ecdsa_curve_name[32]; bool has_show_display; bool show_display; + bool has_coin_name; + char coin_name[17]; } GetPublicKey; typedef struct _LoadDevice { @@ -831,6 +833,7 @@ typedef struct _WordRequest { } WordRequest; /* Default values for struct fields */ +extern const char GetPublicKey_coin_name_default[17]; extern const char GetAddress_coin_name_default[17]; extern const InputScriptType GetAddress_script_type_default; extern const char LoadDevice_language_default[17]; @@ -867,7 +870,7 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define PassphraseAck_init_default {""} #define GetEntropy_init_default {0} #define Entropy_init_default {{0, {0}}} -#define GetPublicKey_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, "", false, 0} +#define GetPublicKey_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, "", false, 0, false, "Bitcoin"} #define PublicKey_init_default {HDNodeType_init_default, false, ""} #define GetAddress_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, "Bitcoin", false, 0, false, MultisigRedeemScriptType_init_default, false, InputScriptType_SPENDADDRESS} #define EthereumGetAddress_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, 0} @@ -933,7 +936,7 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define PassphraseAck_init_zero {""} #define GetEntropy_init_zero {0} #define Entropy_init_zero {{0, {0}}} -#define GetPublicKey_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, "", false, 0} +#define GetPublicKey_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, "", false, 0, false, ""} #define PublicKey_init_zero {HDNodeType_init_zero, false, ""} #define GetAddress_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, "", false, 0, false, MultisigRedeemScriptType_init_zero, false, (InputScriptType)0} #define EthereumGetAddress_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, false, 0} @@ -1090,6 +1093,7 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define GetPublicKey_address_n_tag 1 #define GetPublicKey_ecdsa_curve_name_tag 2 #define GetPublicKey_show_display_tag 3 +#define GetPublicKey_coin_name_tag 4 #define LoadDevice_mnemonic_tag 1 #define LoadDevice_node_tag 2 #define LoadDevice_pin_tag 3 @@ -1178,7 +1182,7 @@ extern const pb_field_t PassphraseRequest_fields[1]; extern const pb_field_t PassphraseAck_fields[2]; extern const pb_field_t GetEntropy_fields[2]; extern const pb_field_t Entropy_fields[2]; -extern const pb_field_t GetPublicKey_fields[4]; +extern const pb_field_t GetPublicKey_fields[5]; extern const pb_field_t PublicKey_fields[3]; extern const pb_field_t GetAddress_fields[6]; extern const pb_field_t EthereumGetAddress_fields[3]; @@ -1246,7 +1250,7 @@ extern const pb_field_t DebugLinkFlashErase_fields[2]; #define PassphraseAck_size 53 #define GetEntropy_size 6 #define Entropy_size 1027 -#define GetPublicKey_size 84 +#define GetPublicKey_size 103 #define PublicKey_size (121 + HDNodeType_size) #define GetAddress_size (81 + MultisigRedeemScriptType_size) #define EthereumGetAddress_size 50 From 258d3eadddc425ce3ccdeb430f6eeb19e54af91e Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Fri, 21 Apr 2017 12:55:14 +0200 Subject: [PATCH 2/5] GetPublicKey: use Bitcoin as default coin if not provided disable SimpleSignTx and Firmware messages update submodules --- firmware/fsm.c | 35 +++++++++++--------------- firmware/fsm.h | 2 -- firmware/messages.c | 2 -- firmware/protob/messages.options | 10 +++----- firmware/protob/messages.pb.c | 20 +-------------- firmware/protob/messages.pb.h | 43 +------------------------------- firmware/protob/types.pb.c | 6 ++++- firmware/protob/types.pb.h | 16 +++++++++--- vendor/trezor-common | 2 +- vendor/trezor-crypto | 2 +- vendor/trezor-qrenc | 2 +- 11 files changed, 40 insertions(+), 100 deletions(-) diff --git a/firmware/fsm.c b/firmware/fsm.c index 0893d3f5bd..41133ed312 100644 --- a/firmware/fsm.c +++ b/firmware/fsm.c @@ -116,9 +116,14 @@ void fsm_sendFailure(FailureType code, const char *text) msg_write(MessageType_MessageType_Failure, resp); } -const CoinType *fsm_getCoin(const char *name) +const CoinType *fsm_getCoin(bool has_name, const char *name) { - const CoinType *coin = coinByName(name); + const CoinType *coin; + if (has_name) { + coin = coinByName(name); + } else { + coin = coinByName("Bitcoin"); + } if (!coin) { fsm_sendFailure(FailureType_Failure_Other, "Invalid coin name"); layoutHome(); @@ -278,18 +283,6 @@ void fsm_msgWipeDevice(WipeDevice *msg) layoutHome(); } -void fsm_msgFirmwareErase(FirmwareErase *msg) -{ - (void)msg; - fsm_sendFailure(FailureType_Failure_UnexpectedMessage, "Not in bootloader mode"); -} - -void fsm_msgFirmwareUpload(FirmwareUpload *msg) -{ - (void)msg; - fsm_sendFailure(FailureType_Failure_UnexpectedMessage, "Not in bootloader mode"); -} - void fsm_msgGetEntropy(GetEntropy *msg) { layoutDialogSwipe(&bmp_icon_question, "Cancel", "Confirm", NULL, "Do you really want to", "send entropy?", NULL, NULL, NULL, NULL); @@ -317,7 +310,7 @@ void fsm_msgGetPublicKey(GetPublicKey *msg) CHECK_PIN - const CoinType *coin = fsm_getCoin(msg->coin_name); + const CoinType *coin = fsm_getCoin(msg->has_coin_name, msg->coin_name); if (!coin) return; const char *curve = SECP256K1_NAME; @@ -363,7 +356,7 @@ void fsm_msgGetPublicKey(GetPublicKey *msg) resp->node.public_key.bytes[0] = 0; } resp->has_xpub = true; - hdnode_serialize_public(node, fingerprint, resp->xpub, sizeof(resp->xpub), coin->xpub_magic); + hdnode_serialize_public(node, fingerprint, coin->xpub_magic, resp->xpub, sizeof(resp->xpub)); msg_write(MessageType_MessageType_PublicKey, resp); layoutHome(); } @@ -419,7 +412,7 @@ void fsm_msgSignTx(SignTx *msg) CHECK_PIN - const CoinType *coin = fsm_getCoin(msg->coin_name); + const CoinType *coin = fsm_getCoin(msg->has_coin_name, msg->coin_name); if (!coin) return; const HDNode *node = fsm_getDerivedNode(SECP256K1_NAME, 0, 0); if (!node) return; @@ -580,7 +573,7 @@ void fsm_msgGetAddress(GetAddress *msg) CHECK_PIN - const CoinType *coin = fsm_getCoin(msg->coin_name); + const CoinType *coin = fsm_getCoin(msg->has_coin_name, msg->coin_name); if (!coin) return; HDNode *node = fsm_getDerivedNode(SECP256K1_NAME, msg->address_n, msg->address_n_count); if (!node) return; @@ -690,7 +683,7 @@ void fsm_msgSignMessage(SignMessage *msg) CHECK_PIN - const CoinType *coin = fsm_getCoin(msg->coin_name); + const CoinType *coin = fsm_getCoin(msg->has_coin_name, msg->coin_name); if (!coin) return; HDNode *node = fsm_getDerivedNode(SECP256K1_NAME, msg->address_n, msg->address_n_count); if (!node) return; @@ -713,7 +706,7 @@ void fsm_msgVerifyMessage(VerifyMessage *msg) CHECK_PARAM(msg->has_address, "No address provided"); CHECK_PARAM(msg->has_message, "No message provided"); - const CoinType *coin = fsm_getCoin(msg->coin_name); + const CoinType *coin = fsm_getCoin(msg->has_coin_name, msg->coin_name); if (!coin) return; uint8_t addr_raw[MAX_ADDR_RAW_SIZE]; uint32_t address_type; @@ -883,7 +876,7 @@ void fsm_msgEncryptMessage(EncryptMessage *msg) const HDNode *node = 0; uint8_t address_raw[MAX_ADDR_RAW_SIZE]; if (signing) { - const CoinType *coin = fsm_getCoin(msg->coin_name); + const CoinType *coin = fsm_getCoin(msg->has_coin_name, msg->coin_name); if (!coin) return; CHECK_PIN diff --git a/firmware/fsm.h b/firmware/fsm.h index 085c236381..04be361f32 100644 --- a/firmware/fsm.h +++ b/firmware/fsm.h @@ -32,8 +32,6 @@ void fsm_msgGetFeatures(GetFeatures *msg); void fsm_msgPing(Ping *msg); void fsm_msgChangePin(ChangePin *msg); void fsm_msgWipeDevice(WipeDevice *msg); -void fsm_msgFirmwareErase(FirmwareErase *msg); -void fsm_msgFirmwareUpload(FirmwareUpload *msg); void fsm_msgGetEntropy(GetEntropy *msg); void fsm_msgGetPublicKey(GetPublicKey *msg); void fsm_msgLoadDevice(LoadDevice *msg); diff --git a/firmware/messages.c b/firmware/messages.c index c927e531b7..9e761a326a 100644 --- a/firmware/messages.c +++ b/firmware/messages.c @@ -44,8 +44,6 @@ static const struct MessagesMap_t MessagesMap[] = { {'n', 'i', MessageType_MessageType_Ping, Ping_fields, (void (*)(void *))fsm_msgPing}, {'n', 'i', MessageType_MessageType_ChangePin, ChangePin_fields, (void (*)(void *))fsm_msgChangePin}, {'n', 'i', MessageType_MessageType_WipeDevice, WipeDevice_fields, (void (*)(void *))fsm_msgWipeDevice}, - {'n', 'i', MessageType_MessageType_FirmwareErase, FirmwareErase_fields, (void (*)(void *))fsm_msgFirmwareErase}, - {'n', 'i', MessageType_MessageType_FirmwareUpload, FirmwareUpload_fields, (void (*)(void *))fsm_msgFirmwareUpload}, {'n', 'i', MessageType_MessageType_GetEntropy, GetEntropy_fields, (void (*)(void *))fsm_msgGetEntropy}, {'n', 'i', MessageType_MessageType_GetPublicKey, GetPublicKey_fields, (void (*)(void *))fsm_msgGetPublicKey}, {'n', 'i', MessageType_MessageType_LoadDevice, LoadDevice_fields, (void (*)(void *))fsm_msgLoadDevice}, diff --git a/firmware/protob/messages.options b/firmware/protob/messages.options index c0f88fc3ff..7138c65978 100644 --- a/firmware/protob/messages.options +++ b/firmware/protob/messages.options @@ -120,13 +120,11 @@ GetECDHSessionKey.ecdsa_curve_name max_size:32 ECDHSessionKey.session_key max_size:65 # not used in firmware -SimpleSignTx.inputs max_count:0 -SimpleSignTx.outputs max_count:0 -SimpleSignTx.transactions max_count:0 -SimpleSignTx.coin_name max_size:17 +SimpleSignTx skip_message:true +FirmwareRequest skip_message:true +FirmwareUpload skip_message:true -# not used in firmware -FirmwareUpload.payload max_size:0 +# used in debug firmware DebugLinkState.layout max_size:1024 DebugLinkState.pin max_size:10 diff --git a/firmware/protob/messages.pb.c b/firmware/protob/messages.pb.c index 8e85255962..b2421129d4 100644 --- a/firmware/protob/messages.pb.c +++ b/firmware/protob/messages.pb.c @@ -17,9 +17,6 @@ const char EstimateTxSize_coin_name_default[17] = "Bitcoin"; const char SignTx_coin_name_default[17] = "Bitcoin"; const uint32_t SignTx_version_default = 1u; const uint32_t SignTx_lock_time_default = 0u; -const char SimpleSignTx_coin_name_default[17] = "Bitcoin"; -const uint32_t SimpleSignTx_version_default = 1u; -const uint32_t SimpleSignTx_lock_time_default = 0u; const pb_field_t Initialize_fields[1] = { @@ -316,16 +313,6 @@ const pb_field_t SignTx_fields[6] = { PB_LAST_FIELD }; -const pb_field_t SimpleSignTx_fields[7] = { - PB_FIELD2( 1, MESSAGE , REPEATED, STATIC , FIRST, SimpleSignTx, inputs, inputs, &TxInputType_fields), - PB_FIELD2( 2, MESSAGE , REPEATED, STATIC , OTHER, SimpleSignTx, outputs, inputs, &TxOutputType_fields), - PB_FIELD2( 3, MESSAGE , REPEATED, STATIC , OTHER, SimpleSignTx, transactions, outputs, &TransactionType_fields), - PB_FIELD2( 4, STRING , OPTIONAL, STATIC , OTHER, SimpleSignTx, coin_name, transactions, &SimpleSignTx_coin_name_default), - PB_FIELD2( 5, UINT32 , OPTIONAL, STATIC , OTHER, SimpleSignTx, version, coin_name, &SimpleSignTx_version_default), - PB_FIELD2( 6, UINT32 , OPTIONAL, STATIC , OTHER, SimpleSignTx, lock_time, version, &SimpleSignTx_lock_time_default), - PB_LAST_FIELD -}; - const pb_field_t TxRequest_fields[4] = { PB_FIELD2( 1, ENUM , OPTIONAL, STATIC , FIRST, TxRequest, request_type, request_type, 0), PB_FIELD2( 2, MESSAGE , OPTIONAL, STATIC , OTHER, TxRequest, details, request_type, &TxRequestDetailsType_fields), @@ -400,11 +387,6 @@ const pb_field_t FirmwareErase_fields[1] = { PB_LAST_FIELD }; -const pb_field_t FirmwareUpload_fields[2] = { - PB_FIELD2( 1, BYTES , REQUIRED, STATIC , FIRST, FirmwareUpload, payload, payload, 0), - PB_LAST_FIELD -}; - const pb_field_t DebugLinkDecision_fields[2] = { PB_FIELD2( 1, BOOL , REQUIRED, STATIC , FIRST, DebugLinkDecision, yes_no, yes_no, 0), PB_LAST_FIELD @@ -472,7 +454,7 @@ const pb_field_t DebugLinkFlashErase_fields[2] = { * numbers or field sizes that are larger than what can fit in 8 or 16 bit * field descriptors. */ -STATIC_ASSERT((pb_membersize(Features, coins[0]) < 65536 && pb_membersize(PublicKey, node) < 65536 && pb_membersize(GetAddress, multisig) < 65536 && pb_membersize(LoadDevice, node) < 65536 && pb_membersize(SimpleSignTx, inputs[0]) < 65536 && pb_membersize(SimpleSignTx, outputs[0]) < 65536 && pb_membersize(SimpleSignTx, transactions[0]) < 65536 && pb_membersize(TxRequest, details) < 65536 && pb_membersize(TxRequest, serialized) < 65536 && pb_membersize(TxAck, tx) < 65536 && pb_membersize(SignIdentity, identity) < 65536 && pb_membersize(GetECDHSessionKey, identity) < 65536 && pb_membersize(DebugLinkState, node) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_Initialize_GetFeatures_Features_ClearSession_ApplySettings_ChangePin_Ping_Success_Failure_ButtonRequest_ButtonAck_PinMatrixRequest_PinMatrixAck_Cancel_PassphraseRequest_PassphraseAck_GetEntropy_Entropy_GetPublicKey_PublicKey_GetAddress_EthereumGetAddress_Address_EthereumAddress_WipeDevice_LoadDevice_ResetDevice_EntropyRequest_EntropyAck_RecoveryDevice_WordRequest_WordAck_SignMessage_VerifyMessage_MessageSignature_EncryptMessage_EncryptedMessage_DecryptMessage_DecryptedMessage_CipherKeyValue_CipheredKeyValue_EstimateTxSize_TxSize_SignTx_SimpleSignTx_TxRequest_TxAck_EthereumSignTx_EthereumTxRequest_EthereumTxAck_SignIdentity_SignedIdentity_GetECDHSessionKey_ECDHSessionKey_SetU2FCounter_FirmwareErase_FirmwareUpload_DebugLinkDecision_DebugLinkGetState_DebugLinkState_DebugLinkStop_DebugLinkLog_DebugLinkMemoryRead_DebugLinkMemory_DebugLinkMemoryWrite_DebugLinkFlashErase) +STATIC_ASSERT((pb_membersize(Features, coins[0]) < 65536 && pb_membersize(PublicKey, node) < 65536 && pb_membersize(GetAddress, multisig) < 65536 && pb_membersize(LoadDevice, node) < 65536 && pb_membersize(TxRequest, details) < 65536 && pb_membersize(TxRequest, serialized) < 65536 && pb_membersize(TxAck, tx) < 65536 && pb_membersize(SignIdentity, identity) < 65536 && pb_membersize(GetECDHSessionKey, identity) < 65536 && pb_membersize(DebugLinkState, node) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_Initialize_GetFeatures_Features_ClearSession_ApplySettings_ChangePin_Ping_Success_Failure_ButtonRequest_ButtonAck_PinMatrixRequest_PinMatrixAck_Cancel_PassphraseRequest_PassphraseAck_GetEntropy_Entropy_GetPublicKey_PublicKey_GetAddress_EthereumGetAddress_Address_EthereumAddress_WipeDevice_LoadDevice_ResetDevice_EntropyRequest_EntropyAck_RecoveryDevice_WordRequest_WordAck_SignMessage_VerifyMessage_MessageSignature_EncryptMessage_EncryptedMessage_DecryptMessage_DecryptedMessage_CipherKeyValue_CipheredKeyValue_EstimateTxSize_TxSize_SignTx_TxRequest_TxAck_EthereumSignTx_EthereumTxRequest_EthereumTxAck_SignIdentity_SignedIdentity_GetECDHSessionKey_ECDHSessionKey_SetU2FCounter_FirmwareErase_DebugLinkDecision_DebugLinkGetState_DebugLinkState_DebugLinkStop_DebugLinkLog_DebugLinkMemoryRead_DebugLinkMemory_DebugLinkMemoryWrite_DebugLinkFlashErase) #endif #if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) diff --git a/firmware/protob/messages.pb.h b/firmware/protob/messages.pb.h index ced5e9b6e1..0dad8391fc 100644 --- a/firmware/protob/messages.pb.h +++ b/firmware/protob/messages.pb.h @@ -20,6 +20,7 @@ typedef enum _MessageType { MessageType_MessageType_WipeDevice = 5, MessageType_MessageType_FirmwareErase = 6, MessageType_MessageType_FirmwareUpload = 7, + MessageType_MessageType_FirmwareRequest = 8, MessageType_MessageType_GetEntropy = 9, MessageType_MessageType_Entropy = 10, MessageType_MessageType_GetPublicKey = 11, @@ -551,15 +552,6 @@ typedef struct _Features { bool firmware_present; } Features; -typedef struct { - size_t size; - uint8_t bytes[0]; -} FirmwareUpload_payload_t; - -typedef struct _FirmwareUpload { - FirmwareUpload_payload_t payload; -} FirmwareUpload; - typedef struct _GetAddress { size_t address_n_count; uint32_t address_n[8]; @@ -763,21 +755,6 @@ typedef struct _SignedIdentity { SignedIdentity_signature_t signature; } SignedIdentity; -typedef struct _SimpleSignTx { - size_t inputs_count; - TxInputType inputs[0]; - size_t outputs_count; - TxOutputType outputs[0]; - size_t transactions_count; - TransactionType transactions[0]; - bool has_coin_name; - char coin_name[17]; - bool has_version; - uint32_t version; - bool has_lock_time; - uint32_t lock_time; -} SimpleSignTx; - typedef struct _Success { bool has_message; char message[256]; @@ -847,9 +824,6 @@ extern const char EstimateTxSize_coin_name_default[17]; extern const char SignTx_coin_name_default[17]; extern const uint32_t SignTx_version_default; extern const uint32_t SignTx_lock_time_default; -extern const char SimpleSignTx_coin_name_default[17]; -extern const uint32_t SimpleSignTx_version_default; -extern const uint32_t SimpleSignTx_lock_time_default; /* Initializer values for message structs */ #define Initialize_init_default {0} @@ -896,7 +870,6 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define EstimateTxSize_init_default {0, 0, false, "Bitcoin"} #define TxSize_init_default {false, 0} #define SignTx_init_default {0, 0, false, "Bitcoin", false, 1u, false, 0u} -#define SimpleSignTx_init_default {0, {}, 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} @@ -908,7 +881,6 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define ECDHSessionKey_init_default {false, {0, {0}}} #define SetU2FCounter_init_default {false, 0} #define FirmwareErase_init_default {0} -#define FirmwareUpload_init_default {{0, {0}}} #define DebugLinkDecision_init_default {0} #define DebugLinkGetState_init_default {0} #define DebugLinkState_init_default {false, {0, {0}}, false, "", false, "", false, "", false, HDNodeType_init_default, false, 0, false, "", false, {0, {0}}, false, "", false, 0} @@ -962,7 +934,6 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define EstimateTxSize_init_zero {0, 0, false, ""} #define TxSize_init_zero {false, 0} #define SignTx_init_zero {0, 0, false, "", false, 0, false, 0} -#define SimpleSignTx_init_zero {0, {}, 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} @@ -974,7 +945,6 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define ECDHSessionKey_init_zero {false, {0, {0}}} #define SetU2FCounter_init_zero {false, 0} #define FirmwareErase_init_zero {0} -#define FirmwareUpload_init_zero {{0, {0}}} #define DebugLinkDecision_init_zero {0} #define DebugLinkGetState_init_zero {0} #define DebugLinkState_init_zero {false, {0, {0}}, false, "", false, "", false, "", false, HDNodeType_init_zero, false, 0, false, "", false, {0, {0}}, false, "", false, 0} @@ -1080,7 +1050,6 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define Features_pin_cached_tag 16 #define Features_passphrase_cached_tag 17 #define Features_firmware_present_tag 18 -#define FirmwareUpload_payload_tag 1 #define GetAddress_address_n_tag 1 #define GetAddress_coin_name_tag 2 #define GetAddress_show_display_tag 3 @@ -1144,12 +1113,6 @@ extern const uint32_t SimpleSignTx_lock_time_default; #define SignedIdentity_address_tag 1 #define SignedIdentity_public_key_tag 2 #define SignedIdentity_signature_tag 3 -#define SimpleSignTx_inputs_tag 1 -#define SimpleSignTx_outputs_tag 2 -#define SimpleSignTx_transactions_tag 3 -#define SimpleSignTx_coin_name_tag 4 -#define SimpleSignTx_version_tag 5 -#define SimpleSignTx_lock_time_tag 6 #define Success_message_tag 1 #define TxAck_tx_tag 1 #define TxRequest_request_type_tag 1 @@ -1208,7 +1171,6 @@ extern const pb_field_t CipheredKeyValue_fields[2]; extern const pb_field_t EstimateTxSize_fields[4]; extern const pb_field_t TxSize_fields[2]; extern const pb_field_t SignTx_fields[6]; -extern const pb_field_t SimpleSignTx_fields[7]; extern const pb_field_t TxRequest_fields[4]; extern const pb_field_t TxAck_fields[2]; extern const pb_field_t EthereumSignTx_fields[10]; @@ -1220,7 +1182,6 @@ extern const pb_field_t GetECDHSessionKey_fields[4]; extern const pb_field_t ECDHSessionKey_fields[2]; extern const pb_field_t SetU2FCounter_fields[2]; extern const pb_field_t FirmwareErase_fields[1]; -extern const pb_field_t FirmwareUpload_fields[2]; extern const pb_field_t DebugLinkDecision_fields[2]; extern const pb_field_t DebugLinkGetState_fields[1]; extern const pb_field_t DebugLinkState_fields[11]; @@ -1276,7 +1237,6 @@ extern const pb_field_t DebugLinkFlashErase_fields[2]; #define EstimateTxSize_size 31 #define TxSize_size 6 #define SignTx_size 43 -#define SimpleSignTx_size (31 + 0*TxInputType_size + 0*TxOutputType_size + 0*TransactionType_size) #define TxRequest_size (18 + TxRequestDetailsType_size + TxRequestSerializedType_size) #define TxAck_size (6 + TransactionType_size) #define EthereumSignTx_size 1245 @@ -1288,7 +1248,6 @@ extern const pb_field_t DebugLinkFlashErase_fields[2]; #define ECDHSessionKey_size 67 #define SetU2FCounter_size 6 #define FirmwareErase_size 0 -#define FirmwareUpload_size 2 #define DebugLinkDecision_size 2 #define DebugLinkGetState_size 0 #define DebugLinkState_size (1468 + HDNodeType_size) diff --git a/firmware/protob/types.pb.c b/firmware/protob/types.pb.c index 67148cacd7..7863d57ad6 100644 --- a/firmware/protob/types.pb.c +++ b/firmware/protob/types.pb.c @@ -7,6 +7,8 @@ const uint32_t CoinType_address_type_default = 0u; const uint32_t CoinType_address_type_p2sh_default = 5u; const uint32_t CoinType_address_type_p2wpkh_default = 6u; const uint32_t CoinType_address_type_p2wsh_default = 10u; +const uint32_t CoinType_xpub_magic_default = 76067358u; +const uint32_t CoinType_xprv_magic_default = 76066276u; const uint32_t TxInputType_sequence_default = 4294967295u; const InputScriptType TxInputType_script_type_default = InputScriptType_SPENDADDRESS; const uint32_t IdentityType_index_default = 0u; @@ -28,7 +30,7 @@ const pb_field_t HDNodePathType_fields[3] = { PB_LAST_FIELD }; -const pb_field_t CoinType_fields[9] = { +const pb_field_t CoinType_fields[11] = { PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, CoinType, coin_name, coin_name, 0), PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, CoinType, coin_shortcut, coin_name, 0), PB_FIELD2( 3, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, address_type, coin_shortcut, &CoinType_address_type_default), @@ -37,6 +39,8 @@ const pb_field_t CoinType_fields[9] = { PB_FIELD2( 6, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, address_type_p2wpkh, address_type_p2sh, &CoinType_address_type_p2wpkh_default), PB_FIELD2( 7, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, address_type_p2wsh, address_type_p2wpkh, &CoinType_address_type_p2wsh_default), PB_FIELD2( 8, STRING , OPTIONAL, STATIC , OTHER, CoinType, signed_message_header, address_type_p2wsh, 0), + PB_FIELD2( 9, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, xpub_magic, signed_message_header, &CoinType_xpub_magic_default), + PB_FIELD2( 10, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, xprv_magic, xpub_magic, &CoinType_xprv_magic_default), PB_LAST_FIELD }; diff --git a/firmware/protob/types.pb.h b/firmware/protob/types.pb.h index 68b5ec6a55..4586a9407b 100644 --- a/firmware/protob/types.pb.h +++ b/firmware/protob/types.pb.h @@ -98,6 +98,10 @@ typedef struct _CoinType { uint32_t address_type_p2wsh; bool has_signed_message_header; char signed_message_header[32]; + bool has_xpub_magic; + uint32_t xpub_magic; + bool has_xprv_magic; + uint32_t xprv_magic; } CoinType; typedef struct { @@ -288,6 +292,8 @@ extern const uint32_t CoinType_address_type_default; extern const uint32_t CoinType_address_type_p2sh_default; extern const uint32_t CoinType_address_type_p2wpkh_default; extern const uint32_t CoinType_address_type_p2wsh_default; +extern const uint32_t CoinType_xpub_magic_default; +extern const uint32_t CoinType_xprv_magic_default; extern const uint32_t TxInputType_sequence_default; extern const InputScriptType TxInputType_script_type_default; extern const uint32_t IdentityType_index_default; @@ -295,7 +301,7 @@ extern const uint32_t IdentityType_index_default; /* Initializer values for message structs */ #define HDNodeType_init_default {0, 0, 0, {0, {0}}, false, {0, {0}}, false, {0, {0}}} #define HDNodePathType_init_default {HDNodeType_init_default, 0, {0, 0, 0, 0, 0, 0, 0, 0}} -#define CoinType_init_default {false, "", false, "", false, 0u, false, 0, false, 5u, false, 6u, false, 10u, false, ""} +#define CoinType_init_default {false, "", false, "", false, 0u, false, 0, false, 5u, false, 6u, false, 10u, false, "", false, 76067358u, false, 76066276u} #define MultisigRedeemScriptType_init_default {0, {HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default}, 0, {{0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}}, false, 0} #define TxInputType_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, {0, {0}}, 0, false, {0, {0}}, false, 4294967295u, false, InputScriptType_SPENDADDRESS, false, MultisigRedeemScriptType_init_default, false, 0} #define TxOutputType_init_default {false, "", 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, (OutputScriptType)0, false, MultisigRedeemScriptType_init_default, false, {0, {0}}} @@ -306,7 +312,7 @@ extern const uint32_t IdentityType_index_default; #define IdentityType_init_default {false, "", false, "", false, "", false, "", false, "", false, 0u} #define HDNodeType_init_zero {0, 0, 0, {0, {0}}, false, {0, {0}}, false, {0, {0}}} #define HDNodePathType_init_zero {HDNodeType_init_zero, 0, {0, 0, 0, 0, 0, 0, 0, 0}} -#define CoinType_init_zero {false, "", false, "", false, 0, false, 0, false, 0, false, 0, false, 0, false, ""} +#define CoinType_init_zero {false, "", false, "", false, 0, false, 0, false, 0, false, 0, false, 0, false, "", false, 0, false, 0} #define MultisigRedeemScriptType_init_zero {0, {HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero}, 0, {{0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}}, false, 0} #define TxInputType_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, {0, {0}}, 0, false, {0, {0}}, false, 0, false, (InputScriptType)0, false, MultisigRedeemScriptType_init_zero, false, 0} #define TxOutputType_init_zero {false, "", 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, (OutputScriptType)0, false, MultisigRedeemScriptType_init_zero, false, {0, {0}}} @@ -325,6 +331,8 @@ extern const uint32_t IdentityType_index_default; #define CoinType_address_type_p2wpkh_tag 6 #define CoinType_address_type_p2wsh_tag 7 #define CoinType_signed_message_header_tag 8 +#define CoinType_xpub_magic_tag 9 +#define CoinType_xprv_magic_tag 10 #define HDNodeType_depth_tag 1 #define HDNodeType_fingerprint_tag 2 #define HDNodeType_child_num_tag 3 @@ -382,7 +390,7 @@ extern const uint32_t IdentityType_index_default; /* Struct field encoding specification for nanopb */ extern const pb_field_t HDNodeType_fields[7]; extern const pb_field_t HDNodePathType_fields[3]; -extern const pb_field_t CoinType_fields[9]; +extern const pb_field_t CoinType_fields[11]; extern const pb_field_t MultisigRedeemScriptType_fields[4]; extern const pb_field_t TxInputType_fields[9]; extern const pb_field_t TxOutputType_fields[7]; @@ -395,7 +403,7 @@ extern const pb_field_t IdentityType_fields[7]; /* Maximum encoded size of messages (where known) */ #define HDNodeType_size 121 #define HDNodePathType_size 171 -#define CoinType_size 99 +#define CoinType_size 111 #define MultisigRedeemScriptType_size 3741 #define TxInputType_size 5508 #define TxOutputType_size 3934 diff --git a/vendor/trezor-common b/vendor/trezor-common index 80c7b666a2..dd1f7a2b0b 160000 --- a/vendor/trezor-common +++ b/vendor/trezor-common @@ -1 +1 @@ -Subproject commit 80c7b666a204c74be1d1ed6b019d1fad2d2fe909 +Subproject commit dd1f7a2b0b44793734e286239f64ddb3d816058d diff --git a/vendor/trezor-crypto b/vendor/trezor-crypto index df2524e35b..fa82ba6d3f 160000 --- a/vendor/trezor-crypto +++ b/vendor/trezor-crypto @@ -1 +1 @@ -Subproject commit df2524e35bc7d10129b965be017277ce46d2cae0 +Subproject commit fa82ba6d3f4ca9bbfee0c3dd7f8da22a8bfc6f11 diff --git a/vendor/trezor-qrenc b/vendor/trezor-qrenc index 9344f23d86..392ee5654f 160000 --- a/vendor/trezor-qrenc +++ b/vendor/trezor-qrenc @@ -1 +1 @@ -Subproject commit 9344f23d869030fbe7261d3361862eaba12b9975 +Subproject commit 392ee5654f4862f2e2b49b69a4e802997715d34f From 2866e6fe889beb7989135920db4ed70de597ee10 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 24 Apr 2017 20:34:13 +0200 Subject: [PATCH 3/5] ethereum: add EthereumSignTx.prefix --- firmware/ethereum.c | 8 ++++++++ firmware/protob/messages.options | 1 + firmware/protob/messages.pb.c | 3 ++- firmware/protob/messages.pb.h | 16 ++++++++++++---- vendor/trezor-common | 2 +- 5 files changed, 24 insertions(+), 6 deletions(-) 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 From aafd61ec8bb915f83dfa9d8f49824bf73238e9e1 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 26 Apr 2017 15:43:57 +0200 Subject: [PATCH 4/5] update trezor-common, add cointype.segwit bool --- firmware/coins-gen.py | 5 ++++- firmware/coins.c | 16 ++++++++-------- firmware/protob/types.pb.c | 3 ++- firmware/protob/types.pb.h | 11 +++++++---- vendor/trezor-common | 2 +- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/firmware/coins-gen.py b/firmware/coins-gen.py index c7181d942e..39de05c38e 100755 --- a/firmware/coins-gen.py +++ b/firmware/coins-gen.py @@ -35,7 +35,10 @@ for c in coins: '0x%s' % c['xpub_magic'] if c['xpub_magic'] is not None else '00000000', 'true' if c['xprv_magic'] is not None else 'false', - '0x%s' % c['xprv_magic'] if c['xprv_magic'] is not None else '00000000' + '0x%s' % c['xprv_magic'] if c['xprv_magic'] is not None else '00000000', + + 'true' if c['segwit'] is not None else 'false', + 'true' if c['segwit'] else 'false' ]) for j in range(len(fields[0])): diff --git a/firmware/coins.c b/firmware/coins.c index f26808e2bf..abe080f75e 100644 --- a/firmware/coins.c +++ b/firmware/coins.c @@ -26,14 +26,14 @@ // filled CoinType Protobuf structure defined in https://github.com/trezor/trezor-common/blob/master/protob/types.proto#L133 // address types > 0xFF represent a two-byte prefix in big-endian order const CoinType coins[COINS_COUNT] = { - {true, "Bitcoin", true, "BTC", true, 0, true, 300000, true, 5, true, 6, true, 10, true, "\x18" "Bitcoin Signed Message:\n", true, 0x0488b21e, true, 0x0488ade4, }, - {true, "Testnet", true, "TEST", true, 111, true, 10000000, true, 196, true, 3, true, 40, true, "\x18" "Bitcoin Signed Message:\n", true, 0x043587cf, true, 0x04358394, }, - {true, "Namecoin", true, "NMC", true, 52, true, 10000000, true, 5, false, 0, false, 0, true, "\x19" "Namecoin Signed Message:\n", true, 0x019da462, true, 0x019d9cfe, }, - {true, "Litecoin", true, "LTC", true, 48, true, 1000000, true, 5, false, 0, false, 0, true, "\x19" "Litecoin Signed Message:\n", true, 0x019da462, true, 0x019d9cfe, }, - {true, "Dogecoin", true, "DOGE", true, 30, true, 1000000000, true, 22, false, 0, false, 0, true, "\x19" "Dogecoin Signed Message:\n", true, 0x02facafd, true, 0x02fac398, }, - {true, "Dash", true, "DASH", true, 76, true, 100000, true, 16, false, 0, false, 0, true, "\x19" "DarkCoin Signed Message:\n", true, 0x02fe52cc, true, 0x02fe52f8, }, - {true, "Zcash", true, "ZEC", true, 7352, true, 1000000, true, 7357, false, 0, false, 0, true, "\x16" "Zcash Signed Message:\n", true, 0x0488b21e, true, 0x0488ade4, }, - {true, "Zcash Testnet", true, "TAZ", true, 7461, true, 10000000, true, 7354, false, 0, false, 0, true, "\x16" "Zcash Signed Message:\n", true, 0x043587cf, true, 0x04358394, }, + {true, "Bitcoin", true, "BTC", true, 0, true, 300000, true, 5, true, 6, true, 10, true, "\x18" "Bitcoin Signed Message:\n", true, 0x0488b21e, true, 0x0488ade4, true, false, }, + {true, "Testnet", true, "TEST", true, 111, true, 10000000, true, 196, true, 3, true, 40, true, "\x18" "Bitcoin Signed Message:\n", true, 0x043587cf, true, 0x04358394, true, true, }, + {true, "Namecoin", true, "NMC", true, 52, true, 10000000, true, 5, false, 0, false, 0, true, "\x19" "Namecoin Signed Message:\n", true, 0x019da462, true, 0x019d9cfe, true, false, }, + {true, "Litecoin", true, "LTC", true, 48, true, 1000000, true, 5, false, 0, false, 0, true, "\x19" "Litecoin Signed Message:\n", true, 0x019da462, true, 0x019d9cfe, true, true, }, + {true, "Dogecoin", true, "DOGE", true, 30, true, 1000000000, true, 22, false, 0, false, 0, true, "\x19" "Dogecoin Signed Message:\n", true, 0x02facafd, true, 0x02fac398, true, false, }, + {true, "Dash", true, "DASH", true, 76, true, 100000, true, 16, false, 0, false, 0, true, "\x19" "DarkCoin Signed Message:\n", true, 0x02fe52cc, true, 0x02fe52f8, true, false, }, + {true, "Zcash", true, "ZEC", true, 7352, true, 1000000, true, 7357, false, 0, false, 0, true, "\x16" "Zcash Signed Message:\n", true, 0x0488b21e, true, 0x0488ade4, true, false, }, + {true, "Zcash Testnet", true, "TAZ", true, 7461, true, 10000000, true, 7354, false, 0, false, 0, true, "\x16" "Zcash Signed Message:\n", true, 0x043587cf, true, 0x04358394, true, false, }, }; const CoinType *coinByShortcut(const char *shortcut) diff --git a/firmware/protob/types.pb.c b/firmware/protob/types.pb.c index 7863d57ad6..13448c606c 100644 --- a/firmware/protob/types.pb.c +++ b/firmware/protob/types.pb.c @@ -30,7 +30,7 @@ const pb_field_t HDNodePathType_fields[3] = { PB_LAST_FIELD }; -const pb_field_t CoinType_fields[11] = { +const pb_field_t CoinType_fields[12] = { PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, CoinType, coin_name, coin_name, 0), PB_FIELD2( 2, STRING , OPTIONAL, STATIC , OTHER, CoinType, coin_shortcut, coin_name, 0), PB_FIELD2( 3, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, address_type, coin_shortcut, &CoinType_address_type_default), @@ -41,6 +41,7 @@ const pb_field_t CoinType_fields[11] = { PB_FIELD2( 8, STRING , OPTIONAL, STATIC , OTHER, CoinType, signed_message_header, address_type_p2wsh, 0), PB_FIELD2( 9, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, xpub_magic, signed_message_header, &CoinType_xpub_magic_default), PB_FIELD2( 10, UINT32 , OPTIONAL, STATIC , OTHER, CoinType, xprv_magic, xpub_magic, &CoinType_xprv_magic_default), + PB_FIELD2( 11, BOOL , OPTIONAL, STATIC , OTHER, CoinType, segwit, xprv_magic, 0), PB_LAST_FIELD }; diff --git a/firmware/protob/types.pb.h b/firmware/protob/types.pb.h index 4586a9407b..8dd5cc5dfc 100644 --- a/firmware/protob/types.pb.h +++ b/firmware/protob/types.pb.h @@ -102,6 +102,8 @@ typedef struct _CoinType { uint32_t xpub_magic; bool has_xprv_magic; uint32_t xprv_magic; + bool has_segwit; + bool segwit; } CoinType; typedef struct { @@ -301,7 +303,7 @@ extern const uint32_t IdentityType_index_default; /* Initializer values for message structs */ #define HDNodeType_init_default {0, 0, 0, {0, {0}}, false, {0, {0}}, false, {0, {0}}} #define HDNodePathType_init_default {HDNodeType_init_default, 0, {0, 0, 0, 0, 0, 0, 0, 0}} -#define CoinType_init_default {false, "", false, "", false, 0u, false, 0, false, 5u, false, 6u, false, 10u, false, "", false, 76067358u, false, 76066276u} +#define CoinType_init_default {false, "", false, "", false, 0u, false, 0, false, 5u, false, 6u, false, 10u, false, "", false, 76067358u, false, 76066276u, false, 0} #define MultisigRedeemScriptType_init_default {0, {HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default}, 0, {{0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}}, false, 0} #define TxInputType_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, {0, {0}}, 0, false, {0, {0}}, false, 4294967295u, false, InputScriptType_SPENDADDRESS, false, MultisigRedeemScriptType_init_default, false, 0} #define TxOutputType_init_default {false, "", 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, (OutputScriptType)0, false, MultisigRedeemScriptType_init_default, false, {0, {0}}} @@ -312,7 +314,7 @@ extern const uint32_t IdentityType_index_default; #define IdentityType_init_default {false, "", false, "", false, "", false, "", false, "", false, 0u} #define HDNodeType_init_zero {0, 0, 0, {0, {0}}, false, {0, {0}}, false, {0, {0}}} #define HDNodePathType_init_zero {HDNodeType_init_zero, 0, {0, 0, 0, 0, 0, 0, 0, 0}} -#define CoinType_init_zero {false, "", false, "", false, 0, false, 0, false, 0, false, 0, false, 0, false, "", false, 0, false, 0} +#define CoinType_init_zero {false, "", false, "", false, 0, false, 0, false, 0, false, 0, false, 0, false, "", false, 0, false, 0, false, 0} #define MultisigRedeemScriptType_init_zero {0, {HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero}, 0, {{0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}}, false, 0} #define TxInputType_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, {0, {0}}, 0, false, {0, {0}}, false, 0, false, (InputScriptType)0, false, MultisigRedeemScriptType_init_zero, false, 0} #define TxOutputType_init_zero {false, "", 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, (OutputScriptType)0, false, MultisigRedeemScriptType_init_zero, false, {0, {0}}} @@ -333,6 +335,7 @@ extern const uint32_t IdentityType_index_default; #define CoinType_signed_message_header_tag 8 #define CoinType_xpub_magic_tag 9 #define CoinType_xprv_magic_tag 10 +#define CoinType_segwit_tag 11 #define HDNodeType_depth_tag 1 #define HDNodeType_fingerprint_tag 2 #define HDNodeType_child_num_tag 3 @@ -390,7 +393,7 @@ extern const uint32_t IdentityType_index_default; /* Struct field encoding specification for nanopb */ extern const pb_field_t HDNodeType_fields[7]; extern const pb_field_t HDNodePathType_fields[3]; -extern const pb_field_t CoinType_fields[11]; +extern const pb_field_t CoinType_fields[12]; extern const pb_field_t MultisigRedeemScriptType_fields[4]; extern const pb_field_t TxInputType_fields[9]; extern const pb_field_t TxOutputType_fields[7]; @@ -403,7 +406,7 @@ extern const pb_field_t IdentityType_fields[7]; /* Maximum encoded size of messages (where known) */ #define HDNodeType_size 121 #define HDNodePathType_size 171 -#define CoinType_size 111 +#define CoinType_size 113 #define MultisigRedeemScriptType_size 3741 #define TxInputType_size 5508 #define TxOutputType_size 3934 diff --git a/vendor/trezor-common b/vendor/trezor-common index 78da723c06..2148e5ff8d 160000 --- a/vendor/trezor-common +++ b/vendor/trezor-common @@ -1 +1 @@ -Subproject commit 78da723c063ae0aa76e06a517fe48d0013928cc4 +Subproject commit 2148e5ff8d76444f82f8e4c833157df7de8eaba5 From 13f03d38808b28ecd24c09333208c60c8a1261f9 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Sun, 30 Apr 2017 03:26:57 +0200 Subject: [PATCH 5/5] Revert "ethereum: add EthereumSignTx.prefix" This reverts commit 2866e6fe889beb7989135920db4ed70de597ee10. --- firmware/ethereum.c | 8 -------- firmware/protob/messages.options | 1 - firmware/protob/messages.pb.c | 3 +-- firmware/protob/messages.pb.h | 16 ++++------------ vendor/trezor-common | 2 +- 5 files changed, 6 insertions(+), 24 deletions(-) diff --git a/firmware/ethereum.c b/firmware/ethereum.c index 8d6c78ec11..a7342391ad 100644 --- a/firmware/ethereum.c +++ b/firmware/ethereum.c @@ -438,8 +438,6 @@ 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) { @@ -514,9 +512,6 @@ 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]); @@ -534,9 +529,6 @@ 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 c538e5e99d..7138c65978 100644 --- a/firmware/protob/messages.options +++ b/firmware/protob/messages.options @@ -100,7 +100,6 @@ 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 5a55dbeb03..b2421129d4 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[11] = { +const pb_field_t EthereumSignTx_fields[10] = { 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,7 +335,6 @@ const pb_field_t EthereumSignTx_fields[11] = { 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 d8470eb997..0dad8391fc 100644 --- a/firmware/protob/messages.pb.h +++ b/firmware/protob/messages.pb.h @@ -444,11 +444,6 @@ 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]; @@ -468,8 +463,6 @@ 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 { @@ -879,7 +872,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, false, {0, {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} #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, ""} @@ -943,7 +936,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, false, {0, {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} #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, ""} @@ -1032,7 +1025,6 @@ 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 @@ -1181,7 +1173,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[11]; +extern const pb_field_t EthereumSignTx_fields[10]; extern const pb_field_t EthereumTxRequest_fields[5]; extern const pb_field_t EthereumTxAck_fields[2]; extern const pb_field_t SignIdentity_fields[5]; @@ -1247,7 +1239,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 1279 +#define EthereumSignTx_size 1245 #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 2148e5ff8d..fe6e62c11f 160000 --- a/vendor/trezor-common +++ b/vendor/trezor-common @@ -1 +1 @@ -Subproject commit 2148e5ff8d76444f82f8e4c833157df7de8eaba5 +Subproject commit fe6e62c11f7dca8cb601e53c5865f15f770fd079