trezorctl+client: add support for CoSi commit/sign

pull/25/head
Pavol Rusnak 7 years ago
parent 54df69a407
commit a71c33d123
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -681,6 +681,11 @@ def ethereum_sign_tx(connect, host, chain_id, address, value, gas_limit, gas_pri
return 'Signed raw transaction: %s' % tx_hex
#
# NEM functions
#
@cli.command(help='Get NEM address for specified path.')
@click.option('-n', '--address', required=True, help="BIP-32 path, e.g. m/44'/0'/43'/0/0")
@click.option('-N', '--network', type=int, default=0x68)
@ -692,7 +697,7 @@ def nem_get_address(connect, address, network, show_display):
return client.nem_get_address(address_n, network, show_display)
@cli.command(help='Sign (and optionally broadcast) NEM transaction')
@cli.command(help='Sign (and optionally broadcast) NEM transaction.')
@click.option('-n', '--address', help='BIP-32 path to signing key')
@click.option('-f', '--file', type=click.File('r'), default='-', help='Transaction in NIS (RequestPrepareAnnounce) format')
@click.option('-b', '--broadcast', help='NIS to announce transaction to')
@ -714,6 +719,33 @@ def nem_sign_tx(connect, address, file, broadcast):
return payload
#
# CoSi functions
#
@cli.command(help='Ask device to commit to CoSi signing.')
@click.option('-n', '--address', required=True, help="BIP-32 path, e.g. m/44'/0'/0'/0/0")
@click.argument('data')
@click.pass_obj
def cosi_commit(connect, address, data):
client = connect()
address_n = client.expand_path(address)
return client.cosi_commit(address_n, binascii.unhexlify(data))
@cli.command(help='Ask device to sign using CoSi.')
@click.option('-n', '--address', required=True, help="BIP-32 path, e.g. m/44'/0'/0'/0/0")
@click.argument('data')
@click.argument('global_commitment')
@click.argument('global_pubkey')
@click.pass_obj
def cosi_sign(connect, address, data, global_commitment, global_pubkey):
client = connect()
address_n = client.expand_path(address)
return client.cosi_sign(address_n, binascii.unhexlify(data), binascii.unhexlify(global_commitment), binascii.unhexlify(global_pubkey))
#
# Main
#

@ -659,6 +659,16 @@ class ProtocolMixin(object):
def get_ecdh_session_key(self, identity, peer_public_key, ecdsa_curve_name=DEFAULT_CURVE):
return self.call(proto.GetECDHSessionKey(identity=identity, peer_public_key=peer_public_key, ecdsa_curve_name=ecdsa_curve_name))
@expect(proto.CosiCommitment)
def cosi_commit(self, n, data):
n = self._convert_prime(n)
return self.call(proto.CosiCommit(address_n=n, data=data))
@expect(proto.CosiSignature)
def cosi_sign(self, n, data, global_commitment, global_pubkey):
n = self._convert_prime(n)
return self.call(proto.CosiSign(address_n=n, data=data, global_commitment=global_commitment, global_pubkey=global_pubkey))
@field('message')
@expect(proto.Success)
def set_u2f_counter(self, u2f_counter):

File diff suppressed because one or more lines are too long

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: types.proto
# libprotoc 3.3.2
# trezor-common 0e3f6e73ed1d97c653fea162581d47a74d0c2854
# libprotoc 3.3.0
# trezor-common c20bb1c567ac0c1ddabf74354f204043eeacad10
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))

Loading…
Cancel
Save