added return_output_info collection to SVB scanning

This commit is contained in:
Some Random Crypto Guy
2025-11-10 11:55:59 +00:00
parent f9b060e552
commit d22389b37a
3 changed files with 40 additions and 33 deletions

View File

@@ -525,37 +525,44 @@ bool try_scan_carrot_enote_internal_receiver(const CarrotEnoteV1 &enote,
crypto::public_key K_r = rct::rct2pk(rct::addKeys(rct::pk2rct(K_return), rct::pk2rct(enote.onetime_address)));
// Is this a watch-only wallet?
// if (watch_only) {
if (watch_only) {
// HERE BE DRAGONS!!!
// SRCG: test whether this will even work for return_payment detection
account.insert_return_output_info({{K_r, {input_context, output_key, enote.onetime_address, crypto::key_image{}, crypto::null_skey, crypto::null_skey}}});
// LAND AHOY!!!
// calculate the key image for the return output
crypto::secret_key sum_g;
sc_add(to_bytes(sum_g), to_bytes(sender_extension_g_out), to_bytes(k_return));
crypto::key_image key_image = account.derive_key_image_view_only(address_spend_pubkey_out,
sum_g,
sender_extension_t_out,
K_r
);
// } else {
// HERE BE DRAGONS!!!
// SRCG: test whether this will even work for return_payment detection
account.insert_return_output_info({{K_r, {input_context, output_key, enote.onetime_address, key_image, crypto::null_skey, crypto::null_skey}}});
// LAND AHOY!!!
// // calculate the key image for the return output
// crypto::secret_key sum_g;
// sc_add(to_bytes(sum_g), to_bytes(sender_extension_g_out), to_bytes(k_return));
// crypto::key_image key_image = account.derive_key_image(
// address_spend_pubkey_out, // THIS WAS WRONG!!! -> account.get_keys().m_carrot_account_address.m_spend_public_key,
// sum_g,
// sender_extension_t_out,
// K_r
// );
} else {
// crypto::secret_key x, y;
// account.try_searching_for_opening_for_onetime_address(
// address_spend_pubkey_out, // THIS WAS WRONG!!! -> account.get_keys().m_carrot_account_address.m_spend_public_key,
// sum_g,
// sender_extension_t_out,
// x,
// y
// );
// calculate the key image for the return output
crypto::secret_key sum_g;
sc_add(to_bytes(sum_g), to_bytes(sender_extension_g_out), to_bytes(k_return));
crypto::key_image key_image = account.derive_key_image(address_spend_pubkey_out,
sum_g,
sender_extension_t_out,
K_r
);
// // save the input context & change output key
// account.insert_return_output_info({{K_r, {input_context, output_key, enote.onetime_address, key_image, x, y}}});
// }
crypto::secret_key x, y;
account.try_searching_for_opening_for_onetime_address(address_spend_pubkey_out,
sum_g,
sender_extension_t_out,
x,
y
);
// save the input context & change output key
account.insert_return_output_info({{K_r, {input_context, output_key, enote.onetime_address, key_image, x, y}}});
}
}
// janus protection checks are not needed for internal scans

View File

@@ -130,18 +130,18 @@ DISABLE_VS_WARNINGS(4244 4345)
// encrypt a large enough byte stream with chacha20
epee::wipeable_string key_stream = get_key_stream(key, m_encryption_iv, sizeof(crypto::secret_key) * 8);
const char *ptr = key_stream.data();
ptr += sizeof(crypto::secret_key);
ptr += sizeof(crypto::secret_key); // Skip m_spend_secret_key
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
m_view_secret_key.data[i] ^= *ptr++;
ptr += (2*sizeof(crypto::secret_key)); // skip s_master & k_prove_spend
ptr += (2 * sizeof(crypto::secret_key)); // Skip s_master, k_prove_spend
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
s_view_balance.data[i] ^= *ptr++;
s_view_balance.data[i] ^= *ptr++;
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
k_view_incoming.data[i] ^= *ptr++;
k_view_incoming.data[i] ^= *ptr++;
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
k_generate_image.data[i] ^= *ptr++;
k_generate_image.data[i] ^= *ptr++;
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
s_generate_address.data[i] ^= *ptr++;
s_generate_address.data[i] ^= *ptr++;
}
//-----------------------------------------------------------------
void account_keys::decrypt_viewkey(const crypto::chacha_key &key)

View File

@@ -2439,7 +2439,7 @@ void wallet2::scan_key_image(const wallet::enote_view_incoming_scan_info_t &enot
{
ki_out = std::nullopt;
if (m_multisig || m_background_syncing) // no complete spend privkey
if (m_multisig || m_background_syncing/* || m_watch_only*/) // no complete spend privkey
return;
// if keys are encrypted, ask for password