Refactor program logic (Loom + pRHL-like) and prove ElGamal IND-CPA via DDH#115
Refactor program logic (Loom + pRHL-like) and prove ElGamal IND-CPA via DDH#115
Conversation
Rewrites Examples/HHS_Elgamal.lean from scratch with an honest hybrid argument: q-step hybrid family (decreasing), allRandomHalf at index 0, per-hop DDH reduction, and main theorem bounding IND-CPA advantage by sum of per-hop DDH advantages. Three honest sorrys remain for the inductive b-independence lemma, allRandomHalf, and per-hop bound. Cleans up VCVio/CryptoFoundations/AsymmEncAlg.lean: removes the AI-added one-time-specific definitions (IND_CPA_OneTime_SignedAdvantageReal, IND_CPA_OneTime_AdvantageAbs, and the bogus hybrid-lift theorem) while keeping the generic telescoping infrastructure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 AI-Generated PR SummaryFiles Changed:
Overview of Changes: Here is a summary of the key changes:
New 'sorry's: 1 |
Made-with: Cursor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da3f8e1d46
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| AsymmEncAlg.trueProbReal (IND_CPA_HybridGame (G := G) (P := P) adversary k)| ≤ | ||
| 2 * |AsymmEncAlg.trueProbReal | ||
| (DiffieHellman.ddhExp (IND_CPA_stepDDHReduction adversary k)) - 1 / 2| := by | ||
| sorry |
There was a problem hiding this comment.
Prove per-hop DDH bound instead of using placeholder
The theorem IND_CPA_stepDDH_hopBound is left as sorry, which turns this result into an axiom and makes downstream security claims (including ElGamal_IND_CPA_bound_toReal, which applies this lemma at line 896) non-verified in the formal sense. This is especially problematic for a cryptography proof file because the main IND-CPA bound now depends on an unproven assumption rather than a checked reduction.
Useful? React with 👍 / 👎.
Summary
Two interlocking workstreams:
1. Program logic refactor — monad-algebra foundation
HoareTriple.lean) from the oldOracleComp.StateM-specific formulation to a generic ordered-monad-algebra framework adapted from Loom (POPL 2026).StdDoBridge.lean: bridges Lean 4'sStd.Domonad notation to the program-logic layer, with examples inStdDoExamples.lean.Relational/Basic.lean,Relational/Examples.lean):RelTriplefor relational pre/post reasoning overOracleComp, proved via SPMF couplings.ToMathlib/Control/Monad/RelationalAlgebra.lean: standalone relational monad-algebra theory (359 lines, new file).ToMathlib/Control/Monad/Algebra.lean: expanded ordered-monad-algebra infrastructure (+244 lines).ToMathlib/ProbabilityTheory/Coupling.lean: renamed coupling API toRelTriple, cleaned up.SPMF.leanandMonad/Basic.lean(probOutput_map_injective,probEvent_bind_bind_swap,probEvent_map,probOutput_bind_congr', etc.) — used extensively in the ElGamal proof.2. ElGamal multi-query IND-CPA security via DDH
Complete rewrite of
Examples/HHS_Elgamal.lean(was fully commented-out old-API code → 929 lines of live proof):AddTorsor G P(hard homogeneous space) and perfect correctness proof.IND_CPA_HybridGame adversary ianswers the firstifresh LR queries with real ElGamal, the rest with random masking (uniform group element + uniform point).IND_CPA_allRandomHalf): proved viasimulateQ_hybrid0_bdistrib_eq— the adversary's view is b-independent when all queries are randomly masked, usingRelTriplefrom the relational logic layer.IND_CPA_stepDDHReduction): DDH adversary that embeds the DDH challenge into the k-th fresh query.ddhExp_stepDDHReduction_decomp): decomposes DDH advantage into difference of hybrid success probabilities.IND_CPA_advantage_le_sum_DDH): IND-CPA advantage ≤ Σ per-hop DDH advantages, using telescoping and triangle inequality fromAsymmEncAlg.lean.Remaining
sorrys:IND_CPA_stepDDH_hopBound(connecting per-hop DDH decomposition to the hybrid bound — the core identity is proved inddhExp_stepDDHReduction_decompbut the final wiring needs equatingstepDDH_realBranchGame/stepDDH_randBranchGamewith the adjacent hybrids).3.
AsymmEncAlg.leancleanuptrueProbReal,signedAdvantageReal,advantage_le_sum_hops) for anyAsymmEncAlg.Test plan
lake buildpasses (all files compile; the onlysorrys are inIND_CPA_stepDDH_hopBoundand the main theorem which depends on it)IND_CPA_allRandomHalfproof compiles withoutsorryMade with Cursor