y property

  1. @override
BigInt get y
override

Get the y-coordinate of the Edwards curve point.

This getter method computes and returns the y-coordinate of the Edwards curve point using the stored coordinates, considering the base field element modulo the curve's prime value (p).

Returns:

  • The y-coordinate of the point.

Implementation

@override
BigInt get y {
  /// Create a new list to avoid modifying the original coordinates.

  BigInt y1 = _coords[1];
  BigInt z1 = _coords[2];

  /// If the z-coordinate is 1, return y1 directly.
  if (z1 == BigInt.one) {
    return y1;
  }

  /// Retrieve the prime value (p) of the curve.
  BigInt p = curve.p;

  /// Compute the inverse of z1 modulo p.
  BigInt zInv = BigintUtils.inverseMod(z1, p);

  /// Calculate and return the y-coordinate modulo p.
  return (y1 * zInv) % p;
}