Skip to content

Commit

Permalink
feat(ui): implement NBGL display for public key verification
Browse files Browse the repository at this point in the history
- Replace simple address review with detailed NBGL review layout
- Add BIP32 path display alongside public key
- Update test snapshots for new UI layout

The change improves the user experience by showing both the BIP32 path and
public key in a clear, structured format using the NBGL review light interface.
  • Loading branch information
keiff3r committed Nov 29, 2024
1 parent 67792e4 commit e6a2edf
Show file tree
Hide file tree
Showing 37 changed files with 41 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/handler/get_public_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ int handler_get_public_key(buffer_t *cdata, bool display, bool sign_public_key)
}
int path_type = derivation_path_type(G_context.bip32_path, G_context.bip32_path_len);
if (display) {
// Special display for governance keys
// TODO: Implement special display for signed public keys ?

// TODO: Display governance key info
if (path_type >= 10) {
// TODO: Display governance key info
// Special display for governance keys
} else {
return ui_display_pubkey();
}
Expand Down
9 changes: 9 additions & 0 deletions src/ui/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,12 @@ int ui_display_verify_address(void);
*
*/
int ui_display_simple_transfer(void);


/**
* Display public key information on the device and ask confirmation to export.
*
* @return 0 if success, negative integer otherwise.
*
*/
int ui_display_pubkey(void);
32 changes: 26 additions & 6 deletions src/ui/nbgl_display_public_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
#include "../menu.h"

static char g_public_key[PUBKEY_LEN * 2 + 1];
static char g_bip32_path_string[MAX_SERIALIZED_BIP32_PATH_LENGTH + 1];

static nbgl_layoutTagValue_t pairs[2];
static nbgl_layoutTagValueList_t pairList;

static void review_choice(bool confirm) {
// Answer, display a status page and go back to main
Expand All @@ -61,12 +65,28 @@ int ui_display_pubkey() {
return io_send_sw(SW_PUBLIC_KEY_DISPLAY_FAIL);
}

nbgl_useCaseAddressReview(g_public_key,
NULL,
&C_app_concordium_64px,
"Verify Public Key",
NULL,
review_choice);
bip32_path_format(G_context.bip32_path, G_context.bip32_path_len, g_bip32_path_string, sizeof(g_bip32_path_string));

// Setup data to display
pairs[0].item = "BIP32 Path";
pairs[0].value = g_bip32_path_string;
pairs[1].item = "Public Key";
pairs[1].value = g_public_key;

// Setup list
pairList.nbMaxLinesForValue = 0;
pairList.nbPairs = 2;
pairList.pairs = pairs;

// Start review flow
nbgl_useCaseReviewLight(TYPE_OPERATION,
&pairList,
&C_app_concordium_64px,
"Verify Public Key",
NULL,
"Verify Public Key",
review_choice);

return 0;
}

Expand Down
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.
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.
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.
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.
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.
1 change: 1 addition & 0 deletions tests/test_pubkey_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
def test_get_legacy_public_key_confirm_accepted(backend, scenario_navigator):
client = BoilerplateCommandSender(backend)
path = "m/1105/0/0/0/0/2/0/0"
# TODO: Edit instruction for nbgl display to click on approve
with client.get_public_key_with_confirmation(path=path):
scenario_navigator.address_review_approve()

Expand Down
2 changes: 1 addition & 1 deletion z_debug
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ get public key:
20
87e16c8269270b1c75b930224df456d2927b80c760ffa77e57dbd738f6399492
40
78446f07f48b2dffa4c32656b3a5fdbb5a727c1bb86c985f13d41239ed367b0e1baa3c9daca748a23ff886d66bb455883b1f9aedcae436692dbd6274bee622039000
3f499aa9fe41f0b911a3cccde3080143f10d108b2ba72343ad70fa03458333a328c542ce0685632b16636cc579fcfe715743c332eff416589631057eb0e08d049000
expected:
20
87e16c8269270b1c75b930224df456d2927b80c760ffa77e57dbd738f6399492
Expand Down

0 comments on commit e6a2edf

Please sign in to comment.