Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src_nbgl/ui_tx_simulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ static bool g_response_expected;
* @param[in] callback Callback to be called after the user has made a choice
*/
void ui_tx_simulation_error(nbgl_choiceCallback_t callback) {
#ifdef HAVE_PIEZO_SOUND
io_seproxyhal_play_tune(TUNE_NEUTRAL);
#endif // HAVE_PIEZO_SOUND
nbgl_useCaseChoice(&C_Denied_Circle_64px,
"Transaction Check failed because of technical reasons",
"Reject this transaction and try again. "
Expand Down Expand Up @@ -180,6 +183,9 @@ void ui_tx_simulation_opt_in(bool response_expected) {
// add button and footer on bottom
nbgl_layoutAddChoiceButtons(layoutCtx, &buttonsInfo);

#ifdef HAVE_PIEZO_SOUND
io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
#endif // HAVE_PIEZO_SOUND
nbgl_layoutDraw(layoutCtx);
nbgl_refresh();
}
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.
Binary file modified tests/ragger/snapshots/flex/test_tx_simulation_eip712/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/ragger/snapshots/nanos/test_blind_sign/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 modified tests/ragger/snapshots/nanos/test_blind_sign/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/ragger/snapshots/nanos/test_blind_sign/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/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/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/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/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/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/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/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/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/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/00012.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/00013.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 not shown.
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_nonzero/00001.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_nonzero/00003.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_nonzero/00004.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_nonzero/00005.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_nonzero/00006.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_nonzero/00007.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_nonzero/00008.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_nonzero/00009.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_nonzero/00010.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_nonzero/00011.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_nonzero/00012.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_nonzero/00013.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_nonzero/00014.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_rejected/00001.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_rejected/00006.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_rejected/00008.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_rejected/00009.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_rejected/00010.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_rejected/00011.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_rejected/00012.png
Binary file modified tests/ragger/snapshots/nanos/test_blind_sign_rejected/00013.png
Diff not rendered.
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign/00000.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign/00001.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign/00002.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign/00003.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign/00004.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign/00005.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign/00006.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign/00007.png
Diff not rendered.
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_nonzero/00001.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_nonzero/00002.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_nonzero/00003.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_nonzero/00004.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_nonzero/00005.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_nonzero/00006.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_nonzero/00007.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_nonzero/00008.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_rejected/00001.png
Binary file modified tests/ragger/snapshots/nanosp/test_blind_sign_rejected/00003.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign/00000.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign/00001.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign/00002.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign/00003.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign/00004.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign/00005.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign/00006.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign/00007.png
Diff not rendered.
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_nonzero/00001.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_nonzero/00002.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_nonzero/00003.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_nonzero/00004.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_nonzero/00005.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_nonzero/00006.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_nonzero/00007.png
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_nonzero/00008.png
Diff not rendered.
Binary file modified tests/ragger/snapshots/nanox/test_blind_sign_rejected/00001.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
Diff not rendered.
Binary file modified tests/ragger/snapshots/stax/test_tx_simulation_eip712/00001.png
112 changes: 62 additions & 50 deletions tests/ragger/test_blind_sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
BIP32_PATH = "m/44'/60'/0'/0/0"
DEVICE_ADDR: Optional[bytes] = None

# TODO: do one test with nonce display


@pytest.fixture(name="reject", params=[False, True])
def reject_fixture(request) -> bool:
Expand All @@ -37,6 +35,14 @@ def amount_fixture(request) -> float:
return request.param


def common_get_address(app_client: EthAppClient) -> None:
global DEVICE_ADDR
if DEVICE_ADDR is None:
with app_client.get_public_addr(bip32_path=BIP32_PATH, display=False):
pass
_, DEVICE_ADDR, _ = ResponseParser.pk_addr(app_client.response().data)


def common_tx_params(amount: float) -> dict:
with open(f"{ABIS_FOLDER}/erc20.json", encoding="utf-8") as file:
contract = Web3().eth.contract(
Expand All @@ -61,22 +67,52 @@ def common_tx_params(amount: float) -> dict:
}


def common_blind_sign(scenario_navigator: NavigateWithScenario,
test_name: str,
app_client: EthAppClient,
tx_params: dict,
reject: bool = False) -> dict:
try:
with app_client.sign(BIP32_PATH, tx_params):
if reject:
test_name += "_rejected"

if tx_params["value"] > 0.0:
test_name += "_nonzero"

if reject:
scenario_navigator.review_reject_with_warning(test_name=test_name)
else:
scenario_navigator.review_approve_with_warning(test_name=test_name)

except ExceptionRAPDU as e:
assert reject
assert e.status == StatusWord.CONDITION_NOT_SATISFIED
else:
assert not reject
# verify signature
vrs = ResponseParser.signature(app_client.response().data)
addr = recover_transaction(tx_params, vrs)
assert addr == DEVICE_ADDR


# Token approval, would require providing the token metadata from the CAL
def test_blind_sign(firmware: Firmware,
backend: BackendInterface,
navigator: Navigator,
scenario_navigator: NavigateWithScenario,
default_screenshot_path: Path,
test_name: str,
reject: bool,
amount: float,
simu_params: Optional[TxSimu] = None):
global DEVICE_ADDR
app_client = EthAppClient(backend)

if reject and amount > 0.0:
pytest.skip()

app_client = EthAppClient(backend)
common_get_address(app_client)

settings_toggle(firmware, navigator, [SettingID.BLIND_SIGNING])

tx_params = common_tx_params(amount)

if not reject and simu_params is not None:
Expand All @@ -87,48 +123,29 @@ def test_blind_sign(firmware: Firmware,
response = app_client.provide_tx_simulation(simu_params)
assert response.status == StatusWord.OK

settings_toggle(firmware, navigator, [SettingID.BLIND_SIGNING])
if DEVICE_ADDR is None:
with app_client.get_public_addr(bip32_path=BIP32_PATH, display=False):
pass
_, DEVICE_ADDR, _ = ResponseParser.pk_addr(app_client.response().data)
common_blind_sign(scenario_navigator,
test_name,
app_client,
tx_params,
reject)

try:
with app_client.sign(BIP32_PATH, tx_params):
if reject:
test_name += "_rejected"

if amount > 0.0:
test_name += "_nonzero"

if firmware.is_nano:
end_text = "^Accept risk"
moves = [NavInsID.RIGHT_CLICK]
else:
end_text = "^Hold to sign$"
moves = [NavInsID.USE_CASE_CHOICE_REJECT]

if not firmware.is_nano:
# Warning Screen
navigator.navigate_and_compare(default_screenshot_path,
f"{test_name}/warning",
moves,
screen_change_after_last_instruction=False)
# Token approval, would require providing the token metadata from the CAL
def test_blind_sign_nonce(firmware: Firmware,
backend: BackendInterface,
navigator: Navigator,
scenario_navigator: NavigateWithScenario,
test_name: str):
app_client = EthAppClient(backend)
common_get_address(app_client)

if reject:
scenario_navigator.review_reject(test_name=test_name)
else:
scenario_navigator.review_approve(test_name=test_name, custom_screen_text=end_text)
settings_toggle(firmware, navigator, [SettingID.BLIND_SIGNING, SettingID.NONCE])

except ExceptionRAPDU as e:
assert reject
assert e.status == StatusWord.CONDITION_NOT_SATISFIED
else:
assert not reject
# verify signature
vrs = ResponseParser.signature(app_client.response().data)
addr = recover_transaction(tx_params, vrs)
assert addr == DEVICE_ADDR
tx_params = common_tx_params(1.2)
common_blind_sign(scenario_navigator,
test_name,
app_client,
tx_params)


def test_blind_sign_reject_in_risk_review(firmware: Firmware,
Expand Down Expand Up @@ -158,13 +175,8 @@ def test_sign_parameter_selector(firmware: Firmware,
navigator: Navigator,
test_name: str,
default_screenshot_path: Path):
global DEVICE_ADDR
app_client = EthAppClient(backend)

if DEVICE_ADDR is None:
with app_client.get_public_addr(bip32_path=BIP32_PATH, display=False):
pass
_, DEVICE_ADDR, _ = ResponseParser.pk_addr(app_client.response().data)
common_get_address(app_client)

settings_toggle(firmware, navigator, [SettingID.BLIND_SIGNING, SettingID.DEBUG_DATA])

Expand Down
2 changes: 0 additions & 2 deletions tests/ragger/test_tx_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ def test_tx_simulation_blind_sign(firmware: Firmware,
navigator: Navigator,
scenario_navigator: NavigateWithScenario,
test_name: str,
default_screenshot_path: Path,
config: str) -> None:
"""Test the TX Simulation APDU with a Blind Sign transaction"""

Expand All @@ -276,7 +275,6 @@ def test_tx_simulation_blind_sign(firmware: Firmware,
backend,
navigator,
scenario_navigator,
default_screenshot_path,
test_name,
False,
0.0,
Expand Down
Loading