Skip to content

Commit

Permalink
xmr: fix new transaction type for CLSAG, HF=13
Browse files Browse the repository at this point in the history
(cherry picked from 9d7b0bf)
  • Loading branch information
ph4r05 authored and tsusanka committed Sep 24, 2020
1 parent 5c24e2c commit 04d757a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/src/apps/monero/signing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ class RctType:
"""

Bulletproof2 = 4
CLSAG = 5
1 change: 1 addition & 0 deletions core/src/apps/monero/signing/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(self, ctx):

self.output_change = None
self.fee = 0
self.tx_type = 0

# wallet sub-address major index
self.account_idx = 0
Expand Down
6 changes: 5 additions & 1 deletion core/src/apps/monero/signing/step_01_init_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ async def init_transaction(
if tsx_data.hard_fork:
state.hard_fork = tsx_data.hard_fork

state.tx_type = (
signing.RctType.CLSAG if state.hard_fork >= 13 else signing.RctType.Bulletproof2
)

# Ensure change is correct
_check_change(state, tsx_data.outputs)

Expand All @@ -92,7 +96,7 @@ async def init_transaction(

# Final message hasher
state.full_message_hasher.init()
state.full_message_hasher.set_type_fee(signing.RctType.Bulletproof2, state.fee)
state.full_message_hasher.set_type_fee(state.tx_type, state.fee)

# Sub address precomputation
if tsx_data.account is not None and tsx_data.minor_indices:
Expand Down
3 changes: 1 addition & 2 deletions core/src/apps/monero/signing/step_07_all_outputs_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from trezor import utils

from apps.monero.layout import confirms
from apps.monero.signing import RctType
from apps.monero.xmr import crypto

from .state import State
Expand Down Expand Up @@ -56,7 +55,7 @@ async def all_outputs_set(state: State) -> MoneroTransactionAllOutSetAck:

# Initializes RCTsig structure (fee, tx prefix hash, type)
rv_pb = MoneroRingCtSig(
txn_fee=state.fee, message=state.tx_prefix_hash, rv_type=RctType.Bulletproof2,
txn_fee=state.fee, message=state.tx_prefix_hash, rv_type=state.tx_type,
)

_out_pk(state)
Expand Down
3 changes: 2 additions & 1 deletion core/src/apps/monero/signing/step_09_sign_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ async def sign_input(
state.mem_trace(4, True)

from apps.monero.xmr import mlsag
from apps.monero import signing

mg_buffer = []
ring_pubkeys = [x.key for x in src_entr.outputs if x]
Expand All @@ -182,7 +183,7 @@ async def sign_input(

state.mem_trace(5, True)

if state.hard_fork and state.hard_fork >= 13:
if state.tx_type == signing.RctType.CLSAG:
state.mem_trace("CLSAG")
mlsag.generate_clsag_simple(
state.full_message,
Expand Down

0 comments on commit 04d757a

Please sign in to comment.