Documentation

CslibFrontier.Crypto.Computational.Encryption.KEMDEM

KEM–DEM hybrid encryption #

A key encapsulation mechanism E : KEM PK SK CT K and a symmetric cipher D : Cipher K M C on its keys combine into the public-key encryption scheme E.hybrid D : PKE PK SK M (CT × C) ([BS23], Exercise 11.9(a)): encryption encapsulates a key and encrypts the message under it with D, and decryption decapsulates the key and decrypts. KEM.hybrid_correct states that the hybrid is correct when both components are.

Chosen-plaintext security of the hybrid reduces to security of the KEM and one-time security of the cipher. These are the concrete bounds for a corrected form of Exercise 11.9(b): the KEM experiment KEM.cpaExperiment gives the distinguisher the public key, which the exercise's printed KEM game does not, and under the printed game part (b) is false (Encryption.KEMINDCPA gives a counterexample). Fix a sampler sampleKey for the random KEM key, which is also the key distribution of the one-time cipher experiment. For every two-stage adversary A against the hybrid and every admissibility predicate on message pairs:

The distinguisher for bit b runs A on the challenge public key and answers its challenge by encrypting the selected message under the challenge key. With the encapsulated key this is the hybrid experiment (eval_cpaExperiment_hybridDistinguisher_false); with a random key it is the one-time experiment of hybridCipherAdversary E A, which generates the KEM keys and the encapsulation itself (eval_cpaExperiment_hybridDistinguisher_true).

Main definitions #

Main results #

References #

def Cslib.Crypto.KEM.hybrid {PK SK CT K M C : Type} (E : KEM PK SK CT K) (D : Cipher K M C) :
PKE PK SK M (CT × C)

KEM–DEM hybrid encryption ([BS23], Exercise 11.9(a)). Key generation is that of the KEM. Encryption encapsulates a key under the public key and encrypts the message under it with the cipher; the ciphertext is the encapsulation together with the cipher's ciphertext. Decryption decapsulates the key and decrypts; either step may reject.

theorem Cslib.Crypto.KEM.hybrid_correct {PK SK CT K M C : Type} {E : KEM PK SK CT K} {D : Cipher K M C} (hE : E.Correct) (hD : D.Correct) :

The hybrid of a correct KEM and a correct cipher is correct.

def Cslib.Crypto.KEM.hybridDistinguisher {PK CT K M C : Type} (D : Cipher K M C) (valid : M → M → Bool) {σ : Type} (A : TwoStage PK (MessagePair M) (CT × C) Bool σ) (b : Bool) (ch : Challenge PK CT K) :

The KEM distinguisher of the hybrid argument for challenge bit b ([BS23], Exercise 11.9(b)): run the left-or-right experiment of A on the challenge public key, answering the challenge by encrypting the selected message under the challenge key and pairing the result with the challenge ciphertext.

noncomputable def Cslib.Crypto.KEM.hybridHiddenBitDistinguisher {PK CT K M C : Type} (D : Cipher K M C) (valid : M → M → Bool) {σ : Type} (A : TwoStage PK (MessagePair M) (CT × C) Bool σ) (ch : Challenge PK CT K) :

The single KEM distinguisher of the hybrid argument ([BS23], Exercise 11.9(b)): draw a fair challenge bit b, run hybridDistinguisher D valid A b, and output its guess XOR b.

def Cslib.Crypto.KEM.hybridCipherAdversary {PK SK CT K M C : Type} (E : KEM PK SK CT K) {σ : Type} (A : TwoStage PK (MessagePair M) (CT × C) Bool σ) :

The one-time cipher adversary of the hybrid argument ([BS23], Exercise 11.9(b)). Its first stage generates a KEM key pair, runs the first stage of A on the public key, and encapsulates under it, saving the encapsulation with the state of A; its second stage pairs the encapsulation with the cipher's challenge and runs the second stage of A.

theorem Cslib.Crypto.KEM.eval_cpaExperiment_hybridDistinguisher_false {PK SK CT K M C : Type} (E : KEM PK SK CT K) (sampleKey : ProbComp K) (D : Cipher K M C) (valid : M → M → Bool) {σ : Type} (A : TwoStage PK (MessagePair M) (CT × C) Bool σ) (b : Bool) :
ProbComp.eval (E.cpaExperiment sampleKey (hybridDistinguisher D valid A b) false) = ProbComp.eval ((E.hybrid D).cpaExperiment (fun (x : PK) => valid) A b)

With the encapsulated key, hybridDistinguisher D valid A b runs the chosen-plaintext experiment of the hybrid for bit b.

theorem Cslib.Crypto.KEM.eval_cpaExperiment_hybridDistinguisher_true {PK SK CT K M C : Type} (E : KEM PK SK CT K) (sampleKey : ProbComp K) (D : Cipher K M C) (valid : M → M → Bool) {σ : Type} (A : TwoStage PK (MessagePair M) (CT × C) Bool σ) (b : Bool) :

With a random key, hybridDistinguisher D valid A b runs the one-time experiment of hybridCipherAdversary E A for bit b.

theorem Cslib.Crypto.KEM.eval_cpaExperiment_hybridHiddenBitDistinguisher {PK SK CT K M C : Type} (E : KEM PK SK CT K) (sampleKey : ProbComp K) (D : Cipher K M C) (valid : M → M → Bool) {σ : Type} (A : TwoStage PK (MessagePair M) (CT × C) Bool σ) (c : Bool) :
ProbComp.eval (E.cpaExperiment sampleKey (hybridHiddenBitDistinguisher D valid A) c) = (Probability.PMF.uniformOfFintype Bool).bind fun (b : Bool) => PMF.map (fun (guess : Bool) => guess ^^ b) (ProbComp.eval (E.cpaExperiment sampleKey (hybridDistinguisher D valid A b) c))

hybridHiddenBitDistinguisher D valid A averages the experiments of hybridDistinguisher D valid A b over a fair bit b, complementing the guess for b = true.

theorem Cslib.Crypto.KEM.advantage_hybrid_le {PK SK CT K M C : Type} (E : KEM PK SK CT K) (sampleKey : ProbComp K) (D : Cipher K M C) (valid : M → M → Bool) {σ : Type} (A : TwoStage PK (MessagePair M) (CT × C) Bool σ) :
((E.hybrid D).cpaExperiment (fun (x : PK) => valid) A false).advantage ((E.hybrid D).cpaExperiment (fun (x : PK) => valid) A true) ≤ (E.cpaExperiment sampleKey (hybridDistinguisher D valid A false) false).advantage (E.cpaExperiment sampleKey (hybridDistinguisher D valid A false) true) + (E.cpaExperiment sampleKey (hybridDistinguisher D valid A true) false).advantage (E.cpaExperiment sampleKey (hybridDistinguisher D valid A true) true) + (D.oneTimeExperiment sampleKey valid (E.hybridCipherAdversary A) false).advantage (D.oneTimeExperiment sampleKey valid (E.hybridCipherAdversary A) true)

Hybrid encryption from two per-bit KEM distinguishers, the concrete bound for the corrected form of [BS23], Exercise 11.9(b) (§11.8, pp. 460–461), in a two-distinguisher variant: the chosen-plaintext advantage of the hybrid is at most the KEM advantages of hybridDistinguisher D valid A false and hybridDistinguisher D valid A true plus the one-time advantage of hybridCipherAdversary E A. KEM.cpaExperiment gives the distinguisher the public key; the exercise's printed KEM game does not, and under it part (b) is false (see Encryption.KEMINDCPA).

theorem Cslib.Crypto.KEM.advantage_hybrid_le_two_mul {PK SK CT K M C : Type} (E : KEM PK SK CT K) (sampleKey : ProbComp K) (D : Cipher K M C) (valid : M → M → Bool) {σ : Type} (A : TwoStage PK (MessagePair M) (CT × C) Bool σ) :
((E.hybrid D).cpaExperiment (fun (x : PK) => valid) A false).advantage ((E.hybrid D).cpaExperiment (fun (x : PK) => valid) A true) ≤ 2 * (E.cpaExperiment sampleKey (hybridHiddenBitDistinguisher D valid A) false).advantage (E.cpaExperiment sampleKey (hybridHiddenBitDistinguisher D valid A) true) + (D.oneTimeExperiment sampleKey valid (E.hybridCipherAdversary A) false).advantage (D.oneTimeExperiment sampleKey valid (E.hybridCipherAdversary A) true)

Hybrid encryption from one KEM distinguisher, the concrete bound for the corrected form of [BS23], Exercise 11.9(b) (§11.8, pp. 460–461): the chosen-plaintext advantage of the hybrid is at most twice the KEM advantage of hybridHiddenBitDistinguisher D valid A plus the one-time advantage of hybridCipherAdversary E A. KEM.cpaExperiment gives the distinguisher the public key; the exercise's printed KEM game does not, and under it part (b) is false (see Encryption.KEMINDCPA).