Section PedersenHiding.
Variable A_State : Set.
Variable A1 : GroupElement -> Comp (nat * nat * A_State).
Hypothesis A1_wf : forall p, well_formed_comp (A1 p).
Variable A2 : A_State -> GroupElement -> Comp bool.
Hypothesis A2_wf :
forall s c, well_formed_comp (A2 s c).
Definition PedersenHiding_G0 :=
a <-$ [ 0  .. order);
[v1, v2, s_A] <-$3 A1 (g^a);
b <-$ {0,1};
v <- (if b then v1 else v2);
z <-$
(r <-$ [ 0  .. order);
ret (g^a)^r);
b' <-$ A2 s_A (g ^ v * z);
ret eqb b b'.
Definition PedersenHiding_G1 :=
a <-$ [ 0  .. order);
[v1, v2, s_A] <-$3 A1 (g^a);
b <-$ {0,1};
v <- (if b then v1 else v2);
z <-$
(x <-$ RndGrpElem;
ret (g ^ v * x));
b' <-$ A2 s_A z;
ret eqb b b'.
Definition PedersenHiding_G2 :=
a <-$ [ 0  .. order);
[v1, v2, s_A] <-$3 A1 (g^a);
b <-$ {0,1};
x <-$ RndGrpElem;
b' <-$ A2 s_A x;
ret eqb b b'.
Definition PedersenHiding_G3 :=
a <-$ [ 0  .. order);
[v1, v2, s_A] <-$3 A1 (g^a);
x <-$ RndGrpElem;
b' <-$ A2 s_A x;
b <-$ {0,1};
ret eqb b b'.
unfold HidingCommit_G, PedersenSetup, PedersenCommit, PedersenHiding_G0.
repeat (inline_first; comp_skip; comp_simp).
Qed.

Theorem PedersenHiding_G1_equiv :
Pr[PedersenHiding_G0] ==
Pr[PedersenHiding_G1].