scale method
Scale the Edwards curve point.
This method scales the point by converting it to projective coordinates (if not already), performing the scaling operation, and then converting it back to extended coordinates.
Returns:
- A reference to the scaled Edwards curve point.
Implementation
EDPoint scale() {
final BigInt z1 = _coords[2];
/// If the z-coordinate is already 1, the point is already in projective form, and no scaling is required.
if (z1 == BigInt.one) {
return this;
}
final BigInt x1 = _coords[0];
final BigInt y1 = _coords[1];
/// 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);
final BigInt x = (x1 * zInv) % p;
final BigInt y = (y1 * zInv) % p;
final BigInt t = (x * y) % p;
/// Update the coordinates to their scaled values and set z-coordinate to 1 (projective form).
_coords[0] = x;
_coords[1] = y;
_coords[2] = BigInt.one;
_coords[3] = t;
return this;
}