mulAddTruncated32 static method
Implementation
static List<int> mulAddTruncated32(List<int> a, List<int> b, List<int> c) {
if (a.length < 32 || b.length < 32 || c.length < 32) {
throw ArgumentException(
"All input lists must have at least 32 elements.");
}
assert(a.length == 32 && b.length == 32 && c.length == 32);
final r = List<int>.filled(32, 0);
final tmp = List<int>.filled(64, 0);
for (int i = 0; i < 32; i++) {
int carry = 0;
for (int j = 0; j < 32; j++) {
int rIndex = i + j;
int ai = a[i];
int bj = b[j];
int mul = ai * bj + tmp[rIndex] + carry;
tmp[rIndex] = mul & 0xFF;
carry = mul >> 8;
}
tmp[i + 32] += carry;
}
int carry = 0;
for (int i = 0; i < 32; i++) {
int sum = tmp[i] + c[i] + carry;
r[i] = sum & 0xFF;
carry = sum >> 8;
}
return r;
}