예제 #1
0
def _set_out_tx_out(
    state: State,
    dst_entr: MoneroTransactionDestinationEntry,
    tx_out_key: crypto.Point,
    derivation: crypto.Point,
) -> tuple[bytes, bytes]:
    """
    Manually serializes TxOut(0, TxoutToKey(key)) and calculates hmac.
    """
    use_tags = state.hard_fork >= 15
    tx_out_bin = bytearray(35 if use_tags else 34)
    tx_out_bin[0] = 0  # amount varint
    tx_out_bin[1] = (3 if use_tags else 2
                     )  # variant code txout_to_tagged_key or txout_to_key
    crypto.encodepoint_into(tx_out_bin, tx_out_key, 2)
    if use_tags:
        view_tag = _derive_view_tags(derivation, state.current_output_index)
        tx_out_bin[-1] = view_tag[0]

    state.mem_trace(8, True)

    # Tx header prefix hashing
    state.tx_prefix_hasher.buffer(tx_out_bin)
    state.mem_trace(9, True)

    # Hmac dst_entr
    hmac_vouti = offloading_keys.gen_hmac_vouti(state.key_hmac, dst_entr,
                                                tx_out_bin,
                                                state.current_output_index)
    state.mem_trace(10, True)
    return tx_out_bin, hmac_vouti
예제 #2
0
def _set_out_tx_out(state: State, dst_entr: MoneroTransactionDestinationEntry,
                    tx_out_key: Ge25519) -> Tuple[bytes, bytes]:
    """
    Manually serializes TxOut(0, TxoutToKey(key)) and calculates hmac.
    """
    tx_out_bin = bytearray(34)
    tx_out_bin[0] = 0  # amount varint
    tx_out_bin[1] = 2  # variant code TxoutToKey
    crypto.encodepoint_into(tx_out_bin, tx_out_key, 2)
    state.mem_trace(8)

    # Tx header prefix hashing
    state.tx_prefix_hasher.buffer(tx_out_bin)
    state.mem_trace(9, True)

    # Hmac dst_entr
    hmac_vouti = offloading_keys.gen_hmac_vouti(state.key_hmac, dst_entr,
                                                tx_out_bin,
                                                state.current_output_index)
    state.mem_trace(10, True)
    return tx_out_bin, hmac_vouti