double method

  1. @override
VestaNativePoint double()
override

Implementation

@override
VestaNativePoint double() {
  if (isIdentity()) return identity();
  // Step 1: Squares
  final a = x.square(); // a = x^2
  final b = y.square(); // b = y^2
  final c = VestaNativeFq(b.v * b.v); // c = b^2

  // Step 2: d = 2*((x+b)^2 - a - c)
  final dRaw = ((x.v + b.v) * (x.v + b.v)) - a.v - c.v;
  final d = VestaNativeFq(dRaw * BigInt.from(2));

  // Step 3: e = 3*a
  final e = VestaNativeFq(a.v * BigInt.from(3));
  final f = e.square();

  // Step 4: z3 = 2*y*z
  final z3 = VestaNativeFq(y.v * z.v * BigInt.from(2));

  // Step 5: x3 = f - 2*d
  final x3 = VestaNativeFq(f.v - d.v * BigInt.from(2));

  // Step 6: c = 8*c
  final c8 = VestaNativeFq(c.v << 3);

  // Step 7: y3 = e*(d - x3) - 8*c
  final y3 = VestaNativeFq(e.v * (d.v - x3.v) - c8.v);

  return from(x: x3, y: y3, z: z3);
}