Skip to content

Commit

Permalink
feat: improve keys data review for better user experience (#121)
Browse files Browse the repository at this point in the history
* feat: update snapshots

* feat: improve keys data review for better user experience

* feat: update snapshots
  • Loading branch information
emmanuelm41 authored Sep 9, 2024
1 parent a257190 commit 8992a45
Show file tree
Hide file tree
Showing 194 changed files with 420 additions and 159 deletions.
4 changes: 2 additions & 2 deletions app/Makefile.version
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is the major version
APPVERSION_M=4
# This is the minor version
APPVERSION_N=1
APPVERSION_N=2
# This is the patch version
APPVERSION_P=4
APPVERSION_P=0
1 change: 1 addition & 0 deletions app/src/common/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@

address_state_t action_addrResponse;
key_state_t key_state;
bool keys_permission_granted = false;
2 changes: 2 additions & 0 deletions app/src/common/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

extern address_state_t action_addrResponse;
extern key_state_t key_state;
extern bool keys_permission_granted;

__Z_INLINE void app_reject() {
transaction_reset();
Expand All @@ -41,6 +42,7 @@ __Z_INLINE void app_reject() {
}

__Z_INLINE void app_reply_key() {
keys_permission_granted = true;
set_code(G_io_apdu_buffer, key_state.len, APDU_CODE_OK);
io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, key_state.len + 2);
}
Expand Down
47 changes: 35 additions & 12 deletions app/src/handlers/handler_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "view_internal.h"
#include "zxmacros.h"



// Transmitted notes are stored on the blockchain in encrypted form.
// If the note was sent to Alice, she uses her incoming viewing key (IVK)
// to decrypt the note (so that she can subsequently send it).
Expand Down Expand Up @@ -61,9 +63,15 @@ __Z_INLINE void handleGetKeyIVK(volatile uint32_t *flags, volatile uint32_t *tx,
}
key_state.len = (uint8_t)replyLen;

view_review_init(key_getItem, key_getNumItems, app_reply_key);
view_review_show(REVIEW_GENERIC);
*flags |= IO_ASYNCH_REPLY;
if (app_mode_expert() || !keys_permission_granted) {
view_review_init(key_getItem, key_getNumItems, app_reply_key);
view_review_show(REVIEW_GENERIC);
*flags |= IO_ASYNCH_REPLY;
return;
}

*tx = replyLen;
THROW(APDU_CODE_OK);
}

// If Bob sends a note to Alice (stored on the blockchain in encrypted form),
Expand All @@ -89,9 +97,14 @@ __Z_INLINE void handleGetKeyOVK(volatile uint32_t *flags, volatile uint32_t *tx,
}
key_state.len = (uint8_t)replyLen;

view_review_init(key_getItem, key_getNumItems, app_reply_key);
view_review_show(REVIEW_GENERIC);
*flags |= IO_ASYNCH_REPLY;
if (app_mode_expert() || !keys_permission_granted) {
view_review_init(key_getItem, key_getNumItems, app_reply_key);
view_review_show(REVIEW_GENERIC);
*flags |= IO_ASYNCH_REPLY;
}

*tx = replyLen;
THROW(APDU_CODE_OK);
}

// Get the sapling full viewing key (ak, nk, ovk)
Expand Down Expand Up @@ -119,9 +132,14 @@ __Z_INLINE void handleGetKeyFVK(volatile uint32_t *flags, volatile uint32_t *tx,
}
key_state.len = (uint8_t)replyLen;

view_review_init(key_getItem, key_getNumItems, app_reply_key);
view_review_show(REVIEW_GENERIC);
*flags |= IO_ASYNCH_REPLY;
if (app_mode_expert() || !keys_permission_granted) {
view_review_init(key_getItem, key_getNumItems, app_reply_key);
view_review_show(REVIEW_GENERIC);
*flags |= IO_ASYNCH_REPLY;
}

*tx = replyLen;
THROW(APDU_CODE_OK);
}

// Computing the note nullifier nf is required in order to spend the note.
Expand Down Expand Up @@ -164,9 +182,14 @@ __Z_INLINE void handleGetNullifier(volatile uint32_t *flags, volatile uint32_t *
}
key_state.len = (uint8_t)replyLen;

view_review_init(key_getItem, key_getNumItems, app_reply_key);
view_review_show(REVIEW_GENERIC);
*flags |= IO_ASYNCH_REPLY;
if (app_mode_expert() || !keys_permission_granted) {
view_review_init(key_getItem, key_getNumItems, app_reply_key);
view_review_show(REVIEW_GENERIC);
*flags |= IO_ASYNCH_REPLY;
}

*tx = replyLen;
THROW(APDU_CODE_OK);
}

__Z_INLINE void handleGetDiversifierList(volatile uint32_t *tx, uint32_t rx) {
Expand Down
65 changes: 40 additions & 25 deletions app/src/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,51 @@ zxerr_t key_getItem(int8_t displayIdx,
}

zemu_log_stack("key_getItem");
char tmpBuffer[200];
char tmpBuffer[200] = "";

switch (displayIdx) {
case 0: {
zemu_log_stack("case 0");
MEMZERO(tmpBuffer, sizeof(tmpBuffer));
switch (key_state.kind) {
case key_ovk:
snprintf(outKey, outKeyLen, "Send OVK?");
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
return zxerr_ok;
case key_ivk:
snprintf(outKey, outKeyLen, "Send IVK?");
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
return zxerr_ok;
case key_fvk:
snprintf(outKey, outKeyLen, "Send FVK?\n");
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
return zxerr_ok;
case nf:
zemu_log_stack("Send NF?");
snprintf(outKey, outKeyLen, "Send NF?");
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
return zxerr_ok;
default:
return zxerr_unknown;

if (app_mode_expert()) {
switch (key_state.kind) {
case key_ovk:
snprintf(outKey, outKeyLen, "Send OVK?");
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
return zxerr_ok;
case key_ivk:
snprintf(outKey, outKeyLen, "Send IVK?");
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
return zxerr_ok;
case key_fvk:
snprintf(outKey, outKeyLen, "Send FVK?\n");
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
return zxerr_ok;
case nf:
zemu_log_stack("Send NF?");
snprintf(outKey, outKeyLen, "Send NF?");
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
return zxerr_ok;
default:
return zxerr_unknown;
}
} else {
switch (key_state.kind) {
case key_ovk:
case key_ivk:
case key_fvk:
case nf:
snprintf(outKey, outKeyLen, "Retrieve data?");
snprintf(outVal, outValLen, "IVKs, OVKs, FVKs or NFs");
return zxerr_ok;
default:
return zxerr_unknown;
}
}
}
case 1: {
Expand Down
Binary file added tests_zemu/snapshots/fl-get-fvk-expert/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/fl-get-fvk-expert/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/fl-get-fvk-expert/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-get-fvk/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/fl-get-ivk-expert/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/fl-get-ivk-expert/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/fl-get-ivk-expert/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-get-ivk/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/fl-get-ovk-expert/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/fl-get-ovk-expert/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/fl-get-ovk-expert/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-get-ovk/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-show_nullifier-0x1/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/fl-show_nullifier-0xFF/00001.png
Binary file added tests_zemu/snapshots/s-get-fvk-expert/00000.png
Binary file added tests_zemu/snapshots/s-get-fvk-expert/00001.png
Binary file added tests_zemu/snapshots/s-get-fvk-expert/00002.png
Binary file added tests_zemu/snapshots/s-get-fvk-expert/00003.png
File renamed without changes
Binary file modified tests_zemu/snapshots/s-get-fvk/00000.png
Binary file modified tests_zemu/snapshots/s-get-fvk/00001.png
Binary file modified tests_zemu/snapshots/s-get-fvk/00002.png
Binary file added tests_zemu/snapshots/s-get-ivk-expert/00000.png
Binary file added tests_zemu/snapshots/s-get-ivk-expert/00001.png
Binary file added tests_zemu/snapshots/s-get-ivk-expert/00002.png
Binary file added tests_zemu/snapshots/s-get-ivk-expert/00003.png
File renamed without changes
Binary file modified tests_zemu/snapshots/s-get-ivk/00000.png
Binary file modified tests_zemu/snapshots/s-get-ivk/00001.png
Binary file modified tests_zemu/snapshots/s-get-ivk/00002.png
Binary file added tests_zemu/snapshots/s-get-ovk-expert/00000.png
Binary file added tests_zemu/snapshots/s-get-ovk-expert/00001.png
Binary file added tests_zemu/snapshots/s-get-ovk-expert/00002.png
Binary file added tests_zemu/snapshots/s-get-ovk-expert/00003.png
File renamed without changes
Binary file modified tests_zemu/snapshots/s-get-ovk/00000.png
Binary file modified tests_zemu/snapshots/s-get-ovk/00001.png
Binary file modified tests_zemu/snapshots/s-get-ovk/00002.png
Binary file modified tests_zemu/snapshots/s-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/s-mainmenu/00010.png
Binary file modified tests_zemu/snapshots/s-show_nullifier-0x1/00000.png
Binary file modified tests_zemu/snapshots/s-show_nullifier-0x1/00001.png
Binary file modified tests_zemu/snapshots/s-show_nullifier-0x1/00002.png
Binary file modified tests_zemu/snapshots/s-show_nullifier-0xFF/00000.png
Binary file modified tests_zemu/snapshots/s-show_nullifier-0xFF/00001.png
Binary file modified tests_zemu/snapshots/s-show_nullifier-0xFF/00002.png
Binary file added tests_zemu/snapshots/sp-get-fvk-expert/00000.png
Binary file added tests_zemu/snapshots/sp-get-fvk-expert/00001.png
Binary file added tests_zemu/snapshots/sp-get-fvk-expert/00002.png
Binary file added tests_zemu/snapshots/sp-get-fvk-expert/00003.png
Binary file added tests_zemu/snapshots/sp-get-fvk-expert/00004.png
File renamed without changes
Binary file modified tests_zemu/snapshots/sp-get-fvk/00001.png
Binary file modified tests_zemu/snapshots/sp-get-fvk/00002.png
Binary file modified tests_zemu/snapshots/sp-get-fvk/00003.png
Binary file added tests_zemu/snapshots/sp-get-ivk-expert/00000.png
Binary file added tests_zemu/snapshots/sp-get-ivk-expert/00001.png
Binary file added tests_zemu/snapshots/sp-get-ivk-expert/00002.png
Binary file added tests_zemu/snapshots/sp-get-ivk-expert/00003.png
Binary file added tests_zemu/snapshots/sp-get-ivk-expert/00004.png
File renamed without changes
Binary file modified tests_zemu/snapshots/sp-get-ivk/00001.png
Binary file modified tests_zemu/snapshots/sp-get-ivk/00002.png
Binary file modified tests_zemu/snapshots/sp-get-ivk/00003.png
Binary file added tests_zemu/snapshots/sp-get-ovk-expert/00000.png
Binary file added tests_zemu/snapshots/sp-get-ovk-expert/00001.png
Binary file added tests_zemu/snapshots/sp-get-ovk-expert/00002.png
Binary file added tests_zemu/snapshots/sp-get-ovk-expert/00003.png
Binary file added tests_zemu/snapshots/sp-get-ovk-expert/00004.png
File renamed without changes
Binary file modified tests_zemu/snapshots/sp-get-ovk/00001.png
Binary file modified tests_zemu/snapshots/sp-get-ovk/00002.png
Binary file modified tests_zemu/snapshots/sp-get-ovk/00003.png
Binary file modified tests_zemu/snapshots/sp-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/sp-mainmenu/00010.png
Binary file modified tests_zemu/snapshots/sp-show_nullifier-0x1/00001.png
Binary file modified tests_zemu/snapshots/sp-show_nullifier-0x1/00002.png
Binary file modified tests_zemu/snapshots/sp-show_nullifier-0x1/00003.png
Binary file modified tests_zemu/snapshots/sp-show_nullifier-0xFF/00001.png
Binary file modified tests_zemu/snapshots/sp-show_nullifier-0xFF/00002.png
Binary file modified tests_zemu/snapshots/sp-show_nullifier-0xFF/00003.png
Binary file added tests_zemu/snapshots/st-get-fvk-expert/00000.png
Binary file added tests_zemu/snapshots/st-get-fvk-expert/00001.png
Binary file added tests_zemu/snapshots/st-get-fvk-expert/00002.png
Binary file added tests_zemu/snapshots/st-get-fvk-expert/00003.png
Binary file modified tests_zemu/snapshots/st-get-fvk/00001.png
Binary file added tests_zemu/snapshots/st-get-ivk-expert/00000.png
Binary file added tests_zemu/snapshots/st-get-ivk-expert/00001.png
Binary file added tests_zemu/snapshots/st-get-ivk-expert/00002.png
Binary file added tests_zemu/snapshots/st-get-ivk-expert/00003.png
Binary file modified tests_zemu/snapshots/st-get-ivk/00001.png
Binary file added tests_zemu/snapshots/st-get-ovk-expert/00000.png
Binary file added tests_zemu/snapshots/st-get-ovk-expert/00001.png
Binary file added tests_zemu/snapshots/st-get-ovk-expert/00002.png
Binary file added tests_zemu/snapshots/st-get-ovk-expert/00003.png
Binary file modified tests_zemu/snapshots/st-get-ovk/00001.png
Binary file modified tests_zemu/snapshots/st-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/st-show_nullifier-0x1/00001.png
Binary file modified tests_zemu/snapshots/st-show_nullifier-0xFF/00001.png
Binary file added tests_zemu/snapshots/x-get-fvk-expert/00000.png
Binary file added tests_zemu/snapshots/x-get-fvk-expert/00001.png
Binary file added tests_zemu/snapshots/x-get-fvk-expert/00002.png
Binary file added tests_zemu/snapshots/x-get-fvk-expert/00003.png
Binary file added tests_zemu/snapshots/x-get-fvk-expert/00004.png
File renamed without changes
Binary file modified tests_zemu/snapshots/x-get-fvk/00001.png
Binary file modified tests_zemu/snapshots/x-get-fvk/00002.png
Binary file modified tests_zemu/snapshots/x-get-fvk/00003.png
Binary file added tests_zemu/snapshots/x-get-ivk-expert/00000.png
Binary file added tests_zemu/snapshots/x-get-ivk-expert/00001.png
Binary file added tests_zemu/snapshots/x-get-ivk-expert/00002.png
Binary file added tests_zemu/snapshots/x-get-ivk-expert/00003.png
Binary file added tests_zemu/snapshots/x-get-ivk-expert/00004.png
File renamed without changes
Binary file modified tests_zemu/snapshots/x-get-ivk/00001.png
Binary file modified tests_zemu/snapshots/x-get-ivk/00002.png
Binary file modified tests_zemu/snapshots/x-get-ivk/00003.png
Binary file added tests_zemu/snapshots/x-get-ovk-expert/00000.png
Binary file added tests_zemu/snapshots/x-get-ovk-expert/00001.png
Binary file added tests_zemu/snapshots/x-get-ovk-expert/00002.png
Binary file added tests_zemu/snapshots/x-get-ovk-expert/00003.png
Binary file added tests_zemu/snapshots/x-get-ovk-expert/00004.png
File renamed without changes
Binary file modified tests_zemu/snapshots/x-get-ovk/00001.png
Binary file modified tests_zemu/snapshots/x-get-ovk/00002.png
Binary file modified tests_zemu/snapshots/x-get-ovk/00003.png
Binary file modified tests_zemu/snapshots/x-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/x-mainmenu/00010.png
Binary file modified tests_zemu/snapshots/x-show_nullifier-0x1/00001.png
Binary file modified tests_zemu/snapshots/x-show_nullifier-0x1/00002.png
Binary file modified tests_zemu/snapshots/x-show_nullifier-0x1/00003.png
Binary file modified tests_zemu/snapshots/x-show_nullifier-0xFF/00001.png
Binary file modified tests_zemu/snapshots/x-show_nullifier-0xFF/00002.png
Binary file modified tests_zemu/snapshots/x-show_nullifier-0xFF/00003.png
Loading

0 comments on commit 8992a45

Please sign in to comment.