Documentation

CslibFrontier.Crypto.Protocols.PKE.ExplicitCoin

Public-key encryption with explicit coins #

This module formalizes public-key encryption PKE = (Gen, Enc, Dec) with an explicit encryption coin type R, following [HHK17], IACR ePrint 2017/604 (full version dated 2 November 2021), §2.1. Exposing deterministic encryption encDet : PK → M → R → CT lets transforms such as Fujisaki--Okamoto derive coins from a message and repeat encryption exactly.

ExplicitCoinPKE uses a fixed type R and an arbitrary sampler sampleCoins : ProbComp R, while HHK17 permits a public-key-dependent randomness space and draws coins uniformly. Its DeltaCorrect definition preserves the source's expectation over key generation of the worst-message decryption-failure probability, and GammaSpread likewise generalizes the source's uniform coin draw to sampleCoins.

IND-CPA security is the two-stage game of HHK17 §2.1, Definition 2.2 / Figure 4: a first stage receives the public key and chooses two messages and a state, and a second stage receives the state and an encryption of one of them. toPKE is the randomized scheme (Gen, Enc, Dec) of an explicit-coin scheme, and cpaAdvantage is its advantage in the shared chosen-plaintext experiment Cslib.Crypto.PKE.cpaExperiment, with every pair of messages admissible. The advantage is the two-world difference |Pr[1 | b = 0] - Pr[1 | b = 1]|, which is twice HHK17's hidden-bit advantage |Pr[b' = b] - 1/2|. The Fujisaki--Okamoto theorems are stated against cpaAdvantage.

indCpaGame and indCpaAdvantage are a narrower, fixed-message experiment: the messages m₀, m₁ are given before key generation and the adversary is single-stage. Security for every fixed pair does not give two-stage security, since a two-stage adversary may choose its messages after seeing the public key. The fixed-message experiment is kept for the spread-necessity example Cslib.Crypto.Protocols.FujisakiOkamoto.unspreadPointPKE_indCpaAdvantage, a scheme that is secure for every fixed pair of messages away from one point but not two-stage secure.

Unlike the standard-model bit-string KEM interfaces in Cslib.Crypto.Encryption.KEMINDCPA and Cslib.Crypto.Encryption.encryptKeyEncaps, this interface retains encryption coins and deterministic encryption. KEM transforms and their security reductions live in separate modules.

Main definitions #

Main results #

References #

A public-key encryption scheme PKE = (Gen, Enc, Dec) with explicit encryption coins r : R ([HHK17], ePrint 2017/604 (2 Nov 2021), §2.1): randomized encryption draws r ← sampleCoins and evaluates deterministic encryption encDet pk m r, allowing Fujisaki--Okamoto transforms to derandomize encryption with G(m) : R and perform exact re-encryption checks. Unlike §2.1's uniform draw from a potentially pk-dependent coin space, R is a fixed type and sampleCoins : ProbComp R is an arbitrary sampler.

  • keyGen : ProbComp (PK × SK)

    Key generation (pk, sk) ← keyGen.

  • sampleCoins : ProbComp R

    Encryption coin sampler r ← sampleCoins.

  • encDet : PK → M → R → CT

    Deterministic encryption Enc(pk, m; r) with explicit coins r : R.

  • dec : SK → CT → Option M

    Deterministic decryption Dec(sk, c) ∈ M ∪ {⊥}.

def Cslib.Crypto.Protocols.ExplicitCoinPKE.encrypt {PK SK M R CT : Type} (P : ExplicitCoinPKE PK SK M R CT) (pk : PK) (m : M) :

Randomized encryption Enc(pk, m) drawing fresh coins r ← sampleCoins.

theorem Cslib.Crypto.Protocols.ExplicitCoinPKE.eval_encrypt_eq_toOuterMeasure {PK SK M R CT : Type} (P : ExplicitCoinPKE PK SK M R CT) (pk : PK) (m : M) (c : CT) :
(P.encrypt pk m).eval c = P.sampleCoins.eval.toOuterMeasure {r : R | P.encDet pk m r = c}

The probability that P.encrypt pk m outputs c is the probability that fresh coins r satisfy P.encDet pk m r = c.

def Cslib.Crypto.Protocols.ExplicitCoinPKE.toPKE {PK SK M R CT : Type} (P : ExplicitCoinPKE PK SK M R CT) :
PKE PK SK M CT

The randomized public-key encryption scheme (Gen, Enc, Dec) of P: key generation P.keyGen, encryption P.encrypt with fresh coins, and decryption P.dec.

noncomputable def Cslib.Crypto.Protocols.ExplicitCoinPKE.cpaAdvantage {PK SK M R CT σ : Type} (P : ExplicitCoinPKE PK SK M R CT) (A : TwoStage PK (MessagePair M) CT Bool σ) :

Two-stage IND-CPA advantage of A against P ([HHK17], ePrint 2017/604 (2 Nov 2021), §2.1, Def. 2.2 / Fig. 4), in the shared chosen-plaintext experiment PKE.cpaExperiment of P.toPKE with every pair of messages admissible. The first stage of A receives pk and chooses (m₀, m₁) and a state; the second stage receives the state and an encryption of m_b, and keeps pk only if the first stage saved it. The advantage is the two-world difference |Pr[A → 1 | b = 0] - Pr[A → 1 | b = 1]|, which is twice HHK17's hidden-bit advantage |Pr[b' = b] - 1/2|.

noncomputable def Cslib.Crypto.Protocols.ExplicitCoinPKE.msgFailProb {PK SK M R CT : Type} (P : ExplicitCoinPKE PK SK M R CT) (pk : PK) (sk : SK) (m : M) :

Per-message decryption failure probability Pr_{r ← sampleCoins}[Dec(sk, Enc(pk, m; r)) ≠ m] for a fixed key pair (pk, sk) and message m ([HHK17], ePrint 2017/604 (2 Nov 2021), §2.1, generalized from uniform coins to sampleCoins).

theorem Cslib.Crypto.Protocols.ExplicitCoinPKE.msgFailProb_nonneg {PK SK M R CT : Type} (P : ExplicitCoinPKE PK SK M R CT) (pk : PK) (sk : SK) (m : M) :
0 ≤ P.msgFailProb pk sk m
theorem Cslib.Crypto.Protocols.ExplicitCoinPKE.msgFailProb_le_one {PK SK M R CT : Type} (P : ExplicitCoinPKE PK SK M R CT) (pk : PK) (sk : SK) (m : M) :
P.msgFailProb pk sk m ≤ 1
theorem Cslib.Crypto.Protocols.ExplicitCoinPKE.msgFailProb_eq_zero_of_support {PK SK M R CT : Type} (P : ExplicitCoinPKE PK SK M R CT) (pk : PK) (sk : SK) (m : M) (hdec : ∀ r ∈ P.sampleCoins.eval.support, P.dec sk (P.encDet pk m r) = some m) :
P.msgFailProb pk sk m = 0

If Dec(sk, Enc(pk, m; r)) = some m holds for every supported coin r, the message failure probability at (pk, sk, m) is 0.

noncomputable def Cslib.Crypto.Protocols.ExplicitCoinPKE.keyPairMaxFailProb {PK SK M R CT : Type} [Fintype M] [Nonempty M] (P : ExplicitCoinPKE PK SK M R CT) (pk : PK) (sk : SK) :

Worst-case-over-messages decryption failure probability max_{m ∈ M} Pr_{r ← sampleCoins}[Dec(sk, Enc(pk, m; r)) ≠ m] for a fixed key pair (pk, sk) ([HHK17], ePrint 2017/604 (2 Nov 2021), §2.1).

theorem Cslib.Crypto.Protocols.ExplicitCoinPKE.msgFailProb_le_keyPairMaxFailProb {PK SK M R CT : Type} [Fintype M] [Nonempty M] (P : ExplicitCoinPKE PK SK M R CT) (pk : PK) (sk : SK) (m : M) :
theorem Cslib.Crypto.Protocols.ExplicitCoinPKE.keyPairMaxFailProb_nonneg {PK SK M R CT : Type} [Fintype M] [Nonempty M] (P : ExplicitCoinPKE PK SK M R CT) (pk : PK) (sk : SK) :
theorem Cslib.Crypto.Protocols.ExplicitCoinPKE.keyPairMaxFailProb_le_one {PK SK M R CT : Type} [Fintype M] [Nonempty M] (P : ExplicitCoinPKE PK SK M R CT) (pk : PK) (sk : SK) :
def Cslib.Crypto.Protocols.ExplicitCoinPKE.DeltaCorrect {PK SK M R CT : Type} [Fintype M] [Nonempty M] (P : ExplicitCoinPKE PK SK M R CT) (δ : ℝ) :

HHK17 δ-correctness ([HHK17], ePrint 2017/604 (2 Nov 2021), §2.1, generalized from uniform coins to sampleCoins): the expectation over (pk, sk) ← keyGen of the worst-case message decryption failure probability is at most δ: E_{(pk, sk) ← keyGen}[max_{m ∈ M} Pr_{r ← sampleCoins}[Dec(sk, Enc(pk, m; r)) ≠ m]] ≤ δ.

theorem Cslib.Crypto.Protocols.ExplicitCoinPKE.DeltaCorrect.mono {PK SK M R CT : Type} [Fintype M] [Nonempty M] {P : ExplicitCoinPKE PK SK M R CT} {δ δ' : ℝ} (h : P.DeltaCorrect δ) (hle : δ ≤ δ') :

Monotonicity of DeltaCorrect in the failure bound δ.

theorem Cslib.Crypto.Protocols.ExplicitCoinPKE.deltaCorrect_zero_of_perfect {PK SK M R CT : Type} [Fintype M] [Nonempty M] (P : ExplicitCoinPKE PK SK M R CT) (hperf : ∀ (pk : PK) (sk : SK), (pk, sk) ∈ P.keyGen.eval.support → ∀ (m : M), ∀ r ∈ P.sampleCoins.eval.support, P.dec sk (P.encDet pk m r) = some m) :

A public-key encryption scheme whose supported key pairs and coins never incur decryption errors is 0-correct (DeltaCorrect P 0).

def Cslib.Crypto.Protocols.ExplicitCoinPKE.GammaSpread {PK SK M R CT : Type} (P : ExplicitCoinPKE PK SK M R CT) (γ : ℝ) :

HHK17 γ-spreadness ([HHK17], ePrint 2017/604 (2 Nov 2021), §2.1, generalized from uniform coins to sampleCoins): for every supported key pair (pk, sk) ∈ support(keyGen), message m, and ciphertext c, encryption hits c with probability at most 2 ^ (-γ) over fresh coins r ← sampleCoins.

def Cslib.Crypto.Protocols.ExplicitCoinPKE.indCpaGame {PK SK M R CT : Type} (P : ExplicitCoinPKE PK SK M R CT) (m₀ m₁ : M) (bit : Bool) (adversary : PK → CT → ProbComp Bool) :

Single-challenge fixed-message IND-CPA experiment for ExplicitCoinPKE: on bit false the challenger encrypts m₀, and on bit true it encrypts m₁. Unlike [HHK17] (ePrint 2017/604 (2 Nov 2021), §2.1, Def. 2.2 / Fig. 4), where a first-stage adversary receives pk and chooses (m₀, m₁) with state, (m₀, m₁) are fixed caller-supplied messages independent of pk. The two-stage notion is cpaAdvantage.

noncomputable def Cslib.Crypto.Protocols.ExplicitCoinPKE.indCpaAdvantage {PK SK M R CT : Type} (P : ExplicitCoinPKE PK SK M R CT) (m₀ m₁ : M) (adversary : PK → CT → ProbComp Bool) :

Single-challenge fixed-message IND-CPA probability-difference advantage |Pr[indCpaGame m₀ m₁ false = true] - Pr[indCpaGame m₀ m₁ true = true]| via Game.advantage (whereas [HHK17], ePrint 2017/604 (2 Nov 2021), §2.1, Def. 2.2 / Fig. 4 defines |Pr[b' = b] - 1/2| in a two-stage key-dependent-message guessing game).