|
|
|
@ -212,3 +212,64 @@ void fsm_msgEthereumVerifyMessage(const EthereumVerifyMessage *msg) {
|
|
|
|
|
|
|
|
|
|
layoutHome();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fsm_msgEthereumSignTypedHash(const EthereumSignTypedHash *msg) {
|
|
|
|
|
RESP_INIT(EthereumTypedDataSignature);
|
|
|
|
|
|
|
|
|
|
CHECK_INITIALIZED
|
|
|
|
|
|
|
|
|
|
CHECK_PIN
|
|
|
|
|
|
|
|
|
|
if (msg->domain_separator_hash.size != 32 || msg->message_hash.size != 32) {
|
|
|
|
|
fsm_sendFailure(FailureType_Failure_DataError, _("Invalid hash length"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
layoutDialogSwipe(&bmp_icon_warning, _("Abort"), _("Continue"), NULL,
|
|
|
|
|
_("Unable to show"), _("EIP-712 data."), NULL,
|
|
|
|
|
_("Sign at your own risk."), NULL, NULL);
|
|
|
|
|
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
|
|
|
|
|
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
|
|
|
|
|
layoutHome();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
layoutConfirmHash(&bmp_icon_warning, _("EIP-712 domain hash"),
|
|
|
|
|
msg->domain_separator_hash.bytes, 32);
|
|
|
|
|
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
|
|
|
|
|
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
|
|
|
|
|
layoutHome();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
layoutConfirmHash(&bmp_icon_warning, _("EIP-712 message hash"),
|
|
|
|
|
msg->message_hash.bytes, 32);
|
|
|
|
|
if (!protectButton(ButtonRequestType_ButtonRequest_Other, false)) {
|
|
|
|
|
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
|
|
|
|
|
layoutHome();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ethereum_typed_hash_sign(msg, node, resp);
|
|
|
|
|
layoutHome();
|
|
|
|
|
}
|
|
|
|
|