The Pedersen commitment scheme (EasyCrypt examples/Pedersen.ec) #
Pedersen, "Non-interactive and information-theoretic secure verifiable secret sharing". EC's
file, declaration by declaration and script line by line: correctness, perfect hiding (the
unhider wins with probability exactly 1/2), and computational binding by reduction to the
discrete logarithm (Lib/EC/DLog.lean). All of EC's lemmas are proven.
Translation:
clone DLog as DL. import DL.G DL.GP DL.FD DL.GP.ZModE.clones the theory without instantiating it: the file stays abstract in the group, the section'svariable {group exp} … [CyclicGroup.Params group exp](Lib/EC/Group.lean); EC'sDL.DLog.XisDLog.DLog.X,DL.StdRedAdversaryisDLog.StdRedAdversary.theory PedersenTypes(value = group,message = exp,commitment = group,openingkey = exp) is written out in the clone ofCommitment.- The lemmas'
(U <: Unhider),(B <: Binder)are the binders∀ (U <: Unhider). - EC's
local module FakeCommit(U : Unhider)is a module with a module parameter, as there.
Gap list (what keeps the file from reading as EC's; items of the examples' infrastructure batch):
- GAP 1 (closed 2026-11-15): EC's
call (_ : true)on the adversary isequiv_call (_ : True). - GAP 2 (closed 2026-11-15): pHL on an event reached with probability
1—call HwithH : islossless f,rnd,auto— keeps the judgment an event, as EC does (Logic/PHoareRnd.lean):fakecommit_halfis EC's script. - GAP 3 (closed 2026-11-15): after inlining,
xis a group element on the left (Correctness's key) and an exponent on the right (FakeCommit's secret): two variables of one name.§x{2}is the right side's, in the tactics' conditions and in the goals as shown. - GAP 4:
islosslesscloses the samplings (EC's hintrandom) and leaves the calls; EC's takes the hypothesesuc_ll,ug_lland leaves the samplings.hi_llends withassumptionwhere EC's ends withapply dt_ll || apply DBool.dbool_ll. - GAP 5 (closed 2026-11-15):
byequivonPr[…] ≤ Pr[…]closes the events' implicationres{1} → res{2}itself, as EC's=> //. - GAP 6: the field algebra of
pedersen_computational_binding(EC'sfield,ring,pow_bij) is by hand, as is naming whatauto => /> x _ [c m d m' d'] /= comm comm' m_neq_m'names (rename_i,obtain). - GAP 8 (closed 2026-11-15):
inline{2} DL.StdRedAdversary(DLogAttacker(B)).guessfinds the call the experiment makes through its module type. - GAP 7 (goals as shown):
byequivstates={allGlobals}(the whole global state) where EC shows={glob U}.
Instantiating the holes of Pedersen.verify.procedure with a tuple holeArgs of procedures: the body of proc verify 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 [Pedersen.verify.procedure.apply_simp]).
Instantiating the holes of Pedersen.gen.procedure with a tuple holeArgs of procedures: the body of proc gen 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 [Pedersen.gen.procedure.apply_simp]).
proc gen of module Pedersen as a module: Module.proc Pedersen.gen.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — Pedersen.gen.apply_simp says exactly that.
Equations
Instances For
Instantiating the holes of Pedersen.commit.procedure with a tuple holeArgs of procedures: the body of proc commit 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 [Pedersen.commit.procedure.apply_simp]).
@[simp]: Pedersen.gen = Module.proc Pedersen.gen.procedure — true by definition, proc gen using no module parameter and so having no holes to fill.
The body of proc verify of module Pedersen, 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 Pedersen.verify.procedure.apply_simp) rather than run. Use Pedersen.verify for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The body of proc commit of module Pedersen, 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 Pedersen.commit.procedure.apply_simp) rather than run. Use Pedersen.commit for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
proc verify of module Pedersen as a module: Module.proc Pedersen.verify.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — Pedersen.verify.apply_simp says exactly that.
Equations
Instances For
proc commit of module Pedersen as a module: Module.proc Pedersen.commit.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — Pedersen.commit.apply_simp says exactly that.
Equations
Instances For
The module declared by module Pedersen: the record of its procedures Pedersen.gen, Pedersen.commit, Pedersen.verify.
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 Pedersen.apply_simp to apply it with.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: Pedersen.verify = Module.proc Pedersen.verify.procedure — true by definition, proc verify using no module parameter and so having no holes to fill.
@[simp]: Pedersen.commit = Module.proc Pedersen.commit.procedure — true by definition, proc commit using no module parameter and so having no holes to fill.
The body of proc gen of module Pedersen, 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 Pedersen.gen.procedure.apply_simp) rather than run. Use Pedersen.gen for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
proc guess of module DLogAttacker as a module, abstracted over the module parameters it uses (B, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma DLogAttacker.guess.apply_simp, which fills the holes of DLogAttacker.guess.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instantiating the holes of DLogAttacker.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 [DLogAttacker.guess.procedure.apply_simp]).
@[simp]: applying DLogAttacker to a tuple of its single parameter B — the record of its procedures DLogAttacker.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 DLogAttacker.guess.apply_simp to fill that procedure's holes.
@[simp]: applying DLogAttacker.guess to the parameters proc guess uses (B) is Module.proc (DLogAttacker.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 DLogAttacker, abstracted over its single parameter B, 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 DLogAttacker.guess, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma DLogAttacker.apply_simp says.
Equations
Instances For
The body of proc guess of module DLogAttacker, as a procedure of its own: the one call it makes to a module parameter (B) is its single hole.
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 DLogAttacker.guess.procedure.apply_simp) rather than run. Use DLogAttacker.guess for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying FakeCommit.main to the parameters proc main uses (U) is Module.proc (FakeCommit.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.
@[simp]: applying FakeCommit to a tuple of its single parameter U — the record of its procedures FakeCommit.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 FakeCommit.main.apply_simp to fill that procedure's holes.
Instantiating the holes of FakeCommit.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 [FakeCommit.main.procedure.apply_simp]).
The module declared by module FakeCommit, abstracted over its single parameter U, 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 FakeCommit.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma FakeCommit.apply_simp says.
Equations
Instances For
The body of proc main of module FakeCommit, as a procedure of its own: the 2 calls it makes to module parameters (U) 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 FakeCommit.main.procedure.apply_simp) rather than run. Use FakeCommit.main for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
proc main of module FakeCommit as a module, abstracted over the module parameters it uses (U, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma FakeCommit.main.apply_simp, which fills the holes of FakeCommit.main.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Correctness. EC's lemma pedersen_correctness: hoare[Correctness(Pedersen).main: true ==> res].
EC's local lemma hi_ll (U<:Unhider): islossless U.choose => islossless U.guess => islossless FakeCommit(U).main.
Perfect hiding. EC's local lemma fakecommit_half (U<:Unhider) &m: islossless U.choose => islossless U.guess => Pr[FakeCommit(U).main() @ &m : res] = 1%r/2%r.
EC's local lemma phi_hi (U<:Unhider) &m: Pr[HidingExperiment(Pedersen,U).main() @ &m : res] = Pr[FakeCommit(U).main() @ &m : res].
Perfect hiding - QED. EC's lemma pedersen_perfect_hiding (U<:Unhider) &m: islossless U.choose => islossless U.guess => Pr[HidingExperiment(Pedersen,U).main() @ &m : res] = 1%r/2%r.
Computational binding - QED. EC's lemma pedersen_computational_binding (B<:Binder) &m: Pr[BindingExperiment(Pedersen, B).main() @ &m : res] = Pr[DL.DLog.DLogExperiment(DLogAttacker(B)).main() @ &m : res].
EC: "The following two are to compare probability directly with book discrete logarithm experiment. Not strictly necessary though, only for completeness."
EC's local lemma std_red_dl_bridge (B<:Binder) &m: Pr[DL.DLog.DLogExperiment(DLogAttacker(B)).main() @ &m : res] <= Pr[DL.DLog.DLogStdExperiment(DL.StdRedAdversary(DLogAttacker(B))).main() @ &m : res].
EC's lemma pedersen_std_computational_binding (B<:Binder) &m: Pr[BindingExperiment(Pedersen, B).main() @ &m : res] <= Pr[DL.DLog.DLogStdExperiment(DL.StdRedAdversary(DLogAttacker(B))).main() @ &m : res].