Port Address Review steps to 'nbgl_useCaseAddressReview'
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.6 KiB |
BIN
tests/ragger/snapshots/stax/get_pk_1/00003.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.6 KiB |
BIN
tests/ragger/snapshots/stax/get_pk_None/00003.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
BIN
tests/ragger/snapshots/stax/get_pk_rejected_60/00003.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB |
BIN
tests/ragger/snapshots/stax/get_pk_rejected_700/00003.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 21 KiB |
BIN
tests/ragger/snapshots/stax/test_get_eth2_pk/00002.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
tests/ragger/snapshots/stax/test_get_eth2_pk/00003.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
@@ -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
|
||||
|
||||