Skip to content

Commit

Permalink
fix try_get_enote_record_plain_v1 false positive
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffro256 committed Jun 12, 2024
1 parent b9d9d8a commit 1d77688
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/seraphis_main/enote_record_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ bool try_get_enote_record_plain_v1(const SpBasicEnoteRecordV1 &basic_record,
crypto::x25519_pubkey x_ir;
crypto::x25519_scmul_key(d_identify_received, basic_record.enote_ephemeral_pubkey, x_ir);

if (try_complete_balance_recovery_v1(basic_record.enote,
if (!try_complete_balance_recovery_v1(basic_record.enote,
basic_record.enote_ephemeral_pubkey,
basic_record.num_primary_view_tag_bits,
basic_record.input_context,
Expand All @@ -682,7 +682,7 @@ bool try_get_enote_record_plain_v1(const SpBasicEnoteRecordV1 &basic_record,
s_generate_address,
cipher_context,
record_out))
return true;
return false;

return record_out.type == jamtis::JamtisEnoteType::PLAIN;
}
Expand Down
21 changes: 18 additions & 3 deletions tests/performance_tests/view_scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,28 @@ class test_remote_scanner_client_scan_sp
continue;
}

// mangle the view tag complementary bits so that the enote doesn't scan
// mangle the view tag bits so that the enote doesn't scan
// - re-do the fake ones if they succeed by accident
sp::jamtis::view_tag_t &last_view_tag =
m_basic_records.back().enote.unwrap<sp::SpEnoteV1>().view_tag;
const sp::jamtis::view_tag_t og_last_view_tag = last_view_tag;
while (last_view_tag == og_last_view_tag)
bool needs_mangling{true};
while (needs_mangling)
{
last_view_tag = sp::jamtis::gen_view_tag();
needs_mangling = sp::jamtis::test_jamtis_primary_view_tag(m_keys.d_fa,
m_basic_records.back().enote_ephemeral_pubkey,
onetime_address_ref(m_basic_records.back().enote),
last_view_tag,
num_primary_view_tag_bits);
crypto::x25519_pubkey x_ir;
crypto::x25519_scmul_key(m_keys.d_ir, m_basic_records.back().enote_ephemeral_pubkey, x_ir);
bool matched_all_secondary_bits{false};
needs_mangling |= sp::jamtis::test_jamtis_secondary_view_tag(x_ir.data,
onetime_address_ref(m_basic_records.back().enote),
last_view_tag,
num_primary_view_tag_bits,
matched_all_secondary_bits);
}
}

return true;
Expand Down

0 comments on commit 1d77688

Please sign in to comment.