Signature

pub impl EcPointImpl of EcPointTrait;

Impl functions

new

Creates a new EC point from its (x, y) coordinates.

Arguments

  • x - The x-coordinate of the point
  • y - The y-coordinate of the point

Returns

Returns None if the point (x, y) is not on the curve.

Examples

let point = EcPointTrait::new(
    x: 336742005567258698661916498343089167447076063081786685068305785816009957563,
    y: 1706004133033694959518200210163451614294041810778629639790706933324248611779,
).unwrap();

Signature

fn new(x: felt252, y: felt252) -> Option

new_nz

Creates a new NonZero EC point from its (x, y) coordinates.

Signature

fn new_nz(x: felt252, y: felt252) -> Option>

new_from_x

Creates a new EC point from its x coordinate.

Arguments

  • x - The x-coordinate of the point

Returns

Returns None if no point with the given x-coordinate exists on the curve.

Panics

Panics if x is 0, as this would be the point at infinity.

Examples

let valid = EcPointTrait::new_from_x(1);
assert!(valid.is_some());
let invalid = EcPointTrait::new_from_x(0);
assert!(invalid.is_none());

Signature

fn new_from_x(x: felt252) -> Option

new_nz_from_x

Creates a new NonZero EC point from its x coordinate.

Signature

fn new_nz_from_x(x: felt252) -> Option>

coordinates

Returns the coordinates of the EC point.

Returns

A tuple containing the (x, y) coordinates of the point.

Panics

Panics if the point is the point at infinity.

Examples

let point_nz = EcPointTrait::new_nz_from_x(1).unwrap();
let (x, _y) = point_nz.coordinates();
assert!(x == 1);

Signature

fn coordinates(self: NonZero) -> (felt252, felt252)

x

Returns the x coordinate of the EC point.

Panics

Panics if the point is the point at infinity.

Examples

let point_nz = EcPointTrait::new_nz_from_x(1).unwrap();
let x = point_nz.x();
assert!(x == 1);

Signature

fn x(self: NonZero) -> felt252

y

Returns the y coordinate of the EC point.

Panics

Panics if the point is the point at infinity.

Examples

let gen_point =
EcPointTrait::new_nz_from_x(0x1ef15c18599971b7beced415a40f0c7deacfd9b0d1819e03d723d8bc943cfca).unwrap();
let y = gen_point.y();
assert!(y == 0x5668060aa49730b7be4801df46ec62de53ecd11abe43a32873000c36e8dc1f);

Signature

fn y(self: NonZero) -> felt252

mul

Computes the product of an EC point by the given scalar.

Arguments

  • scalar - The scalar to multiply the point by

Returns

The resulting point after scalar multiplication.

Signature

fn mul(self: EcPoint, scalar: felt252) -> EcPoint