mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-10 23:40:58 +00:00
cardano: remove sign/verify functions
This commit is contained in:
parent
936f5180e9
commit
4f572f9e15
24
trezorctl
24
trezorctl
@ -1137,30 +1137,6 @@ def cardano_get_public_key(connect, address):
|
||||
return cardano.get_public_key(client, address_n)
|
||||
|
||||
|
||||
@cli.command(help="Sign Cardano message.")
|
||||
@click.option(
|
||||
"-n", "--address", required=True, help="BIP-32 path to key, e.g. m/44'/1815'/0'/0/0"
|
||||
)
|
||||
@click.option("-m", "--message", required=True, help="String message to sign")
|
||||
@click.pass_obj
|
||||
def cardano_sign_message(connect, address, message):
|
||||
client = connect()
|
||||
address_n = tools.parse_path(address)
|
||||
|
||||
return cardano.sign_message(client, address_n, message)
|
||||
|
||||
|
||||
@cli.command(help="Verify Cardano message.")
|
||||
@click.option("-p", "--public_key", required=True, help="Public key as hex string")
|
||||
@click.option("-s", "--signature", required=True, help="Signature as hex string")
|
||||
@click.option("-m", "--message", required=True, help="String message which was signed")
|
||||
@click.pass_obj
|
||||
def cardano_verify_message(connect, public_key, signature, message):
|
||||
client = connect()
|
||||
|
||||
return cardano.verify_message(client, public_key, signature, message)
|
||||
|
||||
|
||||
#
|
||||
# NEM functions
|
||||
#
|
||||
|
@ -18,7 +18,7 @@ import binascii
|
||||
from typing import List
|
||||
|
||||
from . import messages, tools
|
||||
from .tools import CallException, expect, session
|
||||
from .tools import expect, session
|
||||
|
||||
REQUIRED_FIELDS_TRANSACTION = ("inputs", "outputs", "transactions")
|
||||
REQUIRED_FIELDS_INPUT = ("path", "prev_hash", "prev_index", "type")
|
||||
@ -36,32 +36,6 @@ def get_public_key(client, address_n):
|
||||
return client.call(messages.CardanoGetPublicKey(address_n=address_n))
|
||||
|
||||
|
||||
@expect(messages.CardanoMessageSignature)
|
||||
def sign_message(client, address_n, message):
|
||||
return client.call(
|
||||
messages.CardanoSignMessage(address_n=address_n, message=message.encode())
|
||||
)
|
||||
|
||||
|
||||
def verify_message(client, public_key, signature, message):
|
||||
try:
|
||||
response = client.call(
|
||||
messages.CardanoVerifyMessage(
|
||||
public_key=binascii.unhexlify(public_key),
|
||||
signature=binascii.unhexlify(signature),
|
||||
message=message.encode(),
|
||||
)
|
||||
)
|
||||
|
||||
except CallException as error:
|
||||
response = error
|
||||
|
||||
if isinstance(response, messages.Success):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
@session
|
||||
def sign_tx(
|
||||
client,
|
||||
|
@ -1,61 +0,0 @@
|
||||
# This file is part of the Trezor project.
|
||||
#
|
||||
# Copyright (C) 2012-2018 SatoshiLabs and contributors
|
||||
#
|
||||
# This library is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
from binascii import hexlify
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib.cardano import sign_message
|
||||
from trezorlib.tools import parse_path
|
||||
|
||||
from .common import TrezorTest
|
||||
from .conftest import TREZOR_VERSION
|
||||
|
||||
|
||||
@pytest.mark.cardano
|
||||
@pytest.mark.skip_t1 # T1 support is not planned
|
||||
@pytest.mark.xfail(TREZOR_VERSION == 2, reason="T2 support is not yet finished")
|
||||
class TestMsgCardanoSignMessage(TrezorTest):
|
||||
@pytest.mark.parametrize(
|
||||
"message,path,expected_signature",
|
||||
[
|
||||
(
|
||||
"Test message to sign",
|
||||
"m/44'/1815'/0'/0/0",
|
||||
"dfb89d2b22c20ac7270e7640f9b27fee030c30d72afc342f83f6cb79a2522e17142597dbfb979462fc9fbf6ea17b4eba3b7cbf582e41b6ac31cb491e7cd1e308",
|
||||
),
|
||||
(
|
||||
"New Test message to sign",
|
||||
"m/44'/1815'/0'/0/1",
|
||||
"d2c68818859f94138ad28a59aa3419a96394008bd38657fe5e74b299df33e70ff7de1b2091ba4a4351153ce4b6beb7eb7316d917ed9303b9f7de57f76e4e1307",
|
||||
),
|
||||
(
|
||||
"Another Test message to sign",
|
||||
"m/44'/1815'/0'/0/2",
|
||||
"cfb1a8f76e566d387ed727e3eefbb3a0d280917045f2fc82ff381f296a17344d520c00882bc0656bf04c9e95f8138540d4b6d10ddf34d80e27704d1b0cbd0f05",
|
||||
),
|
||||
(
|
||||
"Just another Test message to sign",
|
||||
"m/44'/1815'/0'/0/3",
|
||||
"a1aadbea98fc4075affb0e0b166b71934ac19420688b80e2ac2cfe3cf0d66404da19a0ab4a9f23335c080dc4cc76d1fd4fdfbb44289a50707d3fcf122a96060d",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_cardano_sign_message(self, message, path, expected_signature):
|
||||
self.setup_mnemonic_allallall()
|
||||
|
||||
signature = sign_message(self.client, parse_path(path), message)
|
||||
assert expected_signature == hexlify(signature.signature).decode("utf8")
|
@ -1,85 +0,0 @@
|
||||
# This file is part of the Trezor project.
|
||||
#
|
||||
# Copyright (C) 2012-2018 SatoshiLabs and contributors
|
||||
#
|
||||
# This library is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib.cardano import verify_message
|
||||
|
||||
from .common import TrezorTest
|
||||
from .conftest import TREZOR_VERSION
|
||||
|
||||
|
||||
@pytest.mark.cardano
|
||||
@pytest.mark.skip_t1 # T1 support is not planned
|
||||
@pytest.mark.xfail(TREZOR_VERSION == 2, reason="T2 support is not yet finished")
|
||||
class TestMsgCardanoVerifyMessage(TrezorTest):
|
||||
# https://github.com/trezor/trezor-core/blob/master/tests/test_apps.cardano.verify_message.py
|
||||
@pytest.mark.parametrize(
|
||||
"message,public_key,signature,expected",
|
||||
[
|
||||
(
|
||||
"Test message to sign",
|
||||
"2df46e04ebf0816e242bfaa1c73e5ebe8863d05d7a96c8aac16f059975e63f30",
|
||||
"07f226da2a59c3083e80f01ef7e0ec46fc726ebe6bd15d5e9040031c342d8651bee9aee875019c41a7719674fd417ad43990988ffd371527604b6964df75960d",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"New Test message to sign",
|
||||
"7d1de3f22f53904d007ff833fadd7cd6482ea1e83918b985b4ea33e63c16d183",
|
||||
"8fd3b9d8a4c30326b720de76f8de2bbf57b29b7593576eac4a3017ea23046812017136520dc2f24e9fb4da56bd87c77ea49265686653b36859b5e1e56ba9eb0f",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"Another Test message to sign",
|
||||
"f59a28d704df090d8fc641248bdb27d0d001da13ddb332a79cfba8a9fa7233e7",
|
||||
"89d63bd32c2eb92aa418b9ce0383a7cf489bc56284876c19246b70be72070d83d361fcb136e8e257b7e66029ef4a566405cda0143d251f851debd62c3c38c302",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"Just another Test message to sign",
|
||||
"723fdc0eb1300fe7f2b9b6989216a831835a88695ba2c2d5c50c8470b7d1b239",
|
||||
"49d948090d30e35a88a26d8fb07aca5d68936feba2d5bd49e0d0f7c027a0c8c2955b93a7c930a3b36d23c2502c18bf39cf9b17bbba1a0965090acfb4d10a9305",
|
||||
True,
|
||||
),
|
||||
(
|
||||
"Test message to sign fail",
|
||||
"2df46e04ebf0816e242bfaa1c73e5ebe8863d05d7a96c8aac16f059975e63f30",
|
||||
"07f226da2a59c3083e80f01ef7e0ec46fc726ebe6bd15d5e9040031c342d8651bee9aee875019c41a7719674fd417ad43990988ffd371527604b6964df75960d",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"New Test message to sign",
|
||||
"7d1de3f22f53904d007ff833fadd7cd6482ea1e83918b985b4ea33e63c16d183",
|
||||
"20d3b9d8a4c30326b720de76f8de2bbf57b29b7593576eac4a3017ea23046812017136520dc2f24e9fb4da56bd87c77ea49265686653b36859b5e1e56ba9eb0f",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"Another Test message to sign",
|
||||
"209a28d704df090d8fc641248bdb27d0d001da13ddb332a79cfba8a9fa7233e7",
|
||||
"89d63bd32c2eb92aa418b9ce0383a7cf489bc56284876c19246b70be72070d83d361fcb136e8e257b7e66029ef4a566405cda0143d251f851debd62c3c38c302",
|
||||
False,
|
||||
),
|
||||
(
|
||||
"Just another Test message to sign fail",
|
||||
"223fdc0eb1300fe7f2b9b6989216a831835a88695ba2c2d5c50c8470b7d1b239",
|
||||
"49d948090d30e35a88a26d8fb07aca5d68936feba2d5bd49e0d0f7c027a0c8c2955b93a7c930a3b36d23c2502c18bf39cf9b17bbba1a0965090acfb4d10a9305",
|
||||
False,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_cardano_verify_message(self, message, public_key, signature, expected):
|
||||
result = verify_message(self.client, public_key, signature, message)
|
||||
assert result == expected
|
Loading…
Reference in New Issue
Block a user