Documentation

CslibFrontier.Crypto.Computational.LubyRackoff

The Luby–Rackoff block ciphers from a pseudorandom function #

From a keyed family family with n-bit keys, inputs and outputs, the Luby–Rackoff cipher lubyRackoffCipher ([BS23], Section 4.5) has 3 * n-bit keys k₁ ++ k₂ ++ k₃ and 2 * n-bit blocks u ++ v. Encryption computes three Feistel rounds w = u ⊕ F(k₁, v), x = v ⊕ F(k₂, w), y = w ⊕ F(k₃, x) and outputs x ++ y; decryption runs the rounds backwards.

Luby–Rackoff theorem ([BS23], Theorem 4.9): if family is a pseudorandom function, the Luby–Rackoff cipher is a pseudorandom permutation (PseudorandomFunction.prp_lubyRackoffCipher). The proof follows the textbook. The 3-wise parallel composition of the PRF (PseudorandomFunction.multiKey_constantCount) replaces the three keyed rounds with independent random functions. The adapter lubyRackoffAdversary turns a block-cipher adversary into a three-channel one, which costs one oracle-PPT reduction (isOraclePPT_lubyRackoffAdversary). With random rounds, the information-theoretic bound LubyRackoff.advantage_feistel3RandomRoundsGame_idealPermGame_le compares the network with a uniform permutation of 2 * n-bit blocks for deterministic adversaries; fixing the private coins of the adversary (ProbOracleComp.coinLaw) transfers it to randomized ones (advantage_lubyRackoffRandomRounds_prpIdealGame_le).

Four rounds ([LR88]; [KL20], Section 8.6): the four-round cipher lubyRackoff4Cipher (keys k₁ ++ k₂ ++ k₃ ++ k₄) is a strong pseudorandom permutation, secure against adversaries that may also decrypt (PseudorandomFunction.strongPRP_lubyRackoff4Cipher); strongly secure block ciphers are [BS23], Section 4.1.3 and Exercise 4.9. The proof has the same structure, with the bidirectional adapter strongLubyRackoffAdversary, four PRF channels and the finite-group bound LubyRackoff.advantage_feistel4StrongRandomRoundsGame_idealStrongGame_le.

Main definitions #

Main results #

References #

Feistel networks on words #

One Feistel round a ++ b ↦ b ++ (a ⊕ g b) on a word with n-bit halves.

The inverse Feistel round c ++ d ↦ (d ⊕ g c) ++ c on a word with n-bit halves.

Feistel rounds with the round oracles gs, applied in order.

Inverse Feistel rounds with the round oracles gs, applied in reverse order.

The cipher #

def Cslib.Crypto.lubyRackoffEncrypt (family : List Bool → List Bool → List Bool) (n : ℕ) (key : List Bool) :

Luby–Rackoff encryption of a block u ++ v under a key k₁ ++ k₂ ++ k₃ ([BS23], Section 4.5): three Feistel rounds keyed by the blocks of the key.

def Cslib.Crypto.lubyRackoffDecrypt (family : List Bool → List Bool → List Bool) (n : ℕ) (key : List Bool) :

Luby–Rackoff decryption of a block x ++ y under a key k₁ ++ k₂ ++ k₃ ([BS23], Section 4.5).

The three-round Luby–Rackoff block cipher with 3 * n-bit keys and 2 * n-bit blocks, built from a length-preserving keyed family computable in polynomial time ([BS23], Section 4.5).

Feistel rounds through PRF channels #

One Feistel round on a word with n-bit halves, reading the round function from channel i. The reply is cut at n bits, which changes nothing for replies of the declared length.

One inverse Feistel round on a word with n-bit halves, reading the round function from channel i.

Feistel rounds reading the round functions from the channels rounds, in order.

Inverse Feistel rounds reading the round functions from the channels rounds, in reverse order.

The reduction to three PRF keys #

Answer one block query through three PRF channels, which provide the three Feistel rounds. Malformed blocks are answered with [] without querying.

Run a block-cipher adversary against three PRF channels, answering each block query with lubyRackoffQuery.

The adapter is oracle PPT for every oracle-PPT block-cipher adversary.

theorem Cslib.Crypto.eval_prpRealGame_lubyRackoffCipher {family : List Bool → List Bool → List Bool} (hfamily : PseudorandomFunction family) (adversary : OracleDistinguisher) (n : ℕ) :
((lubyRackoffCipher family ⋯ ⋯).prpRealGame adversary n).eval = (prfMultiRealGame family 3 (lubyRackoffAdversary adversary) n).eval

The real chosen-plaintext experiment of the Luby–Rackoff cipher is the real three-key experiment of the adapter.

Random rounds against a random permutation #

Pairs of n-bit halves as their 2 * n-bit blocks on the single word channel: the pair (u, v) travels as the block u ++ v, and a request of another length carries no query.

theorem Cslib.Crypto.interpret_prfMultiReduction_lubyRackoffAdversary {family : List Bool → List Bool → List Bool} (hlength : ∀ (key query : List Bool), query.length = key.length → (family key query).length = key.length) (j n : ℕ) (adversary : OracleDistinguisher) (T : BitString n → BitString n) :

The word reduction for three rounds is the finite one. For a length-preserving family and every table T on n-bit strings, presented on the word channel as randomFunctionOracle n T, the j-th hybrid reduction of the three-key adapter lubyRackoffAdversary adversary has the law of the finite reduction LubyRackoff.feistel3Reduction of PRF.atLevel family n on the adversary adapted along pairCodec n, run against T. As for interpret_prfMultiReduction_eq_multiKeyReduction, both PRF games run the word reduction against such a table: prfIdealGame against a uniform one, prfRealGame against PRF.atLevel family n key for a uniform key.

theorem Cslib.Crypto.advantage_lubyRackoffRandomRounds_prpIdealGame_le (adversary : OracleDistinguisher) (n Q : ℕ) (hQ : ProbOracleComp.IsQueryBounded (adversary n []) Q) :
↑(Game.advantage (prfMultiIdealGame 3 (lubyRackoffAdversary adversary) n).eval (prpIdealGame (fun (n : ℕ) => 2 * n) adversary n).eval) ≤ 2 * ↑(Q.choose 2) * (2 ^ n)⁻¹ + ↑(Q.choose 2) * (2 ^ n)⁻¹ ^ 2

Three random Feistel rounds against a random permutation, for randomized word-oracle adversaries ([BS23], proof of Theorem 4.9): with independent uniform random round functions, a Q-query adversary distinguishes the adapter's three-key ideal game from a uniform permutation of 2 * n-bit blocks with advantage at most 2 * Q.choose 2 / 2 ^ n + Q.choose 2 / 4 ^ n.

The Luby–Rackoff theorem ([BS23], Theorem 4.9; [LR88]): the three-round Luby–Rackoff cipher built from a pseudorandom function is a pseudorandom permutation against oracle-PPT distinguishers.

Four rounds: a strong pseudorandom permutation #

Four-round Luby–Rackoff encryption of a block under a key k₁ ++ k₂ ++ k₃ ++ k₄.

Four-round Luby–Rackoff decryption of a block under a key k₁ ++ k₂ ++ k₃ ++ k₄.

The four-round Luby–Rackoff block cipher with 4 * n-bit keys and 2 * n-bit blocks, built from a length-preserving keyed family computable in polynomial time ([LR88]).

The reduction to four PRF keys #

Answer one forward (false) or inverse (true) block query through four PRF channels, which provide the four Feistel rounds. Malformed blocks are answered with [] without querying.

Run a bidirectional block-cipher adversary against four PRF channels, answering each query with strongLubyRackoffQuery.

The bidirectional adapter is oracle PPT for every oracle-PPT adversary.

The real chosen-ciphertext experiment of the four-round cipher is the real four-key experiment of the bidirectional adapter.

Four random rounds against a random permutation, in both directions #

Bidirectional queries on pairs of n-bit halves on the word channels: a forward query (u, v) travels on channel false and an inverse query on channel true, each as the block u ++ v.

The word reduction for four rounds is the finite one. For a length-preserving family and every table T on n-bit strings, presented on the word channel as randomFunctionOracle n T, the j-th hybrid reduction of the bidirectional adapter strongLubyRackoffAdversary adversary has the law of the finite reduction LubyRackoff.feistel4StrongReduction of PRF.atLevel family n on the adversary adapted along strongPermCodec n, run against T. As for interpret_prfMultiReduction_eq_multiKeyReduction, both PRF games run the word reduction against such a table: prfIdealGame against a uniform one, prfRealGame against PRF.atLevel family n key for a uniform key.

theorem Cslib.Crypto.advantage_lubyRackoff4RandomRounds_strongPRPIdealGame_le (adversary : StrongPRPDistinguisher) (n Q : ℕ) (hQ : ProbOracleComp.IsQueryBounded (adversary n []) Q) :
↑(Game.advantage (prfMultiIdealGame 4 (strongLubyRackoffAdversary adversary) n).eval (strongPRPIdealGame (fun (n : ℕ) => 2 * n) adversary n).eval) ≤ 2 * ↑(Q.choose 2) * (2 ^ n)⁻¹ + 2 * ↑(Q.choose 2) * (2 ^ n)⁻¹ ^ 2

Four random Feistel rounds against a random permutation, in both directions ([LR88]), for randomized bidirectional word-oracle adversaries: with independent uniform random round functions, a Q-query adversary distinguishes the adapter's four-key ideal game from a uniform permutation of 2 * n-bit blocks with advantage at most 2 * Q.choose 2 / 2 ^ n + 2 * Q.choose 2 / 4 ^ n.

Four-round Luby–Rackoff theorem ([LR88]; [KL20], Section 8.6; strongly secure block ciphers as in [BS23], Section 4.1.3 and Exercise 4.9): the four-round Luby–Rackoff cipher built from a pseudorandom function is a strong pseudorandom permutation against oracle-PPT distinguishers.

The four-round Luby–Rackoff cipher is in particular a pseudorandom permutation.