11-4 Hashing and authentication

Let H\mathcal H be a class of hash functions in which each hash function hHh \in \mathcal H maps the universe UU of keys to {0,1,,m1}\{0, 1, \ldots, m - 1 \}. We say that H\mathcal H is k-universal if, for every fixed sequence of kk distinct keys x(1),x(2),,x(k)\langle x^{(1)}, x^{(2)}, \ldots, x^{(k)} \rangle and for any hh chosen at random from H\mathcal H, the sequence h(x(1)),h(x(2)),,h(x(k))\langle h(x^{(1)}), h(x^{(2)}), \ldots, h(x^{(k)}) \rangle is equally likely to be any of the mkm^k sequences of length kk with elements drawn from {0,1,,m1}\{0, 1, \ldots, m - 1 \}.

a. Show that if the family H\mathcal H of hash functions is 22-universal, then it is universal.

b. Suppose that the universe UU is the set of nn-tuples of values drawn from Zp={0,1,,p1}\mathbb Z_p = \{0, 1, \ldots, p - 1\}, where pp is prime. Consider an element x=x0,x1,,xn1Ux = \langle x_0, x_1, \ldots, x_{n - 1} \rangle \in U. For any nn-tuple a=a0,a1,,an1Ua = \langle a_0, a_1, \ldots, a_{n - 1} \rangle \in U, define the hash function hah_a by

ha(x)=(j=0n1ajxj)mod  p.h_a(x) = \Bigg(\sum_{j = 0}^{n - 1} a_j x_j \Bigg) \mod p.

Let H={ha}\mathcal H = \{h_a\}. Show that H\mathcal H is universal, but not 22-universal. (Hint:\textit{Hint:} Find a key for which all hash functions in H\mathcal H produce the same value.)

c. Suppose that we modify H\mathcal H slightly from part (b): for any aUa \in U and for any bZpb \in \mathbb Z_p, define

hab(x)=(j=0n1ajxj+b)mod  ph'_{ab}(x) = \Bigg(\sum_{j = 0}^{n - 1} a_j x_j + b \Bigg) \mod p

and h={hab}\mathcal h' = \{h'_{ab}\}. Argue that H\mathcal H' is 22-universal. (Hint:\textit{Hint:} Consider fixed nn-tuples xUx \in U and yUy \in U, with xiyix_i \ne y_i for some ii. What happens to hab(x)h'_{ab}(x) and hab(y)h'_{ab}(y) as aia_i and bb range over Zp\mathbb Z_p?)

d. Suppose that Alice and Bob secretly agree on a hash function hh form 22-universal family H\mathcal H of hash functions. Each hHh \in \mathcal H maps from a universe of keys uu to Zp\mathbb Z_p, where pp is aprime. Later, Alice sends a message mm to Bob over the Internet, where mUm \in U. She authenticates this message to Bob by also sending an authentication tag t=h(m)t = h(m), and Bob checks that the pair (m,t)(m, t) he receives indeed satisfies t=h(m)t = h(m). Suppose that an adversary intercepts (m,t)(m, t) en route and tries to fool Bob by replacing the pair (m,t)(m, t) with a different pair (m,t)(m', t'). Argue that the probability that the adversary succeeds in fooling Bob into accepting (m,t)(m', t') is at most 1/p1 / p, no matter how much computing power the adversary has, and even if the adversary knows the family H\mathcal H of hash functions used.

a. The number of hash functions for which h(k)=h(l)h(k) = h(l) is mm2H=1mH\frac{m}{m^2}|\mathcal H| = \frac{1}{m}|\mathcal H|, therefore the family is universal.

b. For x=0,0,,0x = \langle 0, 0, \ldots, 0 \rangle, H\mathcal H could not be 22-universal.

c. Let x,yUx, y \in U be fixed, distinct nn-tuples. As aia_i and bb range over Zp,hab(x)\mathbb Z_p, h'_{ab}(x) is equally likely to achieve every value from 11 to pp since for any sequence aa, we can let bb vary from 11 to p1p - 1.

Thus, hab(x),hab(y)\langle h'_{ab}(x), h'_{ab}(y) \rangle is equally likely to be any of the p2p^2 sequences, so H\mathcal H is 22-universal.

d. Since H\mathcal H is 22-universal, every pair of t,t\langle t, t' \rangle is equally likely to appear, thus tt' could be any value from Zp\mathbb Z_p. Even the adversary knows H\mathcal H, since H\mathcal H is 22-universal, then H\mathcal H is universal, the probability of choosing a hash function that h(k)=h(l)h(k) = h(l) is at most 1/p1 / p, therefore the probability is at most 1/p1 / p.