secp256k1GejDouble static method

void secp256k1GejDouble(
  1. Secp256k1Gej r,
  2. Secp256k1Gej a
)

Implementation

static void secp256k1GejDouble(Secp256k1Gej r, Secp256k1Gej a) {
  /// Operations: 3 mul, 4 sqr, 8 add/half/mul_int/negate
  Secp256k1Fe l = Secp256k1Fe(), s = Secp256k1Fe(), t = Secp256k1Fe();
  r.infinity = a.infinity;

  secp256k1FeMul(r.z, a.z, a.y);
  secp256k1FeSqr(s, a.y);
  secp256k1FeSqr(l, a.x);
  secp256k1FeMulInt(l, 3);
  secp256k1FeHalf(l);
  secp256k1FeNegate(t, s, 1);
  secp256k1FeMul(t, t, a.x);
  secp256k1FeSqr(r.x, l);
  secp256k1FeAdd(r.x, t);
  secp256k1FeAdd(r.x, t);
  secp256k1FeSqr(s, s);
  secp256k1FeAdd(t, r.x);
  secp256k1FeMul(r.y, t, l);
  secp256k1FeAdd(r.y, s);
  secp256k1FeNegate(r.y, r.y, 2);
}