Section PedersenBinding.
Variable A :  GroupElement -> Comp (GroupElement * (nat * nat) * (nat * nat)).
Definition B (x : GroupElement) :=
[c, p1, p2] <-$3 A x;
[v1, r1] <-2 p1;
[v2, r2] <-2 p2;
ret (modNat ((v1 + (modNatAddInverse v2 order)) * (multInverseModOrder (r2 + (modNatAddInverse r1 order)))) order)%nat.
Local Open Scope nat_scope.
intuition; omega.
Qed.
intuition.
subst.
intuition.
Qed.
induction c; intuition; simpl in *.
Qed.
intuition.
unfold modNatAddInverse.
rewrite mult_minus_distr_l.
rewrite modNat_mult_eq.
remember (modNat b c) as z.
eapply (modNat_add_same_r (modNat (a * z) c)).
rewrite Nat.sub_add.
rewrite modNat_arg_eq.
rewrite plus_comm.
rewrite <- modNat_plus.
rewrite plus_comm.
rewrite Nat.sub_add.
symmetry.
apply modNat_mult.
eapply mult_le_compat; intuition.
subst.
eapply lt_le_weak.
apply modNat_lt.
eapply lt_le_weak.
apply modNat_lt.
Qed.

Theorem modNat_mult_same_r :
forall a b c d,
modNat a d = modNat b d ->
modNat (a * c) d = modNat (b * c) d.