y property
Get the y-coordinate of this point in projective elliptic curve coordinates.
If the point's z-coordinate is already one, this returns the y-coordinate directly. Otherwise, it computes the normalized y-coordinate.
Returns: The y-coordinate of the point in the elliptic curve coordinates.
Note:
- The value is computed modulo the prime field 'p' of the curve.
- This property is used for coordinate transformation and point retrieval.
Implementation
@override
BigInt get y {
final yCoordinate = _coords[1];
final zCoordinate = _coords[2];
final primeField = curve.p;
// Check if the z-coordinate is already one.
if (zCoordinate == BigInt.one) {
return yCoordinate;
}
// Calculate the modular inverse of z-coordinate.
final zInverse = BigintUtils.inverseMod(zCoordinate, primeField);
// Compute the normalized y-coordinate using the formula.
final normalizedY =
(yCoordinate * zInverse * zInverse * zInverse) % primeField;
return normalizedY;
}