Nested encryption #
Given a symmetric cipher E : Cipher K M M whose ciphertexts lie in its plaintext space M,
E.nested n ([BS23], §2.4, p. 37) composes n encryption layers with independent keys
k 0, ..., k (n - 1), applying k 0 innermost and k (n - 1) outermost. Decryption peels the
keys in reverse order. Cipher.nested_correct proves that n-way nesting preserves correctness.
Cipher.nestedExperiment states the n-way nested security game of [BS23], §2.4, p. 37:
the adversary chooses a message pair and the index withheld : Fin n of one hidden key, and
receives the nested ciphertext together with the remaining n - 1 keys (revealKeys).
Relative to [BS23], §2.4, this module has the following differences:
- Ciphertexts share the plaintext type
M(Cipher K M M) son-way composition is well-typed for everyn. - Keys are indexed
0-based byFin nrather than1, ..., n;n = 0is vacuous becauseFin 0is empty. - The challenger draws all
nkeys before callingA.chooserather than after (identical output law), and an inadmissible pair makes both experiments outputfalse. - Key sampling
sampleKeyand challenge admissibilityvalidare parameters where the book fixes uniform keys and equal message length. The theorems below also assumeCipher.PreservesValid, so that prefix-encrypted challenge pairs stay admissible for the outer single-key game. The book does not state this hypothesis, and Theorem 2.12 fails without it: a one-time secure cipher can have nested advantage one (tagCipher_no_wrapperin the tests). They are a corrected form of Theorem 2.12.
nestedToSingleAdversary gives the reduction for Theorem 2.12: it samples a Fin n → K key vector
via OracleComp.replicateFin (never reading the withheld coordinate), encrypts both messages
through the prefix layers 0, ..., withheld - 1, delegates the withheld layer to
oneTimeExperiment, and applies the suffix layers withheld + 1, ..., n - 1 before calling
A.guess when st.admissible holds. eval_oneTimeExperiment_nestedToSingleAdversary and
advantage_nestedExperiment_eq prove exact distribution and advantage equality,
isPPT_nestedToSingleAdversary proves uniform strict polynomial-time efficiency of the reduction,
and indistinguishable_nestedExperiment_of_oneTimeExperiment derives Game.Indistinguishable for
n-way nesting from single-key semantic security.
Main definitions #
Cslib.Crypto.Cipher.nestedEncrypt,Cslib.Crypto.Cipher.nestedDecrypt,Cslib.Crypto.Cipher.nested:n-way nested encryption and decryption.Cslib.Crypto.Cipher.PreservesValid: preservation of challenge-pair admissibility under encryption.Cslib.Crypto.NestedRequest,Cslib.Crypto.NestedChallenge,Cslib.Crypto.revealKeys,Cslib.Crypto.Cipher.nestedExperiment: adversary request/challenge records and multi-key security experiment for Theorem 2.12.Cslib.Crypto.NestedReductionState,Cslib.Crypto.nestedToSingleAdversary: single-key reduction adversary.Cslib.Crypto.encNestedRequest,Cslib.Crypto.encNestedChallenge,Cslib.Crypto.encNestedReductionState: computable encodings of the request, challenge, and reduction state.
Main results #
Cslib.Crypto.Cipher.nested_correct: correctness ofE.nested nfromE.Correct.Cslib.Crypto.eval_oneTimeExperiment_nestedToSingleAdversary: exact distribution equality betweenE.oneTimeExperimentagainstnestedToSingleAdversaryandE.nestedExperiment.Cslib.Crypto.advantage_nestedExperiment_eq: exact advantage equality for Theorem 2.12.Cslib.Crypto.isPPT_nestedToSingleAdversary: uniform strict polynomial-time efficiency certificate fornestedToSingleAdversary.Cslib.Crypto.indistinguishable_nestedExperiment_of_oneTimeExperiment: Theorem 2.12 semantic security forn-way nesting from single-key semantic security.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, §2.4 (Theorem 2.12, p. 37).
Admissibility preservation under encryption: encrypting an admissible pair (m₀, m₁) under any
supported key produces an admissible ciphertext pair (c₀, c₁). [BS23] Theorem 2.12
does not state this condition, and the theorem fails without it (tagCipher_no_wrapper in the
tests); the corrected form here assumes it so prefix-encrypted pairs stay admissible for the outer
game.
Challenge request of an n-way nested encryption adversary: a message pair and the
0-indexed withheld key position withheld : Fin n (empty when n = 0).
- pair : MessagePair M
Pair of challenge plaintexts chosen by the adversary.
- withheld : Fin n
0-based index of the single key withheld from the adversary (Fin 0is empty).
Second-stage challenge received by an n-way nested encryption adversary: the nested
ciphertext and every key except the withheld index.
- ciphertext : M
Challenge ciphertext returned by the
n-way nested cipher.
The n-way nested encryption security experiment ([BS23], §2.4, p. 37). Differs from
the book by indexing keys from 0 via Fin n and permitting the vacuous n = 0 case.
Internal state of the reduction from n-way nested encryption to single-key encryption.
Single-key reduction adversary for Theorem 2.12: draws n keys (ignoring coordinate
withheld), encrypts msg₀ and msg₁ under the prefix 0, ..., withheld - 1, delegates the
withheld layer to oneTimeExperiment, and finishes with the suffix withheld + 1, ..., n - 1
when st.admissible holds.
Exact output-distribution equality between the outer single-key experiment running
nestedToSingleAdversary and the n-way nested experiment running A, under
E.PreservesValid sampleKey valid.
Exact advantage equality for the corrected form of Theorem 2.12 ([BS23], §2.4,
p. 37): under E.PreservesValid sampleKey valid, a hypothesis the book does not state and without
which the equality fails (tagCipher_no_wrapper), the n-way nested advantage of A equals the
one-time advantage of nestedToSingleAdversary.
The tuple of the fields of encNestedRequest.
Computable encoding of a NestedRequest M n as (pair, withheld).
Computable encoding of a NestedChallenge K M n as (ciphertext, revealedKeys).
Computable encoding of NestedReductionState K σ n.
Uniform strict polynomial-time efficiency of nestedToSingleAdversary: for a fixed n, when
sampleKey and encrypt are strict PPT and valid is computable in polynomial time (each
uniformly in the security parameter), the reductions of any uniform strict PPT family A (with
revealed keys encoded as an encFinFn table) form a uniform strict PPT family.
Corrected form of Theorem 2.12 ([BS23], §2.4, p. 37), with the admissibility
hypothesis PreservesValid that the book does not state and without which the theorem fails
(tagCipher_no_wrapper in the tests): for every constant n : ℕ, if sampleKey and
encrypt are strict PPT, valid is computable in polynomial time (each uniformly in the security
parameter), E preserves admissibility (PreservesValid) at every security parameter, and E is
one-time semantically secure (Game.Indistinguishable against uniform strict PPT TwoStage
adversaries for every state type and encoding), then E is semantically secure for n-way nesting
with all keys but one revealed.