x property
Get the x-coordinate of this point in the projective elliptic curve coordinates.
Implementation
@override
BigInt get x {
/// Extract the x-coordinate and z-coordinate from the point's coordinates.
final xCoordinate = _coords[0];
final zCoordinate = _coords[2];
/// If z-coordinate is one, return the x-coordinate as it is.
if (zCoordinate == BigInt.one) {
return xCoordinate;
}
/// Get the prime field modulus from the curve.
final p = curve.p;
/// Calculate the inverse of z-coordinate modulo p.
final zInverse = BigintUtils.inverseMod(zCoordinate, p);
/// Compute and return the x-coordinate in projective coordinates.
final result = (xCoordinate * zInverse * zInverse) % p;
return result;
}