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

[question] What is the purpose of RandomXxHashBuilder64? #51

Open
dsprenkels opened this issue Jun 18, 2020 · 2 comments
Open

[question] What is the purpose of RandomXxHashBuilder64? #51

dsprenkels opened this issue Jun 18, 2020 · 2 comments
Labels

Comments

@dsprenkels
Copy link

This crate supports initializing XxHash with a random seed. I was wondering when would this be used?

First, I imagined that a user could use the random seed for preventing denial-of-service attacks based on the hash-collisions in HashMap (i.e. why we use SipHash-1-3 for HashMap). However, that does not work, because XXHash does not prevent these attacks.

So I was wondering: what is the use case for RandomXxHashBuilder{32,64}? Why not just use XxHash{32,64}::with_seed with some unique constant?

@shepmaster
Copy link
Owner

Wow, I totally missed this question, sorry!

I don't know enough about hashes to be an authoritative source about them. Your best bet is to check with the actual hash authors. I just read code and make the test outputs line up :-).

The true answer is that I was following the pattern in the standard library (which, as you say, aims for HashDOS resistance). I never spent much time thinking about it. 😇

@dsprenkels
Copy link
Author

Thank you!

I already kind-of presumed that it was to mirror the stdlib. :)

However, I feel that this might be dangerous. In the stdlib, the randomized seeds are used for the purpose of preventing HashDoS attacks. Because the crate API mirrors the stdlib, it suggests that these functions could be used for the same purpose (i.e. to prevent HashDoS). But this will not work and might result in insecure usage of the API.

Might I suggest deprecating these functions? Or would you mind me adding a note in the docs urging the user that using random seeds doe not prevent HashDoS attacks?

@dsprenkels dsprenkels changed the title [question] What is the purpose of RandomXxHashBuilder64 [question] What is the purpose of RandomXxHashBuilder64? Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants