Uniform computational block ciphers and pseudorandom permutations #
A BlockCipher ([BS23], Section 4.1, interpreted asymptotically as in Sections 2.3 and
4.1.5) has
polynomial-time key- and block-length schedules keyLen, blockLen : ℕ → ℕ and deterministic
polynomial-time algorithms encrypt n key block and decrypt n key block that receive the unary
security parameter n. On every keyLen n-bit key they preserve blockLen n-bit blocks and invert
one another, so each valid key induces a permutation BlockCipher.permEquiv of
BitString (blockLen n).
There are two adaptive security notions against uniform IsOraclePPT encBool distinguishers:
- Pseudorandom permutation (
BlockCipher.PRP, chosen-plaintext): anOracleDistinguisherqueries encryption onblockLen n-bit words (other words are answered with[]) and cannot tell a uniformly keyed cipher (BlockCipher.prpRealGame) from a uniformly random permutation ofBitString (blockLen n)(prpIdealGame); this is [BS23], Attack Game 4.1 and Definition 4.1. - Strong pseudorandom permutation (
BlockCipher.StrongPRP, chosen-ciphertext): aStrongPRPDistinguisherasks(false, x)for encryption and(true, y)for decryption and cannot tellBlockCipher.strongPRPRealGamefromstrongPRPIdealGame; this is the strongly secure block cipher sketched in [BS23], Section 4.1.3, and left as Exercise 4.9(a).
The ideal-experiment PRP/PRF switching lemma for word-oracle adversaries
(advantage_prpIdealGame_prfIdealGame_le) is the finite switching lemma
PRP.advantage_idealExperiment_prfIdealExperiment_le on blockLen n-bit blocks, applied to the
adversary that reads valid words as blocks (OracleCodec.bitString). Consequently, when
((2 : ℝ≥0) ^ E.blockLen n)⁻¹ is negligible, every block cipher E, with any key length, is a
PRP iff it is a secure PRF: E.prpRealGame is indistinguishable from prfIdealGame E.blockLen E.blockLen (BlockCipher.prp_iff_indistinguishable_prpRealGame_prfIdealGame). When moreover
E.keyLen = id, the PRF side is the library notion PseudorandomFunctionOver E.blockLen E.blockLen (BlockCipher.prp_iff_pseudorandomFunctionOver_of_keyLen_eq_id).
Every StrongPRP is also a PRP (BlockCipher.StrongPRP.prp).
Main definitions #
Cslib.Crypto.StrongPRPDistinguisher: a bidirectional adaptive word-oracle distinguisher.Cslib.Crypto.BlockCipher,Cslib.Crypto.BlockCipher.permEquiv: a uniform deterministic block cipher and the permutation induced by a valid key.Cslib.Crypto.randomPermOracle,Cslib.Crypto.prpIdealGame,Cslib.Crypto.BlockCipher.prpOracle,Cslib.Crypto.BlockCipher.prpRealGame,Cslib.Crypto.BlockCipher.PRP: the chosen-plaintext oracles, games and security notion.Cslib.Crypto.strongRandomPermOracle,Cslib.Crypto.strongPRPIdealGame,Cslib.Crypto.BlockCipher.strongPRPOracle,Cslib.Crypto.BlockCipher.strongPRPRealGame,Cslib.Crypto.BlockCipher.StrongPRP: the chosen-ciphertext oracles, games and security notion.Cslib.Crypto.liftForwardDistinguisher: run a forward distinguisher on the encryption channel.
Main results #
Cslib.Crypto.BlockCipher.prpOracle_eq_randomPermOracle,Cslib.Crypto.BlockCipher.strongPRPOracle_eq_strongRandomPermOracle: a valid key answers as its induced permutation.Cslib.Crypto.BlockCipher.isPPTOn_prpRealGame,Cslib.Crypto.BlockCipher.isPPTOn_strongPRPRealGame: the real experiments are uniformly strict PPT.Cslib.Crypto.isOraclePPT_liftForwardDistinguisher,Cslib.Crypto.BlockCipher.StrongPRP.prp: strong PRP security implies PRP security.Cslib.Crypto.advantage_prpIdealGame_prfIdealGame_le,Cslib.Crypto.indistinguishable_prpIdealGame_prfIdealGame: the ideal-experiment PRP/PRF switching lemma for randomized word-oracle adversaries ([BS23], Attack Game 4.3 and Theorem 4.6).Cslib.Crypto.BlockCipher.prp_iff_indistinguishable_prpRealGame_prfIdealGame: a block cipher with super-polynomial block size is a PRP iff it is a PRF ([BS23], Corollary 4.5).Cslib.Crypto.BlockCipher.prp_iff_pseudorandomFunctionOver_of_keyLen_eq_id: itskeyLen = idcase, with the PRF side stated asPseudorandomFunctionOver.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6: Section 4.1 (printed p. 96), Attack Game 4.1 (p. 97), Definition 4.1 (p. 98), Section 4.1.3 (p. 101), Section 4.1.5 (p. 106) with Section 2.3, Attack Game 4.2 (p. 132), Definition 4.2 (p. 133), Attack Game 4.3 and Theorem 4.6 (p. 135), Corollary 4.5 (p. 135) and Exercise 4.9 (p. 169).
An adaptive test with a unary parameter, an auxiliary word and a bidirectional word channel:
(false, x) asks for encryption of x and (true, y) asks for decryption of y.
A uniform deterministic block cipher ([BS23], Section 4.1, interpreted
asymptotically as in Section 4.1.5). Both algorithms receive the unary security parameter n.
Lengths and inversion are required only for keys of length keyLen n and blocks of length
blockLen n.
Key length at security parameter
n.Block length at security parameter
n.- keyLen_polyTime : Turing.MultiTapeTM.ComputableInPolyTime self.keyLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary
The key length is computable in polynomial time in unary.
- blockLen_polyTime : Turing.MultiTapeTM.ComputableInPolyTime self.blockLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary
The block length is computable in polynomial time in unary.
Encryption
(n, key, block) ↦ ciphertext.Decryption
(n, key, ciphertext) ↦ block.- encrypt_polyTime : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × List Bool) => match x with | (n, key, block) => self.encrypt n key block) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits)) Turing.MultiTapeTM.encBits
One deterministic machine computes encryption.
- decrypt_polyTime : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × List Bool) => match x with | (n, key, block) => self.decrypt n key block) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits)) Turing.MultiTapeTM.encBits
One deterministic machine computes decryption.
- length_encrypt (n : ℕ) (key block : List Bool) : key.length = self.keyLen n → block.length = self.blockLen n → (self.encrypt n key block).length = self.blockLen n
Encryption preserves the block length on valid inputs.
- length_decrypt (n : ℕ) (key block : List Bool) : key.length = self.keyLen n → block.length = self.blockLen n → (self.decrypt n key block).length = self.blockLen n
Decryption preserves the block length on valid inputs.
- decrypt_encrypt (n : ℕ) (key block : List Bool) : key.length = self.keyLen n → block.length = self.blockLen n → self.decrypt n key (self.encrypt n key block) = block
Decryption inverts encryption on valid inputs.
- encrypt_decrypt (n : ℕ) (key block : List Bool) : key.length = self.keyLen n → block.length = self.blockLen n → self.encrypt n key (self.decrypt n key block) = block
Encryption inverts decryption on valid inputs.
Read a permutation of m-bit blocks as a table, answering other words with [].
The ideal chosen-plaintext experiment: a uniform permutation of blockLen n-bit blocks,
sampled independently of the adversary's private coins ([BS23], Attack Game 4.1,
Experiment 1).
The ideal chosen-ciphertext experiment: one uniform permutation answers both forward and inverse queries ([BS23], Section 4.1.3).
The key length of an efficiently computed parameter is efficiently computable.
The block length of an efficiently computed parameter is efficiently computable.
Encryption of efficiently computed arguments is efficiently computable.
Decryption of efficiently computed arguments is efficiently computable.
The permutation of blockLen n-bit blocks induced by a valid key.
The encryption oracle, answering words of the wrong length with [].
A valid key answers encryption queries as its induced permutation.
A valid key answers encryption and decryption queries as its induced permutation.
The real chosen-plaintext experiment: one uniform keyLen n-bit key answers every encryption
query ([BS23], Attack Game 4.1, Experiment 0).
The real chosen-ciphertext experiment: one uniform keyLen n-bit key answers forward queries
with encryption and inverse queries with decryption ([BS23], Section 4.1.3).
Pseudorandom-permutation security against uniform oracle-PPT distinguishers ([BS23], Definition 4.1, interpreted asymptotically as in Section 4.1.5).
Strong pseudorandom-permutation security against uniform oracle-PPT distinguishers ([BS23], Section 4.1.3 and Exercise 4.9(a)).
Efficiency of the real experiments #
The real chosen-plaintext experiment is uniformly strict PPT for every oracle-PPT adversary.
The real chosen-ciphertext experiment is uniformly strict PPT for every oracle-PPT adversary.
Strong pseudorandom permutations are pseudorandom permutations #
Run a forward distinguisher against a bidirectional oracle, sending every query to the
encryption channel false. Replies are cut at blockLen n bits, which changes nothing against the
real or ideal permutation oracles and keeps the substitution polynomial on arbitrary replies.
Lifting an oracle-PPT forward distinguisher with a polynomial-time block length gives an oracle-PPT bidirectional distinguisher.
Against the real bidirectional experiment, the lifted distinguisher has the law of the forward distinguisher in the real chosen-plaintext experiment.
Against the ideal bidirectional experiment, the lifted distinguisher has the law of the forward distinguisher in the ideal chosen-plaintext experiment.
Strong PRP security implies PRP security ([BS23], Section 4.1.3).
The PRP/PRF switching lemma #
Ideal-experiment PRP/PRF switching lemma ([BS23], Attack Game 4.3 and
Theorem 4.6): a randomized word-oracle adversary making at most Q queries distinguishes a uniform
permutation of blockLen n-bit blocks from a uniform random function on them with advantage at most
Q.choose 2 / 2 ^ blockLen n. This is PRP.advantage_idealExperiment_prfIdealExperiment_le for the
adversary reading valid words as blocks through OracleCodec.bitString (blockLen n).
Asymptotic PRP/PRF switching: when (2 ^ blockLen n)⁻¹ is negligible, no oracle-PPT
distinguisher tells a uniform permutation from a uniform random function on blockLen n-bit
blocks.
When E.keyLen = id, E.prpRealGame agrees in distribution with the PRF real game of E.
A block cipher is a PRP iff it is a PRF ([BS23], Corollary 4.5): for every
block cipher E, with any key length, if the block space is super-polynomial
(Negligible fun n => ((2 : ℝ≥0) ^ E.blockLen n)⁻¹), then E.PRP holds iff no oracle-PPT
distinguisher tells E under a uniform E.keyLen n-bit key from a uniform function on
E.blockLen n-bit blocks. The right side is the security of E viewed as a PRF over
(K, X, X) ([BS23], Attack Game 4.2 and Definition 4.2): E.prpRealGame is that PRF's
real experiment, and prfIdealGame E.blockLen E.blockLen its random-function experiment. As in the
source, both directions follow from the switching lemma
(indistinguishable_prpIdealGame_prfIdealGame) by the triangle inequality.
The E.keyLen = id case of BlockCipher.prp_iff_indistinguishable_prpRealGame_prfIdealGame,
with the PRF side stated in the library's PRF notion: E.PRP holds iff E.encrypt, with the
security parameter read from the key length, is a PseudorandomFunctionOver E.blockLen E.blockLen.
The restriction E.keyLen = id comes from PseudorandomFunctionOver, which draws n-bit keys;
[BS23], Corollary 4.5, allows any key space.