Skip to content

Commit 87a3900

Browse files
authored
feat: add proof of elgamal binding
* refactor: rename parameters * feat: add proof of elgamal binding
1 parent 5e564eb commit 87a3900

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

VerifiedCommitments/ElgamalCommitments.lean

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,4 +382,44 @@ theorem computational_hiding_from_ddh (ε : ENNReal)
382382
exact DDH_hard (D_from_adversary hA)
383383

384384

385+
/- ========================================
386+
BINDING PROPERTY
387+
======================================== -/
388+
389+
lemma ordg_eq_q : orderOf params.g = params.q := by
390+
have h_card_zpow : Fintype.card (Subgroup.zpowers params.g) = orderOf params.g := Fintype.card_zpowers
391+
have h_card_eq : Fintype.card (Subgroup.zpowers params.g) = Fintype.card G := by
392+
have : Function.Bijective (Subtype.val : Subgroup.zpowers params.g → G) := by
393+
constructor
394+
· exact Subtype.val_injective
395+
· intro x
396+
use ⟨x, params.g_gen_G x⟩
397+
exact Fintype.card_of_bijective this
398+
rw [← h_card_zpow, h_card_eq, params.card_eq]
399+
400+
401+
theorem perfect_binding : Commitment.perfect_binding (@scheme G params) := by
402+
unfold Commitment.perfect_binding
403+
intro h c m m' o o'
404+
unfold scheme verify
405+
simp only [ite_eq_left_iff, zero_ne_one, imp_false, Decidable.not_not]
406+
intro hc
407+
simp [hc]
408+
congr! with hc₁ hc₂
409+
410+
411+
have h_congr : o.val ≡ o'.val [MOD params.q] := by
412+
simpa [ordg_eq_q] using (pow_eq_pow_iff_modEq.mp hc₁)
413+
414+
have o_eq : o = o' := by
415+
have eq_cast : ((o.val : ℕ) : ZMod params.q) = ((o'.val : ℕ) : ZMod params.q) :=
416+
ZMod.natCast_eq_natCast_iff o.val o'.val params.q |>.mpr h_congr
417+
simp at eq_cast
418+
exact eq_cast
419+
420+
subst o_eq
421+
simp at hc₂
422+
exact hc₂
423+
424+
385425
end Elgamal

0 commit comments

Comments
 (0)