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

paymod: Scale presplit amounts to support larger payments while maintaining size buckets for privacy #3986

Merged
merged 2 commits into from
Aug 27, 2020

Conversation

cdecker
Copy link
Member

@cdecker cdecker commented Aug 26, 2020

This proposal is a simple solution to #3926 and an alternative to
#3942/#3951. It is very much in the spirit of the original presplit payment
modifier in that it will create parts with a fixed size (not considering the
amount fuzzing to obfuscate the remainder), mostly independently of the total
amount. I think this is import to make it harder for observers to invert the
split and derive the original amount.

The change consists in adjusting the target amount for the individual parts
upwards should the current split result in too many parts. We use powers of 16
as a step size between buckets, resulting in at most 16 parts, and all
payments whose total amount is in the range of x < amount <= 16*x result in
the same part amount.

Why 16 as the upper limit of parts? Because it is approximately 1/2 of the
HTLCs available to a single channel, giving us some room to use adaptively
split should that be necessary. At the same time it is large enough such that
the resulting partial amounts are not too specific to the total amount, and
it's a power of two which means after log2(16) adaptive splits the amounts of
the parts mix with the a smaller payment's parts again. This is mostly in
preparation for PTLCs which give us decorrelation, but I think we can already
expect a benefit in amounts snapping to buckets.

Notice that none of the parameters are set in stone, and I'm happy to adjust
should better parameters be found.

Closes #3951
Closes #3942
Fixes #3926

Huge payment + presplit modifier = too many HTLCs...
This is the simplest possible fix: increase the target amount until we get
the desired number of parts, while still bucketizing payments together that
are in approximately the same size.

The current logic puts all payments that are in the range x < amount <= 16*x
in the same bucket, making them harder to distinguish.

Changelog-Fixed: pay: The `presplit` modifier now supports large payments without exhausting the available HTLCs.
Copy link
Contributor

@rustyrussell rustyrussell left a comment

Choose a reason for hiding this comment

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

Ack 9239153

target.millisatoshis = p->amount.millisatoshis / htlcs; /* Raw: division */
else
target = AMOUNT_MSAT(MPP_TARGET_SIZE);
target.millisatoshis = target_amount; /* Raw: init */
Copy link
Contributor

Choose a reason for hiding this comment

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

Simpler as amount_msat(target_amount)

@@ -2888,10 +2903,10 @@ static void presplit_cb(struct presplit_mod_data *d, struct payment *p)
return payment_fail(
p, "Cannot attempt payment, we have no channel to "
"which we can add an HTLC");
} else if (p->amount.millisatoshis / MPP_TARGET_SIZE > htlcs) /* Raw: division */
} else if (p->amount.millisatoshis / target_amount > htlcs) /* Raw: division */
target.millisatoshis = p->amount.millisatoshis / htlcs; /* Raw: division */
Copy link
Contributor

Choose a reason for hiding this comment

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

target = amount_msat_div(p->amount, htlcs);

@rustyrussell
Copy link
Contributor

Minor cleanups only, will push post.

@rustyrussell rustyrussell merged commit 21d87f7 into ElementsProject:master Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MPP pay splits into too many subpayments
2 participants