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 is an efficient function :{0,1}k×{0,1}n→{0,1}n, such that every efficient algorithm A cannot distinguish well FK(⋅) from R(⋅), for a randomly chosen key K∈{0,1}k and a random function R:{0,1}n→{0,1}n. That is, we want that AFK(⋅) behaves like AR(⋅).
A pseudorandom permutation P is an efficient function :{0,1}k×{0,1}n→{0,1}n, such that for every key K, the function PK mapping x↦PK(x) is a bijection. Moreover, we assume that given K, the mapping x↦PK(x) is efficiently invertible (i.e. PK−1 is efficient). The security of P states that every efficient algorithm A cannot distinguish well ⟨PK(⋅),PK−1(⋅)⟩ from ⟨Π(⋅),Π−1(⋅)⟩, for a randomly chosen key K∈{0,1}k and a random permutationΠ:{0,1}n→{0,1}n. That is, we want that APK(⋅),PK−1(⋅) behaves like AΠ(⋅),Π−1(⋅).
We note that the algorithm 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, we can construct a permutation DF:{0,1}2m→{0,1}2m using a technique named after Horst Feistel. The definition of DF is given by
DF(x,y):=y,F(y)⊕x,(1)
where x and y are 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)
Also, note that DF and DF−1 are efficiently computable given F.
However, DF needs not be a pseudorandom permutation even if F is a pseudorandom function, because the output of DF(x,y) must contain 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 and K2, and compose the permutations P(⋅):=DFK2(DFK1(⋅)).
Indeed, the output does not always contain part of the input. However, this construction is still insecure, no matter whether F is pseudorandom or not, as the following example shows.
Here, 0 denotes the all-zero string of length m, 1 denotes the all-one string of length m, and F(⋅) is FK1(⋅). This shows that, restricting to the first half, P(00) is the complement of P(10), regardless of 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 such that
*
PΠ:{0,1}2m→{0,1}2m[AΠ,Π−1=1]=2−Ω(m)
where Π is a random permutation, but for every three functions F1,F2,F3, if we define P(x):=DF3(DF2(DF1(x))) we have
AP,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 be a pseudorandom function, we define the following function P:{0,1}4k×{0,1}2m→{0,1}2m: given a key K=⟨K1,…,K4⟩ and an input x,
PK(x):=DFK4(DFK3(DFK2(DFK1(x)))).(3)
It is easy to construct the inverse permutation by composing their inverses backwards.
Theorem 1 (Pseudorandom Permutations from Pseudorandom Functions) If F is a (O(tr),ϵ)-secure pseudorandom function computable in time r, then P is a (t,4ϵ+t2⋅2−m+t2⋅2−2m) secure pseudorandom permutation.
4. Analysis of the Luby-Rackoff Construction
Given four random functions R=⟨R1,…,R4⟩, Ri:{0,1}m→{0,1}m, let PR be the analog of Construction (3) using the random function Ri instead of the pseudorandom functions FKi,
Proof: Consider the following five algorithms from {0,1}2m to {0,1}2m:
H0: pick random keys K1, K2, K3, K4,
H0(⋅):=DFK4(DFK3(DFK2(DFK1(⋅))));
H1: pick random keys K2, K3, K4 and a random function F1:{0,1}m→{0,1}m,
H1(⋅):=DFK4(DFK3(DFK2(DF1(⋅))));
H2: pick random keys K3, K4 and random functions F1,F2:{0,1}m→{0,1}m,
H2(⋅):=DFK4(DFK3(DF2(DF1(⋅))));
H3: pick a random key K4 and random functions F1,F2,F3:{0,1}m→{0,1}m,
H3(⋅):=DFK4(DF3(DF2(DF1(⋅))));
H4: pick random functions F1,F2,F3,F4:{0,1}m→{0,1}m,
H4(⋅):=DF4(DF3(DF2(DF1(⋅)))).
Clearly, referring to (5), H0 gives the first probability of using all pseudorandom functions in the construction, and H4 gives the second probability of using all completely random functions. By triangle inequality, we know that
∃iP[AHi,Hi−1=1]−P[AHi+1,Hi+1−1=1]>ϵ.(6)
We now construct an algorithm A′G(⋅) of complexity O(tr) that distinguishes whether the oracle G(⋅) is FK(⋅) or a random function R(⋅).
The algorithm A′ picks i keys K1,K2,…,Ki and initialize 4−i−1 data structures Si+2,…,S4 to ∅ to store pairs.
The algorithm A′ simulates AO,O−1. Whenever A queries O (or O−1), the simulating algorithm A′ uses the four compositions of Feistel permutations, where
On the first i layers, run the pseudorandom function F using the i keys K1,K2,…,Ki;
On the i-th layer, run an oracle G;
On the remaining 4−i−1 layers, simulate a random function: when a new value for x is needed, use fresh randomness to generate the random function at x and store the key-value pair into the appropriate data structure; otherwise, simply return the value stored in the data structure.
When G is FK, the algorithm A′G behaves like AHi,Hi−1; when G is a random function R, the algorithm A′G behaves like AHi+1,Hi+1−1. Rewriting (6),
PK[A′FK(⋅)=1]−PR[A′R(⋅)=1]>ϵ,
and F is not (O(tr),ϵ)-secure. □
We say that an algorithm A is non-repeating if it never makes an oracle query to which it knows the answer. (That is, if A is interacting with oracles g,g−1 for some permutation g, then A will not ask twice for g(x) for the same x, and it will not ask twice for g−1(y) for the same y; also, after getting the value y=g(x) in an earlier query, it will not ask for g−1(y) later, and after getting w=g−1(z) it will not ask for 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) that simulates A() and simulates every oracle query by providing a random answer. (Note that the simulated answers in the computation of SA may be incompatible with any permutation.)
We first prove the simple fact that S(A) is close to simulating what really happen when A interacts with a truly random permutation.
Lemma 4 Let A be a non-repeating algorithm of complexity at most t. Then
P[S(A)=1]−PΠ[AΠ,Π−1()=1]≤2⋅22mt2(7)
where Π:{0,1}2m→{0,1}2m is a random permutation.
Finally, it remains to prove:
Lemma 5 For every non-repating algorithm A of complexity ≤t we have
PR[APR,PR−1()=1]−P[S(A)=1]≤2⋅22mt2+2mt2
It is clear that Lemma 3 follows Lemma 4 and Lemma 5.