millerLoop<D extends Object?> static method

D millerLoop<D extends Object?>(
  1. MillerLoopDriver<D> deriver
)

Performs the Miller loop using the given driver.

Implementation

static D millerLoop<D extends Object?>(MillerLoopDriver<D> deriver) {
  D f = deriver.one();
  final blsX = Bls12PairingUtils.blsX;
  bool foundOne = false;
  for (int b = 63; b >= 0; b--) {
    bool i = (((blsX >> 1) >> b) & BigInt.one) == BigInt.one;
    if (!foundOne) {
      foundOne = i;
      continue;
    }
    f = deriver.doublingStep(f);

    if (i) {
      f = deriver.additionStep(f);
    }

    f = deriver.squareOutput(f);
  }

  f = deriver.doublingStep(f);

  f = deriver.conjugate(f);

  return f;
}