aboutsummaryrefslogtreecommitdiff
path: root/src/Spec
diff options
context:
space:
mode:
authorGravatar Andres Erbsen <andreser@mit.edu>2017-02-10 10:12:44 -0500
committerGravatar Andres Erbsen <andreser@mit.edu>2017-03-02 13:37:14 -0500
commitc56ca7b46711128f9287b5105a5b457ca09d4723 (patch)
treedadcbfa07823eaf27c2ccf82fb74d4e7a2382946 /src/Spec
parent55de48a40d269bd900ce0af04449cb33ebb8577d (diff)
fsatz, nsatz_solve_nonzero
Diffstat (limited to 'src/Spec')
-rw-r--r--src/Spec/CompleteEdwardsCurve.v17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/Spec/CompleteEdwardsCurve.v b/src/Spec/CompleteEdwardsCurve.v
index e081ded1e..d475f78c2 100644
--- a/src/Spec/CompleteEdwardsCurve.v
+++ b/src/Spec/CompleteEdwardsCurve.v
@@ -13,13 +13,14 @@ Module E.
Local Infix "=" := Feq : type_scope. Local Notation "a <> b" := (not (a = b)) : type_scope.
Local Notation "0" := Fzero. Local Notation "1" := Fone.
Local Infix "+" := Fadd. Local Infix "*" := Fmul.
- Local Infix "-" := Fsub. Local Infix "/" := Fdiv.
+ Local Infix "-" := Fsub.
Local Notation "x ^ 2" := (x*x) (at level 30).
+ Local Notation "n / d" := (fst (Fdiv n d, (_:(d <> 0)))). (* force nonzero d *)
Context {a d: F}.
Class twisted_edwards_params :=
{
- char_gt_2 : 1 + 1 <> 0;
+ char_gt_2 : forall p : BinNums.positive, BinPos.Pos.le p 2 -> Pre.ZtoR (BinNums.Zpos p) <> 0;
nonzero_a : a <> 0;
square_a : exists sqrt_a, sqrt_a^2 = a;
nonsquare_d : forall x, x^2 <> d
@@ -28,15 +29,20 @@ Module E.
Definition point := { P | let '(x,y) := P in a*x^2 + y^2 = 1 + d*x^2*y^2 }.
Definition coordinates (P:point) : (F*F) := proj1_sig P.
+ Definition eq (P Q:point) :=
+ fst (coordinates P) = fst (coordinates Q) /\
+ snd (coordinates P) = snd (coordinates Q).
Program Definition zero : point := (0, 1).
- Next Obligation. auto using Pre.zeroOnCurve. Defined.
+ Next Obligation. eauto using Pre.onCurve_zero. Qed.
Program Definition add (P1 P2:point) : point :=
let x1y1 := coordinates P1 in let x1 := fst x1y1 in let y1 := snd x1y1 in
let x2y2 := coordinates P2 in let x2 := fst x2y2 in let y2 := snd x2y2 in
(((x1*y2 + y1*x2)/(1 + d*x1*x2*y1*y2)) , ((y1*y2 - a*x1*x2)/(1 - d*x1*x2*y1*y2))).
- Next Obligation. destruct P1 as [[??]?], P2 as [[??]?], H; auto using Pre.add_onCurve. Defined.
+ Next Obligation. destruct P1 as [[??]?], P2 as [[??]?], H. eauto using Pre.denominator_nonzero_x. Qed.
+ Next Obligation. destruct P1 as [[??]?], P2 as [[??]?], H; eauto using Pre.denominator_nonzero_y. Qed.
+ Next Obligation. destruct P1 as [[??]?], P2 as [[??]?], H; eauto using Pre.onCurve_add. Qed.
Fixpoint mul (n:nat) (P : point) : point :=
match n with
@@ -47,5 +53,6 @@ Module E.
End E.
Delimit Scope E_scope with E.
+Infix "=" := E.eq : E_scope.
Infix "+" := E.add : E_scope.
-Infix "*" := E.mul : E_scope.
+Infix "*" := E.mul : E_scope. \ No newline at end of file