scale method
The coordinates are updated to the scaled values, and the scaled point is returned.
Implementation
ProjectiveECCPoint scale() {
final currentZ = _coords[2];
/// If the current z-coordinate is already one, no need to scale
if (currentZ == BigInt.one) {
return this;
}
final currentY = _coords[1];
final currentX = _coords[0];
/// Get the prime field value
final primeField = curve.p;
/// Calculate the modular inverse of z
final zInverse = BigintUtils.inverseMod(currentZ, primeField);
/// Calculate z-inverse squared
final zInverseSquared = (zInverse * zInverse) % primeField;
/// Scale the x and y coordinates
final scaledX = (currentX * zInverseSquared) % primeField;
final scaledY = (currentY * zInverseSquared * zInverse) % primeField;
/// Update the coordinates to the scaled values
_coords = [scaledX, scaledY, BigInt.one];
return this;
}