multiplyTwo static method

ECPoint? multiplyTwo(
  1. ECPoint t,
  2. BigInt j,
  3. ECPoint x,
  4. BigInt k,
)

Implementation

static ECPoint? multiplyTwo(ECPoint t, BigInt j, ECPoint x, BigInt k) {
  int i = max(j.bitLength, k.bitLength) - 1;
  ECPoint? R = t.curve.infinity;
  ECPoint? both = t + x;

  while (i >= 0) {
    bool jBit = testBit(j, i);
    bool kBit = testBit(k, i);

    R = R!.twice();

    if (jBit) {
      if (kBit) {
        R = R! + both;
      } else {
        R = R! + t;
      }
    } else if (kBit) {
      R = R! + x;
    }

    --i;
  }

  return R;
}