Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Off-by-one wallet decoy selection bug fix #1642

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/wallet/wallet2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,8 @@ gamma_picker::gamma_picker(const std::vector<uint64_t>& rct_offsets, double shap
? rct_offsets[rct_offsets.size() - blocks_to_consider - 1]
: 0);
begin = rct_offsets.data();
end = rct_offsets.data() + rct_offsets.size() - DEFAULT_TX_SPENDABLE_AGE;
end = rct_offsets.data() + rct_offsets.size() -
(std::max(1, CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE) - 1);
num_rct_outputs = *(end - 1);
THROW_WALLET_EXCEPTION_IF(num_rct_outputs == 0, error::wallet_internal_error, "No rct outputs");
average_output_time =
Expand Down Expand Up @@ -10599,7 +10600,7 @@ void wallet2::get_outs(
} else {
// the base offset of the first rct output in the first unlocked block (or the one
// to be if there's none)
num_outs = rct_offsets[rct_offsets.size() - DEFAULT_TX_SPENDABLE_AGE];
num_outs = gamma->get_num_rct_outs();
log::info(logcat, "{} unlocked rct outputs", num_outs);
THROW_WALLET_EXCEPTION_IF(
num_outs == 0,
Expand Down Expand Up @@ -10923,7 +10924,7 @@ void wallet2::get_outs(
}
bool use_histogram = amount != 0 || !has_rct_distribution;
if (!use_histogram)
num_outs = rct_offsets[rct_offsets.size() - DEFAULT_TX_SPENDABLE_AGE];
num_outs = gamma->get_num_rct_outs();

// make sure the real outputs we asked for are really included, along
// with the correct key and mask: this guards against an active attack
Expand Down
1 change: 1 addition & 0 deletions src/wallet/wallet2.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class gamma_picker {
uint64_t pick();
gamma_picker(const std::vector<uint64_t>& rct_offsets);
gamma_picker(const std::vector<uint64_t>& rct_offsets, double shape, double scale);
uint64_t get_num_rct_outs() const { return num_rct_outputs; }

private:
struct gamma_engine {
Expand Down