diff --git a/trezorctl b/trezorctl index b901668f87..b9531cd9fc 100755 --- a/trezorctl +++ b/trezorctl @@ -876,6 +876,20 @@ def lisk_get_address(connect, address, show_display): return client.lisk_get_address(address_n, show_display) +@cli.command(help='Get Lisk public key for specified path.') +@click.option('-n', '--address', required=True, help="BIP-32 path, e.g. m/44'/134'/0'/0'") +@click.option('-d', '--show-display', is_flag=True) +@click.pass_obj +def lisk_get_public_key(connect, address, show_display): + client = connect() + address_n = client.expand_path(address) + res = client.lisk_get_public_key(address_n, show_display) + output = { + "public_key": binascii.hexlify(res.public_key).decode() + } + 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') diff --git a/trezorlib/client.py b/trezorlib/client.py index 023c725817..af1daf3435 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -637,6 +637,11 @@ class ProtocolMixin(object): n = self._convert_prime(n) return self.call(proto.LiskGetAddress(address_n=n, show_display=show_display)) + @expect(proto.LiskPublicKey) + def lisk_get_public_key(self, n, show_display=False): + 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) diff --git a/trezorlib/tests/device_tests/test_msg_lisk_getpublickey.py b/trezorlib/tests/device_tests/test_msg_lisk_getpublickey.py new file mode 100644 index 0000000000..60cb64f3b3 --- /dev/null +++ b/trezorlib/tests/device_tests/test_msg_lisk_getpublickey.py @@ -0,0 +1,27 @@ +# This file is part of the TREZOR project. +# +# Copyright (C) 2016-2017 Pavol Rusnak +# +# 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 . + +from .common import * + + +@pytest.mark.skip_t1 +class TestMsgLiskGetPublicKey(TrezorTest): + + def test_lisk_get_public_key(self): + self.setup_mnemonic_nopin_nopassphrase() + sig = self.client.lisk_get_public_key([2147483692, 2147483782, 2147483648, 2147483648]) + assert hexlify(sig.public_key) == b'eb56d7bbb5e8ea9269405f7a8527fe126023d1db2c973cfac6f760b60ae27294'