7 ms·
Possibly stupid question... Why there's _1 and _2 variants for each hash size?
by arthursilva 11y ago
Possibly stupid question... Why there's _1 and _2 variants for each hash size?
- jandrewrogers 11y agoMostly because I could. There are use cases for statistically independent hashes, such as Bloom filters, though these can sometimes be satisfied by other means. Having two independent functions for each gives people flexibility and also serves as a (trivial) proof of capability. It would be a small thing to generate a dozen statistically independent versions of each hash algorithm, primarily because the generation process is so straightforward. This by itself is unique for popular hash functions. One possible use case for random generation of these functions is security through obscurity by having every hash table implementation using a different function to make them more difficult to attack.
- rurban 11y agoWell, we don't call that "security by obscurity", we call that "universal hashing", which is provable secure. The rules to create the constants would nice to have to actually create good universal hashing. 2 variants are not enough yet, but the quality of _1 and _2 are already much better than the typical universal hash function variant.