ecmultConstTableGetGe static method

void ecmultConstTableGetGe(
  1. Secp256k1Ge r,
  2. List<Secp256k1Ge> pre,
  3. int n
)

Implementation

static void ecmultConstTableGetGe(
    Secp256k1Ge r, List<Secp256k1Ge> pre, int n) {
  int m = 0;

  /// If the top bit of n is 0, we want the negation.
  int negative = ((n) >> (Secp256k1Const.constGroupSize - 1)) ^ 1;
  int index =
      ((-negative) ^ n) & ((1 << (Secp256k1Const.constGroupSize - 1)) - 1);
  Secp256k1Fe negY = Secp256k1Fe();
  _cond((n.toBigInt) < (BigInt.one << Secp256k1Const.constGroupSize),
      "ecmultConstTableGetGe");
  _cond(index < (1 << (Secp256k1Const.constGroupSize - 1)),
      "ecmultConstTableGetGe");

  (r).x = (pre)[m].x.clone();
  (r).y = (pre)[m].y.clone();
  for (m = 1; m < Secp256k1Const.constTableSize; m++) {
    secp256k1FeCmov((r).x, (pre)[m].x, (m == index).toInt);
    secp256k1FeCmov((r).y, (pre)[m].y, (m == index).toInt);
  }
  (r).infinity = 0;
  secp256k1FeNegate(negY, (r).y, 1);
  secp256k1FeCmov((r).y, negY, negative);
}