stdlib - 0.0.1

Stdlib.Cairo.Ec

Description

Functions for various actions on the STARK curve: y^2 = x^3 + alpha * x + beta where alpha = 1 and beta = 0x6f21413efbe40de150e596d72f7a8c5609ad26c15c915c1f4cdfcb99cee9e89. The point at infinity is represented as (0, 0). Implementation largely follows: https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/cairo/common/ec.cairo

Definitions

builtin ec_point type PointSource#

Constructors

| mkPoint@{ x : Field; y : Field; }

builtin ec_op axiom ecOp : Point -> Field -> Point -> PointSource#

builtin random_ec_point axiom randomEcPoint : PointSource#

isOnCurve (point : Point) : BoolSource#

Checks if an EC point is on the STARK curve.

double (point : Point) : PointSource#

Doubles a valid `point` (computes point + point) on the elliptic curve.

add (point1 point2 : Point) : PointSource#

Adds two valid points on the EC.

sub (point1 point2 : Point) : PointSource#

Subtracts point2 from point1 on the EC.

addMul (point1 : Point) (alpha : Field) (point2 : Point) : PointSource#

Computes point1 + alpha * point2 on the elliptic curve. Because the EC operation builtin cannot handle inputs where additions of points with the same x coordinate arise during the computation, this function adds and subtracts a nondeterministic point s to the computation, so that regardless of input, the probability that such additions arise will become negligibly small. The precise computation is therefore: ((point1 + s) + alpha * point2) - s so that the inputs to the builtin itself are (point1 + s), alpha, and point2. Arguments: point1 - an EC point. alpha - the multiplication coefficient of point2 (a field element). point2 - an EC point. Returns: point1 + alpha * point2. Assumptions: point1 and point2 are valid points on the curve.

mul (alpha : Field) (point : Point) : PointSource#

Computes alpha * point on the elliptic curve.