From cfdf2b5cac785c89106c798c92319696089b6e38 Mon Sep 17 00:00:00 2001 From: Dusan Klinec Date: Tue, 14 Aug 2018 18:44:34 +0200 Subject: [PATCH] ffix --- src/apps/monero/controller/iface.py | 4 +- src/apps/monero/controller/misc.py | 46 +-------- src/apps/monero/key_image_sync.py | 6 +- src/apps/monero/protocol/tsx_sign.py | 23 +---- src/apps/monero/protocol/tsx_sign_builder.py | 44 ++++----- .../xmr/serialize_messages/tx_construct.py | 96 ------------------- src/apps/monero/xmr/sub/addr.py | 9 +- src/apps/monero/xmr/sub/tsx_helper.py | 9 +- src/apps/monero/xmr/tsx_data.py | 61 ------------ src/trezor/messages/MoneroMultisigKLRki.py | 24 +++++ src/trezor/messages/MoneroOutputEntry.py | 20 ++++ src/trezor/messages/MoneroRctKey.py | 18 ++++ .../MoneroTransactionInputViniRequest.py | 6 +- .../MoneroTransactionSetInputRequest.py | 6 +- .../MoneroTransactionSetOutputRequest.py | 6 +- .../MoneroTransactionSignInputRequest.py | 6 +- .../messages/MoneroTransactionSourceEntry.py | 48 ++++++++++ 17 files changed, 166 insertions(+), 266 deletions(-) delete mode 100644 src/apps/monero/xmr/serialize_messages/tx_construct.py delete mode 100644 src/apps/monero/xmr/tsx_data.py create mode 100644 src/trezor/messages/MoneroMultisigKLRki.py create mode 100644 src/trezor/messages/MoneroOutputEntry.py create mode 100644 src/trezor/messages/MoneroRctKey.py create mode 100644 src/trezor/messages/MoneroTransactionSourceEntry.py diff --git a/src/apps/monero/controller/iface.py b/src/apps/monero/controller/iface.py index 876f8f943..76acba6cc 100644 --- a/src/apps/monero/controller/iface.py +++ b/src/apps/monero/controller/iface.py @@ -40,8 +40,8 @@ async def confirm_transaction(self, tsx_data, creds=None, ctx=None): for idx, dst in enumerate(outs): addr = encode_addr( net_version(creds.network_type), - dst.addr.m_spend_public_key, - dst.addr.m_view_public_key, + dst.addr.spend_public_key, + dst.addr.view_public_key, ) is_change = change_idx and idx == change_idx await layout.require_confirm_tx( diff --git a/src/apps/monero/controller/misc.py b/src/apps/monero/controller/misc.py index 832b41f9a..761e17c0c 100644 --- a/src/apps/monero/controller/misc.py +++ b/src/apps/monero/controller/misc.py @@ -52,36 +52,6 @@ def compute_tx_key(spend_key_private, tx_prefix_hash, salt=None, rand_mult=None) return tx_key, salt, rand_mult -def translate_monero_dest_entry(dst_entry): - from apps.monero.xmr.serialize_messages.tx_dest_entry import TxDestinationEntry - from apps.monero.xmr.serialize_messages.addr import AccountPublicAddress - - d = TxDestinationEntry() - d.amount = dst_entry.amount - d.is_subaddress = dst_entry.is_subaddress - d.addr = AccountPublicAddress( - m_spend_public_key=dst_entry.addr.spend_public_key, - m_view_public_key=dst_entry.addr.view_public_key, - ) - return d - - -async def translate_tsx_data(tsx_data): - from apps.monero.xmr.tsx_data import TsxData - - tsxd = TsxData() - for fld in TsxData.f_specs(): - fname = fld[0] - if hasattr(tsx_data, fname): - setattr(tsxd, fname, getattr(tsx_data, fname)) - - if tsx_data.change_dts: - tsxd.change_dts = translate_monero_dest_entry(tsx_data.change_dts) - - tsxd.outputs = [translate_monero_dest_entry(x) for x in tsx_data.outputs] - return tsxd - - async def parse_msg(bts, msg): from apps.monero.xmr.serialize import xmrserialize from apps.monero.xmr.serialize.readwriter import MemoryReaderWriter @@ -91,18 +61,6 @@ async def parse_msg(bts, msg): return await ar.message(msg) -async def parse_src_entry(bts): - from apps.monero.xmr.serialize_messages.tx_src_entry import TxSourceEntry - - return await parse_msg(bts, TxSourceEntry()) - - -async def parse_dst_entry(bts): - from apps.monero.xmr.serialize_messages.tx_dest_entry import TxDestinationEntry - - return await parse_msg(bts, TxDestinationEntry()) - - async def parse_vini(bts): from apps.monero.xmr.serialize_messages.tx_prefix import TxinToKey @@ -135,7 +93,7 @@ def dst_entry_to_stdobj(dst): return None addr = StdObj( - m_spend_public_key=dst.addr.m_spend_public_key, - m_view_public_key=dst.addr.m_view_public_key, + spend_public_key=dst.addr.spend_public_key, + view_public_key=dst.addr.view_public_key, ) return StdObj(amount=dst.amount, addr=addr, is_subaddress=dst.is_subaddress) diff --git a/src/apps/monero/key_image_sync.py b/src/apps/monero/key_image_sync.py index 0d459bfab..57ae57992 100644 --- a/src/apps/monero/key_image_sync.py +++ b/src/apps/monero/key_image_sync.py @@ -55,7 +55,7 @@ async def layout_key_image_sync(state, ctx, msg): state.ctx_ki = None log.debug(__name__, "KI error, %s: %s", type(e), e) + raise + # from trezor.messages.Failure import Failure - from trezor.messages.Failure import Failure - - return Failure() + # return Failure() diff --git a/src/apps/monero/protocol/tsx_sign.py b/src/apps/monero/protocol/tsx_sign.py index 08422013e..f3459bdf3 100644 --- a/src/apps/monero/protocol/tsx_sign.py +++ b/src/apps/monero/protocol/tsx_sign.py @@ -132,10 +132,7 @@ async def tsx_init(self, tsx_data): """ self.tsx_ctr += 1 try: - tsxd = await misc.translate_tsx_data(tsx_data) - del tsx_data - - return await self.tsx_obj.init_transaction(tsxd, self.tsx_ctr) + return await self.tsx_obj.init_transaction(tsx_data, self.tsx_ctr) except Exception as e: await self.tsx_exc_handler(e) raise @@ -153,10 +150,7 @@ async def tsx_set_input(self, msg): :return: """ try: - src_entr = await misc.parse_src_entry(msg.src_entr) - del msg.src_entr - - return await self.tsx_obj.set_input(src_entr) + return await self.tsx_obj.set_input(msg.src_entr) except Exception as e: await self.tsx_exc_handler(e) raise @@ -181,13 +175,11 @@ async def tsx_input_vini(self, msg): :return: """ try: - src_entr = await misc.parse_src_entry(msg.src_entr) vini = await misc.parse_vini(msg.vini) - del msg.src_entr del msg.vini return await self.tsx_obj.input_vini( - src_entr, vini, msg.vini_hmac, msg.pseudo_out, msg.pseudo_out_hmac + msg.src_entr, vini, msg.vini_hmac, msg.pseudo_out, msg.pseudo_out_hmac ) except Exception as e: await self.tsx_exc_handler(e) @@ -202,10 +194,7 @@ async def tsx_set_output1(self, msg): :return: """ try: - dst_entr = await misc.parse_dst_entry(msg.dst_entr) - del msg.dst_entr - - return await self.tsx_obj.set_out1(dst_entr, msg.dst_entr_hmac) + return await self.tsx_obj.set_out1(msg.dst_entr, msg.dst_entr_hmac) except Exception as e: await self.tsx_exc_handler(e) raise @@ -252,13 +241,11 @@ async def tsx_sign_input(self, msg): :return: """ try: - src_entr = await misc.parse_src_entry(msg.src_entr) vini = await misc.parse_vini(msg.vini) - del msg.src_entr del msg.vini return await self.tsx_obj.sign_input( - src_entr, + msg.src_entr, vini, msg.vini_hmac, msg.pseudo_out, diff --git a/src/apps/monero/protocol/tsx_sign_builder.py b/src/apps/monero/protocol/tsx_sign_builder.py index 028583094..c6fcb7beb 100644 --- a/src/apps/monero/protocol/tsx_sign_builder.py +++ b/src/apps/monero/protocol/tsx_sign_builder.py @@ -358,14 +358,14 @@ async def gen_hmac_vini(self, src_entr, vini, idx): :param idx: :return: """ + import protobuf from apps.monero.xmr.sub.keccak_hasher import get_keccak_writer from apps.monero.xmr.serialize import xmrserialize - from apps.monero.xmr.serialize_messages.tx_src_entry import TxSourceEntry from apps.monero.xmr.serialize_messages.tx_prefix import TxinToKey kwriter = get_keccak_writer() ar = xmrserialize.Archive(kwriter, True) - await ar.message(src_entr, TxSourceEntry) + await protobuf.dump_message(kwriter, src_entr) await ar.message(vini, TxinToKey) hmac_key_vini = self.hmac_key_txin(idx) @@ -380,14 +380,14 @@ async def gen_hmac_vouti(self, dst_entr, tx_out, idx): :param idx: :return: """ + import protobuf from apps.monero.xmr.sub.keccak_hasher import get_keccak_writer from apps.monero.xmr.serialize import xmrserialize - from apps.monero.xmr.serialize_messages.tx_dest_entry import TxDestinationEntry from apps.monero.xmr.serialize_messages.tx_prefix import TxOut kwriter = get_keccak_writer() + await protobuf.dump_message(kwriter, dst_entr) ar = xmrserialize.Archive(kwriter, True) - await ar.message(dst_entr, TxDestinationEntry) await ar.message(tx_out, TxOut) hmac_key_vouti = self.hmac_key_txout(idx) @@ -401,13 +401,11 @@ async def gen_hmac_tsxdest(self, dst_entr, idx): :param idx: :return: """ + import protobuf from apps.monero.xmr.sub.keccak_hasher import get_keccak_writer - from apps.monero.xmr.serialize import xmrserialize - from apps.monero.xmr.serialize_messages.tx_dest_entry import TxDestinationEntry kwriter = get_keccak_writer() - ar = xmrserialize.Archive(kwriter, True) - await ar.message(dst_entr, TxDestinationEntry) + await protobuf.dump_message(kwriter, dst_entr) hmac_key = self.hmac_key_txdst(idx) hmac_tsxdest = crypto.compute_hmac(hmac_key, kwriter.get_digest()) @@ -479,7 +477,7 @@ async def init_transaction(self, tsx_data, tsx_ctr): # if this is a single-destination transfer to a subaddress, we set the tx pubkey to R=s*D if num_stdaddresses == 0 and num_subaddresses == 1: self.r_pub = crypto.ge_scalarmult( - self.r, crypto.decodepoint(single_dest_subaddress.m_spend_public_key) + self.r, crypto.decodepoint(single_dest_subaddress.spend_public_key) ) self.need_additional_txkeys = num_subaddresses > 0 and ( @@ -568,14 +566,15 @@ async def compute_sec_keys(self, tsx_data, tsx_ctr): Generate master key H(TsxData || r || c_tsx) :return: """ + import protobuf from apps.monero.xmr.sub.keccak_hasher import get_keccak_writer from apps.monero.xmr.serialize import xmrserialize writer = get_keccak_writer() - ar1 = xmrserialize.Archive(writer, True) - await ar1.message(tsx_data) + await protobuf.dump_message(writer, tsx_data) await writer.awrite(crypto.encodeint(self.r)) await xmrserialize.dump_uvarint(writer, tsx_ctr) + self.key_master = crypto.keccak_2hash( writer.get_digest() + crypto.encodeint(crypto.random_scalar()) ) @@ -603,7 +602,6 @@ async def set_input(self, src_entr): with key derived for exactly this purpose. :param src_entr: - :type src_entr: apps.monero.xmr.serialize_messages.tx_construct.TxSourceEntry :return: """ from trezor.messages.MoneroTransactionSetInputAck import ( @@ -630,7 +628,7 @@ async def set_input(self, src_entr): self.summary_inputs_money += src_entr.amount # Secrets derivation - out_key = crypto.decodepoint(src_entr.outputs[src_entr.real_output][1].dest) + out_key = crypto.decodepoint(src_entr.outputs[src_entr.real_output].key.dest) tx_key = crypto.decodepoint(src_entr.real_out_tx_key) additional_keys = [ crypto.decodepoint(x) for x in src_entr.real_out_additional_tx_keys @@ -649,7 +647,7 @@ async def set_input(self, src_entr): # Construct tx.vin ki_real = src_entr.multisig_kLRki.ki if self.multi_sig else ki vini = TxinToKey(amount=src_entr.amount, k_image=crypto.encodepoint(ki_real)) - vini.key_offsets = [x[0] for x in src_entr.outputs] + vini.key_offsets = [x.idx for x in src_entr.outputs] vini.key_offsets = tsx_helper.absolute_output_offsets_to_relative( vini.key_offsets ) @@ -976,7 +974,7 @@ async def _set_out1_additional_keys(self, dst_entr): if dst_entr.is_subaddress: additional_txkey = crypto.ge_scalarmult( additional_txkey_priv, - crypto.decodepoint(dst_entr.addr.m_spend_public_key), + crypto.decodepoint(dst_entr.addr.spend_public_key), ) else: additional_txkey = crypto.ge_scalarmult_base(additional_txkey_priv) @@ -1004,7 +1002,7 @@ async def _set_out1_derivation(self, dst_entr, additional_txkey_priv): else self.r ) derivation = monero.generate_key_derivation( - crypto.decodepoint(dst_entr.addr.m_view_public_key), deriv_priv + crypto.decodepoint(dst_entr.addr.view_public_key), deriv_priv ) return derivation @@ -1014,7 +1012,6 @@ async def set_out1(self, dst_entr, dst_entr_hmac): Computes destination stealth address, amount key, range proof + HMAC, out_pk, ecdh_info. :param dst_entr - :type dst_entr: TxDestinationEntry :param dst_entr_hmac :return: """ @@ -1057,9 +1054,7 @@ async def set_out1(self, dst_entr, dst_entr_hmac): amount_key = crypto.derivation_to_scalar(derivation, self.out_idx) tx_out_key = crypto.derive_public_key( - derivation, - self.out_idx, - crypto.decodepoint(dst_entr.addr.m_spend_public_key), + derivation, self.out_idx, crypto.decodepoint(dst_entr.addr.spend_public_key) ) from apps.monero.xmr.serialize_messages.tx_prefix import TxoutToKey @@ -1271,7 +1266,6 @@ async def sign_input( Generates a signature for one input. :param src_entr: Source entry - :type src_entr: apps.monero.xmr.serialize_messages.tx_construct.TxSourceEntry :param vini: tx.vin[i] for the transaction. Contains key image, offsets, amount (usually zero) :param hmac_vini: HMAC for the tx.vin[i] as returned from Trezor :param pseudo_out: pedersen commitment for the current input, uses alpha as the mask. @@ -1355,14 +1349,14 @@ async def sign_input( # Private key correctness test self.assrt( crypto.point_eq( - crypto.decodepoint(src_entr.outputs[src_entr.real_output][1].dest), + crypto.decodepoint(src_entr.outputs[src_entr.real_output].key.dest), crypto.scalarmult_base(in_sk.dest), ), "a1", ) self.assrt( crypto.point_eq( - crypto.decodepoint(src_entr.outputs[src_entr.real_output][1].mask), + crypto.decodepoint(src_entr.outputs[src_entr.real_output].key.mask), crypto.gen_c(in_sk.mask, src_entr.amount), ), "a2", @@ -1378,7 +1372,7 @@ async def sign_input( mg = None if self.use_simple_rct: # Simple RingCT - mix_ring = [x[1] for x in src_entr.outputs] + mix_ring = [x.key for x in src_entr.outputs] mg, msc = mlsag2.prove_rct_mg_simple( self.full_message, mix_ring, @@ -1393,7 +1387,7 @@ async def sign_input( else: # Full RingCt, only one input txn_fee_key = crypto.scalarmult_h(self.get_fee()) - mix_ring = [[x[1]] for x in src_entr.outputs] + mix_ring = [[x.key] for x in src_entr.outputs] mg, msc = mlsag2.prove_rct_mg( self.full_message, diff --git a/src/apps/monero/xmr/serialize_messages/tx_construct.py b/src/apps/monero/xmr/serialize_messages/tx_construct.py deleted file mode 100644 index 26c5d4ede..000000000 --- a/src/apps/monero/xmr/serialize_messages/tx_construct.py +++ /dev/null @@ -1,96 +0,0 @@ -from apps.monero.xmr.serialize.base_types import ( - BoolType, - SizeT, - UInt8, - UInt32, - UInt64, - UVarintType, -) -from apps.monero.xmr.serialize.message_types import ContainerType, MessageType -from apps.monero.xmr.serialize_messages.addr import SubaddressIndex -from apps.monero.xmr.serialize_messages.base import ECKey, ECPublicKey, Hash, KeyImage -from apps.monero.xmr.serialize_messages.tx_dest_entry import TxDestinationEntry -from apps.monero.xmr.serialize_messages.tx_full import RctSig -from apps.monero.xmr.serialize_messages.tx_prefix import TransactionPrefix -from apps.monero.xmr.serialize_messages.tx_src_entry import TxSourceEntry - - -class MultisigOut(MessageType): - @classmethod - def f_specs(cls): - return (("c", ContainerType, ECKey),) - - -class MultisigLR(MessageType): - __slots__ = ("L", "R") - - @classmethod - def f_specs(cls): - return (("L", ECKey), ("R", ECKey)) - - -class MultisigInfo(MessageType): - __slots__ = ("signer", "LR", "partial_key_images") - - @classmethod - def f_specs(cls): - return ( - ("signer", ECPublicKey), - ("LR", ContainerType, MultisigLR), - ("partial_key_images", ContainerType, KeyImage), - ) - - -class MultisigStruct(MessageType): - __slots__ = ("sigs", "ignore", "used_L", "signing_keys", "msout") - - @classmethod - def f_specs(cls): - return ( - ("sigs", RctSig), - ("ignore", ECPublicKey), - ("used_L", ContainerType, ECKey), - ("signing_keys", ContainerType, ECPublicKey), - ("msout", MultisigOut), - ) - - -class TransferDetails(MessageType): - @classmethod - def f_specs(cls): - return ( - ("m_block_height", UInt64), - ("m_tx", TransactionPrefix), - ("m_txid", Hash), - ("m_internal_output_index", SizeT), - ("m_global_output_index", UInt64), - ("m_spent", BoolType), - ("m_spent_height", UInt64), - ("m_key_image", KeyImage), - ("m_mask", ECKey), - ("m_amount", UInt64), - ("m_rct", BoolType), - ("m_key_image_known", BoolType), - ("m_pk_index", SizeT), - ("m_subaddr_index", SubaddressIndex), - ("m_key_image_partial", BoolType), - ("m_multisig_k", ContainerType, ECKey), - ("m_multisig_info", ContainerType, MultisigInfo), - ) - - -class TxConstructionData(MessageType): - @classmethod - def f_specs(cls): - return ( - ("sources", ContainerType, TxSourceEntry), - ("change_dts", TxDestinationEntry), - ("splitted_dsts", ContainerType, TxDestinationEntry), - ("selected_transfers", ContainerType, SizeT), - ("extra", ContainerType, UInt8), - ("unlock_time", UInt64), - ("use_rct", BoolType), - ("dests", ContainerType, TxDestinationEntry), - ("subaddr_account", UInt32), - ("subaddr_indices", ContainerType, UVarintType), # original: x.UInt32 - ) diff --git a/src/apps/monero/xmr/sub/addr.py b/src/apps/monero/xmr/sub/addr.py index f00d5303f..aed85d946 100644 --- a/src/apps/monero/xmr/sub/addr.py +++ b/src/apps/monero/xmr/sub/addr.py @@ -9,7 +9,7 @@ def addr_to_hash(addr): :param addr: :return: """ - return bytes(addr.m_spend_public_key + addr.m_view_public_key) + return bytes(addr.spend_public_key + addr.view_public_key) def encode_addr(version, spend_pub, view_pub): @@ -41,13 +41,12 @@ def public_addr_encode(pub_addr, is_sub=False, net=NetworkTypes.MAINNET): """ Encodes public address to Monero address :param pub_addr: - :type pub_addr: apps.monero.xmr.serialize_messages.addr.AccountPublicAddress :param is_sub: :param net: :return: """ net_ver = net_version(net, is_sub) - return encode_addr(net_ver, pub_addr.m_spend_public_key, pub_addr.m_view_public_key) + return encode_addr(net_ver, pub_addr.spend_public_key, pub_addr.view_public_key) def classify_subaddresses(tx_dests, change_addr): @@ -85,8 +84,8 @@ def addr_eq(a, b): :param b: :return: """ - return pub_eq(a.m_spend_public_key, b.m_spend_public_key) and pub_eq( - a.m_view_public_key, b.m_view_public_key + return pub_eq(a.spend_public_key, b.spend_public_key) and pub_eq( + a.view_public_key, b.view_public_key ) diff --git a/src/apps/monero/xmr/sub/tsx_helper.py b/src/apps/monero/xmr/sub/tsx_helper.py index cafebe663..526aa2baf 100644 --- a/src/apps/monero/xmr/sub/tsx_helper.py +++ b/src/apps/monero/xmr/sub/tsx_helper.py @@ -1,10 +1,11 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # Author: Dusan Klinec, ph4r05, 2018 +from trezor.messages.MoneroAccountPublicAddress import MoneroAccountPublicAddress + from apps.monero.xmr import crypto from apps.monero.xmr.serialize import xmrserialize from apps.monero.xmr.serialize.readwriter import MemoryReaderWriter -from apps.monero.xmr.serialize_messages.addr import AccountPublicAddress from apps.monero.xmr.serialize_messages.tx_extra import ( TxExtraAdditionalPubKeys, TxExtraField, @@ -120,8 +121,8 @@ def get_destination_view_key_pub(destinations, change_addr=None): """ from apps.monero.xmr.sub.addr import addr_eq - addr = AccountPublicAddress( - m_spend_public_key=crypto.NULL_KEY_ENC, m_view_public_key=crypto.NULL_KEY_ENC + addr = MoneroAccountPublicAddress( + spend_public_key=crypto.NULL_KEY_ENC, view_public_key=crypto.NULL_KEY_ENC ) count = 0 for dest in destinations: @@ -135,7 +136,7 @@ def get_destination_view_key_pub(destinations, change_addr=None): return crypto.NULL_KEY_ENC addr = dest.addr count += 1 - return addr.m_view_public_key + return addr.view_public_key def encrypt_payment_id(payment_id, public_key, secret_key): diff --git a/src/apps/monero/xmr/tsx_data.py b/src/apps/monero/xmr/tsx_data.py deleted file mode 100644 index 38733d688..000000000 --- a/src/apps/monero/xmr/tsx_data.py +++ /dev/null @@ -1,61 +0,0 @@ -from apps.monero.xmr.serialize.base_types import BoolType, UVarintType -from apps.monero.xmr.serialize.message_types import BlobType, ContainerType, MessageType -from apps.monero.xmr.serialize_messages.base import SecretKey -from apps.monero.xmr.serialize_messages.tx_dest_entry import TxDestinationEntry - - -class TsxData(MessageType): - """ - TsxData, initial input to the transaction processing. - Serialization structure for easy hashing. - """ - - __slots__ = ( - "version", - "payment_id", - "unlock_time", - "outputs", - "change_dts", - "num_inputs", - "mixin", - "fee", - "account", - "minor_indices", - "is_multisig", - "exp_tx_prefix_hash", - "use_tx_keys", - "is_bulletproof", - ) - - @classmethod - def f_specs(cls): - return ( - ("version", UVarintType), - ("payment_id", BlobType), - ("unlock_time", UVarintType), - ("outputs", ContainerType, TxDestinationEntry), - ("change_dts", TxDestinationEntry), - ("num_inputs", UVarintType), - ("mixin", UVarintType), - ("fee", UVarintType), - ("account", UVarintType), - ("minor_indices", ContainerType, UVarintType), - ("is_multisig", BoolType), - ("exp_tx_prefix_hash", BlobType), # expected prefix hash, bail on error - ("use_tx_keys", ContainerType, SecretKey), # use this secret key, multisig - ("is_bulletproof", BoolType), - ) - - def __init__(self, payment_id=None, outputs=None, change_dts=None, **kwargs): - super().__init__(**kwargs) - - self.payment_id = payment_id - self.change_dts = change_dts - self.fee = 0 - self.account = 0 - self.minor_indices = [0] - self.outputs = outputs if outputs else [] # type: list[TxDestinationEntry] - self.is_multisig = False - self.is_bulletproof = False - self.exp_tx_prefix_hash = b"" - self.use_tx_keys = [] diff --git a/src/trezor/messages/MoneroMultisigKLRki.py b/src/trezor/messages/MoneroMultisigKLRki.py new file mode 100644 index 000000000..8276f2316 --- /dev/null +++ b/src/trezor/messages/MoneroMultisigKLRki.py @@ -0,0 +1,24 @@ +# Automatically generated by pb2py +# fmt: off +import protobuf as p + + +class MoneroMultisigKLRki(p.MessageType): + FIELDS = { + 1: ('K', p.BytesType, 0), + 2: ('L', p.BytesType, 0), + 3: ('R', p.BytesType, 0), + 4: ('ki', p.BytesType, 0), + } + + def __init__( + self, + K: bytes = None, + L: bytes = None, + R: bytes = None, + ki: bytes = None, + ) -> None: + self.K = K + self.L = L + self.R = R + self.ki = ki diff --git a/src/trezor/messages/MoneroOutputEntry.py b/src/trezor/messages/MoneroOutputEntry.py new file mode 100644 index 000000000..03f628e98 --- /dev/null +++ b/src/trezor/messages/MoneroOutputEntry.py @@ -0,0 +1,20 @@ +# Automatically generated by pb2py +# fmt: off +import protobuf as p + +from .MoneroRctKey import MoneroRctKey + + +class MoneroOutputEntry(p.MessageType): + FIELDS = { + 1: ('idx', p.UVarintType, 0), + 2: ('key', MoneroRctKey, 0), + } + + def __init__( + self, + idx: int = None, + key: MoneroRctKey = None, + ) -> None: + self.idx = idx + self.key = key diff --git a/src/trezor/messages/MoneroRctKey.py b/src/trezor/messages/MoneroRctKey.py new file mode 100644 index 000000000..6784be77f --- /dev/null +++ b/src/trezor/messages/MoneroRctKey.py @@ -0,0 +1,18 @@ +# Automatically generated by pb2py +# fmt: off +import protobuf as p + + +class MoneroRctKey(p.MessageType): + FIELDS = { + 1: ('dest', p.BytesType, 0), + 2: ('mask', p.BytesType, 0), + } + + def __init__( + self, + dest: bytes = None, + mask: bytes = None, + ) -> None: + self.dest = dest + self.mask = mask diff --git a/src/trezor/messages/MoneroTransactionInputViniRequest.py b/src/trezor/messages/MoneroTransactionInputViniRequest.py index 148d68526..0ed950e82 100644 --- a/src/trezor/messages/MoneroTransactionInputViniRequest.py +++ b/src/trezor/messages/MoneroTransactionInputViniRequest.py @@ -2,10 +2,12 @@ # fmt: off import protobuf as p +from .MoneroTransactionSourceEntry import MoneroTransactionSourceEntry + class MoneroTransactionInputViniRequest(p.MessageType): FIELDS = { - 1: ('src_entr', p.BytesType, 0), + 1: ('src_entr', MoneroTransactionSourceEntry, 0), 2: ('vini', p.BytesType, 0), 3: ('vini_hmac', p.BytesType, 0), 4: ('pseudo_out', p.BytesType, 0), @@ -14,7 +16,7 @@ class MoneroTransactionInputViniRequest(p.MessageType): def __init__( self, - src_entr: bytes = None, + src_entr: MoneroTransactionSourceEntry = None, vini: bytes = None, vini_hmac: bytes = None, pseudo_out: bytes = None, diff --git a/src/trezor/messages/MoneroTransactionSetInputRequest.py b/src/trezor/messages/MoneroTransactionSetInputRequest.py index 715358a5f..e424b1e7a 100644 --- a/src/trezor/messages/MoneroTransactionSetInputRequest.py +++ b/src/trezor/messages/MoneroTransactionSetInputRequest.py @@ -2,17 +2,19 @@ # fmt: off import protobuf as p +from .MoneroTransactionSourceEntry import MoneroTransactionSourceEntry + class MoneroTransactionSetInputRequest(p.MessageType): FIELDS = { 1: ('version', p.UVarintType, 0), - 2: ('src_entr', p.BytesType, 0), + 2: ('src_entr', MoneroTransactionSourceEntry, 0), } def __init__( self, version: int = None, - src_entr: bytes = None, + src_entr: MoneroTransactionSourceEntry = None, ) -> None: self.version = version self.src_entr = src_entr diff --git a/src/trezor/messages/MoneroTransactionSetOutputRequest.py b/src/trezor/messages/MoneroTransactionSetOutputRequest.py index 3592fb83f..73b59fb26 100644 --- a/src/trezor/messages/MoneroTransactionSetOutputRequest.py +++ b/src/trezor/messages/MoneroTransactionSetOutputRequest.py @@ -2,16 +2,18 @@ # fmt: off import protobuf as p +from .MoneroTransactionDestinationEntry import MoneroTransactionDestinationEntry + class MoneroTransactionSetOutputRequest(p.MessageType): FIELDS = { - 1: ('dst_entr', p.BytesType, 0), + 1: ('dst_entr', MoneroTransactionDestinationEntry, 0), 2: ('dst_entr_hmac', p.BytesType, 0), } def __init__( self, - dst_entr: bytes = None, + dst_entr: MoneroTransactionDestinationEntry = None, dst_entr_hmac: bytes = None, ) -> None: self.dst_entr = dst_entr diff --git a/src/trezor/messages/MoneroTransactionSignInputRequest.py b/src/trezor/messages/MoneroTransactionSignInputRequest.py index 6eda2db7d..9866d5b0f 100644 --- a/src/trezor/messages/MoneroTransactionSignInputRequest.py +++ b/src/trezor/messages/MoneroTransactionSignInputRequest.py @@ -2,10 +2,12 @@ # fmt: off import protobuf as p +from .MoneroTransactionSourceEntry import MoneroTransactionSourceEntry + class MoneroTransactionSignInputRequest(p.MessageType): FIELDS = { - 1: ('src_entr', p.BytesType, 0), + 1: ('src_entr', MoneroTransactionSourceEntry, 0), 2: ('vini', p.BytesType, 0), 3: ('vini_hmac', p.BytesType, 0), 4: ('pseudo_out', p.BytesType, 0), @@ -16,7 +18,7 @@ class MoneroTransactionSignInputRequest(p.MessageType): def __init__( self, - src_entr: bytes = None, + src_entr: MoneroTransactionSourceEntry = None, vini: bytes = None, vini_hmac: bytes = None, pseudo_out: bytes = None, diff --git a/src/trezor/messages/MoneroTransactionSourceEntry.py b/src/trezor/messages/MoneroTransactionSourceEntry.py new file mode 100644 index 000000000..515d02c8c --- /dev/null +++ b/src/trezor/messages/MoneroTransactionSourceEntry.py @@ -0,0 +1,48 @@ +# Automatically generated by pb2py +# fmt: off +import protobuf as p + +from .MoneroMultisigKLRki import MoneroMultisigKLRki +from .MoneroOutputEntry import MoneroOutputEntry + +if __debug__: + try: + from typing import List + except ImportError: + List = None # type: ignore + + +class MoneroTransactionSourceEntry(p.MessageType): + FIELDS = { + 1: ('outputs', MoneroOutputEntry, p.FLAG_REPEATED), + 2: ('real_output', p.UVarintType, 0), + 3: ('real_out_tx_key', p.BytesType, 0), + 4: ('real_out_additional_tx_keys', p.BytesType, p.FLAG_REPEATED), + 5: ('real_output_in_tx_index', p.UVarintType, 0), + 6: ('amount', p.UVarintType, 0), + 7: ('rct', p.BoolType, 0), + 8: ('mask', p.BytesType, 0), + 9: ('multisig_kLRki', MoneroMultisigKLRki, 0), + } + + def __init__( + self, + outputs: List[MoneroOutputEntry] = None, + real_output: int = None, + real_out_tx_key: bytes = None, + real_out_additional_tx_keys: List[bytes] = None, + real_output_in_tx_index: int = None, + amount: int = None, + rct: bool = None, + mask: bytes = None, + multisig_kLRki: MoneroMultisigKLRki = None, + ) -> None: + self.outputs = outputs if outputs is not None else [] + self.real_output = real_output + self.real_out_tx_key = real_out_tx_key + self.real_out_additional_tx_keys = real_out_additional_tx_keys if real_out_additional_tx_keys is not None else [] + self.real_output_in_tx_index = real_output_in_tx_index + self.amount = amount + self.rct = rct + self.mask = mask + self.multisig_kLRki = multisig_kLRki