Explain setting the coefficient in comments.
MODIFY
WalletWasabi/Blockchain/Analysis/BlockchainAnalyzer.cs
WalletWasabi/Blockchain/Analysis/BlockchainAnalyzer.cs
@@ -105,7 +105,13 @@ namespace WalletWasabi.Blockchain.Analysis
// Reusing pubkey on the input side is good, the punishment happened already.
var distinctWalletInputPubKeyCount = distinctWalletInputPubKeys.Count;
var pubKeyReuseCount = ownInputCount - distinctWalletInputPubKeyCount;
- var privacyBonus = Intersect(distinctWalletInputPubKeys.Select(x => x.AnonymitySet), (double)distinctWalletInputPubKeyCount / (tx.Transaction.Inputs.Count - pubKeyReuseCount));
+
+ // We want to weaken the punishment if the input merge happens in coinjoins.
+ // Our strategy would be is to set the coefficient in proportion to our own inputs compared to the total inputs of the transaction.
+ // However the accuracy can be increased if we consider every input with the same pubkey as a single input entity.
+ // This we can only do for our own inputs as we don't know the pubkeys - nor the scripts - of other inputs.
+ double coefficient = (double)distinctWalletInputPubKeyCount / (tx.Transaction.Inputs.Count - pubKeyReuseCount);
+ var privacyBonus = Intersect(distinctWalletInputPubKeys.Select(x => x.AnonymitySet), coefficient);
// If the privacy bonus is <=1 then we are not inheriting any privacy from the inputs.
var normalizedBonus = privacyBonus - 1;

Explain setting the coefficient in comments.