Skip to content

Commit 8992a45

Browse files
authored
feat: improve keys data review for better user experience (#121)
* feat: update snapshots * feat: improve keys data review for better user experience * feat: update snapshots
1 parent a257190 commit 8992a45

File tree

194 files changed

+420
-159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+420
-159
lines changed

app/Makefile.version

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This is the major version
22
APPVERSION_M=4
33
# This is the minor version
4-
APPVERSION_N=1
4+
APPVERSION_N=2
55
# This is the patch version
6-
APPVERSION_P=4
6+
APPVERSION_P=0

app/src/common/actions.c

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@
2020

2121
address_state_t action_addrResponse;
2222
key_state_t key_state;
23+
bool keys_permission_granted = false;

app/src/common/actions.h

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
extern address_state_t action_addrResponse;
3333
extern key_state_t key_state;
34+
extern bool keys_permission_granted;
3435

3536
__Z_INLINE void app_reject() {
3637
transaction_reset();
@@ -41,6 +42,7 @@ __Z_INLINE void app_reject() {
4142
}
4243

4344
__Z_INLINE void app_reply_key() {
45+
keys_permission_granted = true;
4446
set_code(G_io_apdu_buffer, key_state.len, APDU_CODE_OK);
4547
io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, key_state.len + 2);
4648
}

app/src/handlers/handler_keys.h

+35-12
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include "view_internal.h"
3535
#include "zxmacros.h"
3636

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

64-
view_review_init(key_getItem, key_getNumItems, app_reply_key);
65-
view_review_show(REVIEW_GENERIC);
66-
*flags |= IO_ASYNCH_REPLY;
66+
if (app_mode_expert() || !keys_permission_granted) {
67+
view_review_init(key_getItem, key_getNumItems, app_reply_key);
68+
view_review_show(REVIEW_GENERIC);
69+
*flags |= IO_ASYNCH_REPLY;
70+
return;
71+
}
72+
73+
*tx = replyLen;
74+
THROW(APDU_CODE_OK);
6775
}
6876

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

92-
view_review_init(key_getItem, key_getNumItems, app_reply_key);
93-
view_review_show(REVIEW_GENERIC);
94-
*flags |= IO_ASYNCH_REPLY;
100+
if (app_mode_expert() || !keys_permission_granted) {
101+
view_review_init(key_getItem, key_getNumItems, app_reply_key);
102+
view_review_show(REVIEW_GENERIC);
103+
*flags |= IO_ASYNCH_REPLY;
104+
}
105+
106+
*tx = replyLen;
107+
THROW(APDU_CODE_OK);
95108
}
96109

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

122-
view_review_init(key_getItem, key_getNumItems, app_reply_key);
123-
view_review_show(REVIEW_GENERIC);
124-
*flags |= IO_ASYNCH_REPLY;
135+
if (app_mode_expert() || !keys_permission_granted) {
136+
view_review_init(key_getItem, key_getNumItems, app_reply_key);
137+
view_review_show(REVIEW_GENERIC);
138+
*flags |= IO_ASYNCH_REPLY;
139+
}
140+
141+
*tx = replyLen;
142+
THROW(APDU_CODE_OK);
125143
}
126144

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

167-
view_review_init(key_getItem, key_getNumItems, app_reply_key);
168-
view_review_show(REVIEW_GENERIC);
169-
*flags |= IO_ASYNCH_REPLY;
185+
if (app_mode_expert() || !keys_permission_granted) {
186+
view_review_init(key_getItem, key_getNumItems, app_reply_key);
187+
view_review_show(REVIEW_GENERIC);
188+
*flags |= IO_ASYNCH_REPLY;
189+
}
190+
191+
*tx = replyLen;
192+
THROW(APDU_CODE_OK);
170193
}
171194

172195
__Z_INLINE void handleGetDiversifierList(volatile uint32_t *tx, uint32_t rx) {

app/src/key.c

+40-25
Original file line numberDiff line numberDiff line change
@@ -49,36 +49,51 @@ zxerr_t key_getItem(int8_t displayIdx,
4949
}
5050

5151
zemu_log_stack("key_getItem");
52-
char tmpBuffer[200];
52+
char tmpBuffer[200] = "";
5353

5454
switch (displayIdx) {
5555
case 0: {
5656
zemu_log_stack("case 0");
5757
MEMZERO(tmpBuffer, sizeof(tmpBuffer));
58-
switch (key_state.kind) {
59-
case key_ovk:
60-
snprintf(outKey, outKeyLen, "Send OVK?");
61-
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
62-
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
63-
return zxerr_ok;
64-
case key_ivk:
65-
snprintf(outKey, outKeyLen, "Send IVK?");
66-
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
67-
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
68-
return zxerr_ok;
69-
case key_fvk:
70-
snprintf(outKey, outKeyLen, "Send FVK?\n");
71-
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
72-
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
73-
return zxerr_ok;
74-
case nf:
75-
zemu_log_stack("Send NF?");
76-
snprintf(outKey, outKeyLen, "Send NF?");
77-
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
78-
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
79-
return zxerr_ok;
80-
default:
81-
return zxerr_unknown;
58+
59+
if (app_mode_expert()) {
60+
switch (key_state.kind) {
61+
case key_ovk:
62+
snprintf(outKey, outKeyLen, "Send OVK?");
63+
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
64+
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
65+
return zxerr_ok;
66+
case key_ivk:
67+
snprintf(outKey, outKeyLen, "Send IVK?");
68+
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
69+
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
70+
return zxerr_ok;
71+
case key_fvk:
72+
snprintf(outKey, outKeyLen, "Send FVK?\n");
73+
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
74+
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
75+
return zxerr_ok;
76+
case nf:
77+
zemu_log_stack("Send NF?");
78+
snprintf(outKey, outKeyLen, "Send NF?");
79+
array_to_hexstr(tmpBuffer, sizeof(tmpBuffer), G_io_apdu_buffer, 32);
80+
pageString(outVal, outValLen, tmpBuffer, pageIdx, pageCount);
81+
return zxerr_ok;
82+
default:
83+
return zxerr_unknown;
84+
}
85+
} else {
86+
switch (key_state.kind) {
87+
case key_ovk:
88+
case key_ivk:
89+
case key_fvk:
90+
case nf:
91+
snprintf(outKey, outKeyLen, "Retrieve data?");
92+
snprintf(outVal, outValLen, "IVKs, OVKs, FVKs or NFs");
93+
return zxerr_ok;
94+
default:
95+
return zxerr_unknown;
96+
}
8297
}
8398
}
8499
case 1: {
8.74 KB
18.4 KB
8.63 KB
-7.16 KB
8.74 KB
18.5 KB
8.63 KB
-7.3 KB
8.74 KB
18.6 KB
8.63 KB
-7.39 KB
370 Bytes
623 Bytes
630 Bytes
377 Bytes
249 Bytes
-121 Bytes
-381 Bytes
232 Bytes
634 Bytes
612 Bytes
377 Bytes
249 Bytes
-132 Bytes
-363 Bytes
232 Bytes
662 Bytes
634 Bytes
377 Bytes
249 Bytes
-160 Bytes
-385 Bytes
232 Bytes
9 Bytes
9 Bytes
-144 Bytes
-399 Bytes
232 Bytes
-131 Bytes
-380 Bytes
452 Bytes
896 Bytes
508 Bytes
416 Bytes
355 Bytes
-313 Bytes
-153 Bytes
198 Bytes
452 Bytes
901 Bytes
479 Bytes
416 Bytes
355 Bytes
-318 Bytes
-124 Bytes
198 Bytes
452 Bytes
947 Bytes
520 Bytes
416 Bytes
355 Bytes
-364 Bytes
-165 Bytes
198 Bytes
7 Bytes
7 Bytes
-323 Bytes
-146 Bytes
16.6 KB
8.06 KB
12.2 KB
-6.37 KB
16.5 KB
8.06 KB
12.2 KB
-6.29 KB
16.7 KB
8.06 KB
12.2 KB
-6.54 KB
301 Bytes
452 Bytes
896 Bytes
508 Bytes
416 Bytes
355 Bytes
-313 Bytes
-153 Bytes
198 Bytes
452 Bytes
901 Bytes
479 Bytes
416 Bytes
355 Bytes
-318 Bytes
-124 Bytes
198 Bytes
452 Bytes
947 Bytes
520 Bytes
416 Bytes
355 Bytes
-364 Bytes
-165 Bytes
198 Bytes
7 Bytes
7 Bytes
-323 Bytes
-146 Bytes
198 Bytes
-307 Bytes
-147 Bytes

0 commit comments

Comments
 (0)