Documentation

CslibFrontier.Crypto.Computational.Encryption.PublicKeyReplacement

Replacing the public-key distribution in chosen-message security #

One uniform distinguisher samples a hidden fair challenge bit after the adversary has chosen its messages and saved state. It runs the actual encryption and guessing stages, then returns the guess XOR the hidden bit. Comparing this same distinguisher on two public-key distributions controls the change in their chosen-message gaps, with an exact factor of two. The experiment and the distinguisher take the challenge-pair admissibility predicate valid of gameOn; an inadmissible pair outputs false on both sides, so the distinguisher returns the hidden bit.

Main definitions #

Main results #

References #

noncomputable def Cslib.Crypto.Encryption.publicKeyGameOn {Msg : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (keys : PMF (List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (adversary : AdversaryOf Msg) (bit : Bool) (security : ℕ) :

Run the chosen-message experiment gameOn valid with a specified public-key distribution. The complete state returned by message selection is passed unchanged to guessing, and an inadmissible challenge pair outputs false.

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.Encryption.publicKeyGame {Msg : Type} (keys : PMF (List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (adversary : AdversaryOf Msg) (bit : Bool) (security : ℕ) :

The unrestricted experiment with a specified public-key distribution: publicKeyGameOn with every challenge pair admissible.

theorem Cslib.Crypto.Encryption.eval_gameOn_eq_publicKeyGameOn {Msg : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (adversary : AdversaryOf Msg) (bit : Bool) (security : ℕ) :
(gameOn valid keyGen encrypt adversary bit security).eval = publicKeyGameOn valid (PMF.map Prod.fst (keyGen security).eval) encrypt adversary bit security

An honest key generator contributes precisely its public-key marginal to gameOn.

theorem Cslib.Crypto.Encryption.eval_game_eq_publicKeyGame {Msg : Type} (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (adversary : AdversaryOf Msg) (bit : Bool) (security : ℕ) :
(game keyGen encrypt adversary bit security).eval = publicKeyGame (PMF.map Prod.fst (keyGen security).eval) encrypt adversary bit security

An honest key generator contributes precisely its public-key marginal to game.

noncomputable def Cslib.Crypto.Encryption.keyDistinguisherOn {Msg : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (adversary : AdversaryOf Msg) :

A single uniform distinguisher with its own hidden fair challenge bit. The adversary sees only the supplied public key and the actual challenge ciphertext, with its saved state retained. On an inadmissible challenge pair both experiments output false, so the distinguisher returns false ^^ bit.

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.Encryption.keyDistinguisher {Msg : Type} (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (adversary : AdversaryOf Msg) :

The unrestricted reduction: keyDistinguisherOn with every challenge pair admissible.

theorem Cslib.Crypto.Encryption.isPPT_keyDistinguisherOn {Msg : Type} {encMsg : Msg ↪ List Bool} {valid : ℕ → List Bool → Msg → Msg → Bool} {encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)} {adversary : AdversaryOf Msg} (hvalid : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ℕ × List Bool × Msg × Msg) => match x with | (n, pk, m₀, m₁) => valid n pk m₀ m₁) (encChallengePairInput encMsg) Turing.MultiTapeTM.encBool) (hencrypt : Probability.IsPPTOn (encKeyedInput encMsg) Turing.MultiTapeTM.encBits fun (x : ℕ × List Bool × Msg) => match x with | (security, pk, msg) => encrypt security pk msg) (hadversary : AdversaryOf.IsPPT encMsg adversary) :

The reduction is one uniform strict PPT program when the admissibility predicate is computable in polynomial time and encryption and both adversary stages are certified on their complete inputs.

theorem Cslib.Crypto.Encryption.isPPT_keyDistinguisher {Msg : Type} {encMsg : Msg ↪ List Bool} {encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)} {adversary : AdversaryOf Msg} (hencrypt : Probability.IsPPTOn (encKeyedInput encMsg) Turing.MultiTapeTM.encBits fun (x : ℕ × List Bool × Msg) => match x with | (security, pk, msg) => encrypt security pk msg) (hadversary : AdversaryOf.IsPPT encMsg adversary) :

The unrestricted reduction is one uniform strict PPT program when encryption and both adversary stages are certified on their complete inputs.

theorem Cslib.Crypto.Encryption.distinguishingGame_keyDistinguisherOn {Msg : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (keys : PMF (List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (adversary : AdversaryOf Msg) (security : ℕ) :
distinguishingGame keys (keyDistinguisherOn valid encrypt adversary security) = do let bit ← Probability.PMF.uniformOfFintype Bool PMF.map (fun (guess : Bool) => guess ^^ bit) (publicKeyGameOn valid keys encrypt adversary bit security)

The hidden-bit experiment averages the two chosen-message games, complementing the second. No finiteness or independence assumption is imposed on the saved state.

theorem Cslib.Crypto.Encryption.probability_keyDistinguisherOn {Msg : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (keys : PMF (List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (adversary : AdversaryOf Msg) (security : ℕ) :
↑(distinguishingGame keys (keyDistinguisherOn valid encrypt adversary security)).succProbability = (1 + ↑(publicKeyGameOn valid keys encrypt adversary false security).succProbability - ↑(publicKeyGameOn valid keys encrypt adversary true security).succProbability) / 2

Acceptance is one half plus half the signed chosen-message gap.

theorem Cslib.Crypto.Encryption.advantage_publicKeyGameOn_le {Msg : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (real ideal : PMF (List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (adversary : AdversaryOf Msg) (security : ℕ) :
(publicKeyGameOn valid real encrypt adversary false security).advantage (publicKeyGameOn valid real encrypt adversary true security) ≤ 2 * (distinguishingGame real (keyDistinguisherOn valid encrypt adversary security)).advantage (distinguishingGame ideal (keyDistinguisherOn valid encrypt adversary security)) + (publicKeyGameOn valid ideal encrypt adversary false security).advantage (publicKeyGameOn valid ideal encrypt adversary true security)

Replacing the public-key law costs at most twice the advantage of one uniform hidden-bit distinguisher, plus the chosen-message advantage under the replacement law.

theorem Cslib.Crypto.Encryption.advantage_publicKeyGame_le {Msg : Type} (real ideal : PMF (List Bool)) (encrypt : ℕ → List Bool → Msg → ProbComp (List Bool)) (adversary : AdversaryOf Msg) (security : ℕ) :
(publicKeyGame real encrypt adversary false security).advantage (publicKeyGame real encrypt adversary true security) ≤ 2 * (distinguishingGame real (keyDistinguisher encrypt adversary security)).advantage (distinguishingGame ideal (keyDistinguisher encrypt adversary security)) + (publicKeyGame ideal encrypt adversary false security).advantage (publicKeyGame ideal encrypt adversary true security)

Public-key replacement for the unrestricted experiment.