isLessThanConst static method
Constant-time comparison of two 32-byte big-endian values: 1 if a < b, else 0.
Implementation
static int isLessThanConst(List<int> a, List<int> b) {
assert(a.length == 32);
assert(b.length == 32);
int borrow = 0;
for (int i = 31; i >= 0; i--) {
final x = a[i];
final y = b[i];
final diff = x - y - borrow;
// borrow = 1 if x < y + borrow
borrow = (diff >> 8) & 1;
}
return borrow;
}