Skip to content

Commit

Permalink
Merge pull request #692 from LedgerHQ/feat/apa/blind_signing_changes
Browse files Browse the repository at this point in the history
Blind-signing flow changes
  • Loading branch information
apaillier-ledger authored Dec 12, 2024
2 parents ca54030 + cf07914 commit ef08de1
Show file tree
Hide file tree
Showing 109 changed files with 67 additions and 20 deletions.
24 changes: 23 additions & 1 deletion src_bagl/ui_flow_signTx.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ UX_STEP_NOCB(ux_approval_review_step,
"Review",
"transaction",
});
UX_STEP_NOCB(ux_approval_tx_hash_step,
bnnn_paging,
{
#ifdef TARGET_NANOS
.title = "TX hash",
#else
.title = "Transaction hash",
#endif
.text = strings.common.fullAmount
});
UX_STEP_NOCB(
ux_approval_amount_step,
bnnn_paging,
Expand Down Expand Up @@ -237,11 +247,23 @@ void ux_approve_tx(bool fromPlugin) {
ux_approval_tx_flow[step++] = &ux_plugin_approval_display_step;
ux_approval_tx_flow[step++] = &ux_plugin_approval_after_step;
} else {
if (tmpContent.txContent.dataPresent) {
#pragma GCC diagnostic ignored "-Wformat"
snprintf(strings.common.fullAmount,
sizeof(strings.common.fullAmount),
"0x%.*h",
sizeof(tmpCtx.transactionContext.hash),
tmpCtx.transactionContext.hash);
#pragma GCC diagnostic warning "-Wformat"
ux_approval_tx_flow[step++] = &ux_approval_tx_hash_step;
}
// We're in a regular transaction, just show the amount and the address
if (strings.common.fromAddress[0] != 0) {
ux_approval_tx_flow[step++] = &ux_approval_from_step;
}
ux_approval_tx_flow[step++] = &ux_approval_amount_step;
if (!tmpContent.txContent.dataPresent) {
ux_approval_tx_flow[step++] = &ux_approval_amount_step;
}
#ifdef HAVE_TRUSTED_NAME
uint64_t chain_id = get_tx_chain_id();
e_name_type type = TYPE_ACCOUNT;
Expand Down
21 changes: 18 additions & 3 deletions src_nbgl/ui_approve_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,30 @@ static uint8_t setTagValuePairs(void) {
pairs[nbPairs].value = strings.common.maxFee;
nbPairs++;
} else {
if (tmpContent.txContent.dataPresent) {
#pragma GCC diagnostic ignored "-Wformat"
snprintf(strings.common.fullAmount,
sizeof(strings.common.fullAmount),
"0x%.*h",
sizeof(tmpCtx.transactionContext.hash),
tmpCtx.transactionContext.hash);
#pragma GCC diagnostic warning "-Wformat"
pairs[nbPairs].item = "Transaction hash";
pairs[nbPairs].value = strings.common.fullAmount;
nbPairs++;
}

if (strings.common.fromAddress[0] != 0) {
pairs[nbPairs].item = "From";
pairs[nbPairs].value = strings.common.fromAddress;
nbPairs++;
}

pairs[nbPairs].item = "Amount";
pairs[nbPairs].value = strings.common.fullAmount;
nbPairs++;
if (!tmpContent.txContent.dataPresent) {
pairs[nbPairs].item = "Amount";
pairs[nbPairs].value = strings.common.fullAmount;
nbPairs++;
}

#ifdef HAVE_TRUSTED_NAME
uint64_t chain_id = get_tx_chain_id();
Expand Down
Binary file modified tests/ragger/snapshots/flex/test_blind_sign_rejected/00002.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/ragger/snapshots/flex/test_blind_sign_rejected/00003.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/ragger/snapshots/flex/test_blind_sign_signed/00002.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/ragger/snapshots/flex/test_blind_sign_signed/00003.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.
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_rejected/00002.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/ragger/snapshots/nanos/test_blind_sign_rejected/00003.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/ragger/snapshots/nanos/test_blind_sign_rejected/00004.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/ragger/snapshots/nanos/test_blind_sign_rejected/00005.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/ragger/snapshots/nanos/test_blind_sign_rejected/00006.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/ragger/snapshots/nanos/test_blind_sign_rejected/00007.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/ragger/snapshots/nanos/test_blind_sign_rejected/00008.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/ragger/snapshots/nanos/test_blind_sign_rejected/00009.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/ragger/snapshots/nanos/test_blind_sign_rejected/00010.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/ragger/snapshots/nanos/test_blind_sign_rejected/00011.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/ragger/snapshots/nanos/test_blind_sign_rejected/00012.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.
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_signed/00002.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/ragger/snapshots/nanos/test_blind_sign_signed/00003.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/ragger/snapshots/nanos/test_blind_sign_signed/00004.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/ragger/snapshots/nanos/test_blind_sign_signed/00005.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/ragger/snapshots/nanos/test_blind_sign_signed/00006.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/ragger/snapshots/nanos/test_blind_sign_signed/00007.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_signed/00008.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_signed/00009.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_signed/00010.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_signed/00011.png
Binary file modified tests/ragger/snapshots/nanos/test_sign_parameter_selector/00016.png
Binary file modified tests/ragger/snapshots/nanos/test_sign_parameter_selector/00017.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_rejected/00002.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_rejected/00003.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_rejected/00004.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_rejected/00005.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_rejected/00006.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_rejected/00007.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_rejected/00008.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_signed/00002.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_signed/00003.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_signed/00004.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_signed/00005.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_signed/00006.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_signed/00007.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_rejected/00002.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_rejected/00003.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_rejected/00004.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_rejected/00005.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_rejected/00006.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_rejected/00007.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_rejected/00008.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_signed/00002.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_signed/00003.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_signed/00004.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_signed/00005.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_signed/00006.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_signed/00007.png
Binary file modified tests/ragger/snapshots/nanox/test_sign_parameter_selector/00011.png
Binary file modified tests/ragger/snapshots/nanox/test_sign_parameter_selector/00012.png
Binary file modified tests/ragger/snapshots/nanox/test_sign_parameter_selector/00014.png
Binary file modified tests/ragger/snapshots/nanox/test_sign_parameter_selector/00016.png
Binary file modified tests/ragger/snapshots/stax/test_blind_sign_rejected/00001.png
Binary file modified tests/ragger/snapshots/stax/test_blind_sign_rejected/00002.png
Binary file modified tests/ragger/snapshots/stax/test_blind_sign_rejected/00003.png
Binary file modified tests/ragger/snapshots/stax/test_blind_sign_rejected/00004.png
Binary file modified tests/ragger/snapshots/stax/test_blind_sign_rejected/00005.png
Binary file modified tests/ragger/snapshots/stax/test_blind_sign_signed/00001.png
Binary file modified tests/ragger/snapshots/stax/test_blind_sign_signed/00002.png
Binary file modified tests/ragger/snapshots/stax/test_blind_sign_signed/00003.png
Binary file modified tests/ragger/snapshots/stax/test_blind_sign_signed/00004.png
Binary file modified tests/ragger/snapshots/stax/test_sign_parameter_selector/00011.png
42 changes: 26 additions & 16 deletions tests/ragger/test_blind_sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def common_tx_params() -> dict:
}


# Token approval, would require loading the "internal plugin" &
# providing the token metadata from the CAL
# Token approval, would require providing the token metadata from the CAL
def test_blind_sign(firmware: Firmware,
backend: BackendInterface,
navigator: Navigator,
Expand Down Expand Up @@ -81,12 +80,29 @@ def test_blind_sign(firmware: Firmware,
# blind signing warning
moves += [NavInsID.RIGHT_CLICK]

# review | from | amount | to | fees
moves += [NavInsID.RIGHT_CLICK] * 5
# review
moves += [NavInsID.RIGHT_CLICK]

# tx hash
if firmware == Firmware.NANOS:
# for the two addresses
moves += [NavInsID.RIGHT_CLICK] * 4
else:
moves += [NavInsID.RIGHT_CLICK] * 2

# from
if firmware == Firmware.NANOS:
moves += [NavInsID.RIGHT_CLICK] * 3
else:
moves += [NavInsID.RIGHT_CLICK]

# to
if firmware == Firmware.NANOS:
moves += [NavInsID.RIGHT_CLICK] * 3
else:
moves += [NavInsID.RIGHT_CLICK]

# fees
moves += [NavInsID.RIGHT_CLICK]

if not sign:
moves += [NavInsID.RIGHT_CLICK]
Expand All @@ -95,10 +111,7 @@ def test_blind_sign(firmware: Firmware,
else:
moves += [NavInsID.USE_CASE_CHOICE_REJECT]

if firmware == Firmware.STAX:
moves += [NavInsID.SWIPE_CENTER_TO_LEFT] * 2
else:
moves += [NavInsID.SWIPE_CENTER_TO_LEFT] * 3
moves += [NavInsID.SWIPE_CENTER_TO_LEFT] * 3

if sign:
moves += [NavInsID.USE_CASE_REVIEW_CONFIRM]
Expand Down Expand Up @@ -171,21 +184,18 @@ def test_sign_parameter_selector(firmware: Firmware,
moves += [NavInsID.RIGHT_CLICK] * 4 + [NavInsID.BOTH_CLICK]
# parameter 2
moves += [NavInsID.RIGHT_CLICK] * 3 + [NavInsID.BOTH_CLICK]
# blind signing | review | from | amount | to | fees
moves += [NavInsID.RIGHT_CLICK] * 10
# blind signing | review | tx hash | from | to | fees
moves += [NavInsID.RIGHT_CLICK] * 13
else:
# (verify | parameter) * flows
moves += ([NavInsID.RIGHT_CLICK] * 2 + [NavInsID.BOTH_CLICK]) * params
# blind signing | review | from | amount | to | fees
moves += [NavInsID.RIGHT_CLICK] * 6
moves += [NavInsID.RIGHT_CLICK] * 7
moves += [NavInsID.BOTH_CLICK]
else:
moves += ([NavInsID.SWIPE_CENTER_TO_LEFT] * 2 + [NavInsID.USE_CASE_REVIEW_CONFIRM]) * (1 + params)
moves += [NavInsID.USE_CASE_CHOICE_REJECT]
if firmware == Firmware.STAX:
tap_number = 2
else:
tap_number = 3
tap_number = 3
moves += [NavInsID.SWIPE_CENTER_TO_LEFT] * tap_number
moves += [NavInsID.USE_CASE_REVIEW_CONFIRM]
navigator.navigate_and_compare(default_screenshot_path,
Expand Down

0 comments on commit ef08de1

Please sign in to comment.