Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed Oct 11, 2024
1 parent 4e1c031 commit 0f3732c
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions Stdlib/Cairo/Ec.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,22 @@ double (point : Point) : Point :=
};

--- Adds two valid points on the EC.
add (point1 point2 : Point) : Point := case (point1, point2) of
| (mkPoint x1 y1, mkPoint x2 y2) :=
if
| y1 == 0 := point2
| y2 == 0 := point1
| x1 == x2 :=
if
| y1 == y2 := double point1
| else := mkPoint 0 0
| else :=
let
slope := (y1 - y2) / (x1 - x2);
r_x := slope * slope - x1 - x2;
r_y := slope * (x1 - r_x) - y1;
in mkPoint r_x r_y;
add (point1 point2 : Point) : Point :=
case point1, point2 of
mkPoint x1 y1, mkPoint x2 y2 :=
if
| y1 == 0 := point2
| y2 == 0 := point1
| x1 == x2 :=
if
| y1 == y2 := double point1
| else := mkPoint 0 0
| else :=
let
slope := (y1 - y2) / (x1 - x2);
r_x := slope * slope - x1 - x2;
r_y := slope * (x1 - r_x) - y1;
in mkPoint r_x r_y;

--- Subtracts point2 from point1 on the EC.
sub (point1 point2 : Point) : Point := add point1 point2@Point{y := 0 - y};
Expand Down

0 comments on commit 0f3732c

Please sign in to comment.