2 ms·
I realize my other comment might have come across as: "i called it universal because it hashes both strings and numbers, then someone pointed out the technical
by 19eightyfour 9y ago
I realize my other comment might have come across as: "i called it universal because it hashes both strings and numbers, then someone pointed out the technical term universal and i decided i would just turn it into a 'universal hash' as well, because that would be easy."
From that point of view it makes sense to point out what universal hashing means, and how showing universality is non trivial, and not something i can just trivially track on.
However, i didn't communicate this following point before, but the genesis of tifuhash was: yesterday i read the paper i linked in the other comment and wanted to write a universal hash family. There's an open problem at the end of the paper that directly motivated me to try to come up with this.
* from that paper:*
> "Major Open Problem: Can we get something simple and fast like multiply-shift to work directly
for strings, so that we do not need to compute polynomials over prime fields?"
Actually i wrote tifuhash to be universal and work on strings, in other words to be a family of parameterized hash functions with the 2^-64 collision probability. I imposed a bunch of other constraints I myself as well, such as only using arithmetic operations ( no bitwise ops ), making it as simple as possible, and trying to avoid opaque magic constants. I tried a bunch of things related to traditional multiply shift but nothing really clicked for me. Then I had the idea of using ratios of successive message values and from there just went into continued fractions. I was blown away with something so simple and using only arithmetic passed practrand. One reason i think passing practrand is important to universality is reflected in this quote from the wiki page on universal hashing:
> "This is exactly the probability of collision we would expect if the hash function assigned truly random hash codes to every key. "
Anyway, tl;dr is I designed it from the start to be universal.