Post · 9 min read· pp. 560–564

CS276 Lecture 15: Pseudorandom Permutations

Scribed by Siu-Man Chan

Summary

Given one way permutations (of which discrete logarithm is a candidate), we know how to construct pseudorandom functions. Today, we are going to construct pseudorandom permutations (block ciphers) from pseudorandom functions.

1. Pseudorandom Permutations

Recall that a pseudorandom function F{F} is an efficient function  ⁣:{0,1}k×{0,1}n→{0,1}n{\colon\{0,1\}^k\times\{0,1\}^n\rightarrow\{0,1\}^n}, such that every efficient algorithm A{A} cannot distinguish well FK(⋅){F_K(\cdot)} from R(⋅){R(\cdot)}, for a randomly chosen key K∈{0,1}k{K\in\{0,1\}^k} and a random function R ⁣:{0,1}n→{0,1}n{R\colon\{0,1\}^n\rightarrow \{0,1\}^n}. That is, we want that AFK(⋅){A^{F_K(\cdot)}} behaves like AR(⋅){A^{R(\cdot)}}.

 (image unavailable)

A pseudorandom permutation P{P} is an efficient function  ⁣:{0,1}k×{0,1}n→{0,1}n{\colon\{0,1\}^k\times \{0,1\}^n\rightarrow\{0,1\}^n}, such that for every key K{K}, the function PK{P_K} mapping x↦PK(x){x\mapsto P_K(x)} is a bijection. Moreover, we assume that given K{K}, the mapping x↦PK(x){x\mapsto P_K(x)} is efficiently invertible (i.e. PK−1{P_K^{-1}} is efficient). The security of P{P} states that every efficient algorithm A{A} cannot distinguish well ⟨PK(⋅),PK−1(⋅)⟩{\langle P_K(\cdot), P_K^{-1}(\cdot)\rangle} from ⟨Π(⋅),Π−1(⋅)⟩{\langle \Pi(\cdot), \Pi^{-1}(\cdot)\rangle}, for a randomly chosen key K∈{0,1}k{K\in\{0,1\}^k} and a random permutation Π ⁣:{0,1}n→{0,1}n{\Pi\colon\{0,1\}^n\rightarrow\{0,1\}^n}. That is, we want that APK(⋅),PK−1(⋅){A^{P_K(\cdot),P_K^{-1}(\cdot)}} behaves like AΠ(⋅),Π−1(⋅){A^{\Pi(\cdot),\Pi^{-1}(\cdot)}}.

 (image unavailable)

We note that the algorithm A{A} is given access to both an oracle and its (supposed) inverse.

2. Feistel Permutations

Given any function F ⁣:{0,1}m→{0,1}m{F\colon\{0,1\}^m\rightarrow\{0,1\}^m}, we can construct a permutation DF ⁣:{0,1}2m→{0,1}2m{D_F\colon\{0,1\}^{2m}\rightarrow\{0,1\}^{2m}} using a technique named after Horst Feistel. The definition of DF{D_F} is given by

DF(x,y):=y,F(y)⊕x,     (1)\displaystyle D_F(x,y)\mathrel{:}= y,F(y)\oplus x, \ \ \ \ \ (1)

where x{x} and y{y} are m{m}-bit strings. Note that this is an injective (and hence bijective) function, because its inverse is given by

DF−1(z,w):=F(z)⊕w,z.     (2)\displaystyle D_F^{-1}(z,w)\mathrel{:}= F(z)\oplus w, z. \ \ \ \ \ (2)

 (image unavailable)

Also, note that DF{D_F} and DF−1{D^{-1}_F} are efficiently computable given F{F}.

However, DF{D_F} needs not be a pseudorandom permutation even if F{F} is a pseudorandom function, because the output of DF(x,y){D_F(x,y)} must contain y{y}, which is extremely unlikely for a truly random permutation.

To avoid the above pitfall, we may want to repeat the construction twice. We pick two independent random keys K1{K_1} and K2{K_2}, and compose the permutations P(⋅):=DFK2(DFK1(⋅)){P(\cdot)\mathrel{:}= D_{F_{K_2}}(D_{F_{K_1}}(\cdot))}.

 (image unavailable)

Indeed, the output does not always contain part of the input. However, this construction is still insecure, no matter whether F{F} is pseudorandom or not, as the following example shows.

 (image unavailable)

Here, 0‾{\overline0} denotes the all-zero string of length m{m}, 1‾{\overline1} denotes the all-one string of length m{m}, and F(⋅){F(\cdot)} is FK1(⋅){F_{K_1}(\cdot)}. This shows that, restricting to the first half, P(0‾0‾){P(\overline0\overline0)} is the complement of P(1‾0‾){P(\overline1\overline0)}, regardless of F{F}.

What happens if we repeat the construction three times? We still do not get a pseudorandom permutation.

Exercise 1 (Not Easy) Show that there is an efficient oracle algorithm A{A} such that

*

PΠ:{0,1}2m→{0,1}2m[AΠ,Π−1=1]=2−Ω(m)\displaystyle \mathop{\mathbb P}_{\Pi : \{ 0,1 \}^{2m} \rightarrow \{ 0,1 \}^{2m} } [ A^{\Pi,\Pi^{-1} } = 1] = 2^{-\Omega(m) }

where Π{\Pi} is a random permutation, but for every three functions F1,F2,F3{F_1,F_2,F_3}, if we define P(x):=DF3(DF2(DF1(x))){P(x) := D_{F_3} (D_{F_2} ( D_{F_1} (x )))} we have

AP,P−1=1\displaystyle A^{P,P^{-1} } = 1
*

Finally, however, if we repeat the construction four times, with four independent pseudorandom functions, we get a pseudorandom permutation.

3. The Luby-Rackoff Construction

Let F:{0,1}k×{0,1}m→{0,1}m{F: \{ 0,1 \}^k \times \{ 0,1 \}^m \rightarrow \{ 0,1 \}^m} be a pseudorandom function, we define the following function P:{0,1}4k×{0,1}2m→{0,1}2m{P: \{ 0,1 \}^{4k} \times \{ 0,1 \}^{2m} \rightarrow \{ 0,1 \}^{2m}}: given a key K‾=⟨K1,…,K4⟩{\overline K=\langle K_1,\dotsc,K_4\rangle} and an input x{x},

PK‾(x):=DFK4(DFK3(DFK2(DFK1(x)))).     (3)\displaystyle P_{\overline K}(x)\mathrel{:}= D_{F_{K_4}}(D_{F_{K_3}}(D_{F_{K_2}}(D_{F_{K_1}}(x)))). \ \ \ \ \ (3)

 (image unavailable)

It is easy to construct the inverse permutation by composing their inverses backwards.

Theorem 1 (Pseudorandom Permutations from Pseudorandom Functions) If F{F} is a (O(tr),ϵ){(O(tr),\epsilon)}-secure pseudorandom function computable in time r{r}, then P{P} is a (t,4ϵ+t2⋅2−m+t2⋅2−2m){(t, 4\epsilon + t^2 \cdot 2^{-m} + t^2 \cdot 2^{-2m} )} secure pseudorandom permutation.

4. Analysis of the Luby-Rackoff Construction

Given four random functions R‾=⟨R1,…,R4⟩{\overline R = \langle R_1,\ldots,R_4\rangle}, Ri:{0,1}m→{0,1}m{R_i: \{ 0,1 \}^m \rightarrow \{ 0,1 \}^m}, let PR‾{P_{\overline R}} be the analog of Construction (3) using the random function Ri{R_i} instead of the pseudorandom functions FKi{F_{K_i}},

PR‾(x)=DR4(DR3(DR2(DR1(x))))     (4)\displaystyle P_{\overline{R}} (x) = D_{{R_4}} ( D_{{R_3}} ( D_{{R_2}} (D_{{R_1}} (x )))) \ \ \ \ \ (4)

We prove Theorem 1 by showing that

  1. PK‾{P_{\overline K}} is indistinguishable from PR‾{P_{\overline R}} or else we can break the pseudorandom function
  2. PR‾{P_{\overline R}} is indistinguishable from a random permutation

The first part is given by the following lemma, which we prove via a standard hybrid argument.

Lemma 2 If F{F} is a (O(tr),ϵ){(O(tr),\epsilon)}-secure pseudorandom function computable in time r{r}, then for every algorithm A{A} of complexity ≤t{\leq t} we have

∣PK‾[APK‾,PK‾−1()=1]     (5)\displaystyle \left | \mathop{\mathbb P}_{\overline {K} } [ A^{P_{\overline{K}}, P^{-1} _{\overline{K}} } () =1 ] \right. \ \ \ \ \ (5)

And the second part is given by the following lemma:

Lemma 3 For every algorithm A{A} of complexity ≤t{\leq t} we have

∣PR‾[APR‾,PR‾−1()=1]−PΠ[AΠ,Π−1()=1]∣≤t222m+t22m\displaystyle \left| \mathop{\mathbb P}_{\overline {R} } [ A^{P_{\overline{R}}, P^{-1} _{\overline{R}} } () =1 ] - \mathop{\mathbb P}_{\Pi} [ A^{\Pi, \Pi^{-1} } () = 1] \right| \leq \frac{t^2}{ 2^{2m}} + \frac {t^2}{ 2^{m}}

where Π:{0,1}2m→{0,1}2m{\Pi : \{ 0,1 \}^{2m} \rightarrow \{ 0,1 \}^{2m}} is a random permutation.

We now prove Lemma 2 using a hybrid argument.

Proof: Consider the following five algorithms from {0,1}2m{\{0,1\}^{2m}} to {0,1}2m{\{0,1\}^{2m}}:

  • H0{H_0}: pick random keys K1{K_1}, K2{K_2}, K3{K_3}, K4{K_4}, H0(⋅):=DFK4(DFK3(DFK2(DFK1(⋅))));{H_0(\cdot)\mathrel{:}= D_{F_{K_4}}(D_{F_{K_3}}(D_{F_{K_2}}(D_{F_{K_1}}(\cdot))));}
  • H1{H_1}: pick random keys K2{K_2}, K3{K_3}, K4{K_4} and a random function F1 ⁣:{0,1}m→{0,1}m{F_1\colon\{0,1\}^m\rightarrow\{0,1\}^m}, H1(⋅):=DFK4(DFK3(DFK2(DF1(⋅))));{H_1(\cdot)\mathrel{:}= D_{F_{K_4}}(D_{F_{K_3}}(D_{F_{K_2}}(D_{F_1}(\cdot))));}
  • H2{H_2}: pick random keys K3{K_3}, K4{K_4} and random functions F1,F2 ⁣:{0,1}m→{0,1}m{F_1,F_2\colon\{0,1\}^m\rightarrow\{0,1\}^m}, H2(⋅):=DFK4(DFK3(DF2(DF1(⋅))));{H_2(\cdot)\mathrel{:}= D_{F_{K_4}}(D_{F_{K_3}}(D_{F_2}(D_{F_1}(\cdot))));}
  • H3{H_3}: pick a random key K4{K_4} and random functions F1,F2,F3 ⁣:{0,1}m→{0,1}m{F_1,F_2,F_3\colon\{0,1\}^m\rightarrow\{0,1\}^m}, H3(⋅):=DFK4(DF3(DF2(DF1(⋅))));{H_3(\cdot)\mathrel{:}= D_{F_{K_4}}(D_{F_3}(D_{F_2}(D_{F_1}(\cdot))));}
  • H4{H_4}: pick random functions F1,F2,F3,F4 ⁣:{0,1}m→{0,1}m{F_1,F_2,F_3,F_4 \colon\{0,1\}^m\rightarrow\{0,1\}^m}, H4(⋅):=DF4(DF3(DF2(DF1(⋅)))).{H_4(\cdot)\mathrel{:}= D_{F_4}(D_{F_3}(D_{F_2}(D_{F_1}(\cdot)))).}

Clearly, referring to (5), H0{H_0} gives the first probability of using all pseudorandom functions in the construction, and H4{H_4} gives the second probability of using all completely random functions. By triangle inequality, we know that

∃i∣P[AHi,Hi−1=1]−P[AHi+1,Hi+1−1=1]∣>ϵ.     (6)\displaystyle \exists i\quad\Bigl\lvert\mathop{\mathbb P}[A^{H_i,H_i^{-1}}=1]- \mathop{\mathbb P}[A^{H_{i+1},H_{i+1}^{-1}}=1]\Bigr\rvert>\epsilon. \ \ \ \ \ (6)

We now construct an algorithm A′G(⋅){A'^{G(\cdot)}} of complexity O(tr){O(tr)} that distinguishes whether the oracle G(⋅){G(\cdot)} is FK(⋅){F_K(\cdot)} or a random function R(⋅){R(\cdot)}.

  • The algorithm A′{A'} picks i{i} keys K1,K2,…,Ki{K_1,K_2,\dotsc,K_i} and initialize 4−i−1{4-i-1} data structures Si+2,…,S4{S_{i+2},\dotsc,S_4} to ∅{\emptyset} to store pairs.
  • The algorithm A′{A'} simulates AO,O−1{A^{O,O^{-1}}}. Whenever A{A} queries O{O} (or O−1{O^{-1}}), the simulating algorithm A′{A'} uses the four compositions of Feistel permutations, where
    • On the first i{i} layers, run the pseudorandom function F{F} using the i{i} keys K1,K2,…,Ki{K_1,K_2,\dotsc,K_i};
    • On the i{i}-th layer, run an oracle G{G};
    • On the remaining 4−i−1{4-i-1} layers, simulate a random function: when a new value for x{x} is needed, use fresh randomness to generate the random function at x{x} and store the key-value pair into the appropriate data structure; otherwise, simply return the value stored in the data structure.

When G{G} is FK{F_K}, the algorithm A′G{A'^{G}} behaves like AHi,Hi−1{A^{H_i,H_i^{-1}}}; when G{G} is a random function R{R}, the algorithm A′G{A'^{G}} behaves like AHi+1,Hi+1−1{A^{H_{i+1}, H_{i+1}^{-1}}}. Rewriting (6),

∣PK[A′FK(⋅)=1]−PR[A′R(⋅)=1]∣>ϵ,\displaystyle \Bigl\lvert\mathop{\mathbb P}_K[A'^{F_K(\cdot)}=1]-\mathop{\mathbb P}_R[A'^{R(\cdot)}=1] \Bigr\rvert>\epsilon,

and F{F} is not (O(tr),ϵ){(O(tr),\epsilon)}-secure. □\Box

We say that an algorithm A{A} is non-repeating if it never makes an oracle query to which it knows the answer. (That is, if A{A} is interacting with oracles g,g−1{g,g^{-1}} for some permutation g{g}, then A{A} will not ask twice for g(x){g(x)} for the same x{x}, and it will not ask twice for g−1(y){g^{-1}(y)} for the same y{y}; also, after getting the value y=g(x){y=g(x)} in an earlier query, it will not ask for g−1(y){g^{-1} (y)} later, and after getting w=g−1(z){w=g^{-1} (z)} it will not ask for g(w){g(w)} later. )

We shall prove Lemma 3 for non-repeating algorithms. The proof can be extended to arbitrary algorithms with some small changes. Alternatively, we can argue that an arbitrary algorithm can be simulated by a non-repeating algorithm of almost the same complexity in such a way that the algorithm and the simulation have the same output given any oracle permutation.

In order to prove Lemma 3 we introduce one more probabilistic experiment: we consider the probabilistic algorithm S(A){S(A)} that simulates A(){A()} and simulates every oracle query by providing a random answer. (Note that the simulated answers in the computation of SA{SA} may be incompatible with any permutation.)

We first prove the simple fact that S(A){S(A)} is close to simulating what really happen when A{A} interacts with a truly random permutation.

Lemma 4 Let A{A} be a non-repeating algorithm of complexity at most t{t}. Then

∣P[S(A)=1]−PΠ[AΠ,Π−1()=1]∣≤t22⋅22m     (7)\displaystyle \left| \mathop{\mathbb P} [ S(A) =1 ] - \mathop{\mathbb P}_{\Pi} [ A^{\Pi, \Pi^{-1} } () = 1] \right| \leq \frac{t^2}{ 2 \cdot 2^{2m}} \ \ \ \ \ (7)

where Π:{0,1}2m→{0,1}2m{\Pi : \{ 0,1 \}^{2m} \rightarrow \{ 0,1 \}^{2m}} is a random permutation.

Finally, it remains to prove:

Lemma 5 For every non-repating algorithm A{A} of complexity ≤t{\leq t} we have

∣PR‾[APR‾,PR‾−1()=1]−P[S(A)=1]∣≤t22⋅22m+t22m\displaystyle \left| \mathop{\mathbb P}_{\overline {R} } [ A^{P_{\overline{R}}, P^{-1} _{\overline{R}} } () =1 ] - \mathop{\mathbb P} [ S(A) = 1] \right| \leq \frac{t^2}{ 2\cdot 2^{2m}} + \frac {t^2}{ 2^{m}}

It is clear that Lemma 3 follows Lemma 4 and Lemma 5.

We now prove Lemma 4.

∣P[S(A)=1]−PΠ[AΠ,Π−1()=1]∣⩽P[\mboxwhensimulatingS\mbox,getanswersinconsistentwithanypermutation]⩽122m(1+2+⋯+t−1)=(t2)122m⩽t22⋅22m.\displaystyle \begin{array}{rcl} && \left| \mathop{\mathbb P} [ S(A) =1 ] - \mathop{\mathbb P}_{\Pi} [ A^{\Pi, \Pi^{-1} } () = 1] \right| \\ &\leqslant & \mathop{\mathbb P}[\mbox{when simulating }S \mbox{, get answers inconsistent with any permutation}]\\ &\leqslant & \frac1{2^{2m}}(1+2+\cdots+t-1)\\ &= & \binom t2\frac1{2^{2m}}\\ &\leqslant & \frac{t^2}{2\cdot2^{2m}}. \end{array}

We shall prove Lemma 5 next time.