Documentation

CslibFrontier.Crypto.Computational.Encryption.Cipher.Perfect

Equal Ciphertext Laws and Semantic Security of One-Time Pads #

This module derives one-time semantic security (Cipher.oneTimeExperiment advantage 0) for ciphers whose key-averaged ciphertext distribution is invariant across admissible message pairs ([BS23], Example 2.9, p. 17; Exercise 2.7, p. 39), without restricting to deterministic ciphers.

Connecting an information-theoretic EncScheme to a computational Cipher and key sampler via distribution equality yields zero semantic-security advantage for every cipher matching an EncScheme.PerfectlySecret scheme (and clients holding EncScheme.CiphertextIndist directly apply advantage_oneTimeExperiment_eq_zero_of_ciphertextDist_eq with ciphertextDist_eq_encScheme). Instantiations cover both the fixed-length one-time pad over BitVec l and the variable-length one-time pad variableLengthOTPCipher L on equal-length messages.

For the bit-guessing identity SSadv[A, E] = 2 * SSadv*[A, E] ([BS23], Theorem 2.10, p. 26) applied to E.oneTimeExperiment sampleKey valid A, apply Experiment.advantage_eq_two_mul_guessingAdvantage_guessBit from CslibFrontier.Crypto.Game.HiddenBit directly.

Main definitions #

Main results #

References #

noncomputable def Cslib.Crypto.Cipher.ciphertextDist {K M C : Type} (E : Cipher K M C) (sampleKey : ProbComp K) (m : M) :
PMF C

The key-averaged ciphertext distribution of m under cipher E when keys are drawn from sampleKey.

def Cslib.Crypto.Cipher.ofPure {K M C : Type} (enc : K → M → C) (dec : K → C → M) :
Cipher K M C

Build a symmetric cipher from deterministic pure encryption and decryption functions.

theorem Cslib.Crypto.Cipher.ofPure_correct {K M C : Type} (enc : K → M → C) (dec : K → C → M) (h : ∀ (k : K), Function.LeftInverse (dec k) (enc k)) :
(ofPure enc dec).Correct

A deterministic cipher ofPure enc dec is correct when dec k is a left inverse of enc k for every key k.

@[simp]
theorem Cslib.Crypto.Cipher.ciphertextDist_ofPure {K M C : Type} (enc : K → M → C) (dec : K → C → M) (sampleKey : ProbComp K) (m : M) :
(ofPure enc dec).ciphertextDist sampleKey m = PMF.map (fun (x : K) => enc x m) sampleKey.eval

Key-averaged ciphertext distribution of a deterministic cipher ofPure enc dec.

theorem Cslib.Crypto.Cipher.eval_oneTimeExperiment_eq_of_ciphertextDist_eq {K M C σ : Type} (E : Cipher K M C) (sampleKey : ProbComp K) (valid : M → M → Bool) (h : ∀ (m₀ m₁ : M), valid m₀ m₁ = true → E.ciphertextDist sampleKey m₀ = E.ciphertextDist sampleKey m₁) (A : TwoStage Unit (MessagePair M) C Bool σ) (b₀ b₁ : Bool) :
ProbComp.eval (E.oneTimeExperiment sampleKey valid A b₀) = ProbComp.eval (E.oneTimeExperiment sampleKey valid A b₁)

Equal ciphertext laws hide the challenge bit: if the key-averaged ciphertext law of m₀ equals that of m₁ for every admissible pair (m₀, m₁), then oneTimeExperiment has the same output distribution for both challenge bits against every adversary.

theorem Cslib.Crypto.Cipher.advantage_oneTimeExperiment_eq_zero_of_ciphertextDist_eq {K M C σ : Type} (E : Cipher K M C) (sampleKey : ProbComp K) (valid : M → M → Bool) (h : ∀ (m₀ m₁ : M), valid m₀ m₁ = true → E.ciphertextDist sampleKey m₀ = E.ciphertextDist sampleKey m₁) (A : TwoStage Unit (MessagePair M) C Bool σ) :
(E.oneTimeExperiment sampleKey valid A false).advantage (E.oneTimeExperiment sampleKey valid A true) = 0

Equal ciphertext laws give zero semantic-security advantage ([BS23], Example 2.9, p. 17; Exercise 2.7, p. 39).

theorem Cslib.Crypto.Cipher.ciphertextDist_eq_encScheme {K M C : Type} (E : Cipher K M C) (sampleKey : ProbComp K) (S : Protocols.PerfectSecrecy.EncScheme M K C) (hgen : S.gen = sampleKey.eval) (henc : ∀ (k : K) (m : M), (E.encrypt k m).eval = S.enc k m) (m : M) :
E.ciphertextDist sampleKey m = S.ciphertextDist m

A cipher whose key sampler and encryption laws match an information-theoretic EncScheme has the same ciphertext distribution as that scheme.

theorem Cslib.Crypto.Cipher.advantage_oneTimeExperiment_eq_zero_of_perfectlySecret {K M C σ : Type} (E : Cipher K M C) (sampleKey : ProbComp K) (S : Protocols.PerfectSecrecy.EncScheme M K C) (hgen : S.gen = sampleKey.eval) (henc : ∀ (k : K) (m : M), (E.encrypt k m).eval = S.enc k m) (hS : S.PerfectlySecret) (valid : M → M → Bool) (A : TwoStage Unit (MessagePair M) C Bool σ) :
(E.oneTimeExperiment sampleKey valid A false).advantage (E.oneTimeExperiment sampleKey valid A true) = 0

Ciphers matching a perfectly secret EncScheme have zero semantic-security advantage: any Cipher matching an EncScheme.PerfectlySecret scheme through hgen and henc has advantage 0 in oneTimeExperiment against every adversary ([BS23], Example 2.9, p. 17).

The fixed-length one-time pad over BitVec l as a Cipher.

Correctness of the fixed-length one-time pad cipher otpCipher l.

The one-time pad has zero semantic-security advantage under a uniform key against every adversary ([BS23], Example 2.9, p. 17).

The variable-length one-time pad on words of length at most L as a Cipher.

Correctness of the variable-length one-time pad cipher variableLengthOTPCipher L.

The variable-length one-time pad has zero semantic-security advantage on equal-length messages under a uniform key against every adversary ([BS23], Example 2.9, p. 17; Exercise 2.7, p. 39).