Skip to content

Fix HTLC-output-in-commitment sorting for duplicate-HTLCs #319

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

Merged
merged 2 commits into from
Mar 25, 2019

Conversation

TheBlueMatt
Copy link
Collaborator

This resolves both an issue that hits fuzzing due to hash
collisions as well as implements an update to the BOLT spec.

Also removes the input sorting.

@TheBlueMatt TheBlueMatt added this to the 0.0.9 milestone Mar 7, 2019
This resolves both an issue that hits fuzzing due to hash
collisions as well as implements an update to the BOLT spec.
@TheBlueMatt TheBlueMatt force-pushed the 2019-03-htlc-sorting branch from 15a2592 to a085488 Compare March 7, 2019 18:56
Lightning doesn't (currently) do any input sorting at the protocol
level, but if we ever need to re-add this its in git history.
// Note that due to hash collisions, we have to have a fallback comparison
// here for fuzztarget mode (otherwise at least chanmon_fail_consistency
// may fail)!
.then(a_htlc.0.payment_hash.0.cmp(&b_htlc.0.payment_hash.0))
Copy link

Choose a reason for hiding this comment

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

Hmm didn't get you there, if offered HTLC A and offered HTLC B have same pubkey script, isn't it implied that they have same payment hash, as per BOLT-3, hash is part of script and it's the only diff for HTLCs with same per commitment point ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not in fuzztarget, in fuzztarget hashes are just (roughly) the whole input xor'd together, with 31 bytes being set to 0s. Thus, its rather trivial to have different payment hashes have the same script_pubkey.

Copy link

Choose a reason for hiding this comment

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

Okay make sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers MOAR TEST PLZ NEEDS MOAR TEST
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants