core: randomly shuffle outputs

They used to be sorted by amount, which was fine before rct,
but is now suboptimal, since amounts are not known anymore.
In particular, it would give a recipient knowledge of whether
change was higher or lower than the amount received.
This commit is contained in:
moneromooo-monero 2017-07-25 18:42:55 +01:00
parent ab594cfee9
commit 340feedee2
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3

View file

@ -265,7 +265,7 @@ namespace cryptonote
// "Shuffle" outs
std::vector<tx_destination_entry> shuffled_dsts(destinations);
std::sort(shuffled_dsts.begin(), shuffled_dsts.end(), [](const tx_destination_entry& de1, const tx_destination_entry& de2) { return de1.amount < de2.amount; } );
std::random_shuffle(shuffled_dsts.begin(), shuffled_dsts.end(), [](int i) { return crypto::rand<int>() % i; });
uint64_t summary_outs_money = 0;
//fill outputs