ElGamal is IND-CPA under DDH (EasyCrypt examples/elgamal.ec) #
EC's file, declaration by declaration and script line by line (the pilot of the examples' re-port, 2026-11-15). All four lemmas are proven.
Translation:
clone DiffieHellman as DH. import DH.DDH DH.G DH.GP DH.FD DH.GP.ZModE.clones the theory without instantiating it: the file stays abstract in the group, which is the section'svariable {group exp} … [CyclicGroup.Params group exp](Lib/EC/Group.lean), and the theoryDDHis opened.clone DH.GP.ZModE.ZModpField as ZPFis Mathlib'sField exp.- EC's type abbreviations
pkey = group,skey = exp,ptxt = group,ctxt = group * groupare written out in the clone ofPKE_CPA. declare axiom Ac_ll,Ag_llare section hypotheses,included where EC's proofs use them.- EC's
local module Gbreads the section'sA; hereAis its parameter (Gb(A).main), and it is declared before the section.
Gap list (what keeps the file from reading as EC's; each is an item of the examples' infrastructure batch):
- GAP 1:
inlinewrites a call's parameters as one tuple assignment, EC as one assignment per parameter, so EC's positions are off by the number of parameters less one, and aswapbetween two parameters has nothing to move past:stmt_split_paramsafterstmt_inline*(Logic/ECInlineParams.lean), until the inliner does it. - GAP 2 (closed 2026-11-15): EC's
call (_ : true)on the adversary isequiv_call (_ : True). - GAP 3 (closed 2026-11-15):
Gb_halfis EC's script; pHLrnd Eandconseqon an exact bound and the tacticislosslessareLogic/PHoareRnd.lean. - GAP 4 (closed 2026-11-15):
module ElGamal : Schemewith its third proceduredec, whichSchemedoes not list, as in EC (ElGamal.decis a procedure of its own). - GAP 5 (closed 2026-11-15): EC's
rnd f gisequiv_rnd f g(Logic/ECRnd.lean). - GAP 6 (goals as shown):
byequivstates={allGlobals}(the whole global state) where EC shows={glob A}.
proc enc of module ElGamal as a module: Module.proc ElGamal.enc.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — ElGamal.enc.apply_simp says exactly that.
Equations
Instances For
Instantiating the holes of ElGamal.dec.procedure with a tuple holeArgs of procedures: the body of proc dec as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [ElGamal.dec.procedure.apply_simp]).
Instantiating the holes of ElGamal.kg.procedure with a tuple holeArgs of procedures: the body of proc kg as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [ElGamal.kg.procedure.apply_simp]).
@[simp]: ElGamal.enc = Module.proc ElGamal.enc.procedure — true by definition, proc enc using no module parameter and so having no holes to fill.
The body of proc dec of module ElGamal, as a procedure of its own: it calls no module parameter, so it has no holes.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see ElGamal.dec.procedure.apply_simp) rather than run. Use ElGamal.dec for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
proc kg of module ElGamal as a module: Module.proc ElGamal.kg.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — ElGamal.kg.apply_simp says exactly that.
Equations
Instances For
The module declared by module ElGamal: the record of its procedures ElGamal.kg, ElGamal.enc.
The declaration has no parameter list, so no procedure of it can call one either and the module is not a function — it is the plain record itself, and there is no ElGamal.apply_simp to apply it with.
Equations
Instances For
@[simp]: ElGamal.kg = Module.proc ElGamal.kg.procedure — true by definition, proc kg using no module parameter and so having no holes to fill.
Instantiating the holes of ElGamal.enc.procedure with a tuple holeArgs of procedures: the body of proc enc as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [ElGamal.enc.procedure.apply_simp]).
The body of proc enc of module ElGamal, as a procedure of its own: it calls no module parameter, so it has no holes.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see ElGamal.enc.procedure.apply_simp) rather than run. Use ElGamal.enc for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: ElGamal.dec = Module.proc ElGamal.dec.procedure — true by definition, proc dec using no module parameter and so having no holes to fill.
proc dec of module ElGamal as a module: Module.proc ElGamal.dec.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — ElGamal.dec.apply_simp says exactly that.
Equations
Instances For
The body of proc kg of module ElGamal, as a procedure of its own: it calls no module parameter, so it has no holes.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see ElGamal.kg.procedure.apply_simp) rather than run. Use ElGamal.kg for this procedure as a module.
Equations
- GaudisCrypt.Examples.ElGamal.ElGamal.kg.procedure = proc () : (group × exp) { var sk : exp; sk <$ GaudisCrypt.EC.CyclicGroup.dt; return (GaudisCrypt.EC.CyclicGroup.g ^ §sk, §sk) }
Instances For
@[simp]: applying DDHAdv.guess to the parameters proc guess uses (A) is Module.proc (DDHAdv.guess.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
The module declared by module DDHAdv, abstracted over its single parameter A, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the anonymous product of the procedures' own types, the declaration naming no module type.
Applied to such a tuple it is the record of its procedures DDHAdv.guess, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma DDHAdv.apply_simp says.
Equations
Instances For
The body of proc guess of module DDHAdv, as a procedure of its own: the 2 calls it makes to module parameters (A) are its holes, in the order the body makes them.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see DDHAdv.guess.procedure.apply_simp) rather than run. Use DDHAdv.guess for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instantiating the holes of DDHAdv.guess.procedure with a tuple holeArgs of procedures: the body of proc guess as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [DDHAdv.guess.procedure.apply_simp]).
@[simp]: applying DDHAdv to a tuple of its single parameter A — the record of its procedures DDHAdv.guess, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with DDHAdv.guess.apply_simp to fill that procedure's holes.
proc guess of module DDHAdv as a module, abstracted over the module parameters it uses (A, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma DDHAdv.guess.apply_simp, which fills the holes of DDHAdv.guess.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The module declared by module Gb, abstracted over its single parameter A, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the anonymous product of the procedures' own types, the declaration naming no module type.
Applied to such a tuple it is the record of its procedures Gb.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma Gb.apply_simp says.
Equations
Instances For
The body of proc main of module Gb, as a procedure of its own: the 2 calls it makes to module parameters (A) are its holes, in the order the body makes them.
A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see Gb.main.procedure.apply_simp) rather than run. Use Gb.main for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying Gb.main to the parameters proc main uses (A) is Module.proc (Gb.main.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.
proc main of module Gb as a module, abstracted over the module parameters it uses (A, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma Gb.main.apply_simp, which fills the holes of Gb.main.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying Gb to a tuple of its single parameter A — the record of its procedures Gb.main, each applied to the parameters it uses.
This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with Gb.main.apply_simp to fill that procedure's holes.
Instantiating the holes of Gb.main.procedure with a tuple holeArgs of procedures: the body of proc main as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.
Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [Gb.main.procedure.apply_simp]).
EC's local lemma cpa_ddh0 &m: Pr[CPA(ElGamal,A).main() @ &m : res] = Pr[DDH0(DDHAdv(A)).main() @ &m : res].
EC's local lemma ddh1_gb &m: Pr[DDH1(DDHAdv(A)).main() @ &m : res] = Pr[Gb.main() @ &m : res].
EC's local lemma Gb_half &m: Pr[Gb.main()@ &m : res] = 1%r/2%r.
EC's lemma conclusion &m : | Pr[CPA(ElGamal,A).main() @ &m : res] - 1%r/2%r | =
| Pr[DDH0(DDHAdv(A)).main() @ &m : res] - Pr[DDH1(DDHAdv(A)).main() @ &m : res] |.