Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: updated test display flex|stax for GetPublicKey #55

Merged
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
23 changes: 14 additions & 9 deletions src/common/ui/display_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ static void review_choice(bool confirm) {
}
}

static void review_public_key_choice(bool confirm) {
// Answer, display a status page and go back to main
if (confirm) {
sendPublicKey(true);
} else {
sendUserRejection();
}
}

static void review_export_private_key(bool confirm) {
// Answer, display a status page and go back to main
if (confirm) {
Expand All @@ -43,7 +52,6 @@ static void review_choice_sign(bool confirm) {
}

void uiComparePubkey(void) {
// TODO: Implement this
nbgl_useCaseAddressReview(global.exportPublicKeyContext.publicKey,
NULL,
&C_app_concordium_64px,
Expand All @@ -54,14 +62,13 @@ void uiComparePubkey(void) {

void uiGeneratePubkey(volatile unsigned int *flags) {
nbgl_useCaseAddressReview((char *) global.exportPublicKeyContext.display, // Address to display
NULL, // No additional tag-value list
&C_app_concordium_64px, // Icon to display
"Public Key", // Review title
NULL, // No review subtitle
sendPublicKey // Callback function
NULL, // No additional tag-value list
&C_app_concordium_64px, // Icon to display
"Public Key", // Review title
NULL, // No review subtitle
review_public_key_choice // Callback function
);
*flags |= IO_ASYNCH_REPLY;
// TODO: Implement this
}

void uiExportPrivateKey(volatile unsigned int *flags) {
Expand Down Expand Up @@ -301,7 +308,6 @@ void startConfigureBakerUrlDisplay(bool lastUrlPage) {
}
}

// TODO: To fix
void startConfigureDelegationDisplay(void) {
// Get context from global state
signConfigureDelegationContext_t *ctx = &global.signConfigureDelegation;
Expand Down Expand Up @@ -550,7 +556,6 @@ void startTransferDisplay(bool displayMemo, volatile unsigned int *flags) {

*flags |= IO_ASYNCH_REPLY;
displayMemo = false;
// TODO: Implement this
}

void uiSignTransferToEncryptedDisplay(volatile unsigned int *flags) {
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.
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.
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 not shown.
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.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
120 changes: 70 additions & 50 deletions tests/test_pubkey_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,36 @@
from ragger.firmware import Firmware
from utils import navigate_until_text_and_compare


# TODO: remove this test
# # In this test we check that the GET_PUBLIC_KEY works in non-confirmation mode
# def test_get_public_key_no_confirm(backend):
# for path in ["m/44'/919'/0'/0/0", "m/44'/919'/0/0/0", "m/44'/919'/911'/0/0", "m/44'/919'/255/255/255", "m/44'/919'/2147483647/0/0/0/0/0/0/0",
# "m/1105'/0'/0'/0/0", "m/1105'/0'/0/0/0", "m/1105'/0'/911'/0/0", "m/1105'/0'/255/255/255", "m/1105'/0'/2147483647/0/0/0/0/0/0/0"]:
# client = BoilerplateCommandSender(backend)
# response = client.get_public_key(path=path).data
# _, public_key, _, chain_code = unpack_get_public_key_response(response)

# ref_public_key, ref_chain_code = calculate_public_key_and_chaincode(CurveChoice.Secp256k1, path=path)
# assert public_key.hex() == ref_public_key
# assert chain_code.hex() == ref_chain_code

nano_accept_instructions = [
NavInsID.BOTH_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.BOTH_CLICK,
]

nano_refuse_instructions = [
NavInsID.RIGHT_CLICK,
NavInsID.BOTH_CLICK,
]

flex_stax_accept_instructions = [
NavInsID.WAIT_FOR_SCREEN_CHANGE,
NavInsID.SWIPE_CENTER_TO_LEFT,
NavInsID.USE_CASE_CHOICE_CONFIRM,
NavInsID.SWIPE_CENTER_TO_LEFT,
NavInsID.USE_CASE_CHOICE_CONFIRM,
NavInsID.WAIT_FOR_HOME_SCREEN,
]

flex_stax_refuse_instructions = [
NavInsID.SWIPE_CENTER_TO_LEFT,
NavInsID.USE_CASE_CHOICE_REJECT,
NavInsID.WAIT_FOR_HOME_SCREEN,
]

# In this test we check that the GET_PUBLIC_KEY works in confirmation mode
@pytest.mark.active_test_scope
def test_get_legacy_public_key_confirm_accepted(
backend, navigator, firmware, default_screenshot_path, test_name
backend, navigator, firmware, default_screenshot_path, test_name, scenario_navigator
):
client = BoilerplateCommandSender(backend)
path = "m/1105/0/0/0/0/2/0/0"
Expand All @@ -57,12 +52,12 @@ def test_get_legacy_public_key_confirm_accepted(
instructions = flex_stax_accept_instructions

with client.get_public_key_with_confirmation(path=path):

navigator.navigate_and_compare(
default_screenshot_path,
test_name,
instructions,
screen_change_before_first_instruction=False,
screen_change_before_first_instruction=True,
screen_change_after_last_instruction=False,
)

response = client.get_async_response().data
Expand All @@ -80,14 +75,19 @@ def test_get_signed_legacy_public_key_confirm_accepted(
):
client = BoilerplateCommandSender(backend)
path = "m/1105/0/0/0/0/2/0/0"
if firmware.is_nano:
instructions = nano_accept_instructions
else:
instructions = flex_stax_accept_instructions

with client.get_public_key_with_confirmation(path=path, signPublicKey=True):
if firmware.is_nano:
navigator.navigate_and_compare(
default_screenshot_path,
test_name,
nano_accept_instructions,
screen_change_before_first_instruction=False,
)
navigator.navigate_and_compare(
default_screenshot_path,
test_name,
instructions,
screen_change_before_first_instruction=True,
screen_change_after_last_instruction=False,
)

response = client.get_async_response().data
print("km------------------|response:", response.hex())
Expand All @@ -104,14 +104,19 @@ def test_get_signed_legacy_governance_public_key_confirm_accepted(
):
client = BoilerplateCommandSender(backend)
path = "m/1105/0/1/0/0"
if firmware.is_nano:
instructions = nano_accept_instructions
else:
instructions = flex_stax_accept_instructions

with client.get_public_key_with_confirmation(path=path, signPublicKey=True):
if firmware.is_nano:
navigator.navigate_and_compare(
default_screenshot_path,
test_name,
nano_accept_instructions,
screen_change_before_first_instruction=False,
)
navigator.navigate_and_compare(
default_screenshot_path,
test_name,
instructions,
screen_change_before_first_instruction=True,
screen_change_after_last_instruction=False,
)

response = client.get_async_response().data
print("km------------------|response:", response.hex())
Expand All @@ -128,14 +133,19 @@ def test_get_signed_new_public_key_confirm_accepted(
):
client = BoilerplateCommandSender(backend)
path = "m/44/919/0/0/0"
if firmware.is_nano:
instructions = nano_accept_instructions
else:
instructions = flex_stax_accept_instructions

with client.get_public_key_with_confirmation(path=path, signPublicKey=True):
if firmware.is_nano:
navigator.navigate_and_compare(
default_screenshot_path,
test_name,
nano_accept_instructions,
screen_change_before_first_instruction=False,
)
navigator.navigate_and_compare(
default_screenshot_path,
test_name,
instructions,
screen_change_before_first_instruction=True,
screen_change_after_last_instruction=False,
)

response = client.get_async_response().data
print("km------------------|response:", response.hex())
Expand All @@ -144,16 +154,26 @@ def test_get_signed_new_public_key_confirm_accepted(
== "e31d69e500b0f83983fb6080aaa46129cf7c70e27d59b1aae9820b1d03f9840252c415c2552d81fde03a9aef6bba24325711a5924b417d79324f60ef67466a017542c6423387fd0d7679cab784d8178bf15e10eb4cb2eef944d47611682c930c"
)

# In this test we check that the GET_PUBLIC_KEY in confirmation mode replies an error if the user refuses
@pytest.mark.active_test_scope
def test_get_public_key_confirm_refused(backend, firmware, navigator, default_screenshot_path, test_name):
client = BoilerplateCommandSender(backend)
path = "m/44'/919'/0'/0/0"
if firmware.is_nano:
instructions = nano_refuse_instructions
else:
instructions = flex_stax_refuse_instructions

# # In this test we check that the GET_PUBLIC_KEY in confirmation mode replies an error if the user refuses
# def test_get_public_key_confirm_refused(backend, scenario_navigator):
# client = BoilerplateCommandSender(backend)
# path = "m/44'/919'/0'/0/0"

# with pytest.raises(ExceptionRAPDU) as e:
# with client.get_public_key_with_confirmation(path=path):
# scenario_navigator.address_review_reject()
with pytest.raises(ExceptionRAPDU) as e:
with client.get_public_key_with_confirmation(path=path):
navigator.navigate_and_compare(
default_screenshot_path,
test_name,
instructions,
screen_change_before_first_instruction=True,
screen_change_after_last_instruction=False,
)

# # Assert that we have received a refusal
# assert e.value.status == Errors.SW_DENY
# assert len(e.value.data) == 0
# Assert that we have received a refusal
assert e.value.status == Errors.SW_DENY
assert len(e.value.data) == 0
Loading