Skip to content

feat(CryptoFoundations): KEM recipient anonymity — ANO-CPA/ANO-CCA notions for KEMScheme - #1187

Open
Skanislav wants to merge 4 commits into
Verified-zkEVM:mainfrom
Skanislav:feat/kem-ano-cca
Open

Skanislav wants to merge 4 commits into
Verified-zkEVM:mainfrom
Skanislav:feat/kem-ano-cca

Conversation

@Skanislav

Copy link
Copy Markdown
Contributor

Summary

Adds key-privacy (recipient-anonymity) notions for KEMScheme in a new
VCVio/CryptoFoundations/KeyEncapMech/ANO.lean, mirroring the existing
IND-CPA/IND-CCA architecture in KeyEncapMech.lean: an adversary structure,
hidden-bit games over OracleComp, advantage as Measure.boolBias of
runtime.evalDist, a dual-key decapsulation oracle union
spec + ((Bool × C) →ₒ Option K) answered through QueryImpl.add with
spec.passthrough, the challenge ciphertext excluded per branch, and a
CPA-to-CCA embedding with the corresponding game-equality theorem.

IND-CCA protects the encapsulated shared key; recipient anonymity hides which
public key
a ciphertext was encapsulated under. They are independent:
registered public keys and announcements are public, so IND-CCA alone does not
give recipient privacy. This matters wherever ciphertexts are publicly
scanable, e.g. post-quantum stealth-address protocols (ERC-8441), whose draft
assumes ML-KEM provides both properties as separate claims.

Follows up on #848 (tempcheck; no objections were raised). Naming follows
#801's settled conventions; composition with the FO work remains #785's orbit
and is not touched here. No Mathlib, core, or Batteries lemma or idiom is being
replaced, so no docs/reading/upstream-alignment.md row applies.

The change is one new file plus the umbrella line
public import VCVio.CryptoFoundations.KeyEncapMech.ANO in VCVio.lean
(alphabetically directly after KeyEncapMech). No existing declaration is
modified.

Contents:

  • ANO_Adversary — two-phase ciphertext-only anonymity adversary
  • ANO_CPA_Experiment (fixed branch), ANO_CPA_Game (hidden bit, returns
    b == b'), ANO_CPA_Advantage (boolBias of the single game's evalDist,
    as for IND_CPA_Advantage), plus ANO_CPA_Advantage_eq_game_bias
  • ANO_CCA_oracleSpec = spec + ((Bool × C) →ₒ Option K) with pre/post-challenge
    handlers: real decapsulation under the queried key; the challenge ciphertext
    is rejected by both post-challenge oracles
  • ANO_CCA_Adversary, ANO_CCA_Game, ANO_CCA_Advantage — both decapsulation
    oracles stay live throughout, plus ANO_CCA_Advantage_eq_game_bias
  • The oracle-ignoring embedding ANO_Adversary.toANO_CCA (anonymity analogue of
    toIND_CCA), the general collapse lemma simulateQ_add_liftM_left, the phase
    lemmas toANO_CCA_preChallenge / toANO_CCA_postChallenge, and
    ANO_CPA_Game_eq_ANO_CCA_Game_toANO_CCA (mirroring
    IND_CPA_Game_eq_IND_CCA_Game_toIND_CCA)

Design decisions:

  • Ciphertext-only shape: the adversary sees the challenge ciphertext but
    never the encapsulated key. Tempcheck of KEM ANO-CCA game for ERC-8441 (pq-sap) verification? #848 also sketched a key-revealing variant; it is
    deliberately left out so this PR carries one self-contained notion — the
    key-revealing variant plus the implication theorem would be a natural
    follow-up if wanted.
  • Both oracles live pre and post challenge, masked per branch exactly at
    bc.2 = cStar → none; failure semantics of the KEM are preserved for every
    non-challenge ciphertext.
  • Advantage normalization matches the house convention: boolBias of the
    single game's evalDist, with totality noted in the docstrings.
  • Generic over KEMScheme; no ERC-specific definitions, no ML-KEM claims.

Verification

Run against head 31c07870 on base f1e63c78, with the toolchain the branch
pins (Lean/Mathlib v4.36.0):

  • lake env lean VCVio/CryptoFoundations/KeyEncapMech/ANO.lean → exit 0, no
    errors, no warnings, no sorry.
  • #print axioms on ANO_CPA_Game_eq_ANO_CCA_Game_toANO_CCA,
    ANO_CCA_Advantage_eq_game_bias, toANO_CCA_preChallenge, and
    simulateQ_add_liftM_left → propext, Classical.choice, Quot.sound only;
    no sorryAx.
  • lake build VCVio → Build completed successfully (9457 jobs).
  • lake exe axiomsweep --check → passed: 32478 declarations across 1336
    modules, 0 sorryAx-tainted, 0 non-standard-axiom-tainted.
  • lake lint -- --style-only → passes across all 1741 sources.
  • scripts/check-extern-isolation.sh → OK; scripts/check-interop-isolation.sh
    → OK; scripts/check-comment-fences.py → OK (1768 sources);
    scripts/check-expose-boundary.sh → OK.
  • lake exe mk_all --lib VCVio --module --check → "No update necessary", so the
    umbrella line for the new module is already in its generated position.
  • All four Agent Docs commands pass under uv: test-agent-docs.py,
    check-agent-docs.py, extract-doc-fragments.py --check, and
    check-doc-names.py.
  • No line exceeds the 100-column limit, and every declaration in the new file
    has a declaration docstring.

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.
    (mk_all --check reports "No update necessary" for the new module's umbrella line;
    the sweep passed with 0 sorryAx-tainted and 0 non-standard-axiom-tainted declarations
    across 32478 declarations in 1336 modules.)
  • 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.

…tions for KEMScheme

Key-privacy (recipient-anonymity) notions for KEMScheme, mirroring the
existing IND-CPA/IND-CCA architecture in KeyEncapMech.lean: adversary
structure, hidden-bit games over OracleComp, advantage as Measure.boolBias
of runtime.evalDist, dual-key decapsulation oracle union with per-branch
challenge masking, and the oracle-ignoring CPA-to-CCA embedding with its
game-equality theorem. Follows up on Verified-zkEVM#848; naming per Verified-zkEVM#801.

Co-authored-by: Skas <108791624+Skanislav@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🤖 PR Summary

Overview written in Markdown as requested, with no meta prefaces.


Statistics

Metric Count
📝 Files Changed 2
✅ Lines Added 219
❌ Lines Removed 0

Lean Declarations

✏️ Added: 14 declaration(s)

VCVio/CryptoFoundations/KeyEncapMech/ANO.lean (14)

  • def ANO_CCA_oracleSpec (_kem : KEMScheme (OracleComp spec) K PK SK C)
  • def ANO_CCA_postChallengeImpl [DecidableEq C] (sk0 sk1 : SK) (cStar : C) :
  • def ANO_CCA_preChallengeImpl (sk0 sk1 : SK) :
  • def ANO_CPA_Adversary.toANO_CCA (adversary : kem.ANO_CPA_Adversary) : kem.ANO_CCA_Adversary where
  • noncomputable def ANO_CCA_Advantage [DecidableEq C]
  • noncomputable def ANO_CCA_Game [DecidableEq C]
  • noncomputable def ANO_CPA_Advantage (runtime : ProbCompRuntime (OracleComp spec))
  • noncomputable def ANO_CPA_Experiment (adversary : kem.ANO_CPA_Adversary) (b : Bool) :
  • noncomputable def ANO_CPA_Game (runtime : ProbCompRuntime (OracleComp spec))
  • theorem ANO_CCA_Advantage_eq_game_bias [DecidableEq C]
  • theorem ANO_CPA_Advantage_eq_game_bias (runtime : ProbCompRuntime (OracleComp spec))
  • theorem ANO_CPA_Game_eq_ANO_CCA_Game_toANO_CCA [DecidableEq C]
  • theorem toANO_CCA_postChallenge (adversary : kem.ANO_CPA_Adversary) [DecidableEq C]
  • theorem toANO_CCA_preChallenge (adversary : kem.ANO_CPA_Adversary) (sk0 sk1 : SK) (pk0 pk1 : PK) :

sorry Tracking

  • No sorrys were added, removed, or affected.

📋 **Additional Analysis**

Findings on VCVio/CryptoFoundations/KeyEncapMech/ANO.lean

  • File Header: Copyright year is 2026; should match the creation year (likely 2025). Otherwise, the header format is correct.

  • Module Declaration: The file declares only module instead of module VCVio.CryptoFoundations.KeyEncapMech.ANO. This will cause a module resolution error because the import in VCVio.lean expects the full module name. This is a critical violation.

  • Prologue Layout: The standard prologue requires: header, blank line, module, imports (no blank line between module and imports), blank line, module docstring. The diff inserts an extra blank line between module and public import, which is not permitted.

  • Linter Suppression: The attribute [nolint defsWithUnderscore] on ANO_CPA_Adversary.toANO_CCA locally disables a linter. The instructions forbid any local or global linter suppression. Consider renaming the definition to avoid the linter instead.

  • Module Docstring: Present and follows conventions.

  • Section Headers: Use /-! ## ... -/ correctly; no ASCII banners.

  • Public Section: Uses public section and @[expose] as specified for new files.

  • Imports: Uses public import correctly.

Findings on VCVio.lean

  • The addition of public import VCVio.CryptoFoundations.KeyEncapMech.ANO is appropriate, contingent on the new file's module declaration being fixed.

Summary

The submission has several violations requiring correction: missing module name (critical), extra blank line in prologue, and a prohibited linter suppression. The file header year should also be verified.


📄 **Per-File Summaries**
  • VCVio/CryptoFoundations/KeyEncapMech/ANO.lean: Adds the new file ANO.lean defining recipient anonymity (key privacy) notions for KEMScheme. It introduces ANO_CPA_Adversary, ANO_CPA_Game, ANO_CPA_Advantage and the corresponding CCA variants ANO_CCA_oracleSpec, ANO_CCA_preChallengeImpl, ANO_CCA_postChallengeImpl, ANO_CCA_Adversary, ANO_CCA_Game, ANO_CCA_Advantage, each accompanied by a _eq_game_bias theorem. It also provides ANO_CPA_Adversary.toANO_CCA embedding a CPA adversary into the CCA setting, with three fully proved theorems (toANO_CCA_preChallenge, toANO_CCA_postChallenge, ANO_CPA_Game_eq_ANO_CCA_Game_toANO_CCA) that relate the two games. No sorry or admit appear in any declaration.
  • 1 file(s) filtered as noise (lockfiles, generated, or trivial): VCVio.lean

Last updated: 2026-11-21 22:28 UTC.

dtumad and others added 3 commits November 21, 2026 12:29
- Name the CPA adversary `ANO_CPA_Adversary`, so the notion has one token
  in every name (docs/agents/crypto.md, Naming).
- Prove the CPA-to-CCA lift lemmas from the generic
  `QueryImpl.simulateQ_add_simulateQ_toQueryImpl_left`. This removes
  `KEMScheme.simulateQ_add_liftM_left`, which shadowed the root
  `QueryImpl.simulateQ_add_liftM_left` with a different statement, and
  its unused instance `simulateQ_toANO_CCA`.
- State the notion in the module docstring and cite Bellare, Boldyreva,
  Desai and Pointcheval.
- Import only `KeyEncapMech`, which re-exports the other modules; drop
  the unused universe; prove the advantage equations by `rfl`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@dtumad dtumad left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is VCVio's first anonymity notion, and it fits the KeyEncapMech games closely. Before the challenge, the decapsulation oracle answers freely under either key. Afterwards it refuses the challenge ciphertext under both keys, as in the IK-CCA game of Bellare–Boldyreva–Desai–Pointcheval. The bit is drawn after preChallenge, as in IND_CCA_Game. The CPA-to-CCA equality names its embedding, and the typeclass arguments are only what is used.

I pushed one commit with mechanical cleanups, plus a merge of current main so CI runs against the new PolyFun pin:

  • ANO_Adversary is now ANO_CPA_Adversary, so the notion has one token in every name (docs/agents/crypto.md, Naming).
  • The lift lemmas now come from the generic QueryImpl.simulateQ_add_simulateQ_toQueryImpl_left. This removes KEMScheme.simulateQ_add_liftM_left, which shadowed the root QueryImpl.simulateQ_add_liftM_left (a different statement), and the unused simulateQ_toANO_CCA.
  • The module docstring now states the notion and cites Bellare–Boldyreva–Desai–Pointcheval. The imports are just KeyEncapMech, which re-exports the rest. The unused universe is gone, and the advantage equations are proved by rfl.

One design question before merging. Here the adversary sees only the challenge ciphertext, never the encapsulated key. As I read Grubbs–Maram–Paterson (EUROCRYPT 2022), whose KEM-DEM result is what makes KEM anonymity useful for hybrid encryption, their KEM ANO-CCA game gives the adversary the whole encapsulation (c*, K*). The ciphertext-only game is weaker on its own: it follows from the key-revealing one, but the converse also needs IND-CCA. Would you be up for passing K* to postChallenge to match that definition? If the ciphertext-only form is what you need for the stealth-address application, keeping it is fine too. In that case it would help to say so in the names or the docstring, and to cite which definition it follows, so that a later "ML-KEM is ANO-CCA" statement means what readers expect.

Optional, and fine as a follow-up: a small test showing the game is not vacuous, for example a KEM that appends a public-key tag to its ciphertext having ANO-CPA advantage 1.

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.

3 participants