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

wallet: shuffle coins before grouping, where warranted #13808

Merged
merged 1 commit into from Aug 13, 2018

Conversation

kallewoof
Copy link
Member

@kallewoof kallewoof commented Jul 30, 2018

Coins are randomly shuffled in coin selection to avoid unintentional privacy leaks regarding the user's coin set. For the case where a user has a lot of coins with the same destination, these will be grouped into groups of 10 before the shuffling.

It is unclear whether this has any implications at all, but this PR plugs the potential issue, if there ever is one, by shuffling the coins before they are grouped.

Issue brought up in #12257 (comment)

@maflcko maflcko added this to the 0.17.0 milestone Jul 30, 2018
@kallewoof kallewoof force-pushed the random-ordering-output-groups branch 2 times, most recently from 60df230 to bea78f2 Compare July 30, 2018 17:30
@maflcko maflcko added the Wallet label Jul 30, 2018
@promag
Copy link
Member

promag commented Aug 1, 2018

Could shuffle after GroupOutputs()? , just shuffle each group.m_outputs in the same condition? Currently GroupOutputs result depends on the input order, but that can change. Post-shuffle would be guaranteed.

@kallewoof
Copy link
Member Author

@promag You would have to not cap the size of groups and create them with unlimited size, then shuffle each one and break it into groups.. don't see the benefit to this, honestly, unless it has a huge impact on speed for big wallets or something?

if (coin_control.m_avoid_partial_spends && vCoins.size() > 10) {
// Cases where we have 11+ outputs all pointing to the same destination may result in
// privacy leaks as they will potentially be deterministically sorted. We solve that by
// explicitly sorting the outputs before processing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/sorting/shuffling/ ?

@@ -2515,6 +2515,12 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm

// form groups from remaining coins; note that preset coins will not
// automatically have their associated (same address) coins included
if (coin_control.m_avoid_partial_spends && vCoins.size() > 10) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this 10 a constant to make it easier for the reader/future writer, or make it a parameter to the grouping function itself?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second thought: Would an unconditional shuffle just be easier here? We shuffle inputs later post-selection, so nothing of value should be lost.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't checked, but I don't think you can remove the later shuffle, and you at least want to skip shuffling if !m_avoid_partial_spends, so I don't think unconditional is ideal here.

I.e. if we could move the shuffle operation to always happen here, rather than later, that would work fine.

If we can't, we should at least not skip the extra shuffle if we are not grouping, since that's just no-reason-wasteful.

@kallewoof kallewoof force-pushed the random-ordering-output-groups branch from bea78f2 to c3b47e3 Compare August 9, 2018 23:11
@kallewoof
Copy link
Member Author

Addressed @instagibbs nits (except unconditional shuffle).

@kallewoof kallewoof force-pushed the random-ordering-output-groups branch from c3b47e3 to bc9ef87 Compare August 10, 2018 00:07
@kallewoof kallewoof force-pushed the random-ordering-output-groups branch from bc9ef87 to 18f690e Compare August 10, 2018 00:08
@achow101
Copy link
Member

utACK 18f690e

@instagibbs
Copy link
Member

utACK 18f690e

@sipa
Copy link
Member

sipa commented Aug 10, 2018

utACK 18f690e, but can you update the PR description to explain the issue and solution? It isn't at all clear from the commit message or description why this is necessary.

@kallewoof
Copy link
Member Author

@sipa I updated the description.

@maflcko
Copy link
Member

maflcko commented Aug 12, 2018

utACK 18f690e

@fanquake
Copy link
Member

utACK 18f690e

@laanwj laanwj merged commit 18f690e into bitcoin:master Aug 13, 2018
@kallewoof kallewoof deleted the random-ordering-output-groups branch October 17, 2019 08:33
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jul 4, 2021
…ranted

18f690e wallet: shuffle coins before grouping, where warranted (Karl-Johan Alm)

Pull request description:

  Coins are randomly shuffled in coin selection to avoid unintentional privacy leaks regarding the user's coin set. For the case where a user has a lot of coins with the same destination, these will be grouped into groups of 10 *before* the shuffling.

  It is unclear whether this has any implications at all, but this PR plugs the potential issue, if there ever is one, by shuffling the coins before they are grouped.

  Issue brought up in bitcoin#12257 (comment)

Tree-SHA512: fb50ed4b5fc03ab4853d45b76e1c64476ad5bcd797497179bc37b9262885c974ed6811159fd8e581f1461b6cc6d0a66146f4b70a2777c0f5e818d1322e0edb89
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jul 6, 2021
…ranted

18f690e wallet: shuffle coins before grouping, where warranted (Karl-Johan Alm)

Pull request description:

  Coins are randomly shuffled in coin selection to avoid unintentional privacy leaks regarding the user's coin set. For the case where a user has a lot of coins with the same destination, these will be grouped into groups of 10 *before* the shuffling.

  It is unclear whether this has any implications at all, but this PR plugs the potential issue, if there ever is one, by shuffling the coins before they are grouped.

  Issue brought up in bitcoin#12257 (comment)

Tree-SHA512: fb50ed4b5fc03ab4853d45b76e1c64476ad5bcd797497179bc37b9262885c974ed6811159fd8e581f1461b6cc6d0a66146f4b70a2777c0f5e818d1322e0edb89
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jul 6, 2021
…ranted

18f690e wallet: shuffle coins before grouping, where warranted (Karl-Johan Alm)

Pull request description:

  Coins are randomly shuffled in coin selection to avoid unintentional privacy leaks regarding the user's coin set. For the case where a user has a lot of coins with the same destination, these will be grouped into groups of 10 *before* the shuffling.

  It is unclear whether this has any implications at all, but this PR plugs the potential issue, if there ever is one, by shuffling the coins before they are grouped.

  Issue brought up in bitcoin#12257 (comment)

Tree-SHA512: fb50ed4b5fc03ab4853d45b76e1c64476ad5bcd797497179bc37b9262885c974ed6811159fd8e581f1461b6cc6d0a66146f4b70a2777c0f5e818d1322e0edb89
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants