doublePoint method

  1. @override
ProjectiveECCPoint doublePoint()
override

Doubles a point in projective coordinates on an elliptic curve and returns the result.

Implementation

@override
ProjectiveECCPoint doublePoint() {
  BigInt x1 = _coords[0];
  BigInt y1 = _coords[1];
  BigInt z1 = _coords[2];

  if (y1 == BigInt.zero) {
    // If y-coordinate is zero, the result is the point at infinity
    return ProjectiveECCPoint.infinity(curve);
  }

  BigInt primeField = curve.p;
  BigInt curveA = curve.a;

  List<BigInt> result = _double(x1, y1, z1, primeField, curveA);

  if (result[1] == BigInt.zero || result[2] == BigInt.zero) {
    // If the y-coordinate or z-coordinate of the result is zero, return the point at infinity
    return ProjectiveECCPoint.infinity(curve);
  }

  return ProjectiveECCPoint(
      curve: curve, x: result[0], y: result[1], z: result[2], order: order);
}