From 9e3be78f82570d9b379a64be734c03163afa5a0f Mon Sep 17 00:00:00 2001 From: Dusan Klinec Date: Wed, 3 Oct 2018 17:14:28 +0200 Subject: [PATCH] xmr: sign cleanup, comments - state cleanup, comments added, unused code removed --- src/apps/monero/protocol/signing/state.py | 9 ++------- .../monero/protocol/signing/step_01_init_transaction.py | 4 ++-- .../protocol/signing/step_03_inputs_permutation.py | 2 +- src/apps/monero/protocol/signing/step_05_all_in_set.py | 3 ++- src/apps/monero/protocol/signing/step_07_all_out1_set.py | 3 +-- src/apps/monero/protocol/signing/step_08_mlsag_done.py | 8 -------- 6 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/apps/monero/protocol/signing/state.py b/src/apps/monero/protocol/signing/state.py index d5b816900..325a73207 100644 --- a/src/apps/monero/protocol/signing/state.py +++ b/src/apps/monero/protocol/signing/state.py @@ -54,17 +54,15 @@ def __init__(self, ctx): self.tx_priv = None self.tx_pub = None - self.multi_sig = False self.need_additional_txkeys = False self.use_bulletproof = False - self.use_rct = True self.use_simple_rct = False self.input_count = 0 self.output_count = 0 self.output_change = None self.mixin = 0 self.fee = 0 - self.account_idx = 0 + self.account_idx = 0 # wallet sub-address major index self.additional_tx_private_keys = [] self.additional_tx_public_keys = [] @@ -73,8 +71,6 @@ def __init__(self, ctx): self.summary_inputs_money = 0 self.summary_outs_money = 0 self.input_secrets = [] - self.input_alphas = [] - self.input_pseudo_outs = [] self.output_sk_masks = [] self.output_pk_masks = [] # commitments self.output_amounts = [] @@ -90,8 +86,7 @@ def __init__(self, ctx): self.tx_prefix_hasher = None self.tx_prefix_hash = None self.full_message_hasher = None - self.full_message = None - self.exp_tx_prefix_hash = None + self.full_message = None # pre-MLSAG hash self._init() def _init(self): diff --git a/src/apps/monero/protocol/signing/step_01_init_transaction.py b/src/apps/monero/protocol/signing/step_01_init_transaction.py index 95694afbc..c45c4b1f2 100644 --- a/src/apps/monero/protocol/signing/step_01_init_transaction.py +++ b/src/apps/monero/protocol/signing/step_01_init_transaction.py @@ -38,8 +38,8 @@ async def init_transaction( state.mixin = tsx_data.mixin state.fee = tsx_data.fee state.account_idx = tsx_data.account - state.multi_sig = tsx_data.is_multisig - state.exp_tx_prefix_hash = tsx_data.exp_tx_prefix_hash + if tsx_data.is_multisig: + raise NotImplementedError("Multisig is not implemented") # Ensure change is correct _check_change(state, tsx_data.outputs) diff --git a/src/apps/monero/protocol/signing/step_03_inputs_permutation.py b/src/apps/monero/protocol/signing/step_03_inputs_permutation.py index 90595b09d..cbd19c36b 100644 --- a/src/apps/monero/protocol/signing/step_03_inputs_permutation.py +++ b/src/apps/monero/protocol/signing/step_03_inputs_permutation.py @@ -27,7 +27,7 @@ async def tsx_inputs_permutation(state: State, permutation: list): Set permutation on the inputs - sorted by key image on host. """ if len(permutation) != state.input_count: - raise ValueError('Invalid permutation size') + raise ValueError("Invalid permutation size") _check_permutation(permutation) state.source_permutation = permutation diff --git a/src/apps/monero/protocol/signing/step_05_all_in_set.py b/src/apps/monero/protocol/signing/step_05_all_in_set.py index dfc264421..3fa0f960b 100644 --- a/src/apps/monero/protocol/signing/step_05_all_in_set.py +++ b/src/apps/monero/protocol/signing/step_05_all_in_set.py @@ -29,7 +29,8 @@ async def all_in_set(state: State, rsig_data): # todo: rsig_data not used? if not state.rsig_offload: return resp - # Simple offloading - generate random masks that sum to the input mask sum. + # Simple range proof offloading + # Generate random commitment masks that sum to the input mask sum. tmp_buff = bytearray(32) rsig_data.mask = bytearray(32 * state.output_count) state.sumout = crypto.sc_init(0) diff --git a/src/apps/monero/protocol/signing/step_07_all_out1_set.py b/src/apps/monero/protocol/signing/step_07_all_out1_set.py index d6547cbbf..8eb3b41e3 100644 --- a/src/apps/monero/protocol/signing/step_07_all_out1_set.py +++ b/src/apps/monero/protocol/signing/step_07_all_out1_set.py @@ -8,9 +8,8 @@ from .state import State -from apps.monero.controller import misc from apps.monero.layout import confirms -from apps.monero.xmr import common, crypto +from apps.monero.xmr import crypto async def all_out1_set(state: State): diff --git a/src/apps/monero/protocol/signing/step_08_mlsag_done.py b/src/apps/monero/protocol/signing/step_08_mlsag_done.py index 68f2ec5e9..8f2ceb823 100644 --- a/src/apps/monero/protocol/signing/step_08_mlsag_done.py +++ b/src/apps/monero/protocol/signing/step_08_mlsag_done.py @@ -15,7 +15,6 @@ async def mlsag_done(state: State): # state.state.set_final_message_done() todo needed? await confirms.transaction_step(state.ctx, state.STEP_MLSAG) - _ecdh_info(state) _out_pk(state) state.full_message_hasher.rctsig_base_done() state.current_output_index = -1 @@ -27,13 +26,6 @@ async def mlsag_done(state: State): return MoneroTransactionMlsagDoneAck(full_message_hash=state.full_message) -def _ecdh_info(state: State): # todo why is it here? remove - """ - Sets ecdh info for the incremental hashing mlsag. - """ - pass - - def _out_pk(state: State): """ Sets out_pk for the incremental hashing mlsag.