From ae82735b6b7ecbe46a0baf3243ccd0f3e73ca21d Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 22 May 2018 18:32:04 +0200 Subject: [PATCH] protob: remove Stellar{SignMessage,MessageSignature,VerifyMessage} --- firmware/fsm.h | 2 -- firmware/fsm_msg_stellar.h | 40 -------------------------------- firmware/protob/messages.options | 13 ----------- firmware/stellar.c | 17 -------------- firmware/stellar.h | 3 --- vendor/trezor-common | 2 +- 6 files changed, 1 insertion(+), 76 deletions(-) diff --git a/firmware/fsm.h b/firmware/fsm.h index 6bdb22c490..b8af6d1549 100644 --- a/firmware/fsm.h +++ b/firmware/fsm.h @@ -93,8 +93,6 @@ void fsm_msgStellarChangeTrustOp(StellarChangeTrustOp *msg); void fsm_msgStellarAllowTrustOp(StellarAllowTrustOp *msg); void fsm_msgStellarAccountMergeOp(StellarAccountMergeOp *msg); void fsm_msgStellarManageDataOp(StellarManageDataOp *msg); -void fsm_msgStellarSignMessage(StellarSignMessage *msg); -void fsm_msgStellarVerifyMessage(StellarVerifyMessage *msg); void fsm_msgStellarBumpSequenceOp(StellarBumpSequenceOp *msg); // debug message functions diff --git a/firmware/fsm_msg_stellar.h b/firmware/fsm_msg_stellar.h index de92b76b65..d621323a52 100644 --- a/firmware/fsm_msg_stellar.h +++ b/firmware/fsm_msg_stellar.h @@ -19,46 +19,6 @@ void fsm_msgStellarGetPublicKey(StellarGetPublicKey *msg) layoutHome(); } -void fsm_msgStellarSignMessage(StellarSignMessage *msg) -{ - RESP_INIT(StellarMessageSignature); - - CHECK_INITIALIZED - - layoutSignMessage(msg->message.bytes, msg->message.size); - if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) { - fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL); - layoutHome(); - return; - } - - CHECK_PIN - - // Populate response message - stellar_signMessage(msg->message.bytes, msg->message.size, msg->address_n, msg->address_n_count, resp->signature.bytes); - resp->has_signature = true; - resp->signature.size = 64; - - stellar_getPubkeyAtAddress(msg->address_n, msg->address_n_count, resp->public_key.bytes, sizeof(resp->public_key.bytes)); - resp->has_public_key = true; - resp->public_key.size = 32; - - msg_write(MessageType_MessageType_StellarMessageSignature, resp); - - layoutHome(); -} - -void fsm_msgStellarVerifyMessage(StellarVerifyMessage *msg) -{ - if (!stellar_verifyMessage(msg)) { - fsm_sendFailure(FailureType_Failure_DataError, _("Invalid signature")); - return; - } - - fsm_sendSuccess(_("Message verified")); - layoutHome(); -} - void fsm_msgStellarSignTx(StellarSignTx *msg) { CHECK_INITIALIZED diff --git a/firmware/protob/messages.options b/firmware/protob/messages.options index 8e21a7d8d4..f1d69fb7ef 100644 --- a/firmware/protob/messages.options +++ b/firmware/protob/messages.options @@ -182,16 +182,6 @@ StellarGetPublicKey.address_n max_count:10 StellarPublicKey.public_key max_size:32 -StellarSignMessage.address_n max_count:10 -StellarSignMessage.message max_size:1024 - -StellarMessageSignature.public_key max_size:32 -StellarMessageSignature.signature max_size:64 - -StellarVerifyMessage.public_key max_size:32 -StellarVerifyMessage.message max_size:1024 -StellarVerifyMessage.signature max_size:64 - StellarSignTx.address_n max_count:10 StellarSignTx.network_passphrase max_size:1024 StellarSignTx.source_account max_size:32 @@ -249,12 +239,9 @@ SelfTest skip_message:true LiskGetAddress skip_message:true LiskSignTx skip_message:true -LiskSignMessage skip_message:true -LiskVerifyMessage skip_message:true LiskGetPublicKey skip_message:true LiskAddress skip_message:true LiskSignedTx skip_message:true -LiskMessageSignature skip_message:true LiskPublicKey skip_message:true # used only in debug firmware diff --git a/firmware/stellar.c b/firmware/stellar.c index fbb449c4e5..f0fc3d8b6d 100644 --- a/firmware/stellar.c +++ b/firmware/stellar.c @@ -1130,23 +1130,6 @@ void stellar_getSignatureForActiveTx(uint8_t *out_signature) memcpy(out_signature, signature, sizeof(signature)); } -void stellar_signMessage(const uint8_t *message, uint32_t message_len, uint32_t *address_n, size_t address_n_count, uint8_t *out_signature) -{ - HDNode *node = stellar_deriveNode(address_n, address_n_count); - ed25519_sign(message, message_len, node->private_key, node->public_key + 1, out_signature); -} - -bool stellar_verifyMessage(StellarVerifyMessage *msg) -{ - // returns 0 if signature is valid - return ed25519_sign_open( - msg->message.bytes, - msg->message.size, - msg->public_key.bytes, - msg->signature.bytes - ) == 0; -} - /* * Returns number (representing stroops) formatted as XLM * For example, if number has value 1000000000 then it will be returned as "100.0" diff --git a/firmware/stellar.h b/firmware/stellar.h index d94bfb6ab8..57c1697b22 100644 --- a/firmware/stellar.h +++ b/firmware/stellar.h @@ -57,9 +57,6 @@ void stellar_confirmAccountMergeOp(StellarAccountMergeOp *msg); void stellar_confirmManageDataOp(StellarManageDataOp *msg); void stellar_confirmBumpSequenceOp(StellarBumpSequenceOp *msg); -void stellar_signMessage(const uint8_t *message, uint32_t message_len, uint32_t *address_n, size_t address_n_count, uint8_t *out_signature); -bool stellar_verifyMessage(StellarVerifyMessage *msg); - // Layout void stellar_layoutGetPublicKey(uint32_t *address_n, size_t address_n_count); void stellar_layoutTransactionDialog(const char *line1, const char *line2, const char *line3, const char *line4, const char *line5); diff --git a/vendor/trezor-common b/vendor/trezor-common index f54cf5073c..fb662e53b1 160000 --- a/vendor/trezor-common +++ b/vendor/trezor-common @@ -1 +1 @@ -Subproject commit f54cf5073c550d92338beb7e8c70ec703d63aee8 +Subproject commit fb662e53b129b250149d982259696531ff4c2b95