Hash functions

A hash function is a keyed family of functions ; its main security notions ask that, for a random key , no efficient adversary inverts on the image of a uniform input (one-wayness) or finds two distinct inputs with the same image (collision resistance).

Syntax

A hash function is a family with key space , domain and range , where for a polynomial . It comes with three efficient algorithms: a key sampler (for a keyless family is a singleton), a uniform sampler for , and a deterministic polynomial-time algorithm that computes from . Below, , , and stand for , , and .

As an object, a one-way, weakly one-way, sub-exponentially one-way or size-verifiable one-way function, a CRHF, a second-preimage-resistant family, a UOWHF and a weakly collision-resistant family each denote such a family that meets the game of its section.

Properties

A hash function can also be modeled as a random oracle — BR93.

Preimage resistance (one-wayness)

\begin{algorithm}
\algname{Game}
\caption{$\Game^{\mathrm{pr}}_{\hash,\calA}(\secpar)$}
\begin{algorithmic}
\State $k \gets \KeyGen(1^\secpar)$ ; $x \getsr \calD$
\State $y \gets \hash(k,x)$
\State $\hat{x} \gets \calA(1^\secpar, k, y)$
\Return $[\hash(k,\hat{x}) = y]$
\end{algorithmic}
\end{algorithm}

A hash function is one-way or preimage resistant if for every efficient

is negligible. In this case, is called a one-way function (OWF).

One-wayness against non-uniform adversaries

Let be a family of polynomial-size circuits, a non-uniform adversary, with playing . is one-way against non-uniform adversaries if for every such family , is negligible. Security against all non-uniform adversaries implies security against all uniform ones (Non-uniform OWF ⇒ OWF) — standard.

Quantum-secure one-wayness

A hash function is quantum-secure one-way if for all efficient quantum , which receive the classical pair in and output a classical , is negligible; itself is classical and efficiently computable. AC12 call such a function a classical one-way function secure against quantum attack.

Auxiliary-input one-wayness

A function , efficiently computable given the auxiliary input , is auxiliary-input one-way if for all efficient there are infinitely many on which inverts on a uniform input with probability negligible in — OW93.

Weak one-wayness

A hash function is weakly one-way if there is a polynomial such that for all efficient and all sufficiently large , — Yao82a. Every one-way function is weakly one-way — folklore; conversely, weak one-way functions yield one-way functions — Yao82a.

Distributional one-wayness

A function computable in polynomial time is distributionally one-way if there is a polynomial such that for all efficient and all sufficiently large ,

where is statistical distance; equivalently, the statistical distance between and a uniform element of , averaged over , is at least — IL89. The inverter receives , as in ; without it a constant qualifies, since an inverter given only runs in time polynomial in and cannot output bits — standard. Every one-way function is distributionally one-way — folklore; conversely, distributional one-way functions yield one-way functions — IL89.

Sub-exponential one-wayness

A hash function is sub-exponentially one-way if there is a constant such that for all sufficiently large , every adversary of size at most has .

Size-verifiable one-wayness

A one-way function is size-verifiable if the preimage-size problem lies in — AGGM06, BB15. It is approximately size-verifiable, a weaker condition, if the promise problem with yes-instances such that and no-instances such that lies in — BB15. A one-way permutation is size-verifiable, since every has exactly one preimage — standard. A size-verifiable one-way function is a one-way function.

Collision resistance

\begin{algorithm}
\algname{Game}
\caption{$\Game^{\mathrm{cr}}_{\hash,\calA}(\secpar)$}
\begin{algorithmic}
\State $k \gets \KeyGen(1^\secpar)$
\State $(\hat{x}_0, \hat{x}_1) \gets \calA(1^\secpar, k)$
\Return $[\hash(k,\hat{x}_0) = \hash(k,\hat{x}_1) \wedge \hat{x}_0 \neq \hat{x}_1]$
\end{algorithmic}
\end{algorithm}

A compressing family with and , , is collision resistant, a collision-resistant hash function (CRHF), if for every efficient

is negligible. Compression is part of the definition because without it the notion is trivial: the identity has no collisions. A family on other finite sets, such as , is read through binary encodings: its inputs are elements of its domain, efficiently indexed by , and its outputs are written as integers below . These fit in bits exactly when , which is then the compression condition; does not suffice.

The family is keyed because a single compressing function has a collision , and the adversary with that pair hard-wired in outputs it in time linear in its length and wins with probability , whether or not anyone can write it down — Rog06. Against uniform adversaries no key is needed: Rog06 defines collision resistance of an unkeyed family indexed by its output length (Section 8), and states results about a single unkeyed function as explicitly given reductions to finding its collisions. TODO: attribute the keyed definition (Dam87 is unread).

Collision resistance requires . Otherwise there is a constant with for infinitely many , and for those the adversary that evaluates on distinct inputs outputs a collision with probability , by pigeonhole, in polynomial time — standard. The generic birthday attack evaluates at about uniform inputs and finds a collision with constant probability (birthday bound) — standard.

The amount of compression is immaterial. For a family and a polynomial , the fixed-length iteration , with and , maps to , and a collision of yields one of at the last step at which the two computations differ in their input — standard (TODO: check whether Dam89 states this case; it is unread). The iteration with a length block extends a CRHF to inputs of every length (Merkle–Damgård iteration).

Collision resistance implies second-preimage resistance and target collision resistance with no loss — RS04; it implies weak one-wayness, and one-wayness when — folklore.

Arbitrary-length collision resistance

An arbitrary-length family has domain and range with , and is computable from in time polynomial in and ; the bound and the uniform sampler of § Syntax are dropped. It is an arbitrary-length CRHF if for all efficient , , defined by above, is negligible. An efficient outputs strings of length polynomial in , so the game asks for collisions of polynomial length only. Its restriction to is a CRHF (Arbitrary-length CRHF ⇒ CRHF) — folklore.

Merkle–Damgård iteration

Let be a keyed family with . Merkle–Damgård strengthening pads to with , where is least such that divides and is the -bit binary encoding. Write with each . With the fixed initial value , the iterated family has the key generation of and

A collision of with yields a collision of under the same key: the collision finder runs the adversary on , evaluates on its two outputs, and returns the inputs of the last compression call at which the two chains differ in their input but agree in their output — Rog06 (Theorem 4). If , this makes an arbitrary-length CRHF whenever is a CRHF, and the fixed-length iteration of § Collision resistance first raises any compression to (CRHF ⇒ arbitrary-length CRHF (Merkle–Damgård)). Merkle and Damgård each showed that a suitable iteration of a collision-resistant function with a fixed domain is collision resistant on an enlarged domain — RS04 (Appendix A). TODO: cite Mer89b and Dam89 directly; both are unread.

The iterated family has the length-extension property: for all , is computed from , , and , without . Since is a multiple of , the padded form of begins with the blocks , so its chain passes through and continues over the blocks of , which depend on only through — standard. It makes the secret-prefix MAC forgeable after one query (No fixed-construction reduction from CRHF to MAC (secret-prefix MAC)).

Second-preimage resistance

\begin{algorithm}
\algname{Game}
\caption{$\Game^{\mathrm{spr}}_{\hash,\calA}(\secpar)$}
\begin{algorithmic}
\State $k \gets \KeyGen(1^\secpar)$ ; $x \getsr \calD$
\State $\hat{x} \gets \calA(1^\secpar, k, x)$
\Return $[\hash(k,\hat{x}) = \hash(k,x) \wedge \hat{x} \neq x]$
\end{algorithmic}
\end{algorithm}

A family that compresses as in the CRHF definition, from to with or on other finite sets through the same binary encodings, is second-preimage resistant if for all efficient ,

is negligible. This is the notion Sec of RS04; in target collision resistance the adversary chooses before the key instead. Without compression the notion is trivial: the identity has no second preimages — RS04. It follows from collision resistance and from target collision resistance with no loss, and it implies weak one-wayness, with an additive loss of and a factor — RS04.

Length-halving second-preimage resistance

A length-halving second-preimage-resistant family is a second-preimage-resistant family , for a polynomially bounded computable from in polynomial time; it compresses since , and the computability of gives the uniform sampler of § Syntax. As an object, length-halving second-preimage resistance denotes such a family for some such . It meets the definition above with input length (Length-halving second-preimage resistance ⇒ Second-preimage resistance) — folklore, and restricting an arbitrary-length CRHF with range to gives one with no loss (Arbitrary-length CRHF ⇒ Length-halving second-preimage resistance) — RS04. An input is the concatenation of two outputs, which is how a hash tree hashes the two children of a node: the function of XMSS maps -byte strings to -byte strings under -byte keys — HBG+18 (Section 4.1.2).

Second-preimage resistance forces . For each key, two independent uniform inputs have the same image with probability at least , by the Cauchy–Schwarz inequality, and are equal with probability , so the adversary that outputs a uniform wins with probability at least . If , there is a constant with for infinitely many , and for those this is at least , so the advantage is not negligible — standard.

Same-width SPR hash and PRF

A same-width SPR hash and PRF is a pair of a length-halving second-preimage-resistant family and a compression-function PRF with and key generation uniform on , for one polynomially bounded and a polynomially bounded , both computable from in polynomial time. As an object, it denotes such a pair for some such . A length-halving family of width and a compression-function PRF of width each meet their own definitions, but a tree that hashes pairs of -bit PRF outputs with a function on -bit inputs is not defined. For and , two -bit values give bits where the hash takes — standard. Each component meets its own definition (Same-width SPR hash and PRF ⇒ Length-halving second-preimage resistance, Same-width SPR hash and PRF ⇒ Compression-function PRF) — folklore. XMSS uses its keyed functions at one width (SPR hash + PRF ⇒ Stateful DS (XMSS)) — HBG+18 (Sections 3.1.1.1, 3.1.2 and 4.1.2).

Target collision resistance (universal one-wayness)

The adversary commits to a target input before the key is sampled, then must find a second input colliding with it.

\begin{algorithm}
\algname{Game}
\caption{$\Game^{\mathrm{tcr}}_{\hash,\calA}(\secpar)$}
\begin{algorithmic}
\State $(x, \st) \gets \calA_1(1^\secpar)$
\Comment{$\calA_1$ outputs $x \in \calD$ before seeing the key}
\State $k \gets \KeyGen(1^\secpar)$
\State $\hat{x} \gets \calA_2(\st, k)$
\Return $[\hash(k,\hat{x}) = \hash(k,x) \wedge \hat{x} \neq x]$
\end{algorithmic}
\end{algorithm}

A family that compresses as in the CRHF definition, from to with or on other finite sets through the same binary encodings, is a universal one-way hash function (UOWHF), or target collision resistant, if for all efficient ,

is negligible — NY89. Collision resistance implies target collision resistance — RS04. As for CRHFs, does not suffice. Take and the fixed for , key a uniform pair of distinct elements of , and let be the order-preserving bijection, for and for . The map with and for has as its only collision, so it is target collision resistant with no assumption: the committed target lies in with probability exactly — standard.

Weak collision resistance

The key is secret: the adversary sees only through an oracle.

\begin{algorithm}
\algname{Game}
\caption{$\Game^{\mathrm{wcr}}_{\hash,\calA}(\secpar)$}
\begin{algorithmic}
\State $k \gets \KeyGen(1^\secpar)$
\State $\calO(x) := \hash(k, x)$
\State $(\hat{x}_0, \hat{x}_1) \gets \calA^{\calO}(1^\secpar)$
\Comment{$\calA$ never sees $k$}
\Return $[\hash(k,\hat{x}_0) = \hash(k,\hat{x}_1) \wedge \hat{x}_0 \neq \hat{x}_1]$
\end{algorithmic}
\end{algorithm}

A family that is either compressing, as in the CRHF definition, or arbitrary-length, with , is weakly collision resistant if for all efficient ,

is negligible. BCK96 (Definition 3.1) give the notion in concrete form, for an iterated hash function keyed by a secret initial value, against adversaries bounded in time and in the number and length of their queries, and note that it is weaker than collision resistance. An adversary given answers the oracle queries itself, so every CRHF is weakly collision resistant — folklore. Weak collision resistance fails for MD5 and SHA-1 as iterated hash functions keyed by their initial value — Bel06. RS04 list “weak collision resistance” as Merkle’s name for second-preimage resistance, a different notion.

Arbitrary-length weak collision resistance

An arbitrary-length weakly collision-resistant family is an arbitrary-length family that is weakly collision resistant, the second case of the definition above; an efficient queries and outputs strings of polynomial length only. As an object, an arbitrary-length weakly collision-resistant hash denotes such a family. It is one of the families the definition above admits (Arbitrary-length weakly collision-resistant hash ⇒ Weakly collision-resistant hash) — folklore, and an adversary given answers the oracle queries itself, so every arbitrary-length CRHF is one (Arbitrary-length CRHF ⇒ Arbitrary-length weakly collision-resistant hash) — folklore. NMAC is a MAC on if its outer compression function, keyed by its chaining input, is a MAC on its fixed input length and its inner keyed iteration, a family on , is weakly collision resistant (Fixed-length SUF-CMA MAC + arbitrary-length weakly collision-resistant hash ⇒ arbitrary-length SUF-CMA MAC (NMAC)) — BCK96 (Theorem 4.1).

Distributional collision resistance

TODO: definition and game.

Other results

Unknown results

Participates in

Builds on Hash function

Produces Hash function

Barriers