What changed, and why it matters
This Monero wallet code change refactors how transaction proofs are generated. Previously, incoming transaction proofs could be linked to outputs that were not actually destined for the recipient. The patch binds each proof to only the specific recipient output(s), and replaces shared secrets with random values when no matching output exists. This appears to fix a privacy weakness where a proof might incorrectly or over-broadly demonstrate receipt of funds.
Review the proof verification path to ensure the new per-output binding is enforced consistently on the verifier side, and consider whether additional test vectors are needed for multi-output transactions and subaddress proofs.
Security signals we found
Binding transaction proofs to specific recipient outputs
Randomizing shared secret when no recipient output is found
Per-output verification helper introduced
Potential privacy fix for over-broad transaction proof generation
Evidence from the diff
The commit splits check_tx_key_helper into a per-output helper check_tx_key_helper_at, then uses it in get_tx_proof to verify each candidate shared secret against only the relevant output index. For the main tx pub key, it now checks all outputs; for additional tx pub keys, it checks only the corresponding output index (i-1 to i). If no output matches, the shared secret is replaced with rct::pkGen() (a random point), preventing proofs from being generated for non-recipient outputs. This binds transaction proofs to actual recipient outputs rather than allowing a proof to be constructed based on a matching public key alone.
Changed components
src/wallet/wallet2.cppsrc/wallet/wallet2.hwallet2::get_tx_proofwallet2::check_tx_key_helperInspect captured patch +39 / −27
### src/wallet/wallet2.cpp
@@ -12552,27 +12552,24 @@ void wallet2::check_tx_key_helper(const cryptonote::transaction &tx, const crypt
received = 0;
for (size_t n = 0; n < tx.vout.size(); ++n)
- {
- crypto::public_key output_public_key;
- if (!get_output_public_key(tx.vout[n], output_public_key))
- continue;
+ received += check_tx_key_helper_at(tx, derivation, additional_derivations, address, n);
+}
- crypto::key_derivation found_derivation;
- if (is_out_to_acc(address, output_public_key, derivation, additional_derivations, n, get_output_view_tag(tx.vout[n]), found_derivation))
- {
- uint64_t amount;
- if (tx.version == 1 || tx.rct_signatures.type == rct::RCTTypeNull)
- {
- amount = tx.vout[n].amount;
- }
- else
- {
- rct::key mask;
- amount = decodeRct(tx.rct_signatures, found_derivation, n, mask, hw::get_device("default"));
- }
- received += amount;
- }
- }
+uint64_t wallet2::check_tx_key_helper_at(const cryptonote::transaction &tx, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const cryptonote::account_public_address &address, size_t n) const
+{
+ crypto::public_key output_public_key;
+ if (!get_output_public_key(tx.vout[n], output_public_key))
+ return 0;
+
+ crypto::key_derivation found_derivation;
+ if (!is_out_to_acc(address, output_public_key, derivation, additional_derivations, n, get_output_view_tag(tx.vout[n]), found_derivation))
+ return 0;
+
+ if (tx.version == 1 || tx.rct_signatures.type == rct::RCTTypeNull)
+ return tx.vout[n].amount;
+
+ rct::key mask;
+ return decodeRct(tx.rct_signatures, found_derivation, n, mask, hw::get_device("default"));
}
void wallet2::check_tx_key_helper(const crypto::hash &txid, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations)
@@ -12781,33 +12778,42 @@ std::string wallet2::get_tx_proof(const cryptonote::transaction &tx, const crypt
hwdev.scalarmultKey(aP, rct::pk2rct(tx_pub_key), rct::sk2rct(a));
shared_secret[0] = rct2pk(aP);
- const auto has_received = [&](const crypto::public_key &candidate_shared_secret) {
+ const auto has_received = [&](const crypto::public_key &candidate_shared_secret, size_t begin, size_t end) {
crypto::key_derivation derivation;
THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(candidate_shared_secret, rct::rct2sk(rct::I), derivation),
error::wallet_internal_error, "Failed to generate key derivation");
- uint64_t received{0};
- check_tx_key_helper(tx, derivation, {}, address, received);
- return received > 0;
+ for (size_t n = begin; n < end; ++n)
+ {
+ if (check_tx_key_helper_at(tx, derivation, {}, address, n) > 0)
+ return true;
+ }
+ return false;
};
size_t pk_index = 1;
- if (find_tx_extra_field_by_type(tx_extra_fields, pub_key_field, pk_index) && !has_received(shared_secret[0]))
+ bool main_received = has_received(shared_secret[0], 0, tx.vout.size());
+ if (!main_received && find_tx_extra_field_by_type(tx_extra_fields, pub_key_field, pk_index))
{
do
{
const crypto::public_key candidate = crypto::pubkey_clear_torsion(pub_key_field.pub_key);
hwdev.scalarmultKey(aP, rct::pk2rct(candidate), rct::sk2rct(a));
const crypto::public_key candidate_shared_secret = rct::rct2pk(aP);
- if (has_received(candidate_shared_secret))
+ if (has_received(candidate_shared_secret, 0, tx.vout.size()))
{
tx_pub_key = candidate;
shared_secret[0] = candidate_shared_secret;
+ main_received = true;
break;
}
} while (find_tx_extra_field_by_type(tx_extra_fields, pub_key_field, ++pk_index));
}
- if (is_subaddress)
+ if (!main_received)
+ {
+ shared_secret[0] = rct::rct2pk(rct::pkGen());
+ }
+ else if (is_subaddress)
{
hwdev.generate_tx_proof(prefix_hash, address.m_view_public_key, tx_pub_key, address.m_spend_public_key, shared_secret[0], a, sig[0]);
}
@@ -12819,6 +12825,11 @@ std::string wallet2::get_tx_proof(const cryptonote::transaction &tx, const crypt
{
hwdev.scalarmultKey(aP,rct::pk2rct(additional_tx_pub_keys[i - 1]), rct::sk2rct(a));
shared_secret[i] = rct2pk(aP);
+ if (i > tx.vout.size() || !has_received(shared_secret[i], i - 1, i))
+ {
+ shared_secret[i] = rct::rct2pk(rct::pkGen());
+ continue;
+ }
if (is_subaddress)
{
hwdev.generate_tx_proof(prefix_hash, address.m_view_public_key, additional_tx_pub_keys[i - 1], address.m_spend_public_key, shared_secret[i], a, sig[i]);
### src/wallet/wallet2.h
@@ -1254,6 +1254,7 @@ namespace tools
void check_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations);
void check_tx_key_helper(const crypto::hash &txid, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations);
void check_tx_key_helper(const cryptonote::transaction &tx, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const cryptonote::account_public_address &address, uint64_t &received) const;
+ uint64_t check_tx_key_helper_at(const cryptonote::transaction &tx, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const cryptonote::account_public_address &address, size_t n) const;
bool is_out_to_acc(const cryptonote::account_public_address &address, const crypto::public_key& out_key, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const size_t output_index, const boost::optional<crypto::view_tag> &view_tag_opt, crypto::key_derivation &found_derivation) const;
std::string get_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message);
std::string get_tx_proof(const cryptonote::transaction &tx, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message) const;Why this scored 59/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.