Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
539abba
refactor: break pedersen scheme into separate defs
ashandoak Dec 17, 2025
3699a6f
chore: bump to 4.27
ashandoak Dec 17, 2025
3b97cfc
fix: rename commit to Commit
ashandoak Dec 17, 2025
af79045
fix: remove unnecessary hypothesis form hiding proofs
ashandoak Dec 17, 2025
7a842b3
fix: add pedersen scheme back in
ashandoak Dec 17, 2025
a0f1d48
fix: add nonempty instance for Pedersen Commit
ashandoak Dec 17, 2025
c619477
wip: modify commit output to include opening value
ashandoak Dec 17, 2025
e8fea56
wip: add Commitment namespace; remove Commit structure; add Pedersen …
ashandoak Dec 31, 2025
3025e71
wip: mapping logic in hiding; fix hiding def
ashandoak Dec 31, 2025
e60922c
wip: completed hiding lemmas; partial proof of perfect hiding, but ne…
ashandoak Dec 31, 2025
8ec70da
wip: move generate_a to pedersenscheme
ashandoak Jan 1, 2026
dc08d1e
wip: minor update to spec notes and pedersen setup
ashandoak Jan 3, 2026
a9ff617
wip: commitmentscheme to bind defs
ashandoak Jan 4, 2026
ca159b4
wip: pedersen scheme to bind
ashandoak Jan 4, 2026
dd7bd97
wip: dlog switch to bind
ashandoak Jan 4, 2026
b3f9059
wip: change dlog to fintype rather than finset; complete nonempty ins…
ashandoak Jan 4, 2026
4b0d84d
wip: add Fact Nat.Prime q back in where necessary
ashandoak Jan 4, 2026
082f847
wip: most of a fix for pedersen binding - need to equate dlog and com…
ashandoak Jan 4, 2026
c9e4769
fix: import fix
ashandoak Jan 6, 2026
9cad454
wip: change setup from PMF K to PMF K O
ashandoak Jan 6, 2026
7d2b97e
feat: fix binding
ashandoak Jan 7, 2026
a51a84b
wip: hiding in progress - but cycle?
ashandoak Jan 7, 2026
981abb8
wip: all hiding lemma proved
ashandoak Jan 7, 2026
f9b317b
feat: hiding complete
ashandoak Jan 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions VerifiedCommitments/CommitmentScheme.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import Mathlib.Probability.ProbabilityMassFunction.Constructions
import Mathlib.Data.ZMod.Defs


structure commit (C O : Type) where
c : C
o : O
-- namespace Crypto - or similar?
-- structure Commit (C O : Type) where
-- c : C
-- o : O

structure CommitmentScheme (M C O K : Type) where
setup : PMF K
commit : K → M → PMF (commit C O)
setup : PMF (K × O)
commit : K → M → PMF (C × O)
verify : K → M → C → O → ZMod 2

namespace Adversary
Expand All @@ -22,13 +23,18 @@ structure guess (M C O : Type) where
o': O
end Adversary

variable {M C O K : Type}

namespace Commitment

noncomputable section
variable {M C O K : Type}
variable (scheme : CommitmentScheme M C O K)

variable (h : K)

def correctness (scheme : CommitmentScheme M C O K) : Prop :=
∀ (h : K) (m : M),
PMF.bind (scheme.commit h m) (fun commit => pure $ scheme.verify h m commit.c commit.o) = pure 1
PMF.bind (scheme.commit h m) (fun (commit, opening_val) => pure $ scheme.verify h m commit opening_val) = pure 1

-- Perfect binding
def perfect_binding (scheme : CommitmentScheme M C O K) : Prop :=
Expand All @@ -45,48 +51,44 @@ def perfect_binding (scheme : CommitmentScheme M C O K) : Prop :=
def comp_binding_game (scheme : CommitmentScheme M C O K)
(A : K → PMF (C × M × M × O × O)) : PMF $ ZMod 2 :=
open scoped Classical in
do
let h ← scheme.setup
let (c, m, m', o, o') ← A h
if scheme.verify h m c o = 1 ∧ scheme.verify h m' c o' = 1 ∧ m ≠ m' then pure 1 else pure 0
PMF.bind scheme.setup (fun h =>
PMF.bind (A h.1) (fun (c, m , m', o, o') =>
if scheme.verify h.1 m c o = 1 ∧ scheme.verify h.1 m' c o' = 1 ∧ m ≠ m' then pure 1 else pure 0 ))

def computational_binding [DecidableEq M] (scheme : CommitmentScheme M C O K) (ε : ENNReal) : Prop :=
∀ (A : K → PMF (C × M × M × O × O)), comp_binding_game scheme A 1 ≤ ε


-- With Adversary namespace
def comp_binding_game' (scheme : CommitmentScheme M C O K)
(A' : K → PMF (Adversary.guess M C O)) : PMF $ ZMod 2 :=
open scoped Classical in
do
let h ← scheme.setup
let guess ← A' h
if scheme.verify h guess.m guess.c guess.o = 1 ∧ scheme.verify h guess.m' guess.c guess.o' = 1 ∧ guess.m ≠ guess.m' then pure 1 else pure 0
PMF.bind scheme.setup (fun h =>
PMF.bind (A' h.1) (fun guess =>
if scheme.verify h.1 guess.m guess.c guess.o = 1 ∧ scheme.verify h.1 guess.m' guess.c guess.o' = 1 ∧ guess.m ≠ guess.m' then pure 1 else pure 0 ))

def computational_binding' [DecidableEq M] (scheme : CommitmentScheme M C O K) (ε : ENNReal) : Prop :=
∀ (A' : K → PMF (Adversary.guess M C O )), comp_binding_game' scheme A' 1 ≤ ε


-- Perfect hiding
def do_commit (scheme: CommitmentScheme M C O K) (m : M) : PMF C :=
do
let h ← scheme.setup
let commit ← scheme.commit h m
return commit.c
PMF.bind scheme.setup (fun h =>
PMF.bind (scheme.commit h.1 m) (fun commit => pure commit.1))

def perfect_hiding (scheme: CommitmentScheme M C O K) : Prop :=
∀ (m m' : M) (c : C), (do_commit scheme m) c = (do_commit scheme m') c


-- Computational hiding game
def comp_hiding_game (scheme : CommitmentScheme M C O K)
(A : K → C → PMF (ZMod 2)) (m : M) : PMF (ZMod 2) :=
do
let h ← scheme.setup -- As above with comp_binding_game
let commit ← scheme.commit h m
A h commit.c
PMF.bind scheme.setup (fun h =>
PMF.bind (scheme.commit h.1 m) (fun commit => A h.1 commit.1))

def computational_hiding (scheme : CommitmentScheme M C O K) (ε : ENNReal) : Prop :=
∀ (A : K → C → PMF (ZMod 2)) (m₀ m₁ : M),
comp_hiding_game scheme A m₀ 1 - comp_hiding_game scheme A m₁ 1 ≤ ε ||
comp_hiding_game scheme A m₁ 1 - comp_hiding_game scheme A m₀ 1 ≤ ε

end

end Commitment
Loading
Loading