Skip to content

feat(SymmEncAlg): left-or-right CCA game, and CCA security of Encrypt-then-MAC - #1165

Draft
sisyphm wants to merge 3 commits into
Verified-zkEVM:mainfrom
sisyphm:encrypt-then-mac
Draft

sisyphm wants to merge 3 commits into
Verified-zkEVM:mainfrom
sisyphm:encrypt-then-mac

Conversation

@sisyphm

@sisyphm sisyphm commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #1164; only the last commit is new.

Summary

Design discussion: #1161. This is the multi-query textbook theorem: a randomized SymmEncAlg
that is CPA-secure for many encryptions, plus a SUF-CMA MAC. It complements the one-time
deterministic-AEAD bound planned in #1086. Refused and invalid ciphertexts both decrypt to none,
the convention the public-key game has used since #1104.

VCVio/CryptoFoundations/SymmEncAlg/INDCCA.lean

This file adds the multi-query CCA game of a SymmEncAlg (Katz–Lindell 3rd ed. §5.1.2). Katz–Lindell
state the game with one challenge; this is its left-or-right form with many challenges, and the
docstring says so.

  • IND_CCA_Adversary encAlg := OracleComp (spec + LeftOrRight.spec M C + (C →ₒ Option M)) Bool.
  • IND_CCA_challengeImpl: the LeftOrRight.oracle, which also logs the returned ciphertext in
    StateT (List C).
  • IND_CCA_decryptImpl: answers none on logged challenge ciphertexts and encAlg.decrypt k c
    otherwise.
  • IND_CCA_Experiment / IND_CCA_Game / IND_CCA_Advantage (boolBias) and
    IND_CCA_Advantage_probComp (boolDist of the fixed-bit experiments).
  • IND_CCA_Adversary.MakesAtMostDecryptionQueries.

VCVio/Schemes/EncryptThenMac.lean

This file adds scheme enc mac with key (kₑ, kₘ). Encryption returns (c, t) with t a tag on
c, and decryption returns none unless the tag verifies (Katz–Lindell §5.3.1; Boneh–Shoup v0.6
§9.4.1).

Main theorem EncryptThenMac.IND_CCA_Advantage_le: for a MAC with deterministic verification
(hvf : ∀ k c t, mac.verify k c t = pure (vf k c t)) and an adversary with at most q
decryption queries,

Adv_CCA(scheme enc mac, A) ≤ Adv_CPA(enc, cpaReduction enc mac A)
    + Σ_{j<q} (Adv_SUF(mac, forger enc mac leak A true j) + Adv_SUF(mac, forger enc mac leak A false j))

Named reductions:

  • cpaReduction: samples a MAC key, forwards challenge pairs to the CPA oracle, tags the returned
    ciphertexts, and answers every decryption query with none.
  • forger … b j: runs the game at bit b with its own encryption key, gets tags from the tagging
    oracle until the j-th decryption query, then stops tagging and outputs that query.

Proof structure:

  1. The CCA game equals a logged game ccaLogImpl, by state projection
    (IND_CCA_Experiment_eq). The logged game records each decryption query with its freshness.
  2. ccaLogImpl and rejectImpl, which answers every decryption query with none, agree until a
    fresh decryption query verifies (agreeUntilBad_ccaLogImpl_rejectImpl, ForgeryLogged).
    This gives boolDist_IND_CCA_Experiment_rejectExperiment_le.
  3. rejectImpl is the CPA game of cpaReduction (rejectExperiment_eq_IND_CPA_Experiment).
  4. Forgery bound (forgeryExperiment_le_sum):
    • With at most q decryption queries, a logged forgery is one of the first q
      (IsQueryBoundP.cost_le_of_mem_support_run_simulateQ).
    • The j-th query has the same law in the game that stops tagging after it. This uses a
      generic stopping lemma, map_run_simulateQ_evalDistEq_of_eq_until_stopped: two handlers
      equal before a stopping state, which both freeze an observation afterwards, give the
      observation the same law.
    • In the stopped game the j-th fresh query is fresh against the final log
      (preservesInv_stopImpl).
    • The stopped game, viewed through forgerView, is the forger's run against
      MacAlg.taggingOracle (map_run_simulateQ_stopImpl, via QueryImpl.mapStateTBase and
      flattenWriterT).

Assumptions and scope:

  • Deterministic MAC verification (hvf). With probabilistic verification, step 2 would raise
    the bad flag with verification coins that the forger cannot reproduce.
  • [Inhabited C] [Inhabited T]. The forger needs a default output when fewer than j + 1
    decryption queries occur.
  • No correctness assumption on enc or mac: CCA security does not need one.
  • The q_d factor. It comes from guessing the decryption query, because
    MacAlg.strongUnforgeableExperiment has no verification oracle. The bound keeps one forger per
    hidden bit and per index, so no averaging over j is needed.

Generic pieces that could move to OracleComp/SimSemantics if useful:
map_run_simulateQ_evalDistEq_of_eq_until_stopped, flattenWriterT /
run_simulateQ_flattenWriterT, and run_simulateQ_liftTarget_writerT.

No existing declaration changes. VCVio.lean gains the two imports generated by
./scripts/update-lib.sh.

Verification

  • lake build VCVio.CryptoFoundations.SymmEncAlg.INDCCA VCVio.Schemes.EncryptThenMac: 0 errors,
    0 warnings.
  • lake exe axiomsweep --check --root <module> on the four modules of this stack (122 declarations): zero sorry and
    zero non-standard axioms.
  • ./scripts/update-lib.sh, then scripts/check-imports.sh.
  • lake lint -- --style-only.
  • lake exe runLinter --no-build VCVio.Schemes.EncryptThenMac. Its 13 findings are all
    defsWithUnderscore on IND_CPA_* / IND_CCA_* names. scripts/lint.py accepts every one of
    them by its acronym-led naming policy (acronym_led).
  • Shell boundary checks and the Agent Docs Python checks, as in the CPA PR.

I did not run a full lake build or lake lint -- --env-only locally. CI runs both.

Checklist

  • New files carry the standard header and module docstring (CONTRIBUTING.md, Attribution
    And File Headers
    ); docstrings are intrinsic, with no change history or "renamed from" wording.
  • New files use plain public section with per-declaration @[expose] (Module Scopes), and
    the expose-boundary baseline was lowered in this PR if a file was converted.
  • ./scripts/update-lib.sh leaves the umbrella files unchanged, and
    lake exe axiomsweep --check passes: no sorry and no non-standard axiom.
    (axiomsweep --check run with --root on the four modules of this stack (122 declarations); CI runs the whole-library sweep.)
  • No set_option linter.* false, no deprecated aliases (docs/agents/gotchas.md §18, §23),
    and no native FFI test executables on the PR path.
  • Documentation touched by the change is updated and uv run --no-project --python 3.12 python scripts/check-agent-docs.py
    passes.
  • If a simp/grind/gcongr set changed: the gate files under VCVioTest/ gained one-call
    entries, no proof gained a second tactic call outside a dated gap pair, and the before/after
    line counts of the touched proofs are listed above. (N/A: no simp set changed.)

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

🤖 PR Summary

Mathematical Formalization

IND-CCA Security Game (VCVio/CryptoFoundations/SymmEncAlg/INDCCA.lean)

This file defines the left-or-right multi-query IND-CCA game for a SymmEncAlg. The definitions include:

  • IND_CCA_Adversary encAlg: type alias OracleComp (spec + LeftOrRight.spec M C + (C →ₒ Option M)) Bool.
  • IND_CCA_challengeImpl: the LeftOrRight.oracle which logs ciphertexts in StateT (List C).
  • IND_CCA_decryptImpl: returns none on logged challenge ciphertexts and encAlg.decrypt k c otherwise.
  • IND_CCA_Experiment / IND_CCA_Game / IND_CCA_Advantage (boolBias) and IND_CCA_Advantage_probComp (boolDist).
  • IND_CCA_Adversary.MakesAtMostDecryptionQueries.

The file is fully formalized with no sorry or non-standard axioms.

Encrypt-then-MAC Scheme and CCA Security (VCVio/Schemes/EncryptThenMac.lean)

This file implements the scheme scheme enc mac where encryption returns (c, t) and decryption returns none on tag verification failure. The main theorem is:

  • EncryptThenMac.IND_CCA_Advantage_le: for a MAC with deterministic verification (hvf) and an adversary making at most q decryption queries, the CCA advantage is bounded by the CPA advantage of cpaReduction plus the sum over j < q of the SUF-CMA advantages of two forgers forger enc mac leak A true j and forger enc mac leak A false j.

Key reductions:

  • cpaReduction: samples a MAC key, uses the CPA oracle for challenges, tags ciphertexts, and answers all decryption queries with none.
  • forger … b j: runs the game with its own encryption key, uses the tagging oracle until the j-th decryption query, then outputs that query.

Proof structure uses:

  • IND_CCA_Experiment_eq: equivalence to a logged game.
  • agreeUntilBad_ccaLogImpl_rejectImpl: real and rejecting games agree until a forgery.
  • rejectExperiment_eq_IND_CPA_Experiment: rejecting game equals the CPA game.
  • forgeryExperiment_le_sum: bounds forgery probability via stopping lemma map_run_simulateQ_evalDistEq_of_eq_until_stopped and preservesInv_stopImpl.

Scope includes generic lemmas flattenWriterT / run_simulateQ_flattenWriterT, run_simulateQ_liftTarget_writerT, and map_run_simulateQ_evalDistEq_of_eq_until_stopped.

Protocol / Soundness

  • The game design follows Katz–Lindell 3rd ed. §5.1.2 for the multi-query left-or-right CCA game. Refused and invalid ciphertexts decrypt to none.
  • The proof assumes deterministic MAC verification (hvf), and requires [Inhabited C] [Inhabited T] for the forgers. No correctness assumption on enc or mac is needed.
  • The bound keeps one forger per hidden bit and per decryption query index, introducing a factor of q.

Infrastructure / CI

  • VCVio.lean: gains two imports (SymmEncAlg.INDCCA and Schemes.EncryptThenMac), generated by ./scripts/update-lib.sh.
  • No existing declarations were changed.
  • Build and lint checks pass (0 errors, 0 warnings). The linter findings are all defsWithUnderscore on IND_CPA_* / IND_CCA_* names, accepted by the acronym-led naming policy.
  • axiomsweep --check on the four modules of this stack (122 declarations): zero sorry and zero non-standard axioms.

Statistics

Metric Count
📝 Files Changed 3
✅ Lines Added 1037
❌ Lines Removed 0

Lean Declarations

✏️ Added: 63 declaration(s)

VCVio/CryptoFoundations/SymmEncAlg/INDCCA.lean (9)

  • @[expose] def IND_CCA_Adversary.MakesAtMostDecryptionQueries
  • @[expose] def IND_CCA_Experiment [DecidableEq C] (encAlg : SymmEncAlg (OracleComp spec) M K C)
  • @[expose] def IND_CCA_Game [DecidableEq C] (encAlg : SymmEncAlg (OracleComp spec) M K C)
  • @[expose] def IND_CCA_challengeImpl (encAlg : SymmEncAlg (OracleComp spec) M K C) (k : K)
  • @[expose] def IND_CCA_decryptImpl [DecidableEq C] (encAlg : SymmEncAlg (OracleComp spec) M K C)
  • @[expose] def IND_CCA_impl [DecidableEq C] (encAlg : SymmEncAlg (OracleComp spec) M K C) (k : K)
  • @[expose] noncomputable def IND_CCA_Advantage [DecidableEq C]
  • abbrev IND_CCA_Adversary (_encAlg : SymmEncAlg (OracleComp spec) M K C)
  • theorem IND_CCA_Advantage_probComp [DecidableEq C] (encAlg : SymmEncAlg ProbComp M K C)

VCVio/Schemes/EncryptThenMac.lean (54)

  • @[expose] def ForgeryAt (vf : C → T → Bool) (j : ℕ) (s : GameState C T) : Prop
  • @[expose] def ForgeryLogged (vf : C → T → Bool) (s : GameState C T) : Prop
  • @[expose] def FreshValidAt (vf : C → T → Bool) (j : ℕ) (s : GameState C T) : Prop
  • @[expose] def StopInv (j : ℕ) (s : GameState C T) : Prop
  • @[expose] def ccaDecryptImpl (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • @[expose] def ccaLogImpl (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • @[expose] def challengeImpl (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • @[expose] def cpaChallengeImpl (mac : MacAlg ProbComp C Km T) (km : Km) :
  • @[expose] def cpaDecryptImpl :
  • @[expose] def cpaReduction (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • @[expose] def cpaReductionImpl (mac : MacAlg ProbComp C Km T) (km : Km) :
  • @[expose] def flattenWriterT (impl : QueryImpl spec (StateT σ (WriterT (List A) ProbComp))) :
  • @[expose] def forger [Inhabited C] [Inhabited T] (enc : SymmEncAlg ProbComp M Ke C)
  • @[expose] def forgerChallengeImpl (enc : SymmEncAlg ProbComp M Ke C) (ke : Ke) (leak : M → Λ)
  • @[expose] def forgerDecryptImpl : QueryImpl (C × T →ₒ Option M)
  • @[expose] def forgerImpl (enc : SymmEncAlg ProbComp M Ke C) (ke : Ke) (leak : M → Λ) (b : Bool)
  • @[expose] def forgerView (s : GameState C T) : List (C × T) × QueryLog (C →ₒ T)
  • @[expose] def forgeryExperiment (enc : SymmEncAlg ProbComp M Ke C)
  • @[expose] def rejectDecryptImpl :
  • @[expose] def rejectExperiment (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • @[expose] def rejectImpl (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • @[expose] def scheme (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T) :
  • @[expose] def stopChallengeImpl (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • @[expose] def stopImpl (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • @[expose] noncomputable def forgerTaggedImpl (enc : SymmEncAlg ProbComp M Ke C)
  • abbrev GameState (C T : Type)
  • abbrev ccaSpec (M C T : Type)
  • lemma forgeryAt_of_freshValidAt {vf : C → T → Bool} {j : ℕ} {s : GameState C T}
  • lemma forgeryLogged_append {vf : C → T → Bool} {s : GameState C T} (h : ForgeryLogged vf s)
  • lemma rejectImpl_run_inl_inl (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • lemma rejectImpl_run_inr (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • lemma run_simulateQ_liftTarget_writerT {α : Type} (oa : ProbComp α) :
  • lemma snd_of_mem_support_challengeImpl (enc : SymmEncAlg ProbComp M Ke C)
  • lemma stopImpl_run_inl_inl (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • lemma stopImpl_run_inl_inr (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • lemma stopImpl_run_inr (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • lemma win_forgerView_of_forgeryAt [Inhabited C] [Inhabited T] {vf : C → T → Bool} {j : ℕ}
  • theorem IND_CCA_Advantage_le [Inhabited C] [Inhabited T] (enc : SymmEncAlg ProbComp M Ke C)
  • theorem IND_CCA_Experiment_eq (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • theorem agreeUntilBad_ccaLogImpl_rejectImpl (enc : SymmEncAlg ProbComp M Ke C)
  • theorem boolDist_IND_CCA_Experiment_rejectExperiment_le (enc : SymmEncAlg ProbComp M Ke C)
  • theorem forgeryExperiment_le_sum [Inhabited C] [Inhabited T] (enc : SymmEncAlg ProbComp M Ke C)
  • theorem forgeryLogged_imp_exists_freshValidAt (enc : SymmEncAlg ProbComp M Ke C)
  • theorem map_run_simulateQ_evalDistEq_of_eq_until_stopped
  • theorem map_run_simulateQ_evalDistEq_pure_of_stopped (impl : QueryImpl spec (StateT σ ProbComp))
  • theorem map_run_simulateQ_stopImpl (enc : SymmEncAlg ProbComp M Ke C)
  • theorem prEvent_rejectImpl_freshValidAt_eq (enc : SymmEncAlg ProbComp M Ke C)
  • theorem preservesInv_rejectImpl (enc : SymmEncAlg ProbComp M Ke C)
  • theorem preservesInv_stopImpl (enc : SymmEncAlg ProbComp M Ke C) (mac : MacAlg ProbComp C Km T)
  • theorem rejectExperiment_eq_IND_CPA_Experiment (enc : SymmEncAlg ProbComp M Ke C)
  • theorem run'_simulateQ_rejectImpl (enc : SymmEncAlg ProbComp M Ke C)
  • theorem run_simulateQ_eq_map_flattenWriterT
  • theorem run_simulateQ_flattenWriterT (impl : QueryImpl spec (StateT σ (WriterT (List A) ProbComp)))
  • theorem strongUnforgeableExperiment_forger [Inhabited C] [Inhabited T]

sorry Tracking

  • No sorrys were added, removed, or affected.

📋 **Additional Analysis**

Review Findings

Copyright header

  • Both new files (INDCCA.lean and EncryptThenMac.lean) correctly include the standard header with the author name and copyright year 2026. No issues.

File structure (prologue layout)

  • INDCCA.lean: Header, blank line, module, then public import lines, blank line, then module docstring. Correct.
  • EncryptThenMac.lean: Header, blank line, module, then public import lines, blank line, then module docstring. Correct.

Module docstrings

  • Both files have module docstrings giving a concise title and summary, with references when material. Check.
  • INDCCA.lean: includes notation reference (Katz–Lindell §5.1.2) and lists main definitions/statements. Check.
  • EncryptThenMac.lean: includes references, a proof sketch, and lists main definitions/statements. Check.

Declaration docstrings

  • INDCCA.lean: All exposed definitions have descriptive docstrings. Check.
  • EncryptThenMac.lean: All exposed definitions have descriptive docstrings. Check.

Section headers

  • Both files use /-! ## Section title -/ doc-comment headers, not ASCII banners. Check.

set_option lines

  • Neither file adds any per-file set_option lines, including no linter suppressions. Check.

Module scopes

  • Both files use public section (not backward.privateInPublic or backward.proofsInPublic). Check.
  • They use public import, public meta import, or plain import appropriately. Check.
  • No cross-package import all PolyFun.… appears. Check.
  • The @[expose] attribute is used on definitions where unfolding is part of the intended public API (e.g. IND_CCA_Adversary.MakesAtMostDecryptionQueries, IND_CCA_challengeImpl, etc.) and not on all definitions. Check.

Imports

  • Imports are at the top of each file, after the module line. Check.
  • INDCCA.lean imports INDCPA and OracleComp.SimSemantics.StateT.Basic; these are conceptually within the same module layer. Check.
  • EncryptThenMac.lean imports SymmEncAlg.INDCCA, MacAlg, and a few OracleComp simulation helpers. These respect the module layering described in AGENTS.md (CryptoFoundations before Schemes). Check.

omit usage

  • Several omit [DecidableEq C] [DecidableEq T] lines appear in EncryptThenMac.lean for lemmas that do not need these instances. The number of omit lines is not excessive relative to the number of variable binders; each omission is for a specific lemma where the omitted instance is not used in the proof. Check.

variable usage

  • Variables are declared with variable at the top of the public section or in sub-sections. The [DecidableEq C] [DecidableEq T] [DecidableEq Λ] assumptions are placed on the section that genuinely needs them (the game definitions and security theorems). For lemmas that do not need them, omit is used. This matches the guidance on section variables. Check.

Naming conventions

  • Terms of Props (e.g. ForgeryLogged, FreshValidAt, StopInv, MakesAtMostDecryptionQueries) use UpperCamelCase. The .lean file itself uses UpperCamelCase for the module name, but the definition names are correctly capitalized.
  • Functions are named as their return types: IND_CCA_Adversary, IND_CCA_challengeImpl, ccaLogImpl, etc. – these match the Mathlib naming rules.
  • Theorem names are snake_case (e.g. IND_CCA_Advantage_probComp, agreeUntilBad_ccaLogImpl_rejectImpl, etc.). Check.

Buildability (not tested, but structure suggests compliance)

  • No sorry appears in either file.
  • The new files are added to the umbrella import in VCVio.lean (both public import lines in the diff). The contributor likely ran ./scripts/update-lib.sh after adding the files; this cannot be verified from the diff alone, but the imports in VCVio.lean are present.

Exposed definitions and public sections

  • INDCCA.lean uses @[expose] on IND_CCA_Adversary.MakesAtMostDecryptionQueries, IND_CCA_challengeImpl, IND_CCA_decryptImpl, IND_CCA_impl, IND_CCA_Experiment, IND_CCA_Game, IND_CCA_Advantage, IND_CCA_Advantage_probComp. The rest of the definitions (IND_CCA_Adversary) is an abbrev – not exposed, which is fine.
  • EncryptThenMac.lean uses @[expose] on scheme, challengeImpl, ccaDecryptImpl, rejectDecryptImpl, ccaLogImpl, rejectImpl, ForgeryLogged, rejectExperiment, forgeryExperiment, cpaChallengeImpl, cpaDecryptImpl, cpaReductionImpl, cpaReduction, FreshValidAt, stopChallengeImpl, stopImpl, StopInv, ForgeryAt, flattenWriterT, forgerChallengeImpl, forgerDecryptImpl, forgerImpl, forger, forgerTaggedImpl, forgerView. This is a long list but each corresponds to a public component of the proof. The module docstring lists only the most important ones; the remaining exposed definitions are internal helpers that the rest of the construction needs. Not a violation.

Licensing

  • Both headers include the Apache 2.0 license line. Check.

Unused variables/linters

  • No new linter suppressions added. No warning of potential issues from the diff.

Summary of issues found

  • None. The diff complies with the style guide, documentation expectations, module-scope rules, naming conventions, and attribution policy.

📄 **Per-File Summaries**
  • VCVio.lean: The file now publicly imports SymmEncAlg.INDCCA, which provides IND-CCA security definitions for symmetric encryption, and Schemes.EncryptThenMac, which defines an Encrypt-then-MAC construction. These additions indicate that the project’s security hierarchy and composable-scheme library have been extended to cover the authenticated encryption model that corresponding proofs will rely on.
  • VCVio/CryptoFoundations/SymmEncAlg/INDCCA.lean: Summary unavailable — AI generation failed.
  • VCVio/Schemes/EncryptThenMac.lean: This file implements the formal proof that the Encrypt-then-MAC construction yields a CCA-secure symmetric encryption scheme, given a CPA-secure encryption enc and a strongly unforgeable MAC mac with deterministic verification. It defines the scheme, the CCA game ccaLogImpl, the rejecting game rejectImpl, the CPA reduction cpaReduction, and the SUF-CMA forgers forger. The main theorem IND_CCA_Advantage_le bounds the CCA advantage of the combined scheme by the CPA advantage of cpaReduction plus the sum of the SUF-CMA advantages of the forgers. The proof relies on the lemma agreeUntilBad_ccaLogImpl_rejectImpl showing that the real and rejecting games coincide until a forgery is logged, the equivalence rejectExperiment_eq_IND_CPA_Experiment relating the rejecting game to a CPA experiment, and a hybrid argument forgeryExperiment_le_sum bounding the forgery probability via the stopping technique and the forgers.

Last updated: 2026-11-22 02:02 UTC.

…d CPA security of PRF-based encryption

`VCVio/CryptoFoundations/SymmEncAlg/INDCPA.lean` defines the
multi-query left-or-right CPA game of a `SymmEncAlg` with the shared
`LeftOrRight.oracle`, keyed by the scheme's own `keygen`, mirroring
`DEMScheme.IND_CPA_Game`.

`VCVio/Schemes/PRFEncryption.lean` proves that
`Enc_k(m) = (r, F_k(r) + m)` is CPA-secure:

  Adv_CPA ≤ prfAdvantage (prfReduction A true)
          + prfAdvantage (prfReduction A false) + q (q - 1) / |R|,

through a random-function game kept as a log, identical-until-bad
(`QueryImpl.AgreeUntilBad`) against a fresh-value game, and the per-query
hazard bound for nonce repetition.
…-then-MAC

`VCVio/CryptoFoundations/SymmEncAlg/INDCCA.lean` defines the multi-query
CCA game of a `SymmEncAlg`: the left-or-right oracle logs the challenge
ciphertexts in `StateT (List C)` and the decryption oracle rejects them
with `none`.

`VCVio/Schemes/EncryptThenMac.lean` proves, for a MAC with deterministic
verification (`mac.verify k c t = pure (vf k c t)`) and an adversary with
at most `q` decryption queries,

  Adv_CCA(EtM, A) ≤ Adv_CPA(enc, cpaReduction A)
      + Σ_{j<q} (Adv_SUF(forger A true j) + Adv_SUF(forger A false j)).

The proof replaces decryption by rejection until a fresh valid
decryption query (`QueryImpl.AgreeUntilBad`), simulates the rejecting
game with a CPA adversary that tags its own ciphertexts, and bounds the
forgery event by guessing the decryption query. The forger stops tagging
after the guessed query; a stopping lemma
(`map_run_simulateQ_evalDistEq_of_eq_until_stopped`) shows the guessed
query has the same distribution as in the unstopped game.
# Conflicts:
#	VCVio.lean
#	VCVio/CryptoFoundations/SymmEncAlg/INDCPA.lean
#	VCVio/Schemes/PRFEncryption.lean
@dtumad

dtumad commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

#1164 has merged, so I merged main into this branch. The PR now shows only its own changes: the left-or-right CCA game and Encrypt-then-MAC. The conflicts were all in #1164's files, which now match main, including the cleanups made there. EncryptThenMac builds unchanged on top of them. It's still a draft; mark it ready whenever you like, and we'll review it then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants