Skip to content

Commit c29493e

Browse files
committed
Migrate Pedersen.lean to Lean 4
1 parent 00118a1 commit c29493e

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

Cryptolib/Pedersen.lean

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
/-
2+
Copyright (c) 2023 Ashley Blacquiere
3+
Released under Apache 2.0 license as described in the file LICENSE-APACHE.
4+
Authors: Ashley Blacquiere
5+
-/
6+
import Cryptolib.Commitments
7+
import Cryptolib.DiscreteLog
18

2-
import dlog
3-
import commitments
4-
5-
section pedersen
9+
section Pedersen
610

7-
noncomputable theory
11+
noncomputable theory
812

913
variables {M : Type}
1014
(G : Type) [fintype G] [group G] [decidable_eq G]
11-
(g : G) (g_gen_G : ∀ (x : G), x ∈ subgroup.gpowers g)
12-
(q : ℕ) [fact (0 < q)] (G_card_q : fintype.card G = q)
15+
(g : G) (g_gen_G : ∀ (x : G), x ∈ subgroup.gpowers g)
16+
(q : ℕ) [fact (0 < q)] (G_card_q : fintype.card G = q)
1317
(A : G → (pmf (G × zmod q) × zmod q × zmod q × G × G))
1418

1519
include g_gen_G G_card_q -- assumptions used in the game reduction
@@ -22,18 +26,18 @@ To implement:
2226
(gen : pmf G) -- generates the public parameter, h ∈ G
2327
(commit : G → M → pmf (C × D) )
2428
(verify : G → C → D → M → bool)
25-
(BindingAdversary : G → pmf (C × D × D × M × M))
29+
(BindingAdversary : G → pmf (C × D × D × M × M))
2630
-/
2731

2832
-- (gen : pmf (G x zmod q) -- generates the public parameter, h ∈ G and secret x ∈ zmod q
29-
-- Note: Messages in ElGamal come from G not from zmod q
30-
def gen : pmf (G × zmod q) :=
31-
do
33+
-- Note: Messages in ElGamal come from G not from zmod q
34+
def gen : pmf (G × zmod q) :=
35+
do
3236
x ← uniform_zmod q,
33-
pure (g^x.val, x)
37+
pure (g^x.val, x)
3438

3539
-- commit : G → M → pmf (C × D)
36-
def commit (h : G) (m : zmod q) : pmf (G × zmod q) :=
40+
def commit (h : G) (m : zmod q) : pmf (G × zmod q) :=
3741
do
3842
y ← uniform_zmod q,
3943
pure (g^m.val * h^y.val, y)
@@ -42,11 +46,11 @@ do
4246
def verify (h : G) (c : G) (d : zmod q) (m : zmod q) : zmod 2 :=
4347
let c' := g^m.val * h^d.val in if c' = c then 1 else 0
4448

45-
-- Previously had as follows, but problems with the use of ite
49+
-- Previously had as follows, but problems with the use of ite
4650
-- def verify' (h : G) (c : G) (d : zmod q) (m : zmod q) : zmod 2 :=
47-
-- do
51+
-- do
4852
-- let c' := g^m.val * h^d.val,
49-
-- pure (if c' = c then 1 else 0)
53+
-- pure (if c' = c then 1 else 0)
5054

5155

5256
-- BindingAdversary : G → pmf (C × D × D × M × M)
@@ -59,16 +63,14 @@ do
5963
let c := (A h).1,
6064
pure (if (g^x.val * h^r.val) = c.1 then 1 else 0)
6165

62-
/-
63-
The probability of the binding adversary winning the security game (i.e. finding messages, m and m', and opening values, o and o', such that they both resolve to the same commitment c), is equal to the probability of A winning the game DL.
66+
/-
67+
The probability of the binding adversary winning the security game (i.e. finding messages, m and m', and opening values, o and o', such that they both resolve to the same commitment c), is equal to the probability of A winning the game DL.
6468
-/
6569

6670
#check BG
6771

68-
theorem BG_DL : BG gen A verify = DL ?? :=
69-
begin
70-
sorry,
71-
end
72+
theorem BG_DL : BG gen A verify = DL ?? := by
73+
sorry
7274

7375

74-
end pedersen
76+
end Pedersen

0 commit comments

Comments
 (0)