Documentation

CslibFrontier.Crypto.Protocols.KEM.FujisakiOkamoto.Security

ROM IND-CCA Games, Eager/Lazy Equivalence, and CPA Reduction for HHK17 FO-notbot #

This module formalizes the Random Oracle Model (ROM) IND-CCA security experiments, eager/lazy equivalence, keyless oracle simulator, and IND-CPA reduction hit-probability bounds for the implicit-rejection Fujisaki–Okamoto transform FO-notbot (Scheme.keyGenNotBot, Scheme.encapsNotBot, Scheme.decapsNotBot) from CslibFrontier.Crypto.Protocols.KEM.FujisakiOkamoto ([HHK17], IACR ePrint 2017/604 full version dated 2 November 2021, §2.1, §2.1 Def. 2.2 / Fig. 4, §3.1 Fig. 5, and §3.2.2 Fig. 12).

Source map and model notes #

Section and figure locators follow CslibFrontier.Crypto.Protocols.KEM.FujisakiOkamoto and refer to the full version of [HHK17] served by IACR ePrint 2017/604, dated 2 November 2021:

In addition to the ExplicitCoinPKE and Scheme modeling choices documented in CslibFrontier.Crypto.Protocols.KEM.FujisakiOkamoto, this module makes two ROM-specific modeling choices:

On top of those definitions, this module formalizes:

  1. Executable lazy and eager ROM IND-CCA games for FO-notbot (Scheme.roIndCcaGame, Scheme.indCcaRomAdvantage, Scheme.eagerIndCcaGame) over the oracle interface ROQuery M CT (G, H, and punctured decapsulation rejecting c = cStar with none), together with exact eager/lazy equivalence (Scheme.eval_roIndCcaGame_eq_eagerIndCcaGame, Scheme.indCcaRomAdvantage_eq_eager). Both games are instances of one ROM IND-CCA experiment Scheme.romIndCcaExperiment, parameterized by the key generator and the decapsulation oracle (written as a program against the random oracles), whose eager/lazy equivalence Scheme.eval_romIndCcaExperiment_eq_eager follows from the generic represented-cache law RandomOracle.eval_run_interpret_eq_complete_bind. The @[simp] bridges Scheme.romIndCcaExperiment_notBot and Scheme.eagerRomIndCcaExperiment_notBot identify the FO-notbot instance with roIndCcaGame and eagerIndCcaGame; the FO^⊥ instance is in CslibFrontier.Crypto.Protocols.KEM.FujisakiOkamoto.Bot.
  2. Keyless ROM simulator and IND-CPA reduction (Scheme.simHandler, Scheme.romCpaReduction, Scheme.simFilterOwExperiment). Neither is a verbatim construction from [HHK17]; they combine the T and U-notbot proofs. simHandler is adapted from the G/H simulations in two proofs of the full version: the proof of Theorem 3.2 (§3.1, IND-CPA security of the PKE implies OW-PCVA security of T[PKE, G]), which answers G lazily, and the proof of Theorem 3.4 (§3.2.2, IND-CCA security of U-notbot), which answers decapsulation queries and the matching H queries from a ciphertext-indexed table. Here simHandler answers H(false, m, c) via a lazy table H_q(c) whenever the §3.1 Fig. 5 re-encryption check Enc(pk, m; G(m)) = c holds, and answers punctured decapsulation queries c ≠ cStar from H_q(c) without using sk (its consistency with roHandler / eagerIndCcaGame is proved in the NotBot modules). romCpaReduction A is one two-stage IND-CPA adversary: its first stage draws both challenge messages m₀, m₁ ← S.sampleMsg, as D₁ of Fig. 8 (proof of Theorem 3.2) does, and its second stage draws the coins of A, runs A against simHandler on the challenge and outputs whether m₁ was queried to G. With challenge bit true this is the one-wayness experiment simFilterOwExperiment (Scheme.eval_cpaExperiment_romFilterCpaReduction_true); with bit false the target m₁ is independent of the challenge, so the reduction outputs true with probability at most (qG + qH) / |M| (Scheme.succProbability_romFilterCpaReduction_false_le). Together they give Scheme.succProbability_simFilterOwExperiment_le. The IND-CCA bound for FO-notbot is Scheme.indCcaRomAdvantage_le in CslibFrontier.Crypto.Protocols.KEM.FujisakiOkamoto.NotBot.

Main definitions #

Main results #

References #

Section 1: ROM Queries, Executable IND-CCA Game, Simulator, and CPA Reduction #

Oracle query sum type for the ROM IND-CCA game of FO-notbot: random oracle G : M → R, random oracle H : Bool × M × CT → K (its false slice is the scheme’s shared key oracle; the typed adversary can also query an independent auxiliary slice), and the decapsulation oracle Decaps : CT → Option K.

  • G {M CT : Type} (m : M) : ROQuery M CT

    Query the coin-derivation random oracle G : M → R.

  • H {M CT : Type} (x : Bool × M × CT) : ROQuery M CT

    Query the key-derivation random oracle H : Bool × M × CT → K.

  • decaps {M CT : Type} (c : CT) : ROQuery M CT

    Query the decapsulation oracle Decaps : CT → Option K.

@[reducible, inline]

Response type family for ROQuery M CT.

def Cslib.Crypto.Protocols.FujisakiOkamoto.ROQuery.dispatch {M R CT K : Type} [DecidableEq CT] {m : Type → Type} [Monad m] (G : M → m R) (H : Bool × M × CT → m K) (decaps : CT → m (Option K)) (cStar : CT) (q : ROQuery M CT) :
m (ROResp R K q)

The oracle interface of the FO IND-CCA games, in any monad: G and H queries go to the given random-oracle implementations, decapsulation of the challenge cStar is refused with none, and any other ciphertext is answered by decaps. Every lazy, eager and simulated handler of the games and proof hybrids is this dispatcher applied to its own G, H and decaps.

@[reducible, inline]

A deterministic IND-CCA oracle adversary in the Random Oracle Model receives the challenge ⟨pk, c*, k*⟩ and interacts with G, H, and the decapsulation oracle before outputting a Boolean guess. A randomized adversary is a coin draw followed by one of these (RandomizedROAdversary).

Query cost counting calls to G.

Query cost counting calls to H.

Query cost counting combined calls to G and H.

Query cost counting calls to the decapsulation oracle.

def Cslib.Crypto.Protocols.FujisakiOkamoto.ROQueryBounds {PK M R CT K : Type} (A : ROAdversary PK M R CT K) (qG qH : ℕ) :

An ROAdversary satisfies query bounds (qG, qH) if on every challenge ch its execution makes at most qG queries to G and at most qH queries to H.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.ROQueryBounds.ghCost {PK M R CT K : Type} {A : ROAdversary PK M R CT K} {qG qH : ℕ} (hq : ROQueryBounds A qG qH) (ch : KEM.Challenge PK CT K) :

Bounds (qG, qH) on G and H queries bound their combined count by qG + qH.

def Cslib.Crypto.Protocols.FujisakiOkamoto.ROFullQueryBounds {PK M R CT K : Type} (A : ROAdversary PK M R CT K) (qG qH qD : ℕ) :

An ROAdversary satisfies full query bounds (qG, qH, qD) if on every challenge ch its execution makes at most qG queries to G, qH queries to H, and qD queries to decaps.

A randomized ROM IND-CCA adversary with explicit coins: it draws its coins ω ← coins once, before it receives the challenge, and then runs the deterministic oracle adversary run ω. This is the explicit-coin adversary model of Cslib.Crypto.Protocols.ROMSignature.Forger; a deterministic adversary is the case of a single coin value (ofDeterministic).

  • Coins : Type

    The adversary's coins.

  • coins : ProbComp self.Coins

    Draw the adversary's coins.

  • run : self.Coins → ROAdversary PK M R CT K

    The deterministic adversary run with fixed coins.

A deterministic adversary, as a randomized adversary with a single coin value.

Play a game for deterministic adversaries: draw the coins ω and play the game with A.run ω.

@[simp]
theorem Cslib.Crypto.Protocols.FujisakiOkamoto.RandomizedROAdversary.play_ofDeterministic {PK M R CT K : Type} (A : ROAdversary PK M R CT K) (game : ROAdversary PK M R CT K → Bool → ProbComp Bool) (b : Bool) :
(ofDeterministic A).play game b = game A b

Every coin value obeys the query bounds (qG, qH) on G and H.

Every coin value obeys the query bounds (qG, qH, qD) on G, H and decapsulation.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.RandomizedROAdversary.advantage_play_le {PK M R CT K : Type} (A : RandomizedROAdversary PK M R CT K) (game : ROAdversary PK M R CT K → Bool → ProbComp Bool) (ow : ROAdversary PK M R CT K → Experiment) {e : ℝ} (he : 0 ≤ e) (h : ∀ (ω : A.Coins), ↑(Experiment.advantage (game (A.run ω) false) (game (A.run ω) true)) ≤ e + 2 * ((ProbComp.eval (ow (A.run ω))) true).toReal) :
↑(Experiment.advantage (A.play game false) (A.play game true)) ≤ e + 2 * ((do let ω ← A.coins ow (A.run ω)).eval true).toReal

Averaging over the adversary's coins. If, for every coin value ω, the advantage of A.run ω in game is at most e + 2 · Pr[ow (A.run ω)], then the advantage of A is at most e + 2 · Pr[ow (A.run ω)] with ω ← A.coins drawn inside the experiment.

Association-list caches for the lazy random oracles G : M → R and H : Bool × M × CT → K in the executable ROM IND-CCA game.

  • gCache : List (M × R)

    Cached query-response pairs for G : M → R.

  • hCache : List ((Bool × M × CT) × K)

    Cached query-response pairs for H : Bool × M × CT → K.

Association-list caches for the keyless ROM simulator Scheme.simHandler, extending ROCache (gCache for G : M → R and hCache for unprogrammed queries to H : Bool × M × CT → K) with hqCache for the ciphertext-indexed key table H_q : CT → K.

def Cslib.Crypto.Protocols.FujisakiOkamoto.roHashG {M R CT K : Type} [DecidableEq M] (sampleCoins : ProbComp R) (m : M) :
StateT (ROCache M R CT K) ProbComp R

Lazy evaluation of G : M → R inside ROCache via memoize.

def Cslib.Crypto.Protocols.FujisakiOkamoto.roHashH {M R CT K : Type} [DecidableEq M] [DecidableEq CT] (sampleKey : ProbComp K) (x : Bool × M × CT) :
StateT (ROCache M R CT K) ProbComp K

Lazy evaluation of H : Bool × M × CT → K inside ROCache via memoize.

def Cslib.Crypto.Protocols.FujisakiOkamoto.simHashG {M R CT K : Type} [DecidableEq M] (sampleCoins : ProbComp R) (m : M) :
StateT (SimState M R CT K) ProbComp R

Lazy evaluation of G : M → R on the inherited gCache of SimState via memoize.

def Cslib.Crypto.Protocols.FujisakiOkamoto.simHashHRaw {M R CT K : Type} [DecidableEq M] [DecidableEq CT] (sampleKey : ProbComp K) (x : Bool × M × CT) :
StateT (SimState M R CT K) ProbComp K

Lazy evaluation of unprogrammed H : Bool × M × CT → K queries on the inherited hCache of SimState via memoize.

def Cslib.Crypto.Protocols.FujisakiOkamoto.simHashHq {M R CT K : Type} [DecidableEq CT] (sampleKey : ProbComp K) (c : CT) :
StateT (SimState M R CT K) ProbComp K

Lazy evaluation of the ciphertext-key table H_q : CT → K inside SimState via memoize.

def Cslib.Crypto.Protocols.FujisakiOkamoto.filterDecaps {M R CT K : Type} (Hq : CT → StateT (SimState M R CT K) ProbComp K) (d : List (M × R) → CT → Bool) (c : CT) :

Filtered decapsulation branch of the lazy SimState handlers: answer some (Hq c) when the filter d accepts c on the current G cache, and none otherwise.

@[reducible, inline]

The random oracles G : M → R and H : Bool × M × CT → K as one interface.

def Cslib.Crypto.Protocols.FujisakiOkamoto.romProgram {M R CT K : Type} [DecidableEq CT] (decaps : CT → OracleComp (ROSpec M R CT K) (Option K)) (cStar : CT) (q : ROQuery M CT) :
OracleComp (ROSpec M R CT K) (ROResp R K q)

Each query of a ROM IND-CCA game as a program over the random oracles: G and H are forwarded, decapsulation of cStar is refused, and any other ciphertext runs decaps.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.roHandler {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (dk : ImplicitSK PK SK M) (cStar : CT) (q : ROQuery M CT) :
StateT (ROCache M R CT K) ProbComp (ROResp R K q)

Stateful oracle handler for the real ROM IND-CCA game of FO-notbot. Queries to the challenge ciphertext cStar are rejected with none; other decapsulation queries run the scheme's decapsulation decapsNotBotM against the lazy random oracles G and H.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.roIndCcaGame {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (A : ROAdversary PK M R CT K) (b : Bool) :

The executable ROM IND-CCA security game for FO-notbot with bit b : Bool (standard KEM IND-CCA experiment, not separately located in the source map above). When b = false, the adversary receives the real encapsulated key kReal = H(false, m*, c*); when b = true, it receives an independent key kRand ← S.sampleKey. Decapsulation queries are punctured at cStar and otherwise unbounded.

noncomputable def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.indCcaRomAdvantage {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (A : RandomizedROAdversary PK M R CT K) :

The ROM IND-CCA advantage of a randomized adversary A against FO-notbot: the adversary draws its coins and plays roIndCcaGame.

noncomputable def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.coinTable {PK SK M R CT K : Type} [Fintype M] [Finite R] (S : Scheme PK SK M R CT K) :
PMF (M → R)

The eager random oracle G : M → R: an independent coin S.pke.sampleCoins at every message.

noncomputable def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.keyTable {PK SK M R CT K : Type} [Finite K] (S : Scheme PK SK M R CT K) (X : Type) [Fintype X] :
PMF (X → K)

An eager random oracle X → K into the key space: an independent key S.sampleKey at every point. The FO games draw H ← S.keyTable (Bool × M × CT) and their ciphertext-indexed key tables S.keyTable CT from it.

noncomputable def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.eagerHandler {PK SK M R CT K : Type} [DecidableEq CT] (S : Scheme PK SK M R CT K) (G : M → R) (H : Bool × M × CT → K) (dk : ImplicitSK PK SK M) (cStar : CT) (q : ROQuery M CT) :
PMF (ROResp R K q)

Stateless handler for S.eagerIndCcaGame: G and H are complete functions and decapsulation of c ≠ cStar uses the shared key oracle fun mc => H (false, mc).

noncomputable def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.eagerIndCcaGame {PK SK M R CT K : Type} [DecidableEq CT] [Fintype M] [Finite R] [Fintype CT] [Finite K] (S : Scheme PK SK M R CT K) (A : ROAdversary PK M R CT K) (b : Bool) :

The eager random-oracle IND-CCA game for FO-notbot (standard KEM IND-CCA experiment, not separately located in the source map above), defined directly from S.keyGenNotBot, S.encapsNotBot, and S.decapsNotBot over eager random oracles G ← S.coinTable and H ← S.keyTable (Bool × M × CT) and kRand ← S.sampleKey.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.simHashH {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (pk : PK) (x : Bool × M × CT) :
StateT (SimState M R CT K) ProbComp K

Simulated H oracle of simHandler: on key-derivation queries (false, m, c), checks whether S.pke.encDet pk m (G(m)) = c and if so returns H_q(c). This is designed so that decapsulation queries can be answered from H_q(c) without the secret key sk; its consistency with the real game is proved in the NotBot modules. The H_q table is adapted from the proof of the §3.2.2 IND-CCA theorem for U-notbot in [HHK17] (IACR ePrint 2017/604, full version dated 2 November 2021), with that proof's plaintext check replaced by the re-encryption check of T and the auxiliary slice answered from the raw table.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.simFilterDispatch {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (hH : Bool × M × CT → StateT (SimState M R CT K) ProbComp K) (d : List (M × R) → CT → Bool) (cStar : CT) (q : ROQuery M CT) :
StateT (SimState M R CT K) ProbComp (ROResp R K q)

Common ROQuery dispatcher for lazy SimState handlers parameterized by an H handler hH and a decapsulation filter d : List (M × R) → CT → Bool.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.simFilterHandler {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (d : List (M × R) → CT → Bool) (pk : PK) (cStar : CT) (q : ROQuery M CT) :
StateT (SimState M R CT K) ProbComp (ROResp R K q)

Keyless ROM simulator parameterized by a decapsulation acceptance filter d : List (M × R) → CT → Bool on the cached G-queries gCache. On c ≠ cStar, decapsulation returns some (H_q(c)) when d st.gCache c = true and none otherwise. Taking d = fun _ _ => true recovers simHandler for FO-notbot, while filtering by whether c is a cached re-encryption gives the simulator for FO^⊥.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.simHandler {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (pk : PK) (cStar : CT) (q : ROQuery M CT) :
StateT (SimState M R CT K) ProbComp (ROResp R K q)

Stateful oracle handler for a keyless ROM simulator of the FO-notbot IND-CCA game, designed to answer decapsulation queries for c ≠ cStar directly from H_q(c) without using sk (consistency with the real game is proved in the NotBot modules). It is not a verbatim construction from [HHK17] (IACR ePrint 2017/604, full version dated 2 November 2021): it is adapted from the lazy G simulation in the proof of the §3.1 theorem for T (IND-CPA implies OW-PCVA) and the H/decapsulation simulation in the proof of the §3.2.2 IND-CCA theorem for U-notbot, combined for FO-notbot.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.simFilterHit {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (d : PK → List (M × R) → CT → Bool) (A : ROAdversary PK M R CT K) (pk : PK) (m : M) (cStar : CT) :

The simulator run inside the IND-CPA reduction: given the public key pk, a target message m and a challenge ciphertext cStar, draw a challenge key kStar ← S.sampleKey, run the deterministic adversary A ⟨pk, cStar, kStar⟩ against S.simFilterHandler (d pk) pk cStar from empty caches, and output whether m was queried to G.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.romFilterCpaReduction {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (d : PK → List (M × R) → CT → Bool) (A : RandomizedROAdversary PK M R CT K) :
TwoStage PK (MessagePair M) CT Bool (PK × M)

The IND-CPA reduction of the FO proofs, for the keyless simulator with decapsulation filter d, as one two-stage IND-CPA adversary. The first stage receives pk, draws the challenge messages m₀, m₁ ← S.sampleMsg itself and keeps (pk, m₁). The second stage receives the challenge cStar, draws the coins ω of A, runs A.run ω against the simulator (simFilterHit) and outputs whether m₁ was queried to G.

The first stage is D₁ of the IND-CPA adversary D = (D₁, D₂) in the proof of Theorem 3.2 of [HHK17] (§3.1, IND-CPA security of the PKE implies OW-PCVA security of T[PKE, G]; IACR ePrint 2017/604, full version dated 2 November 2021, Fig. 8), which draws (m₀, m₁) uniformly. There are two differences. D₂ compares the G-queries on m₀ and m₁ and breaks ties with a coin, whereas this second stage checks m₁ only. The wrapped adversary is an IND-CCA adversary against the KEM, whose decapsulation queries are simulated as in the proof of Theorem 3.4 (§3.2.2), rather than an OW-PCVA adversary against T[PKE, G].

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.romCpaReduction {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (A : RandomizedROAdversary PK M R CT K) :
TwoStage PK (MessagePair M) CT Bool (PK × M)

The IND-CPA reduction for FO-notbot: romFilterCpaReduction with the unfiltered simulator simHandler.

Section 2: One ROM IND-CCA Experiment and Eager/Lazy Equivalence #

The ROM IND-CCA games of FO-notbot and FO^⊥ differ only in their key generation and in the decapsulation they run against the random oracles G and H. romIndCcaExperiment takes both as parameters, with decapsulation a program over the joined interface ROSpec of G and H. roIndCcaGame and eagerIndCcaGame are its FO-notbot instances (romIndCcaExperiment_notBot, eagerRomIndCcaExperiment_notBot), and CslibFrontier.Crypto.Protocols.KEM.FujisakiOkamoto.Bot gives the FO^⊥ instances. Every query of the experiment is the oracle program romProgram, so RandomOracle.eval_run_interpret_eq_complete_bind replaces both caches by complete tables in one step, and RandomOracle.bind_complete_sum splits the completed table into G and H (eval_romIndCcaExperiment_eq_eager).

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.romHandler {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (decaps : CT → OracleComp (ROSpec M R CT K) (Option K)) (cStar : CT) (q : ROQuery M CT) :
StateT (ROCache M R CT K) ProbComp (ROResp R K q)

The lazy handler of a ROM IND-CCA game: romProgram against the lazy oracles roHashG and roHashH.

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.romEagerHandler {M R CT K : Type} [DecidableEq CT] (G : M → R) (H : Bool × M × CT → K) (decaps : CT → OracleComp (ROSpec M R CT K) (Option K)) (cStar : CT) (q : ROQuery M CT) :
PMF (ROResp R K q)

The eager handler of a ROM IND-CCA game: romProgram against complete tables G and H.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.romIndCcaExperiment {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] {DK : Type} (S : Scheme PK SK M R CT K) (keyGen : ProbComp (PK × DK)) (decaps : PK → DK → CT → OracleComp (ROSpec M R CT K) (Option K)) (A : ROAdversary PK M R CT K) (b : Bool) :

The ROM IND-CCA experiment of an FO-style KEM with key generation keyGen and decapsulation decaps pk dk, a program over the random oracles, for challenge bit b. The challenge encrypts m* ← sampleMsg under coins r* ← sampleCoins, which are programmed as G(m*); the real key kReal ← sampleKey is programmed as H(false, m*, c*). The adversary receives kReal when b = false and an independent kRand ← sampleKey when b = true, and interacts with the lazy oracles through romHandler.

noncomputable def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.eagerRomIndCcaExperiment {PK SK M R CT K : Type} [DecidableEq CT] [Fintype M] [Finite R] [Fintype CT] [Finite K] {DK : Type} (S : Scheme PK SK M R CT K) (keyGen : ProbComp (PK × DK)) (decaps : PK → DK → CT → OracleComp (ROSpec M R CT K) (Option K)) (A : ROAdversary PK M R CT K) (b : Bool) :

The eager ROM IND-CCA experiment: romIndCcaExperiment with eager random oracles G ← S.coinTable and H ← S.keyTable (Bool × M × CT) and the challenge S.encapsBot G H pk.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.dispatch_eq_interpret_romProgram {M R CT K : Type} [DecidableEq CT] {n : Type → Type} [Monad n] [LawfulMonad n] (oracle : (q : M ⊕ Bool × M × CT) → n (ROSpec M R CT K q)) (decaps : CT → OracleComp (ROSpec M R CT K) (Option K)) (cStar : CT) (q : ROQuery M CT) :
ROQuery.dispatch (fun (m : M) => oracle (Sum.inl m)) (fun (x : Bool × M × CT) => oracle (Sum.inr x)) (fun (c : CT) => OracleComp.interpret oracle (decaps c)) cStar q = OracleComp.interpret oracle (romProgram decaps cStar q)

A dispatcher whose random oracles are the calls of oracle and whose decapsulation interprets decaps against oracle is oracle interpreting romProgram.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.interpret_decapsNotBotM {PK SK M R CT K : Type} [DecidableEq CT] {ι : Type} {spec : OracleSpec ι} {n : Type → Type} [Monad n] [LawfulMonad n] (oracle : (q : ι) → n (spec q)) (S : Scheme PK SK M R CT K) (G : M → OracleComp spec R) (H : M × CT → OracleComp spec K) (dk : ImplicitSK PK SK M) (c : CT) :
OracleComp.interpret oracle (S.decapsNotBotM G H dk c) = S.decapsNotBotM (fun (m : M) => OracleComp.interpret oracle (G m)) (fun (x : M × CT) => OracleComp.interpret oracle (H x)) dk c

Interpreting decapsNotBotM against oracle calls runs it against the interpreted calls.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.interpret_decapsBotM {PK SK M R CT K : Type} [DecidableEq CT] {ι : Type} {spec : OracleSpec ι} {n : Type → Type} [Monad n] [LawfulMonad n] (oracle : (q : ι) → n (spec q)) (S : Scheme PK SK M R CT K) (G : M → OracleComp spec R) (H : M × CT → OracleComp spec K) (pk : PK) (sk : SK) (c : CT) :
OracleComp.interpret oracle (S.decapsBotM G H pk sk c) = S.decapsBotM (fun (m : M) => OracleComp.interpret oracle (G m)) (fun (x : M × CT) => OracleComp.interpret oracle (H x)) pk sk c

Interpreting decapsBotM against oracle calls runs it against the interpreted calls.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.eval_romIndCcaExperiment_eq_eager {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] [Fintype M] [Finite R] [Fintype CT] [Finite K] {DK : Type} (S : Scheme PK SK M R CT K) (keyGen : ProbComp (PK × DK)) (decaps : PK → DK → CT → OracleComp (ROSpec M R CT K) (Option K)) (A : ROAdversary PK M R CT K) (b : Bool) :
(S.romIndCcaExperiment keyGen decaps A b).eval = S.eagerRomIndCcaExperiment keyGen decaps A b

Eager/lazy equivalence for the ROM IND-CCA experiment: for every key generation and decapsulation program, the lazy experiment has the output distribution of the eager one.

The FO-notbot instance #

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.notBotDecaps {PK SK M R CT K : Type} [DecidableEq CT] (S : Scheme PK SK M R CT K) (dk : ImplicitSK PK SK M) (c : CT) :
OracleComp (ROSpec M R CT K) (Option K)

FO-notbot decapsulation decapsNotBotM as a program over the random oracles.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.roHandler_eq_romHandler {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (dk : ImplicitSK PK SK M) (cStar : CT) :
S.roHandler dk cStar = S.romHandler (S.notBotDecaps dk) cStar

roHandler is the lazy handler of romProgram with FO-notbot decapsulation.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.eagerHandler_eq_romEagerHandler {PK SK M R CT K : Type} [DecidableEq CT] (S : Scheme PK SK M R CT K) (G : M → R) (H : Bool × M × CT → K) (dk : ImplicitSK PK SK M) (cStar : CT) :
S.eagerHandler G H dk cStar = romEagerHandler G H (S.notBotDecaps dk) cStar

eagerHandler is the eager handler of romProgram with FO-notbot decapsulation.

@[simp]
theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.romIndCcaExperiment_notBot {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (A : ROAdversary PK M R CT K) (b : Bool) :
S.romIndCcaExperiment S.keyGenNotBot (fun (x : PK) (dk : ImplicitSK PK SK M) => S.notBotDecaps dk) A b = S.roIndCcaGame A b

roIndCcaGame is the ROM IND-CCA experiment of FO-notbot.

@[simp]
theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.eagerRomIndCcaExperiment_notBot {PK SK M R CT K : Type} [DecidableEq CT] [Fintype M] [Finite R] [Fintype CT] [Finite K] (S : Scheme PK SK M R CT K) (A : ROAdversary PK M R CT K) (b : Bool) :
S.eagerRomIndCcaExperiment S.keyGenNotBot (fun (x : PK) (dk : ImplicitSK PK SK M) => S.notBotDecaps dk) A b = S.eagerIndCcaGame A b

eagerIndCcaGame is the eager ROM IND-CCA experiment of FO-notbot.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.eval_roIndCcaGame_eq_eagerIndCcaGame {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] [Fintype M] [Finite R] [Fintype CT] [Finite K] (S : Scheme PK SK M R CT K) (A : ROAdversary PK M R CT K) (b : Bool) :

Eager/lazy equivalence for the FO-notbot ROM IND-CCA game: evaluating the executable lazy-cached game S.roIndCcaGame A b yields the exact same output distribution as the eager random-oracle game S.eagerIndCcaGame A b.

The ROM IND-CCA advantage of a deterministic adversary A against FO-notbot equals the distinguishing advantage between S.eagerIndCcaGame A false and S.eagerIndCcaGame A true.

Section 3: The One-Wayness Experiment and the IND-CPA Reduction #

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.simHashG_gCache_length_le {M R CT K : Type} [DecidableEq M] (sampleCoins : ProbComp R) (m : M) (st : SimState M R CT K) (z : R × SimState M R CT K) (hz : z ∈ (simHashG sampleCoins m st).eval.support) :

A supported transition of simHashG adds at most one entry to gCache.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.simHashHRaw_gCache_eq {M R CT K : Type} [DecidableEq M] [DecidableEq CT] (sampleKey : ProbComp K) (x : Bool × M × CT) (st : SimState M R CT K) (z : K × SimState M R CT K) (hz : z ∈ (simHashHRaw sampleKey x st).eval.support) :
z.2.gCache = st.gCache

A supported transition of simHashHRaw preserves gCache.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.simHashHq_gCache_eq {M R CT K : Type} [DecidableEq CT] (sampleKey : ProbComp K) (c : CT) (st : SimState M R CT K) (z : K × SimState M R CT K) (hz : z ∈ (simHashHq sampleKey c st).eval.support) :
z.2.gCache = st.gCache

A supported transition of simHashHq preserves gCache.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.simFilterHandler_gCache_length_le {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (d : List (M × R) → CT → Bool) (pk : PK) (cStar : CT) (q : ROQuery M CT) (st : SimState M R CT K) (res : ROResp R K q) (st' : SimState M R CT K) (hmem : (res, st') ∈ (S.simFilterHandler d pk cStar q st).eval.support) :

Each query q to S.simFilterHandler d pk cStar increases gCache.length by at most ROQuery.ghCost q.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.simHandler_gCache_length_le {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (pk : PK) (cStar : CT) (q : ROQuery M CT) (st : SimState M R CT K) (res : ROResp R K q) (st' : SimState M R CT K) (hmem : (res, st') ∈ (S.simHandler pk cStar q st).eval.support) :

Each query q to S.simHandler pk cStar increases gCache.length by at most ROQuery.ghCost q.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.simFilterOwExperiment {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (d : PK → List (M × R) → CT → Bool) (A : ROAdversary PK M R CT K) :

The one-wayness experiment of the challenge hop: draw a key pair and a message m ← S.sampleMsg, encrypt m with fresh coins, and run the simulator of simFilterHit on the encryption. The experiment outputs whether the simulator queried G at m.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.eval_cpaExperiment_romFilterCpaReduction_true {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] (S : Scheme PK SK M R CT K) (d : PK → List (M × R) → CT → Bool) (A : RandomizedROAdversary PK M R CT K) :
ProbComp.eval (S.pke.toPKE.cpaExperiment (fun (x : PK) (x_1 x_2 : M) => true) (S.romFilterCpaReduction d A) true) = (do let ω ← A.coins S.simFilterOwExperiment d (A.run ω)).eval

With challenge bit true, the IND-CPA experiment of romFilterCpaReduction d A encrypts the message that the reduction looks for, and the other message is never used: the experiment is the one-wayness experiment of A.run ω for coins ω ← A.coins.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.succProbability_romFilterCpaReduction_false_le {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] [Fintype M] [Nonempty M] (S : Scheme PK SK M R CT K) (d : PK → List (M × R) → CT → Bool) (A : RandomizedROAdversary PK M R CT K) {qG qH : ℕ} (hq : A.QueryBounds qG qH) (hmsg : S.sampleMsg.eval = Probability.PMF.uniformOfFintype M) :
((ProbComp.eval (S.pke.toPKE.cpaExperiment (fun (x : PK) (x_1 x_2 : M) => true) (S.romFilterCpaReduction d A) false)) true).toReal ≤ (↑qG + ↑qH) / ↑(Fintype.card M)

With challenge bit false, the IND-CPA experiment of romFilterCpaReduction d A encrypts m₀, and the reduction looks for an independent uniform message m₁. The simulator caches at most qG + qH messages, so the reduction outputs true with probability at most (qG + qH) / |M|.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.succProbability_simFilterOwExperiment_le {PK SK M R CT K : Type} [DecidableEq M] [DecidableEq CT] [Fintype M] [Nonempty M] (S : Scheme PK SK M R CT K) (d : PK → List (M × R) → CT → Bool) (A : RandomizedROAdversary PK M R CT K) {qG qH : ℕ} (hq : A.QueryBounds qG qH) (hmsg : S.sampleMsg.eval = Probability.PMF.uniformOfFintype M) :
((do let ω ← A.coins S.simFilterOwExperiment d (A.run ω)).eval true).toReal ≤ ↑(S.pke.cpaAdvantage (S.romFilterCpaReduction d A)) + (↑qG + ↑qH) / ↑(Fintype.card M)

One-wayness from IND-CPA (the step Pr[QUERY] ≤ … of the proof of Theorem 3.2 of [HHK17], for the two-world advantage): for uniform messages and an adversary whose every coin value makes at most qG queries to G and qH queries to H, the averaged one-wayness experiment is bounded by the two-stage IND-CPA advantage of the single reduction romFilterCpaReduction d A: Pr[OW] ≤ Adv^{IND-CPA}(romFilterCpaReduction d A) + (qG + qH) / |M|.