Documentation

CslibFrontier.Crypto.Protocols.KEM.FujisakiOkamoto

HHK17 Modular Fujisaki–Okamoto KEM Transforms #

Hofheinz, Hövelmanns, and Kiltz ([HHK17], IACR ePrint 2017/604 full version dated 2 November 2021) decompose the Fujisaki–Okamoto transformation of a public-key encryption scheme PKE = (Gen, Enc, Dec) with explicit coin space R into two modular steps:

  1. Derandomization with mandatory re-encryption check T[PKE, G] (encT, decT; §3.1, Fig. 5): given a function G : M → R, encrypt m deterministically as Enc(pk, m; G(m)), and on decryption recompute Enc(pk, m'; G(m')) = c after running Dec(sk, c) = some m', rejecting any ciphertext failing the check (encT_of_decT_eq_some).
  2. Key encapsulation with explicit or implicit rejection:
    • FO^⊥ = U^⊥ ∘ T (Scheme.encapsBot, Scheme.decapsBot; §3.2.1, Fig. 9): decapsulation returns none on re-encryption failure and some (H(m', c)) on success.
    • FO-notbot = U-notbot ∘ T (Scheme.keyGenNotBot, Scheme.encapsNotBot, Scheme.decapsNotBot; §3.2.2, Fig. 12, written with a negated-⊥ superscript in the paper): the secret key (ImplicitSK) retains the public key pk and a secret fallback seed fallback ← M, returning a pseudorandom fallback key H(fallback, c) on decapsulation rejection so decapsulation never outputs failure externally.

Scope of this module: this file formalizes the T, FO^⊥, and FO-notbot transforms together with their deterministic recovery and re-encryption rigidity lemmas. The generic explicit-coin PKE interface, correctness and spreadness live in CslibFrontier.Crypto.Protocols.PKE.ExplicitCoin. The IND-CPA notion of the FO security theorems is two-stage IND-CPA (cpaAdvantage, via PKE.cpaExperiment on ExplicitCoinPKE.toPKE), not the fixed-message indCpaGame. Adaptive random-oracle IND-CCA games and the security reductions live in the FujisakiOkamoto/ submodules; a standalone transfer of PKE δ-correctness to KEM correctness is not formalized (δ enters only as a hop inside the IND-CCA bounds).

Source map and model differences #

All section and figure locators refer to the full version of [HHK17] served by IACR ePrint 2017/604, dated 2 November 2021:

The PKE-level fixed-coin-type and arbitrary-sampler differences are documented in CslibFrontier.Crypto.Protocols.PKE.ExplicitCoin; the security theorems use two-stage IND-CPA. In Figures 9 and 12 the encapsulated message, fallback seed and ideal key are uniform. The algorithms take explicit message and key samplers, and the word-level security theorem instantiates them with uniform fixed-length words. In Figure 12 both successful decapsulation and implicit rejection query the same function on a message and ciphertext. The secret seed is the message argument on rejection.

The imported ExplicitCoinPKE interface exposes the deterministic encryption needed for T to recompute Enc(pk, m'; G(m')) during decapsulation.

Main definitions #

Main results #

References #

T[PKE, G]: Derandomization with Mandatory Re-Encryption Check #

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

Derandomized encryption Enc_1(pk, m) := Enc(pk, m; G(m)) of T[PKE, G] ([HHK17], ePrint 2017/604 (2 Nov 2021), §3.1, Fig. 5).

def Cslib.Crypto.Protocols.FujisakiOkamoto.decTM {PK SK M R CT : Type} [DecidableEq CT] {m : Type → Type} [Monad m] (P : ExplicitCoinPKE PK SK M R CT) (G : M → m R) (pk : PK) (sk : SK) (c : CT) :
m (Option M)

Derandomized decryption Dec_1(pk, sk, c) of T[PKE, G] with mandatory re-encryption check ([HHK17], ePrint 2017/604 (2 Nov 2021), §3.1, Fig. 5): runs m' ← Dec(sk, c) and accepts m' only when Enc(pk, m'; G(m')) = c, with oracle access to G : M → m R in a monad m. G is queried only when Dec succeeds. The random-oracle games run it with lazily sampled G; decT is the case of a fixed function G.

def Cslib.Crypto.Protocols.FujisakiOkamoto.decT {PK SK M R CT : Type} [DecidableEq CT] (P : ExplicitCoinPKE PK SK M R CT) (G : M → R) (pk : PK) (sk : SK) (c : CT) :

Derandomized decryption Dec_1(pk, sk, c) of T[PKE, G] with mandatory re-encryption check ([HHK17], ePrint 2017/604 (2 Nov 2021), §3.1, Fig. 5) for a fixed function G: decTM in the identity monad.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.decT_eq {PK SK M R CT : Type} [DecidableEq CT] (P : ExplicitCoinPKE PK SK M R CT) (G : M → R) (pk : PK) (sk : SK) (c : CT) :
decT P G pk sk c = match P.dec sk c with | none => none | some m' => if encT P G pk m' = c then some m' else none

decT runs m' ← Dec(sk, c) and accepts m' only when Enc(pk, m'; G(m')) = c.

@[simp]
theorem Cslib.Crypto.Protocols.FujisakiOkamoto.decTM_pure {PK SK M R CT : Type} [DecidableEq CT] {m : Type → Type} [Monad m] [LawfulMonad m] (P : ExplicitCoinPKE PK SK M R CT) (G : M → R) (pk : PK) (sk : SK) (c : CT) :
decTM P (pure ∘ G) pk sk c = pure (decT P G pk sk c)

With a pure oracle, decTM is decT.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.decT_encT_eq_some {PK SK M R CT : Type} [DecidableEq CT] (P : ExplicitCoinPKE PK SK M R CT) (G : M → R) (pk : PK) (sk : SK) (m : M) (hdec : P.dec sk (encT P G pk m) = some m) :
decT P G pk sk (encT P G pk m) = some m

Whenever Dec(sk, Enc_1(pk, m)) = some m, the re-encryption check succeeds and decT recovers some m.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.encT_of_decT_eq_some {PK SK M R CT : Type} [DecidableEq CT] {P : ExplicitCoinPKE PK SK M R CT} {G : M → R} {pk : PK} {sk : SK} {c : CT} {m' : M} (h : decT P G pk sk c = some m') :
encT P G pk m' = c

Rigidity of T: any plaintext m' accepted by decT re-encrypts strictly to c, and satisfies P.dec sk c = some m'.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.dec_of_decT_eq_some {PK SK M R CT : Type} [DecidableEq CT] {P : ExplicitCoinPKE PK SK M R CT} {G : M → R} {pk : PK} {sk : SK} {c : CT} {m' : M} (h : decT P G pk sk c = some m') :
P.dec sk c = some m'
theorem Cslib.Crypto.Protocols.FujisakiOkamoto.decT_eq_none_of_reencrypt_ne {PK SK M R CT : Type} [DecidableEq CT] (P : ExplicitCoinPKE PK SK M R CT) (G : M → R) (pk : PK) (sk : SK) (c : CT) (hbad : ∀ (m' : M), P.dec sk c = some m' → encT P G pk m' ≠ c) :
decT P G pk sk c = none

Any ciphertext failing the re-encryption check on its decrypted candidate is rejected by decT.

FO^⊥ and FO-notbot: Explicit- and Implicit-Rejection KEM Transforms #

Extended secret key (sk, pk, fallback) of the implicit-rejection KEM FO-notbot ([HHK17], ePrint 2017/604 (2 Nov 2021), §3.2.2, Fig. 12), retaining the public key for the re-encryption check and a secret fallback message seed fallback ∈ M.

  • sk : SK

    Underlying PKE secret key sk.

  • pk : PK

    Underlying PKE public key pk, stored to recompute Enc(pk, m'; G(m')).

  • fallback : M

    Secret fallback seed s ∈ M used to derive pseudorandom keys on invalid ciphertexts.

@[instance_reducible]
def Cslib.Crypto.Protocols.FujisakiOkamoto.instDecidableEqImplicitSK.decEq {PK✝ SK✝ M✝ : Type} [DecidableEq PK✝] [DecidableEq SK✝] [DecidableEq M✝] (x✝ x✝¹ : ImplicitSK PK✝ SK✝ M✝) :
Decidable (x✝ = x✝¹)

Parameter bundle for the HHK17 Fujisaki–Okamoto KEM transforms FO^⊥ and FO-notbot ([HHK17], ePrint 2017/604 (2 Nov 2021), §3.2.1 Fig. 9 and §3.2.2 Fig. 12): an ExplicitCoinPKE scheme paired with its message-space sampler sampleMsg and shared-key sampler sampleKey (generalizing the paper's uniform draws from M and K).

  • pke : ExplicitCoinPKE PK SK M R CT

    Underlying explicit-coin public-key encryption scheme PKE.

  • sampleMsg : ProbComp M

    Sampler m ← M for encapsulated plaintexts and implicit-rejection seeds.

  • sampleKey : ProbComp K

    Sampler k ← K for shared KEM keys.

Decapsulation with oracle access #

The random-oracle games answer G and H lazily, so their decapsulation oracles run the decapsulation algorithms with G : M → m R and H : M × CT → m K given as oracles in a monad m. Both run the T check decTM and add only their rejection policy and H query. decapsBotM_eq and decapsNotBotM_eq unfold them into explicit oracle calls. The fixed-function decapsulations decapsBot and decapsNotBot below are these algorithms in the identity monad; with pure oracles in any lawful monad, the oracle-access versions return them (decapsBotM_pure, decapsNotBotM_pure).

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsBotM {PK SK M R CT K : Type} [DecidableEq CT] {m : Type → Type} [Monad m] (S : Scheme PK SK M R CT K) (G : M → m R) (H : M × CT → m K) (pk : PK) (sk : SK) (c : CT) :
m (Option K)

Explicit-rejection decapsulation Decaps^⊥(pk, sk, c) of FO^⊥ with oracle access to G and H: returns some (H(m', c)) when decTM accepts m', and none otherwise.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsNotBotM {PK SK M R CT K : Type} [DecidableEq CT] {m : Type → Type} [Monad m] (S : Scheme PK SK M R CT K) (G : M → m R) (H : M × CT → m K) (dk : ImplicitSK PK SK M) (c : CT) :
m K

Implicit-rejection decapsulation Decaps-notbot(dk, c) of FO-notbot with oracle access to G and H: returns H(m', c) when decTM accepts m', and the fallback key H(dk.fallback, c) otherwise.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsBotM_eq {PK SK M R CT K : Type} [DecidableEq CT] {m : Type → Type} [Monad m] [LawfulMonad m] (S : Scheme PK SK M R CT K) (G : M → m R) (H : M × CT → m K) (pk : PK) (sk : SK) (c : CT) :
S.decapsBotM G H pk sk c = match S.pke.dec sk c with | none => pure none | some m' => do let r' ← G m' if S.pke.encDet pk m' r' = c then do let k ← H (m', c) pure (some k) else pure none

decapsBotM as explicit oracle calls: no query when Dec fails; otherwise G(m'), then H(m', c) exactly when the re-encryption check passes.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsNotBotM_eq {PK SK M R CT K : Type} [DecidableEq CT] {m : Type → Type} [Monad m] [LawfulMonad m] (S : Scheme PK SK M R CT K) (G : M → m R) (H : M × CT → m K) (dk : ImplicitSK PK SK M) (c : CT) :
S.decapsNotBotM G H dk c = match S.pke.dec dk.sk c with | none => H (dk.fallback, c) | some m' => do let r' ← G m' if S.pke.encDet dk.pk m' r' = c then H (m', c) else H (dk.fallback, c)

decapsNotBotM as explicit oracle calls: H(dk.fallback, c) when Dec fails; otherwise G(m'), then H(m', c) or H(dk.fallback, c) by the re-encryption check.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.encapsBot {PK SK M R CT K : Type} (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (pk : PK) :
ProbComp (CT × K)

Encapsulation Encaps^⊥(pk) for FO^⊥ = U^⊥ ∘ T with fixed functions G and H ([HHK17], ePrint 2017/604 (2 Nov 2021), §3.2.1, Fig. 9): samples m ← sampleMsg, computes c := Enc(pk, m; G(m)), and outputs (c, H(m, c)).

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsBot {PK SK M R CT K : Type} [DecidableEq CT] (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (pk : PK) (sk : SK) (c : CT) :

Explicit-rejection decapsulation Decaps^⊥(pk, sk, c) for FO^⊥ = U^⊥ ∘ T ([HHK17], ePrint 2017/604 (2 Nov 2021), §3.2.1, Fig. 9) with fixed functions G and H: decapsBotM in the identity monad. It returns some (H(m', c)) when decT accepts m', and none otherwise (decapsBot_eq).

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsBot_eq {PK SK M R CT K : Type} [DecidableEq CT] (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (pk : PK) (sk : SK) (c : CT) :
S.decapsBot G H pk sk c = Option.map (fun (m' : M) => H (m', c)) (decT S.pke G pk sk c)

decapsBot returns some (H(m', c)) when decT accepts m', and none otherwise.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsBot_encT_eq_some {PK SK M R CT K : Type} [DecidableEq CT] (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (pk : PK) (sk : SK) (m : M) (hdec : S.pke.dec sk (encT S.pke G pk m) = some m) :
S.decapsBot G H pk sk (encT S.pke G pk m) = some (H (m, encT S.pke G pk m))

Honest recovery for FO^⊥: whenever Dec(sk, Enc_1(pk, m)) = some m, decapsBot returns some (H(m, Enc_1(pk, m))).

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsBot_eq_none_of_decT_eq_none {PK SK M R CT K : Type} [DecidableEq CT] (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (pk : PK) (sk : SK) (c : CT) (hnone : decT S.pke G pk sk c = none) :
S.decapsBot G H pk sk c = none
theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsBot_eq_none_of_reencrypt_ne {PK SK M R CT K : Type} [DecidableEq CT] (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (pk : PK) (sk : SK) (c : CT) (hbad : ∀ (m' : M), S.pke.dec sk c = some m' → encT S.pke G pk m' ≠ c) :
S.decapsBot G H pk sk c = none

Explicit rejection for FO^⊥: any tampered ciphertext failing the re-encryption check decapsulates to none.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.keyGenNotBot {PK SK M R CT K : Type} (S : Scheme PK SK M R CT K) :
ProbComp (PK × ImplicitSK PK SK M)

Key generation Gen-notbot for FO-notbot = U-notbot ∘ T ([HHK17], ePrint 2017/604 (2 Nov 2021), §3.2.2, Fig. 12): generates (pk, sk) ← pke.keyGen, samples a secret seed s ← sampleMsg, and outputs (pk, ⟨sk, pk, s⟩).

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.encapsNotBot {PK SK M R CT K : Type} (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (pk : PK) :
ProbComp (CT × K)

Encapsulation Encaps-notbot(pk) for FO-notbot = U-notbot ∘ T ([HHK17], ePrint 2017/604 (2 Nov 2021), §3.2.2, Fig. 12), identical to encapsBot.

def Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsNotBot {PK SK M R CT K : Type} [DecidableEq CT] (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (dk : ImplicitSK PK SK M) (c : CT) :
K

Implicit-rejection decapsulation for FO-notbot = U-notbot ∘ T ([HHK17], §3.2.2, Figure 12), with fixed functions G and H. A rejection and an ordinary key query at the fallback seed use the same H(dk.fallback, c).

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsNotBot_eq {PK SK M R CT K : Type} [DecidableEq CT] (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (dk : ImplicitSK PK SK M) (c : CT) :
S.decapsNotBot G H dk c = match decT S.pke G dk.pk dk.sk c with | some m' => H (m', c) | none => H (dk.fallback, c)

decapsNotBot returns H(m', c) when decT accepts m', and the fallback key H(dk.fallback, c) otherwise.

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsNotBot_encT_eq {PK SK M R CT K : Type} [DecidableEq CT] (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (dk : ImplicitSK PK SK M) (m : M) (hdec : S.pke.dec dk.sk (encT S.pke G dk.pk m) = some m) :
S.decapsNotBot G H dk (encT S.pke G dk.pk m) = H (m, encT S.pke G dk.pk m)

Honest recovery for FO-notbot: whenever Dec(dk.sk, Enc_1(dk.pk, m)) = some m, the re-encryption check passes and decapsNotBot outputs H(m, Enc_1(dk.pk, m)).

theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsNotBot_of_decT_eq_none {PK SK M R CT K : Type} [DecidableEq CT] (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (dk : ImplicitSK PK SK M) (c : CT) (hnone : decT S.pke G dk.pk dk.sk c = none) :
S.decapsNotBot G H dk c = H (dk.fallback, c)
theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsNotBot_of_reencrypt_ne {PK SK M R CT K : Type} [DecidableEq CT] (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (dk : ImplicitSK PK SK M) (c : CT) (hbad : ∀ (m' : M), S.pke.dec dk.sk c = some m' → encT S.pke G dk.pk m' ≠ c) :
S.decapsNotBot G H dk c = H (dk.fallback, c)

Implicit pseudorandom rejection for FO-notbot: any tampered ciphertext failing the re-encryption check decapsulates to H(dk.fallback, c).

Pure oracles #

With pure oracles pure ∘ G and pure ∘ H in any lawful monad, the oracle-access decapsulations return the fixed-function ones.

@[simp]
theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsBotM_pure {PK SK M R CT K : Type} [DecidableEq CT] {m : Type → Type} [Monad m] [LawfulMonad m] (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (pk : PK) (sk : SK) (c : CT) :
S.decapsBotM (pure ∘ G) (pure ∘ H) pk sk c = pure (S.decapsBot G H pk sk c)

With pure oracles, decapsBotM is the fixed-function decapsulation decapsBot.

@[simp]
theorem Cslib.Crypto.Protocols.FujisakiOkamoto.Scheme.decapsNotBotM_pure {PK SK M R CT K : Type} [DecidableEq CT] {m : Type → Type} [Monad m] [LawfulMonad m] (S : Scheme PK SK M R CT K) (G : M → R) (H : M × CT → K) (dk : ImplicitSK PK SK M) (c : CT) :
S.decapsNotBotM (pure ∘ G) (pure ∘ H) dk c = pure (S.decapsNotBot G H dk c)

With pure oracles, decapsNotBotM is the fixed-function decapsulation decapsNotBot.