Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xmr: fix new transaction type for CLSAG, HF=13 #1246

Merged
merged 1 commit into from
Sep 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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