mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-17 20:08:12 +00:00
feat(legacy): Show address confirmation in SignMessage.
This commit is contained in:
parent
39a0901e99
commit
5e6e56ac4d
1
legacy/firmware/.changelog.d/1586.added.1
Normal file
1
legacy/firmware/.changelog.d/1586.added.1
Normal file
@ -0,0 +1 @@
|
||||
Show address confirmation in SignMessage.
|
@ -905,16 +905,6 @@ static void ethereum_message_hash(const uint8_t *message, size_t message_len,
|
||||
|
||||
void ethereum_message_sign(const EthereumSignMessage *msg, const HDNode *node,
|
||||
EthereumMessageSignature *resp) {
|
||||
uint8_t pubkeyhash[20] = {0};
|
||||
if (!hdnode_get_ethereum_pubkeyhash(node, pubkeyhash)) {
|
||||
return;
|
||||
}
|
||||
|
||||
resp->address[0] = '0';
|
||||
resp->address[1] = 'x';
|
||||
ethereum_address_checksum(pubkeyhash, resp->address + 2, false, 0);
|
||||
// ethereum_address_checksum adds trailing zero
|
||||
|
||||
uint8_t hash[32] = {0};
|
||||
ethereum_message_hash(msg->message.bytes, msg->message.size, hash);
|
||||
|
||||
|
@ -256,13 +256,6 @@ void fsm_msgSignMessage(const SignMessage *msg) {
|
||||
|
||||
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
|
||||
|
||||
const CoinInfo *coin = fsm_getCoin(msg->has_coin_name, msg->coin_name);
|
||||
@ -271,24 +264,39 @@ void fsm_msgSignMessage(const SignMessage *msg) {
|
||||
msg->address_n_count, NULL);
|
||||
if (!node) return;
|
||||
|
||||
if (hdnode_fill_public_key(node) != 0) {
|
||||
fsm_sendFailure(FailureType_Failure_ProcessError,
|
||||
_("Failed to derive public key"));
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!compute_address(coin, msg->script_type, node, false, NULL,
|
||||
resp->address)) {
|
||||
fsm_sendFailure(FailureType_Failure_ProcessError,
|
||||
_("Error computing address"));
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
|
||||
layoutVerifyAddress(coin, resp->address);
|
||||
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
|
||||
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
|
||||
layoutSignMessage(msg->message.bytes, msg->message.size);
|
||||
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
|
||||
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
|
||||
layoutProgressSwipe(_("Signing"), 0);
|
||||
if (cryptoMessageSign(coin, node, msg->script_type, msg->no_script_type,
|
||||
msg->message.bytes, msg->message.size,
|
||||
resp->signature.bytes) == 0) {
|
||||
if (hdnode_fill_public_key(node) != 0) {
|
||||
fsm_sendFailure(FailureType_Failure_ProcessError,
|
||||
_("Failed to derive public key"));
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!compute_address(coin, msg->script_type, node, false, NULL,
|
||||
resp->address)) {
|
||||
fsm_sendFailure(FailureType_Failure_ProcessError,
|
||||
_("Error computing address"));
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
resp->signature.size = 65;
|
||||
msg_write(MessageType_MessageType_MessageSignature, resp);
|
||||
} else {
|
||||
|
@ -150,6 +150,29 @@ void fsm_msgEthereumSignMessage(const EthereumSignMessage *msg) {
|
||||
|
||||
CHECK_INITIALIZED
|
||||
|
||||
CHECK_PIN
|
||||
|
||||
const HDNode *node = fsm_getDerivedNode(SECP256K1_NAME, msg->address_n,
|
||||
msg->address_n_count, NULL);
|
||||
if (!node) return;
|
||||
|
||||
uint8_t pubkeyhash[20] = {0};
|
||||
if (!hdnode_get_ethereum_pubkeyhash(node, pubkeyhash)) {
|
||||
return;
|
||||
}
|
||||
|
||||
resp->address[0] = '0';
|
||||
resp->address[1] = 'x';
|
||||
ethereum_address_checksum(pubkeyhash, resp->address + 2, false, 0);
|
||||
// ethereum_address_checksum adds trailing zero
|
||||
|
||||
layoutVerifyAddress(NULL, resp->address);
|
||||
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
|
||||
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
|
||||
layoutSignMessage(msg->message.bytes, msg->message.size);
|
||||
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
|
||||
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
|
||||
@ -157,12 +180,6 @@ void fsm_msgEthereumSignMessage(const EthereumSignMessage *msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK_PIN
|
||||
|
||||
const HDNode *node = fsm_getDerivedNode(SECP256K1_NAME, msg->address_n,
|
||||
msg->address_n_count, NULL);
|
||||
if (!node) return;
|
||||
|
||||
ethereum_message_sign(msg, node, resp);
|
||||
layoutHome();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user