aboutsummaryrefslogtreecommitdiff
path: root/src/Spec
diff options
context:
space:
mode:
authorGravatar Andres Erbsen <andreser@mit.edu>2017-02-12 19:16:26 -0500
committerGravatar Andres Erbsen <andreser@mit.edu>2017-03-02 13:37:14 -0500
commitbc46f85d089099aa92d3ea12555e6510cbcffa78 (patch)
treecac00ea0f50bc3b7ba101181161ab76dbd55e797 /src/Spec
parente8fab6b839e19da231333ca8173bbb2a3d8a4033 (diff)
change weierstrass spec, prove most cases of associativity
Diffstat (limited to 'src/Spec')
-rw-r--r--src/Spec/WeierstrassCurve.v20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/Spec/WeierstrassCurve.v b/src/Spec/WeierstrassCurve.v
index 8b5480620..3f8ab2100 100644
--- a/src/Spec/WeierstrassCurve.v
+++ b/src/Spec/WeierstrassCurve.v
@@ -48,18 +48,24 @@ Module W.
_
(match coordinates P1, coordinates P2 return _ with
| (x1, y1), (x2, y2) =>
- if x1 =? x2 then
- if y2 =? -y1 then ∞
- else ((3*x1^2+a)^2 / (2*y1)^2 - x1 - x1,
- (2*x1+x1)*(3*x1^2+a) / (2*y1) - (3*x1^2+a)^3/(2*y1)^3-y1)
- else ((y2-y1)^2 / (x2-x1)^2 - x1 - x2,
- (2*x1+x2)*(y2-y1) / (x2-x1) - (y2-y1)^3 / (x2-x1)^3 - y1)
+ if x1 =? x2
+ then
+ if y2 =? -y1
+ then ∞
+ else let k := (3*x1^2+a)/(2*y1) in
+ let x3 := k^2-x1-x1 in
+ let y3 := k*(x1-x3)-y1 in
+ (x3, y3)
+ else let k := (y2-y1)/(x2-x1) in
+ let x3 := k^2-x1-x2 in
+ let y3 := k*(x1-x3)-y1 in
+ (x3, y3)
| ∞, ∞ => ∞
| ∞, _ => coordinates P2
| _, ∞ => coordinates P1
end)
_.
- Next Obligation. exact (Pre.unifiedAdd'_onCurve _ _ (proj2_sig _) (proj2_sig _)). Qed.
+ Next Obligation. Admitted.
Fixpoint mul (n:nat) (P : point) : point :=
match n with