secp256k1GeSetXoVar static method

int secp256k1GeSetXoVar(
  1. Secp256k1Ge r,
  2. Secp256k1Fe x,
  3. int odd
)

Implementation

static int secp256k1GeSetXoVar(Secp256k1Ge r, Secp256k1Fe x, int odd) {
  Secp256k1Fe x2 = Secp256k1Fe(), x3 = Secp256k1Fe();
  int ret;

  r.x = x.clone();
  secp256k1FeSqr(x2, x);
  secp256k1FeMul(x3, x, x2);
  r.infinity = 0;
  secp256k1FeAddInt(x3, Secp256k1Const.secp256k1B);
  ret = secp256k1FeSqrt(r.y, x3);
  secp256k1FeNormalizeVar(r.y);
  if (secp256k1FeIsOdd(r.y) != odd) {
    secp256k1FeNegate(r.y, r.y, 1);
  }
  return ret;
}