Generic commitment schemes #
A transliteration of EasyCrypt's theories/crypto/Commitment.ec (theory
CommitmentProtocol) into the Gaudí module/procedure syntax.
- EC's abstract theory types
value,message,commitment,openingkeybecome the type classCommitmentTypes(instance-implicit section parameters, so themoduletype-generated definitions elaborate — the same pattern as[ProgramSpec]). - EC
module types becomemoduletypes. - EC's parameterized modules (
Correctness(S),HidingExperiment(S,U),BindingExperiment(S,B)) becomemodule X (P : T) { … }declarations: the calls are written against the parameters' own fields and the holes are inferred from them.
The abstract types of EC's theory CommitmentProtocol: the public value (key), the
message space, commitments, and opening keys. Inhabited is needed for program
local variables of these types — that one is real content (a default value has to exist).
There is deliberately no DecidableEq here. It was a field (message_deceq), justified
by EC's binding experiment comparing m ≠ m', but decidability is never needed for proofs —
only to form a Bool-valued program expression via BEq — and no program in this development
compares messages, so nothing consumed it. (Commitment never had one either, and that has
never been missed.) When BindingExperiment does need m ≠ m', note that these programs are
never executed — the semantics is a measure and every proc is noncomputable — so
Classical.decEq at the point of use is enough; a class field buys nothing. See
Lib/RO/CollisionResistance.lean, which does exactly that.
- Value : Type
- Message : Type
- Commitment : Type
- OpeningKey : Type
- commitment_inhabited : Inhabited Commitment
- openingKey_inhabited : Inhabited OpeningKey
Instances
Equations
- GaudisCrypt.Examples.Pedersen.f x y = x + y
Instances For
Disjointness of tuple-projection lenses #
The proc macro binds each local variable to a Lens.id.ofst/.osnd projection chain into
the local-state tuple; tuple assignment (c, d <- …) pairs those lenses via Lens.pair,
which needs them disjoint. Distinct projection paths are always disjoint, and the instances
deriving that (Lens.disjoint_ofst_osnd, Lens.disjoint_chain, …) now live in
Language/Lens.lean — the "move them to the proper place" TODO that used to sit here is done,
and they are no longer declared in this file.
⚠ They still do not make tuple assignment of locals work (re-tested 2026-08-07): the macro
binds locals as let-variables, and instance search does not unfold local lets, so
disjoint c d is searched at the opaque variables and never reaches these instances.
Both spellings fail, identically — [lvalRaw|] sends the parenthesised tuple to Lens.pair
just as the comma-list does, so there is no way around it by rewriting the assignment:
c, d <- call S.commit (…); -- failed to synthesize instance of type class disjoint c d
(c, d) <- call S.commit (…); -- same
Until the macro binds locals differently (inlining the lens chains, or registering the
disjointness facts itself), the experiments below use pair-typed locals and $-projections
instead — var cd : Commitment × OpeningKey then ($cd).1/($cd).2.
Module types #
module type CommitmentScheme = {
proc gen() : value
proc commit(x: value, m: message) : commitment * openingkey
proc verify(x: value, m: message, c: commitment, d: openingkey) : bool
}.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Equations
- GaudisCrypt.Examples.Pedersen.instIsModuleCommitmentScheme = { moduleTypeRep := GaudisCrypt.Examples.Pedersen.CommitmentScheme.typeRep, isModule := ⋯ }
Equations
- m.verify = (GaudisCrypt.Module.snd' m).snd'
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- m.commit = (GaudisCrypt.Module.snd' m).fst'
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Equations
- GaudisCrypt.Examples.Pedersen.instIsModuleUnhider = { moduleTypeRep := GaudisCrypt.Examples.Pedersen.Unhider.typeRep, isModule := ⋯ }
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
Instances For
Instances For
Equations
Instances For
Equations
Instances For
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Equations
- GaudisCrypt.Examples.Pedersen.instIsModuleBinder = { moduleTypeRep := GaudisCrypt.Examples.Pedersen.Binder.typeRep, isModule := ⋯ }
params and vars are distinct fields of LocalVariableState, so writes through
projections of the two commute — no hypothesis on x, y needed.
The mirror image of LocalVariableState.disjoint_varsL_paramsL; disjoint.symm is a
theorem, not an instance, so search needs both orientations spelled out.
Parameter-slot counterpart of Programs.disjoint_intoVars: distinct parameter slots stay
disjoint after intoParams (two chain layers).
A local variable is disjoint from any parameter: they live in different fields of the
scope record, so no disjoint x y hypothesis is required.
The other orientation of Programs.disjoint_intoVars_intoParams.
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.