Port Address Review steps to 'nbgl_useCaseAddressReview'

This commit is contained in:
Charles-Edouard de la Vergne
2024-04-09 18:52:28 +02:00
parent 75f4694948
commit 1c9f138fdd
30 changed files with 32 additions and 76 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -10,7 +10,7 @@ from ragger.bip.seed import SPECULOS_MNEMONIC
from ragger.error import ExceptionRAPDU
from ragger.firmware import Firmware
from ragger.backend import BackendInterface
from ragger.navigator import Navigator, NavInsID
from ragger.navigator.navigation_scenario import NavigateWithScenario
from ragger.bip import calculate_public_key_and_chaincode, CurveChoice
from client.client import EthAppClient, StatusWord
@@ -27,48 +27,15 @@ def chain_fixture(request) -> Optional[int]:
return request.param
def get_moves(firmware: Firmware,
chain: Optional[int] = None,
reject: bool = False,
pk_eth2: bool = False):
moves = []
if firmware.is_nano:
moves += [NavInsID.RIGHT_CLICK]
if firmware.device == "nanos":
moves += [NavInsID.RIGHT_CLICK] * 3
else:
moves += [NavInsID.RIGHT_CLICK]
if reject:
moves += [NavInsID.RIGHT_CLICK]
if pk_eth2:
if firmware.device == "nanos":
moves += [NavInsID.RIGHT_CLICK] * 2
moves += [NavInsID.RIGHT_CLICK]
moves += [NavInsID.BOTH_CLICK]
else:
if not pk_eth2:
moves += [NavInsID.USE_CASE_REVIEW_TAP]
if chain is not None and chain > 1:
moves += [NavInsID.USE_CASE_ADDRESS_CONFIRMATION_TAP]
if reject:
moves += [NavInsID.USE_CASE_ADDRESS_CONFIRMATION_CANCEL]
else:
moves += [NavInsID.USE_CASE_ADDRESS_CONFIRMATION_CONFIRM]
return moves
@pytest.mark.parametrize(
"path, suffix",
"path, suffix",
[
("m/44'/60'/0'/0/0", "60"),
("m/44'/700'/1'/0/0", "700")
],
)
def test_get_pk_rejected(firmware: Firmware,
backend: BackendInterface,
navigator: Navigator,
def test_get_pk_rejected(backend: BackendInterface,
scenario_navigator: NavigateWithScenario,
default_screenshot_path: Path,
path,
suffix):
@@ -76,24 +43,21 @@ def test_get_pk_rejected(firmware: Firmware,
with pytest.raises(ExceptionRAPDU) as e:
with app_client.get_public_addr(bip32_path=path):
navigator.navigate_and_compare(default_screenshot_path,
f"get_pk_rejected_{suffix}",
get_moves(firmware, reject=True))
scenario_navigator.address_review_reject(default_screenshot_path, f"get_pk_rejected_{suffix}")
assert e.value.status == StatusWord.CONDITION_NOT_SATISFIED
def test_get_pk(firmware: Firmware,
backend: BackendInterface,
navigator: Navigator,
def test_get_pk(backend: BackendInterface,
default_screenshot_path: Path,
scenario_navigator: NavigateWithScenario,
with_chaincode: bool,
chain: Optional[int]):
app_client = EthAppClient(backend)
with app_client.get_public_addr(chaincode=with_chaincode, chain_id=chain):
navigator.navigate_and_compare(default_screenshot_path,
f"get_pk_{chain}",
get_moves(firmware, chain=chain))
scenario_navigator.address_review_approve(default_screenshot_path, f"get_pk_{chain}")
pk, _, chaincode = ResponseParser.pk_addr(app_client.response().data, with_chaincode)
ref_pk, ref_chaincode = calculate_public_key_and_chaincode(curve=CurveChoice.Secp256k1,
path="m/44'/60'/0'/0/0")
@@ -104,20 +68,19 @@ def test_get_pk(firmware: Firmware,
def test_get_eth2_pk(firmware: Firmware,
backend: BackendInterface,
navigator: Navigator,
scenario_navigator: NavigateWithScenario,
test_name: str,
default_screenshot_path: Path):
app_client = EthAppClient(backend)
path="m/12381/3600/0/0"
with app_client.get_eth2_public_addr(bip32_path=path):
navigator.navigate_and_compare(default_screenshot_path,
test_name,
get_moves(firmware, pk_eth2=True))
scenario_navigator.address_review_approve(default_screenshot_path, test_name)
pk = app_client.response().data
ref_pk = bls.SkToPk(mnemonic_and_path_to_key(SPECULOS_MNEMONIC, path))
if firmware.name == "stax":
if firmware.name in ("stax", "flex"):
pk = pk[1:49]
assert pk == ref_pk