x property
Get the x-coordinate of the Edwards curve point.
This getter method computes and returns the x-coordinate of the Edwards curve point using the stored coordinates, considering the base field element modulo the curve's prime value (p).
Returns:
- The x-coordinate of the point.
Implementation
@override
BigInt get x {
final BigInt x1 = _coords[0];
final BigInt z1 = _coords[2];
/// If the z-coordinate is 1, return x1 directly.
if (z1 == BigInt.one) {
return x1;
}
/// Retrieve the prime value (p) of the curve.
final BigInt p = curve.p;
/// Compute the inverse of z1 modulo p.
final BigInt zInv = BigintUtils.inverseMod(z1, p);
/// Calculate and return the x-coordinate modulo p.
return (x1 * zInv) % p;
}