-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #464 from LedgerHQ/feat/apa/getpk_on_other_chains
Get PK on other chains
- Loading branch information
Showing
120 changed files
with
215 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import pytest | ||
from typing import Optional | ||
from pathlib import Path | ||
from ragger.error import ExceptionRAPDU | ||
from ragger.firmware import Firmware | ||
from ragger.backend import BackendInterface | ||
from ragger.navigator import Navigator, NavInsID | ||
from ledger_app_clients.ethereum.client import EthAppClient, StatusWord | ||
from ledger_app_clients.ethereum.settings import SettingID, settings_toggle | ||
import ledger_app_clients.ethereum.response_parser as ResponseParser | ||
from ragger.bip import calculate_public_key_and_chaincode, CurveChoice | ||
|
||
ROOT_SCREENSHOT_PATH = Path(__file__).parent | ||
|
||
@pytest.fixture(params=[True, False]) | ||
def with_chaincode(request) -> bool: | ||
return request.param | ||
|
||
@pytest.fixture(params=[None, 1, 2, 5, 137]) | ||
def chain(request) -> Optional[int]: | ||
return request.param | ||
|
||
def get_moves(firmware: Firmware, | ||
navigator: BackendInterface, | ||
chain: Optional[int] = None, | ||
reject: bool = False): | ||
moves = list() | ||
|
||
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 ] | ||
moves += [ NavInsID.BOTH_CLICK ] | ||
else: | ||
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 | ||
|
||
def test_get_pk_rejected(firmware: Firmware, | ||
backend: BackendInterface, | ||
navigator: Navigator): | ||
app_client = EthAppClient(backend) | ||
|
||
try: | ||
with app_client.get_public_addr(): | ||
navigator.navigate_and_compare(ROOT_SCREENSHOT_PATH, | ||
"get_pk_rejected", | ||
get_moves(firmware, navigator, reject=True)) | ||
except ExceptionRAPDU as e: | ||
assert e.status == StatusWord.CONDITION_NOT_SATISFIED | ||
else: | ||
assert False # An exception should have been raised | ||
|
||
def test_get_pk(firmware: Firmware, | ||
backend: BackendInterface, | ||
navigator: Navigator, | ||
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(ROOT_SCREENSHOT_PATH, | ||
"get_pk_%s" % (chain), | ||
get_moves(firmware, navigator, chain=chain)) | ||
pk, addr, 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") | ||
assert pk.hex() == ref_pk | ||
if with_chaincode: | ||
assert chaincode.hex() == ref_chaincode |