From 5debebefc8c13ab88addda6142d890e4fb10e310 Mon Sep 17 00:00:00 2001 From: matejcik Date: Fri, 18 Sep 2020 11:32:38 +0200 Subject: [PATCH] chore(legacy): update code to handle protobuf changes correctly --- legacy/firmware/crypto.c | 7 +++---- legacy/firmware/fsm_msg_coin.h | 4 ---- legacy/firmware/fsm_msg_ethereum.h | 1 - legacy/firmware/protob/Makefile | 3 ++- .../firmware/protob/messages-bitcoin.options | 18 ++++++++++++++++++ legacy/firmware/transaction.c | 2 -- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/legacy/firmware/crypto.c b/legacy/firmware/crypto.c index 2dfc9ef867..a8cff67e9a 100644 --- a/legacy/firmware/crypto.c +++ b/legacy/firmware/crypto.c @@ -388,7 +388,7 @@ const HDNode *cryptoMultisigPubkey(const CoinInfo *coin, return 0; } if (node_ptr->chain_code.size != 32) return 0; - if (!node_ptr->has_public_key || node_ptr->public_key.size != 33) return 0; + if (node_ptr->public_key.size != 33) return 0; static HDNode node; if (!hdnode_from_xpub(node_ptr->depth, node_ptr->child_num, node_ptr->chain_code.bytes, node_ptr->public_key.bytes, @@ -429,7 +429,7 @@ int cryptoMultisigFingerprint(const MultisigRedeemScriptType *multisig, if (n < 1 || n > 15) { return 0; } - if (!multisig->has_m || multisig->m < 1 || multisig->m > 15) { + if (multisig->m < 1 || multisig->m > 15) { return 0; } for (uint32_t i = 0; i < n; i++) { @@ -442,8 +442,7 @@ int cryptoMultisigFingerprint(const MultisigRedeemScriptType *multisig, } } for (uint32_t i = 0; i < n; i++) { - if (!pubnodes[i]->has_public_key || pubnodes[i]->public_key.size != 33) - return 0; + if (pubnodes[i]->public_key.size != 33) return 0; if (pubnodes[i]->chain_code.size != 32) return 0; } // minsort according to pubkey diff --git a/legacy/firmware/fsm_msg_coin.h b/legacy/firmware/fsm_msg_coin.h index 17e6642b55..107e807251 100644 --- a/legacy/firmware/fsm_msg_coin.h +++ b/legacy/firmware/fsm_msg_coin.h @@ -56,7 +56,6 @@ void fsm_msgGetPublicKey(const GetPublicKey *msg) { resp->node.chain_code.size = 32; memcpy(resp->node.chain_code.bytes, node->chain_code, 32); resp->node.has_private_key = false; - resp->node.has_public_key = true; resp->node.public_key.size = 33; memcpy(resp->node.public_key.bytes, node->public_key, 33); if (node->public_key[0] == 1) { @@ -237,9 +236,6 @@ void fsm_msgSignMessage(const SignMessage *msg) { } void fsm_msgVerifyMessage(const VerifyMessage *msg) { - CHECK_PARAM(msg->has_address, _("No address provided")); - CHECK_PARAM(msg->has_message, _("No message provided")); - const CoinInfo *coin = fsm_getCoin(msg->has_coin_name, msg->coin_name); if (!coin) return; layoutProgressSwipe(_("Verifying"), 0); diff --git a/legacy/firmware/fsm_msg_ethereum.h b/legacy/firmware/fsm_msg_ethereum.h index 8eb08ae386..6c1325d971 100644 --- a/legacy/firmware/fsm_msg_ethereum.h +++ b/legacy/firmware/fsm_msg_ethereum.h @@ -51,7 +51,6 @@ void fsm_msgEthereumGetPublicKey(const EthereumGetPublicKey *msg) { resp->node.chain_code.size = 32; memcpy(resp->node.chain_code.bytes, node->chain_code, 32); resp->node.has_private_key = false; - resp->node.has_public_key = true; resp->node.public_key.size = 33; memcpy(resp->node.public_key.bytes, node->public_key, 33); diff --git a/legacy/firmware/protob/Makefile b/legacy/firmware/protob/Makefile index aff7aecf5c..79ab9d0a53 100644 --- a/legacy/firmware/protob/Makefile +++ b/legacy/firmware/protob/Makefile @@ -5,7 +5,8 @@ endif SKIPPED_MESSAGES := Binance Cardano DebugMonero Eos Monero Ontology Ripple SdProtect Tezos WebAuthn \ DebugLinkRecordScreen DebugLinkReseedRandom DebugLinkShowText DebugLinkEraseSdCard DebugLinkWatchLayout \ GetOwnershipProof OwnershipProof GetOwnershipId OwnershipId AuthorizeCoinJoin DoPreauthorized \ - CancelAuthorization + CancelAuthorization \ + TxAckInput TxAckOutput TxAckPrev ifeq ($(BITCOIN_ONLY), 1) SKIPPED_MESSAGES += Ethereum Lisk NEM Stellar diff --git a/legacy/firmware/protob/messages-bitcoin.options b/legacy/firmware/protob/messages-bitcoin.options index c958e56a15..dd572c5367 100644 --- a/legacy/firmware/protob/messages-bitcoin.options +++ b/legacy/firmware/protob/messages-bitcoin.options @@ -69,3 +69,21 @@ OwnershipId.ownership_id max_size:32 AuthorizeCoinJoin.coordinator max_size:18 AuthorizeCoinJoin.address_n max_count:8 AuthorizeCoinJoin.coin_name max_size:21 + +TxAckInputType.address_n max_count:8 +TxAckInputType.prev_hash max_size:32 +TxAckInputType.script_sig max_size:1650 +TxAckInputType.witness max_size:109 +TxAckInputType.ownership_proof max_size:171 +TxAckInputType.commitment_data max_size:32 + +TxAckOutputType.address max_size:130 +TxAckOutputType.address_n max_count:8 +TxAckOutputType.op_return_data max_size:80 + +TxAckPrevInputType.prev_hash max_size:32 +TxAckPrevInputType.script_sig max_size:1650 + +TxAckPrevOutputType.script_pubkey max_size:520 + +TxAckPrevExtraDataWrapper.extra_data_chunk max_size:1024 diff --git a/legacy/firmware/transaction.c b/legacy/firmware/transaction.c index 98ece0c369..8423ef3e1e 100644 --- a/legacy/firmware/transaction.c +++ b/legacy/firmware/transaction.c @@ -356,7 +356,6 @@ uint32_t compile_script_sig(uint32_t address_type, const uint8_t *pubkeyhash, uint32_t compile_script_multisig(const CoinInfo *coin, const MultisigRedeemScriptType *multisig, uint8_t *out) { - if (!multisig->has_m) return 0; const uint32_t m = multisig->m; const uint32_t n = cryptoMultisigPubkeyCount(multisig); if (m < 1 || m > 15) return 0; @@ -386,7 +385,6 @@ uint32_t compile_script_multisig(const CoinInfo *coin, uint32_t compile_script_multisig_hash(const CoinInfo *coin, const MultisigRedeemScriptType *multisig, uint8_t *hash) { - if (!multisig->has_m) return 0; const uint32_t m = multisig->m; const uint32_t n = cryptoMultisigPubkeyCount(multisig); if (m < 1 || m > 15) return 0;