@@ -12182,8 +12182,14 @@ bool wallet2::is_out_to_acc(const cryptonote::account_public_address &address, c
1218212182 crypto::public_key derived_out_key;
1218312183 bool found = false;
1218412184 bool r;
12185+
12186+ const auto is_null_derivation = [](const crypto::key_derivation &d) {
12187+ static const crypto::key_derivation null_derivation{};
12188+ return memcmp(&d, &null_derivation, sizeof(d)) == 0;
12189+ };
12190+
1218512191 // first run quick check if output has matching view tag, otherwise output should not belong to account
12186- if (out_can_be_to_acc(view_tag_opt, derivation, output_index))
12192+ if (!is_null_derivation(derivation) && out_can_be_to_acc(view_tag_opt, derivation, output_index))
1218712193 {
1218812194 // if view tag match, run slower check deriving output pub key and comparing to expected
1218912195 r = crypto::derive_public_key(derivation, output_index, address.m_spend_public_key, derived_out_key);
@@ -12197,15 +12203,21 @@ bool wallet2::is_out_to_acc(const cryptonote::account_public_address &address, c
1219712203
1219812204 if (!found && !additional_derivations.empty())
1219912205 {
12200- const crypto::key_derivation &additional_derivation = additional_derivations[output_index];
12201- if (out_can_be_to_acc(view_tag_opt, additional_derivation, output_index))
12206+ for (const crypto::key_derivation &additional_derivation : additional_derivations)
1220212207 {
12203- r = crypto::derive_public_key(additional_derivation, output_index, address.m_spend_public_key, derived_out_key);
12204- THROW_WALLET_EXCEPTION_IF(!r, error::wallet_internal_error, "Failed to derive public key");
12205- if (out_key == derived_out_key)
12208+ if (is_null_derivation(additional_derivation))
12209+ continue;
12210+
12211+ if (out_can_be_to_acc(view_tag_opt, additional_derivation, output_index))
1220612212 {
12207- found = true;
12208- found_derivation = additional_derivation;
12213+ r = crypto::derive_public_key(additional_derivation, output_index, address.m_spend_public_key, derived_out_key);
12214+ THROW_WALLET_EXCEPTION_IF(!r, error::wallet_internal_error, "Failed to derive public key");
12215+ if (out_key == derived_out_key)
12216+ {
12217+ found = true;
12218+ found_derivation = additional_derivation;
12219+ break;
12220+ }
1220912221 }
1221012222 }
1221112223 }
@@ -12482,7 +12494,7 @@ bool wallet2::check_tx_proof(const cryptonote::transaction &tx, const cryptonote
1248212494 if (std::any_of(good_signature.begin(), good_signature.end(), [](int i) { return i > 0; }))
1248312495 {
1248412496 // obtain key derivation by multiplying scalar 1 to the shared secret
12485- crypto::key_derivation derivation;
12497+ crypto::key_derivation derivation{} ;
1248612498 if (good_signature[0])
1248712499 THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(shared_secret[0], rct::rct2sk(rct::I), derivation), error::wallet_internal_error, "Failed to generate key derivation");
1248812500
0 commit comments