Port Address Review steps to 'nbgl_useCaseAddressReview'
@@ -14,21 +14,22 @@ static void confirmTransation(void) {
|
||||
|
||||
static void reviewChoice(bool confirm) {
|
||||
if (confirm) {
|
||||
// display a status page and go back to main
|
||||
nbgl_useCaseStatus("ADDRESS\nVERIFIED", true, confirmTransation);
|
||||
nbgl_useCaseReviewStatus(STATUS_TYPE_ADDRESS_VERIFIED, confirmTransation);
|
||||
} else {
|
||||
nbgl_useCaseStatus("Address verification\ncancelled", false, reviewReject);
|
||||
nbgl_useCaseReviewStatus(STATUS_TYPE_ADDRESS_REJECTED, reviewReject);
|
||||
}
|
||||
}
|
||||
|
||||
static void buildScreen(void) {
|
||||
void ui_display_public_eth2(void) {
|
||||
bytes_to_string(strings.tmp.tmp,
|
||||
sizeof(strings.tmp.tmp),
|
||||
tmpCtx.publicKeyContext.publicKey.W,
|
||||
48);
|
||||
nbgl_useCaseAddressConfirmation(strings.tmp.tmp, reviewChoice);
|
||||
}
|
||||
|
||||
void ui_display_public_eth2(void) {
|
||||
buildScreen();
|
||||
strlcpy(g_stax_shared_buffer, "Verify ETH2\naddress", sizeof(g_stax_shared_buffer));
|
||||
nbgl_useCaseAddressReview(strings.tmp.tmp,
|
||||
NULL,
|
||||
get_app_icon(false),
|
||||
g_stax_shared_buffer,
|
||||
NULL,
|
||||
reviewChoice);
|
||||
}
|
||||
|
||||
@@ -13,27 +13,14 @@ static void confirm_send(void) {
|
||||
io_seproxyhal_touch_address_ok(NULL);
|
||||
}
|
||||
|
||||
static void confirm_addr(void) {
|
||||
// display a status page and go back to main
|
||||
nbgl_useCaseStatus("ADDRESS\nVERIFIED", true, confirm_send);
|
||||
}
|
||||
|
||||
static void reject_addr(void) {
|
||||
nbgl_useCaseStatus("Address verification\ncancelled", false, cancel_send);
|
||||
}
|
||||
|
||||
static void review_choice(bool confirm) {
|
||||
if (confirm) {
|
||||
confirm_addr();
|
||||
nbgl_useCaseReviewStatus(STATUS_TYPE_ADDRESS_VERIFIED, confirm_send);
|
||||
} else {
|
||||
reject_addr();
|
||||
nbgl_useCaseReviewStatus(STATUS_TYPE_ADDRESS_REJECTED, cancel_send);
|
||||
}
|
||||
}
|
||||
|
||||
static void display_addr(void) {
|
||||
nbgl_useCaseAddressConfirmation(strings.common.fullAddress, review_choice);
|
||||
}
|
||||
|
||||
void ui_display_public_key(const uint64_t *chain_id) {
|
||||
const nbgl_icon_details_t *icon;
|
||||
|
||||
@@ -54,5 +41,10 @@ void ui_display_public_key(const uint64_t *chain_id) {
|
||||
icon = get_app_icon(false);
|
||||
}
|
||||
strlcat(g_stax_shared_buffer, "address", sizeof(g_stax_shared_buffer));
|
||||
nbgl_useCaseReviewStart(icon, g_stax_shared_buffer, NULL, "Cancel", display_addr, reject_addr);
|
||||
nbgl_useCaseAddressReview(strings.common.fullAddress,
|
||||
NULL,
|
||||
icon,
|
||||
g_stax_shared_buffer,
|
||||
NULL,
|
||||
review_choice);
|
||||
}
|
||||
|
||||
|
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
|
||||
|
||||