1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 12:28:09 +00:00

layout: show path for CoSi commit/sign if following SLIP-0018

This commit is contained in:
Pavol Rusnak 2017-10-09 21:05:59 +02:00
parent 15eefd5646
commit b56da1e4b4
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 17 additions and 6 deletions

View File

@ -1343,7 +1343,7 @@ void fsm_msgCosiCommit(CosiCommit *msg)
CHECK_PARAM(msg->has_data, _("No data provided"));
layoutCosiCommitSign(msg->data.bytes, msg->data.size, false);
layoutCosiCommitSign(msg->address_n, msg->address_n_count, msg->data.bytes, msg->data.size, false);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();
@ -1383,7 +1383,7 @@ void fsm_msgCosiSign(CosiSign *msg)
CHECK_PARAM(msg->has_global_commitment && msg->global_commitment.size == 32, _("Invalid global commitment"));
CHECK_PARAM(msg->has_global_pubkey && msg->global_pubkey.size == 32, _("Invalid global pubkey"));
layoutCosiCommitSign(msg->data.bytes, msg->data.size, true);
layoutCosiCommitSign(msg->address_n, msg->address_n_count, msg->data.bytes, msg->data.size, true);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
layoutHome();

View File

@ -645,8 +645,20 @@ void layoutNEMLevy(const NEMMosaicDefinition *definition, uint8_t network) {
}
}
void layoutCosiCommitSign(const uint8_t *data, uint32_t len, bool final_sign)
void layoutCosiCommitSign(const uint32_t *address_n, size_t address_n_count, const uint8_t *data, uint32_t len, bool final_sign)
{
char *desc = final_sign ? _("CoSi sign message?") : _("CoSi commit message?");
if (address_n_count == 2 && address_n[0] == (0x80000000 + 10018) && (address_n[1] & 0x80000000) && (address_n[1] & 0x7FFFFFFF) <= 9) {
char desc_buf[32];
if (final_sign) {
strlcpy(desc_buf, _("CoSi sign index #?"), sizeof(desc_buf));
desc_buf[16] = '0' + (address_n[1] & 0x7FFFFFFF);
} else {
strlcpy(desc_buf, _("CoSi commit index #?"), sizeof(desc_buf));
desc_buf[18] = '0' + (address_n[1] & 0x7FFFFFFF);
}
desc = desc_buf;
}
char str[4][17];
if (len == 32) {
data2hex(data , 8, str[0]);
@ -659,7 +671,6 @@ void layoutCosiCommitSign(const uint8_t *data, uint32_t len, bool final_sign)
strlcpy(str[2], "unsupported", sizeof(str[2]));
strlcpy(str[3], "length", sizeof(str[3]));
}
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"),
final_sign ? _("CoSi sign message?") : _("CoSi commit message?"),
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), desc,
str[0], str[1], str[2], str[3], NULL, NULL);
}

View File

@ -57,6 +57,6 @@ void layoutNEMTransferPayload(const uint8_t *payload, size_t length, bool encryp
void layoutNEMMosaicDescription(const char *description);
void layoutNEMLevy(const NEMMosaicDefinition *definition, uint8_t network);
void layoutCosiCommitSign(const uint8_t *data, uint32_t len, bool final_sign);
void layoutCosiCommitSign(const uint32_t *address_n, size_t address_n_count, const uint8_t *data, uint32_t len, bool final_sign);
#endif