Short and to the point. I'm assuming that it is not a kind of hash function that can be used universally. After having read about universal hash functions used with the one-time pad to form an authentication scheme, these things have bugged me out.

  • 1
    $\begingroup$ It is a complicated way of saying that you have a parameter to make the hashing unique. For example if you include a nonce or a key as in HMACs. en.m.wikipedia.org/wiki/Universal_hashing $\endgroup$
    – eckes
    Commented Nov 9, 2017 at 3:51

1 Answer 1


From Wikipedia:

In mathematics and computing universal hashing (in a randomized algorithm or data structure) refers to selecting a hash function at random from a family of hash functions with a certain mathematical property. This guarantees a low number of collisions in expectation, even if the data is chosen by an adversary. Many universal families are known (for hashing integers, vectors, strings), and their evaluation is often very efficient. Universal hashing has numerous uses in computer science, for example in implementations of hash tables, randomized algorithms, and cryptography.

A randomized algorithm $H$ for constructing hash functions $h\colon U \to \{1,\ldots,M\}$ is universal if for all $x \neq y$ in $U$, we have $\Pr_{h\gets H} [h(x) = h(y)] \leq 1/M$

From this answer:

Let $\Phi$ be a finite collection of hash functions that map a given universe $U$ of keys into the range $\{0, 1, 2,\ldots, m - 1\}.$

$\Phi$ is called universal if for each pair of distinct keys $x, y \in U$, the number of hash functions $h \in\Phi$ for which $h(x) = h(y)$ is precisely equal to $$\frac{\lvert\Phi\rvert}{m}.$$

With a function randomly chosen from $\Phi$, the chance of a collision between $x$ and $y$ where $x \neq y$ is exactly $\frac{1}{m}$.

  • 2
    $\begingroup$ So can you have a non universal hash function, and if so what would its properties be? A contra example is always useful to hammer home a point as I'm as bugged out about it as the OP. $\endgroup$
    – Paul Uszak
    Commented Nov 9, 2017 at 10:42
  • 1
    $\begingroup$ Let's say you have h(x)=x mod m. Then an adversary can choose keys: 1, 1+m, 1+2m, 1+3m etc. They will all cause collisions. But if the function h is chosen randomly from a universal family, you can't guarantee such a "bad" set of keys. $\endgroup$
    – kartoniks
    Commented May 28, 2019 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.