Expand description
§Elliptic points coordinates
Elliptic points are defined differently for different types of curves:
- Curves in non-complete form (Weierstrass or Montgomery curves):
Points have $(x, y)$ coordinates that must satisfy curve equation unless it’s point at infinity that has no coordinates (see points at infinity) - Curves in complete form (Edwards curves):
Points always have $(x, y)$ coordinates that must satisfy curve equation
§Usage
This module provides various traits that can be used to retrieve coordinates. Refer to curve documentation to see what coordinates it exposes.
use generic_ec::{Point, coords::HasAffineX, curves::Secp256k1};
let point = Point::<Secp256k1>::generator().to_point();
let x = point.x();§In generic code
Generic code needs to explicitly state that it needs access to coordinates by specifying it in bounds:
use generic_ec::{Point, Curve, coords::HasAffineX};
fn func_that_accesses_x_coord<E: Curve>(point: &Point<E>)
where
Point<E>: HasAffineX<E>
{
let x = point.x();
// ...
}Note: it’s not recommended to access points coordinates in generic code unless it’s really necessary. Practically it lessens variety of curves that can work with your code. If you need unique representation of a point, use its byte representation.
§Curves support
Some curve implementations intentionally chosen not to expose coordinates, so they, for instance, can expose $y$ coordinate but hide $x$.
Structs§
- Coordinate
- Affine coordinate of a point on elliptic curve
- Coordinates
- Affine $x, y$ coordinates of a point on elliptic curve
Enums§
Traits§
- Always
HasAffineX - Point always has affine $x$ coordinate (for Edwards curves and non-zero points)
- Always
HasAffineXY - Point is uniquely represented by affine $x$ and $y$ coordinates (for Edward curves and non-zero points)
- Always
HasAffineY - Point always has affine $y$ coordinate (for Edwards curves and non-zero points)
- Always
HasAffineY AndSign - Point is uniquely represented by affine $y$ coordinate and sign of $x$ coordinate (for Edwards curves)
- HasAffineX
- Point has affine $x$ coordinate
- HasAffineX
AndParity - Point is uniquely represented by $x$ coordinate and parity of $y$ coordinate
- HasAffineXY
- Point is uniquely represented by affine $x, y$ coordinates
- HasAffineY
- Point has affine $y$ coordinate