mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-16 03:18:09 +00:00
xmr: step_09_sign - unimport after heavy ops
This commit is contained in:
parent
ddcb836ff7
commit
cdf9d51ee2
@ -41,8 +41,6 @@ async def sign_input(
|
|||||||
:param spend_enc: one time address spending private key. Encrypted.
|
:param spend_enc: one time address spending private key. Encrypted.
|
||||||
:return: Generated signature MGs[i]
|
:return: Generated signature MGs[i]
|
||||||
"""
|
"""
|
||||||
from apps.monero.signing import offloading_keys
|
|
||||||
|
|
||||||
await confirms.transaction_step(
|
await confirms.transaction_step(
|
||||||
state.ctx, state.STEP_SIGN, state.current_input_index + 1, state.input_count
|
state.ctx, state.STEP_SIGN, state.current_input_index + 1, state.input_count
|
||||||
)
|
)
|
||||||
@ -58,8 +56,11 @@ async def sign_input(
|
|||||||
raise ValueError("Two and more inputs must imply SimpleRCT")
|
raise ValueError("Two and more inputs must imply SimpleRCT")
|
||||||
|
|
||||||
input_position = state.source_permutation[state.current_input_index]
|
input_position = state.source_permutation[state.current_input_index]
|
||||||
|
mods = utils.unimport_begin()
|
||||||
|
|
||||||
# Check input's HMAC
|
# Check input's HMAC
|
||||||
|
from apps.monero.signing import offloading_keys
|
||||||
|
|
||||||
vini_hmac_comp = await offloading_keys.gen_hmac_vini(
|
vini_hmac_comp = await offloading_keys.gen_hmac_vini(
|
||||||
state.key_hmac, src_entr, vini_bin, input_position
|
state.key_hmac, src_entr, vini_bin, input_position
|
||||||
)
|
)
|
||||||
@ -69,6 +70,8 @@ async def sign_input(
|
|||||||
gc.collect()
|
gc.collect()
|
||||||
state.mem_trace(1, True)
|
state.mem_trace(1, True)
|
||||||
|
|
||||||
|
from apps.monero.xmr.crypto import chacha_poly
|
||||||
|
|
||||||
if state.rct_type == RctType.Simple:
|
if state.rct_type == RctType.Simple:
|
||||||
# both pseudo_out and its mask were offloaded so we need to
|
# both pseudo_out and its mask were offloaded so we need to
|
||||||
# validate pseudo_out's HMAC and decrypt the alpha
|
# validate pseudo_out's HMAC and decrypt the alpha
|
||||||
@ -81,8 +84,6 @@ async def sign_input(
|
|||||||
|
|
||||||
state.mem_trace(2, True)
|
state.mem_trace(2, True)
|
||||||
|
|
||||||
from apps.monero.xmr.crypto import chacha_poly
|
|
||||||
|
|
||||||
pseudo_out_alpha = crypto.decodeint(
|
pseudo_out_alpha = crypto.decodeint(
|
||||||
chacha_poly.decrypt_pack(
|
chacha_poly.decrypt_pack(
|
||||||
offloading_keys.enc_key_txin_alpha(state.key_enc, input_position),
|
offloading_keys.enc_key_txin_alpha(state.key_enc, input_position),
|
||||||
@ -92,9 +93,6 @@ async def sign_input(
|
|||||||
pseudo_out_c = crypto.decodepoint(pseudo_out)
|
pseudo_out_c = crypto.decodepoint(pseudo_out)
|
||||||
|
|
||||||
# Spending secret
|
# Spending secret
|
||||||
from apps.monero.xmr.crypto import chacha_poly
|
|
||||||
from apps.monero.xmr.serialize_messages.ct_keys import CtKey
|
|
||||||
|
|
||||||
spend_key = crypto.decodeint(
|
spend_key = crypto.decodeint(
|
||||||
chacha_poly.decrypt_pack(
|
chacha_poly.decrypt_pack(
|
||||||
offloading_keys.enc_key_spend(state.key_enc, input_position),
|
offloading_keys.enc_key_spend(state.key_enc, input_position),
|
||||||
@ -102,8 +100,19 @@ async def sign_input(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
del (
|
||||||
|
offloading_keys,
|
||||||
|
chacha_poly,
|
||||||
|
pseudo_out,
|
||||||
|
pseudo_out_hmac,
|
||||||
|
pseudo_out_alpha_enc,
|
||||||
|
spend_enc,
|
||||||
|
)
|
||||||
|
utils.unimport_end(mods)
|
||||||
state.mem_trace(3, True)
|
state.mem_trace(3, True)
|
||||||
|
|
||||||
|
from apps.monero.xmr.serialize_messages.ct_keys import CtKey
|
||||||
|
|
||||||
# Basic setup, sanity check
|
# Basic setup, sanity check
|
||||||
index = src_entr.real_output
|
index = src_entr.real_output
|
||||||
input_secret_key = CtKey(dest=spend_key, mask=crypto.decodeint(src_entr.mask))
|
input_secret_key = CtKey(dest=spend_key, mask=crypto.decodeint(src_entr.mask))
|
||||||
|
Loading…
Reference in New Issue
Block a user