doublePoint method

  1. @override
AffinePointt doublePoint()
override

Doubles the AffinePointt by performing point doubling operation. It computes the new point representing the result of doubling this point on the elliptic curve. If this is the point at infinity, it returns the point at infinity.

The doubling operation on the elliptic curve is used to efficiently calculate scalar multiplications. It computes the new coordinates (x, y) on the curve that results from doubling the given point.

Returns a new AffinePointt representing the result of doubling this point.

Implementation

@override
AffinePointt doublePoint() {
  if (isInfinity) {
    return AffinePointt(curve, BigInt.zero, BigInt.zero);
  }

  BigInt p = curve.p;
  BigInt a = curve.a;

  BigInt l = (BigInt.from(3) * x * x + a) *
      BigintUtils.inverseMod(BigInt.from(2) * y, p) %
      p;

  BigInt x3 = (l * l - BigInt.from(2) * x) % p;
  BigInt y3 = (l * (x - x3) - y) % p;

  return AffinePointt(curve, x3, y3, order: null);
}