ctSelectBigInt static method

BigInt ctSelectBigInt(
  1. BigInt a,
  2. BigInt b,
  3. bool choice
)

Implementation

static BigInt ctSelectBigInt(BigInt a, BigInt b, bool choice) {
  final mask = choice ? BigInt.from(-1) : BigInt.zero; // 0 or -1
  final s = a ^ (mask & (a ^ b));
  assert(s == a || s == b);
  return s;
}