From 258d3eadddc425ce3ccdeb430f6eeb19e54af91e Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Fri, 21 Apr 2017 12:55:14 +0200 Subject: [PATCH] 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