ctSelect static method

Uint64 ctSelect(
  1. Uint64 a,
  2. Uint64 b,
  3. bool choice
)

Branchless select: returns b if choice else a. Built from a bitmask blend, matching the shape of typical constant-time field code (this is a helper, not a hardened constant-time guarantee — Dart's runtime doesn't guarantee branchless codegen).

Implementation

static Uint64 ctSelect(Uint64 a, Uint64 b, bool choice) {
  final mask = choice ? Uint64.max : Uint64.zero;
  return (b & mask) | (a & ~mask); // Inverted from original
}