Пример #1
0
def test_derivation_irrelevant_on_slip39(client: Client, derivation_type):
    client.init_device(new_session=True, derive_cardano=False)
    pubkey = get_public_key(client, ADDRESS_N, derivation_type=D.ICARUS)
    test_pubkey = get_public_key(client,
                                 ADDRESS_N,
                                 derivation_type=derivation_type)
    assert pubkey == test_pubkey
Пример #2
0
def test_bad_session(client: Client):
    client.init_device(new_session=True)
    with pytest.raises(TrezorFailure, match="not enabled"):
        get_public_key(client, ADDRESS_N, derivation_type=D.ICARUS)

    client.init_device(new_session=True, derive_cardano=False)
    with pytest.raises(TrezorFailure, match="not enabled"):
        get_public_key(client, ADDRESS_N, derivation_type=D.ICARUS)
    def test_cardano_get_public_key(self, path, public_key, chain_code):
        self.setup_mnemonic_allallall()

        key = get_public_key(self.client, parse_path(path))

        assert key.node.public_key.hex() == public_key
        assert key.node.chain_code.hex() == chain_code
        assert key.xpub == public_key + chain_code
Пример #4
0
def test_cardano_get_public_key(client, path, public_key, chain_code):
    # enter passphrase
    assert client.features.passphrase_protection is True
    client.set_passphrase("TREZOR")

    key = get_public_key(client, parse_path(path))

    assert key.node.public_key.hex() == public_key
    assert key.node.chain_code.hex() == chain_code
    assert key.xpub == public_key + chain_code
Пример #5
0
def test_cardano_get_public_key(client: Client, parameters, result):
    client.init_device(new_session=True, derive_cardano=True)

    derivation_type = CardanoDerivationType.__members__[
        parameters.get("derivation_type", "ICARUS_TREZOR")
    ]
    key = get_public_key(client, parse_path(parameters["path"]), derivation_type)

    assert key.node.public_key.hex() == result["public_key"]
    assert key.node.chain_code.hex() == result["chain_code"]
    assert key.xpub == result["public_key"] + result["chain_code"]
Пример #6
0
def test_derive_cardano_running_session(client: Client):
    # start new session
    client.init_device(new_session=True)
    session_id = client.session_id
    # force derivation of seed
    get_test_address(client)

    # session should not have Cardano capability
    with pytest.raises(TrezorFailure, match="not enabled"):
        cardano.get_public_key(client, parse_path("m/44h/1815h/0h"))

    # restarting same session should go well
    client.init_device()
    assert session_id == client.session_id

    # restarting same session should go well if we _don't_ want to derive cardano
    client.init_device(derive_cardano=False)
    assert session_id == client.session_id

    # restarting with derive_cardano=True should kill old session and create new one
    client.init_device(derive_cardano=True)
    assert session_id != client.session_id

    session_id = client.session_id

    # new session should have Cardano capability
    cardano.get_public_key(client, parse_path("m/44h/1815h/0h"))

    # restarting with derive_cardano=True should keep same session
    client.init_device(derive_cardano=True)
    assert session_id == client.session_id

    # restarting with no setting should keep same session
    client.init_device()
    assert session_id == client.session_id

    # restarting with derive_cardano=False should kill old session and create new one
    client.init_device(derive_cardano=False)
    assert session_id != client.session_id

    with pytest.raises(TrezorFailure, match="not enabled"):
        cardano.get_public_key(client, parse_path("m/44h/1815h/0h"))
def test_cardano_get_public_key(client, path, public_key, chain_code):
    key = get_public_key(client, parse_path(path))

    assert key.node.public_key.hex() == public_key
    assert key.node.chain_code.hex() == chain_code
    assert key.xpub == public_key + chain_code
Пример #8
0
def test_ledger_available_always(client: Client):
    client.init_device(new_session=True, derive_cardano=False)
    get_public_key(client, ADDRESS_N, derivation_type=D.LEDGER)

    client.init_device(new_session=True, derive_cardano=True)
    get_public_key(client, ADDRESS_N, derivation_type=D.LEDGER)
Пример #9
0
def test_cardano_get_public_key(client, parameters, result):
    key = get_public_key(client, parse_path(parameters["path"]))

    assert key.node.public_key.hex() == result["public_key"]
    assert key.node.chain_code.hex() == result["chain_code"]
    assert key.xpub == result["public_key"] + result["chain_code"]