payjoin / rust-payjoin

Supercharged payment batching to save you fees and preserve your privacy
https://payjoindevkit.org
85 stars 37 forks source link

Shorten subdirectory IDs #386

Closed nothingmuch closed 1 week ago

nothingmuch commented 2 weeks ago

WIP since this should probably be refactored a bit before merging (see TODO comments).

The message for the last commit contains a rationale for 64 bit values and hashing.

nothingmuch commented 2 weeks ago

Akshually, I just realized the last commit message is (edit: was) incorrect, not only was the interception scenario possible before due to the truncated values used for the redis key, since this was 8 characters of Base64 and the first encoded byte was always 0x02 or 0x03 for the compressed y coordinate, the redis level IDs only had 41 bits of entropy, so in fact the last commit improves the robustness against DoS attacks and v1 fallback proposal PSBT leakage

DanGould commented 1 week ago

Concept ACK in response to the "Shorten subdirectory IDs to 64 pseudorandom bits" commit message.

✅ utxo set size ≈ 2^28 ✅ daily tx count limit ≈ 2^21

the probability for an individual session to experience a random collision is << 1e-10

~10~ 12 9s is way more than enough reliability of this particular component, and the utxo set size and even daily tx counts are already way overestimations of the number of sessions a single directory will ever have and many directories may be run.

Concept ACK also on your note that this already improves collision resistance on the naive truncated shortIDs of not-completely-pseudorandom values.

nothingmuch commented 1 week ago

I find it a bit weird to change the API in the first commit and only to use it in later commits but that's a nit of nits

Squashed first two commits