News for hackers. Stuff that matters.
Re:SeaHash: Explained by notheguyouthink on Friday December 09, 2016 @09:27AM (#13138892)
I've been using blake2(b) for file hashing in some content addressable db stuff. What might be a scenario where i would choose Seahash over Blake2?

My main concern was speed and assurance that i would not see collisions. Beyond that, i am clearly naive on the subject.

Re:SeaHash: Explained by dom0 on Friday December 09, 2016 @09:48AM (#13139015)
The main question, aside from performance, is...

- Is there an (abstract) attack model? (Assuming that you have one if you ought to)

- Then: Can an attacker insert collisions into the DB, and is that problematic?

- Then: A non-cryptographic hash might be much easier to "reverse", especially for short inputs. Is that problematic?

If none of these are problematic you probably don't need a cryptographic hash.

Regarding performance: BLAKE2b on a Haswell gives you, in a "naive", pure C implementation (compiled to pure, non-vectorized AMD64 assembly), about 230 MB/s / GHz. (Referring to https://github.com/borgbackup/borg/issues/45#issuecomment-22... ), ie. something like 850-1000 MB/s on a desktop SKU. There are implementations that are around 10-30 % faster than that.

AFAIK all these newer n-c hash functions that popped up in the last couple years perform (on desktop SKUs) in the area of beyond ~10 GB/s.

Re:SeaHash: Explained by leeoniya on Friday December 09, 2016 @10:19AM (#13139175)
Re:SeaHash: Explained by ticki_ on Friday December 09, 2016 @11:19AM (#13139597)
SeaHash is obviously not cryptographic (nor is SipHash), but I hope it is a secure PRF (i.e. the keys cannot be extracted), and this was the best attack I was able to construct. Still, it isn't a practical attack, but I suppose it is possible to improve.

Note that I am not a cryptographer, and my only piece of advice is: For the sake of god, don't use hash functions not designed for cryptographic security, if you need cryptographic security. It's that simple.

Re:SeaHash: Explained by tptacek on Friday December 09, 2016 @12:14PM (#13139995)
SipHash is a cryptographic hash with a pretty good pedigree. The distinction between SipHash and Blake2 is more subtle than "cryptographic vs not".
Re:SeaHash: Explained by dom0 on Friday December 09, 2016 @12:16PM (#13140009)
Sure. For starters SipHash targets a lower-end spectrum of device (in a way) than Blake2, and is also less flexible. Since SipHash produces a 64 bit digest it isn't suitable for many applications in the first place. The two also differ significantly in other cryptographic properties, making Blake2 a more secure and easier (safer) to apply choice.

I would tend to say that SipHash is, in a cryptographic context, more an "if you know what you're doing" choice, and not at all a general purpose [cryptographic] hash function.

Re:SeaHash: Explained by ticki_ on Friday December 09, 2016 @03:48PM (#13141705)
No, it's not a cryptographic hash function. It's a MAC function.

The paper clearly states that it is not collision resistant.

Re:SeaHash: Explained by kibwen on Friday December 09, 2016 @05:02PM (#13142241)
I believe that you and tptacek may be using differing definitions of "cryptographic", because he tends to knows what he's talking about when it comes to cryptography (e.g. https://gist.github.com/tqbf/be58d2d39690c3b366ad).
Re:SeaHash: Explained by ticki_ on Friday December 09, 2016 @05:46PM (#13142537)
Oh, well.

What I think of as "cryptographic hash function" is a function resistent to pre-image attack, second pre-image attack, and collision generation.

Neither of those are satisfied by SipHash, and can thus not classify as a cryptographic hash function by the normal definition.

Re:SeaHash: Explained by tptacek on Friday December 09, 2016 @06:10PM (#13142679)
It's a cryptographic hash function, but not one suitable for all of the same applications as SHA2. It has security characteristics that other hash-table hashes (for instance) lack.
Re:SeaHash: Explained by ticki_ on Friday December 09, 2016 @06:32PM (#13142830)
If you know the key, it is as weak as it gets (as the paper notes too, you can construct collisions easily if the key is known), so I disagree.
Re:SeaHash: Explained by tptacek on Friday December 09, 2016 @08:04PM (#13143327)
Honestly, I really don't care about this debate, except to the extent that it's about whether SipHash "isn't cryptographic and therefore you might as well use CityHash or SeaHash", which just isn't true.
Re:SeaHash: Explained by ticki_ on Saturday December 10, 2016 @05:50AM (#13145085)
I agree. SipHash is certainly strong if you don't know the key.
Re:SeaHash: Explained by ticki_ on Friday December 09, 2016 @11:22AM (#13139613)
There's a huge difference between cryptographic and non-cryptographic. Note that blake2 has various length, whereas SeaHash is fixed to 64-bit (although I suppose it's not to hard to make a version with bigger length), and thus naturally collisions will happen.

If you need fingerprints, don't use SeaHash, but if you are looking to insert into e.g. a hash table, you shouldn't use BLAKE2. It's awfully slow for that.

Re:SeaHash: Explained by JoshTriplett on Friday December 09, 2016 @12:17PM (#13140019)
For a content-addressable database, you absolutely want a cryptographic hash. (And please, don't make the mistake Git did: please include the name of the hash function in the "address", to make it possible to change the hash function.)
Re:SeaHash: Explained by loeg on Friday December 09, 2016 @12:28PM (#13140102)
It seems like Git could change the disk format eventually with backwards compatibility for current SHA1 addresses. You don't even need to rewrite old objects. You just need to know which hash method a given tree/commit object is using to verify history or perform checkout. That could be a flag or tag in the object.
Re:SeaHash: Explained by JoshTriplett on Friday December 09, 2016 @01:49PM (#13140828)
Git has some work in progress in that direction, starting by changing all the internal data structures to use a struct rather than a hardcoded array of bytes the size of a SHA1.
Re:SeaHash: Explained by notheguyouthink on Friday December 09, 2016 @09:31AM (#13138912)
And on that note, has anyone seen any benches for blake2 vs Seahash/Metrohash? I'm not finding anything so far
Re:SeaHash: Explained by ticki_ on Friday December 09, 2016 @11:16AM (#13139579)
BLAKE(2) is a cryptographic hash function, SeaHash is not. Even the fastest implementations of BLAKE only gets around 7.8 cycles/byte (hardware might do it twice as fast). SeaHash gets 0.24 cycles/byte.

That's a wide difference, around 32x faster.