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

Add SipHash implementation #8

Open
wkuranowski opened this issue Sep 30, 2015 · 3 comments
Open

Add SipHash implementation #8

wkuranowski opened this issue Sep 30, 2015 · 3 comments

Comments

@wkuranowski
Copy link

Can you add SipHash to your library? It is very popular function, fast, secure and immune to Hash DoS attacks.

https://en.wikipedia.org/wiki/SipHash

@benalexau
Copy link

On the speed issue, Hash-Bench tests over 100 hash implementations on the JVM and finds Zero-Allocation-Hashing's XXH64 is the fastest. Feel free to check the published results for yourself for the buffer sizes and types you wish to hash (ie direct ByteBuffer, on-heap ByteBuffer, plain byte[]) but SipHash is consistently slower. For example, a standard byte[32] with XXH64 hashes in 9 ns vs 52, 114, and 127 ns for the three Java SipHash implementations that Hash-Bench tests.

I don't see much reason to add extra hashers to Zero-Allocation-Hashing unless the algorithm has a material speed or functional advantage. To this end maybe Daniel Lemire's CLHash is worth exploration (see here which also includes a SipHash performance comparison).

@wkuranowski
Copy link
Author

I agree that SipHash is slower than other simple hash functions. Speed is important but you need to look at other aspects. SipHash is a cryptographic hash function. It's really fast when you compare it to other cryptographic hash functions. Maybe we can gain even better performance with a new implementation.

SipHash is also immune to Hash DoS attacks, so it is used as default hash function in many languages: Perl, Python, Ruby, Haskell, Rust... etc.

In my opinion it's really nice to have a secure hash function, especially when one of the authors is DJB. I am not telling that everyone needs SipHash. But it has unique properties and is complementary to others.

@benalexau
Copy link

I agree XXH64 and SipHash aim at different problems. The Hash-Bench Scope section lists some other considerations too when comparing hash algos.

If SipHash is what you would like, the three implementations currently available in Java might be sufficient for you:

See Hash-Bench's 32 byte SipHash Report if you'd like graphs comparing their performance (summary: siphash-java-inline is more than twice as fast as the next fastest alternative).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants