mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-14 03:30:02 +00:00
drop Lisk and Stellar sign/verify message functionality
This commit is contained in:
parent
70172520fb
commit
4b7926268e
51
trezorctl
51
trezorctl
@ -891,33 +891,6 @@ def lisk_get_public_key(connect, address, show_display):
|
||||
return output
|
||||
|
||||
|
||||
@cli.command(help='Sign message with Lisk address.')
|
||||
@click.option('-n', '--address', required=True, help="BIP-32 path, e.g. m/44'/134'/0'/0'")
|
||||
@click.argument('message')
|
||||
@click.pass_obj
|
||||
def lisk_sign_message(connect, address, message):
|
||||
client = connect()
|
||||
address_n = client.expand_path(address)
|
||||
res = client.lisk_sign_message(address_n, message)
|
||||
output = {
|
||||
'message': message,
|
||||
'address': res.address,
|
||||
'signature': binascii.hexlify(res.signature).decode()
|
||||
}
|
||||
return output
|
||||
|
||||
|
||||
@cli.command(help='Verify message signed with Lisk address.')
|
||||
@click.argument('pubkey')
|
||||
@click.argument('signature')
|
||||
@click.argument('message')
|
||||
@click.pass_obj
|
||||
def lisk_verify_message(connect, pubkey, signature, message):
|
||||
signature = bytes.fromhex(signature)
|
||||
pubkey = bytes.fromhex(pubkey)
|
||||
return connect().lisk_verify_message(pubkey, signature, message)
|
||||
|
||||
|
||||
@cli.command(help='Sign Lisk transaction.')
|
||||
@click.option('-n', '--address', required=True, help="BIP-32 path to signing key, e.g. m/44'/134'/0'/0'")
|
||||
@click.option('-f', '--file', type=click.File('r'), default='-', help='Transaction in JSON format')
|
||||
@ -987,30 +960,6 @@ def stellar_sign_message(connect, address, message):
|
||||
return base64.b64encode(response.signature)
|
||||
|
||||
|
||||
@cli.command(help='Verify that a signature is valid')
|
||||
@click.option('--message-is-b64/--no-message-is-b64', default=False, required=False, help="If set, the message argument will be interpreted as a base64-encoded string")
|
||||
@click.argument('address')
|
||||
@click.argument('signatureb64')
|
||||
@click.argument('message')
|
||||
@click.pass_obj
|
||||
def stellar_verify_message(connect, address, message_is_b64, signatureb64, message):
|
||||
if message_is_b64:
|
||||
message = base64.b64decode(message)
|
||||
else:
|
||||
message = message.encode('utf-8')
|
||||
|
||||
pubkey_bytes = stellar.address_to_public_key(address)
|
||||
|
||||
client = connect()
|
||||
is_verified = client.stellar_verify_message(pubkey_bytes, base64.b64decode(signatureb64), message)
|
||||
|
||||
if is_verified:
|
||||
return "Success: message verified"
|
||||
else:
|
||||
print("ERROR: invalid signature, verification failed")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@cli.command(help='Sign a base64-encoded transaction envelope')
|
||||
@click.option('-n', '--address', required=False, help="BIP32 path. Default primary account is m/44'/148'/0'. Always use hardened paths and the m/44'/148'/ prefix")
|
||||
@click.option('-n', '--network-passphrase', default='Public Global Stellar Network ; September 2015', required=False, help="Network passphrase (blank for public network). Testnet is: 'Test SDF Network ; September 2015'")
|
||||
|
@ -640,20 +640,6 @@ class ProtocolMixin(object):
|
||||
n = self._convert_prime(n)
|
||||
return self.call(proto.LiskGetPublicKey(address_n=n, show_display=show_display))
|
||||
|
||||
@expect(proto.LiskMessageSignature)
|
||||
def lisk_sign_message(self, n, message):
|
||||
n = self._convert_prime(n)
|
||||
message = normalize_nfc(message)
|
||||
return self.call(proto.LiskSignMessage(address_n=n, message=message))
|
||||
|
||||
def lisk_verify_message(self, pubkey, signature, message):
|
||||
message = normalize_nfc(message)
|
||||
try:
|
||||
resp = self.call(proto.LiskVerifyMessage(signature=signature, public_key=pubkey, message=message))
|
||||
except CallException as e:
|
||||
resp = e
|
||||
return isinstance(resp, proto.Success)
|
||||
|
||||
@expect(proto.LiskSignedTx)
|
||||
def lisk_sign_tx(self, n, transaction):
|
||||
n = self._convert_prime(n)
|
||||
@ -1212,17 +1198,6 @@ class ProtocolMixin(object):
|
||||
|
||||
return resp
|
||||
|
||||
@expect(proto.StellarMessageSignature)
|
||||
def stellar_sign_message(self, address_n, message):
|
||||
message = normalize_nfc(message)
|
||||
return self.call(proto.StellarSignMessage(address_n=address_n, message=message))
|
||||
|
||||
def stellar_verify_message(self, pubkey_bytes, signature, message):
|
||||
message = normalize_nfc(message)
|
||||
resp = self.call(proto.StellarVerifyMessage(public_key=pubkey_bytes, message=message, signature=signature))
|
||||
|
||||
return isinstance(resp, proto.Success)
|
||||
|
||||
|
||||
class TrezorClient(ProtocolMixin, TextUIMixin, BaseClient):
|
||||
def __init__(self, transport, *args, **kwargs):
|
||||
|
@ -1,37 +0,0 @@
|
||||
# This file is part of the TREZOR project.
|
||||
#
|
||||
# This library is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# 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 GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from .common import TrezorTest
|
||||
from .conftest import TREZOR_VERSION
|
||||
from binascii import hexlify
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.stellar
|
||||
@pytest.mark.xfail(TREZOR_VERSION == 2, reason="T2 support is not yet finished")
|
||||
class TestMsgStellarSignMessage(TrezorTest):
|
||||
|
||||
def test_stellar_sign_message(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
msg = 'Hello world!'
|
||||
response = self.client.stellar_sign_message(self.client.expand_path("m/44'/148'/0'"), msg)
|
||||
assert hexlify(response.public_key) == b'15d648bfe4d36f196cfb5735ffd8ca54cd4b8233f743f22449de7cf301cdb469'
|
||||
assert hexlify(response.signature) == b'3565f5885786fba6cc40c5656fe5444faec882d5e006de509c7fd6420e500179891ada79933024909cd2b57705254cd53cada422f4a7de7790e31c8c1d0c5004'
|
||||
|
||||
msg = 'LongMessage ' * 80 # but shorter than 1024
|
||||
response = self.client.stellar_sign_message(self.client.expand_path("m/44'/148'/0'"), msg)
|
||||
assert hexlify(response.public_key) == b'15d648bfe4d36f196cfb5735ffd8ca54cd4b8233f743f22449de7cf301cdb469'
|
||||
assert hexlify(response.signature) == b'c1e5c477b0451a1cf4b0d8328176470ad3e5aa493c65d64125af57599dfbe5ca2c5c82887aae7e3fa519bbfc3752f1f1188f48efbe4105aa91351319fcd51507'
|
@ -1,63 +0,0 @@
|
||||
# This file is part of the TREZOR project.
|
||||
#
|
||||
# This library is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# 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 GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from binascii import unhexlify
|
||||
import pytest
|
||||
|
||||
from .common import TrezorTest
|
||||
from .conftest import TREZOR_VERSION
|
||||
from trezorlib import messages as proto
|
||||
from trezorlib.client import CallException
|
||||
|
||||
|
||||
@pytest.mark.stellar
|
||||
@pytest.mark.xfail(TREZOR_VERSION == 2, reason="T2 support is not yet finished")
|
||||
class TestMsgStellarVerifyMessage(TrezorTest):
|
||||
|
||||
def test_stellar_verify_message(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
|
||||
msg = 'Hello world!'
|
||||
pubkey = unhexlify('15d648bfe4d36f196cfb5735ffd8ca54cd4b8233f743f22449de7cf301cdb469')
|
||||
signature = unhexlify('3565f5885786fba6cc40c5656fe5444faec882d5e006de509c7fd6420e500179891ada79933024909cd2b57705254cd53cada422f4a7de7790e31c8c1d0c5004')
|
||||
response = self.client.stellar_verify_message(pubkey, signature, msg)
|
||||
assert response is True
|
||||
|
||||
msg = 'LongMessage ' * 80 # but shorter than 1024
|
||||
pubkey = unhexlify('15d648bfe4d36f196cfb5735ffd8ca54cd4b8233f743f22449de7cf301cdb469')
|
||||
signature = unhexlify('c1e5c477b0451a1cf4b0d8328176470ad3e5aa493c65d64125af57599dfbe5ca2c5c82887aae7e3fa519bbfc3752f1f1188f48efbe4105aa91351319fcd51507')
|
||||
response = self.client.stellar_verify_message(pubkey, signature, msg)
|
||||
assert response is True
|
||||
|
||||
def test_stellar_verify_message_invalid(self):
|
||||
msg = 'abc'
|
||||
pubkey = unhexlify('15d648bfe4d36f196cfb5735ffd8ca54cd4b8233f743f22449de7cf301cdb469')
|
||||
signature = unhexlify('0000000000000000') # invalid length
|
||||
with pytest.raises(CallException) as exc:
|
||||
self.client.stellar_verify_message(pubkey, signature, msg)
|
||||
assert exc.value.args[0] == proto.FailureType.DataError
|
||||
|
||||
# invalid signature
|
||||
signature = unhexlify('00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000')
|
||||
with pytest.raises(CallException) as exc:
|
||||
self.client.stellar_verify_message(pubkey, signature, msg)
|
||||
assert exc.value.args[0] == proto.FailureType.DataError
|
||||
|
||||
# invalid pubkey
|
||||
pubkey = unhexlify('00')
|
||||
signature = unhexlify('00')
|
||||
with pytest.raises(CallException) as exc:
|
||||
self.client.stellar_verify_message(pubkey, signature, msg)
|
||||
assert exc.value.args[0] == proto.FailureType.DataError
|
Loading…
Reference in New Issue
Block a user