scMulAdd static method
Implementation
static void scMulAdd(List<int> s, List<int> a, List<int> b, List<int> c) {
s.asMin32("scMulAdd");
a.asMin32("scMulAdd");
b.asMin32("scMulAdd");
c.asMin32("scMulAdd");
BigInt a0 = _b2097151 & _load3(a, 0);
BigInt a1 = _b2097151 & (_load4(a, 2) >> 5);
BigInt a2 = _b2097151 & (_load3(a, 5) >> 2);
BigInt a3 = _b2097151 & (_load4(a, 7) >> 7);
BigInt a4 = _b2097151 & (_load4(a, 10) >> 4);
BigInt a5 = _b2097151 & (_load3(a, 13) >> 1);
BigInt a6 = _b2097151 & (_load4(a, 15) >> 6);
BigInt a7 = _b2097151 & (_load3(a, 18) >> 3);
BigInt a8 = _b2097151 & _load3(a, 21);
BigInt a9 = _b2097151 & (_load4(a, 23) >> 5);
BigInt a10 = _b2097151 & (_load3(a, 26) >> 2);
BigInt a11 = (_load4(a, 28) >> 7);
BigInt b0 = _b2097151 & _load3(b, 0);
BigInt b1 = _b2097151 & (_load4(b, 2) >> 5);
BigInt b2 = _b2097151 & (_load3(b, 5) >> 2);
BigInt b3 = _b2097151 & (_load4(b, 7) >> 7);
BigInt b4 = _b2097151 & (_load4(b, 10) >> 4);
BigInt b5 = _b2097151 & (_load3(b, 13) >> 1);
BigInt b6 = _b2097151 & (_load4(b, 15) >> 6);
BigInt b7 = _b2097151 & (_load3(b, 18) >> 3);
BigInt b8 = _b2097151 & _load3(b, 21);
BigInt b9 = _b2097151 & (_load4(b, 23) >> 5);
BigInt b10 = _b2097151 & (_load3(b, 26) >> 2);
BigInt b11 = (_load4(b, 28) >> 7);
BigInt c0 = _b2097151 & _load3(c, 0);
BigInt c1 = _b2097151 & (_load4(c, 2) >> 5);
BigInt c2 = _b2097151 & (_load3(c, 5) >> 2);
BigInt c3 = _b2097151 & (_load4(c, 7) >> 7);
BigInt c4 = _b2097151 & (_load4(c, 10) >> 4);
BigInt c5 = _b2097151 & (_load3(c, 13) >> 1);
BigInt c6 = _b2097151 & (_load4(c, 15) >> 6);
BigInt c7 = _b2097151 & (_load3(c, 18) >> 3);
BigInt c8 = _b2097151 & _load3(c, 21);
BigInt c9 = _b2097151 & (_load4(c, 23) >> 5);
BigInt c10 = _b2097151 & (_load3(c, 26) >> 2);
BigInt c11 = (_load4(c, 28) >> 7);
BigInt s0;
BigInt s1;
BigInt s2;
BigInt s3;
BigInt s4;
BigInt s5;
BigInt s6;
BigInt s7;
BigInt s8;
BigInt s9;
BigInt s10;
BigInt s11;
BigInt s12;
BigInt s13;
BigInt s14;
BigInt s15;
BigInt s16;
BigInt s17;
BigInt s18;
BigInt s19;
BigInt s20;
BigInt s21;
BigInt s22;
BigInt s23;
BigInt carry0;
BigInt carry1;
BigInt carry2;
BigInt carry3;
BigInt carry4;
BigInt carry5;
BigInt carry6;
BigInt carry7;
BigInt carry8;
BigInt carry9;
BigInt carry10;
BigInt carry11;
BigInt carry12;
BigInt carry13;
BigInt carry14;
BigInt carry15;
BigInt carry16;
BigInt carry17;
BigInt carry18;
BigInt carry19;
BigInt carry20;
BigInt carry21;
BigInt carry22;
s0 = c0 + a0 * b0;
s1 = c1 + (a0 * b1 + a1 * b0);
s2 = c2 + (a0 * b2 + a1 * b1 + a2 * b0);
s3 = c3 + (a0 * b3 + a1 * b2 + a2 * b1 + a3 * b0);
s4 = c4 + (a0 * b4 + a1 * b3 + a2 * b2 + a3 * b1 + a4 * b0);
s5 = c5 + (a0 * b5 + a1 * b4 + a2 * b3 + a3 * b2 + a4 * b1 + a5 * b0);
s6 = c6 +
(a0 * b6 + a1 * b5 + a2 * b4 + a3 * b3 + a4 * b2 + a5 * b1 + a6 * b0);
s7 = c7 +
(a0 * b7 +
a1 * b6 +
a2 * b5 +
a3 * b4 +
a4 * b3 +
a5 * b2 +
a6 * b1 +
a7 * b0);
s8 = c8 +
(a0 * b8 +
a1 * b7 +
a2 * b6 +
a3 * b5 +
a4 * b4 +
a5 * b3 +
a6 * b2 +
a7 * b1 +
a8 * b0);
s9 = c9 +
(a0 * b9 +
a1 * b8 +
a2 * b7 +
a3 * b6 +
a4 * b5 +
a5 * b4 +
a6 * b3 +
a7 * b2 +
a8 * b1 +
a9 * b0);
s10 = c10 +
(a0 * b10 +
a1 * b9 +
a2 * b8 +
a3 * b7 +
a4 * b6 +
a5 * b5 +
a6 * b4 +
a7 * b3 +
a8 * b2 +
a9 * b1 +
a10 * b0);
s11 = c11 +
(a0 * b11 +
a1 * b10 +
a2 * b9 +
a3 * b8 +
a4 * b7 +
a5 * b6 +
a6 * b5 +
a7 * b4 +
a8 * b3 +
a9 * b2 +
a10 * b1 +
a11 * b0);
s12 = (a1 * b11 +
a2 * b10 +
a3 * b9 +
a4 * b8 +
a5 * b7 +
a6 * b6 +
a7 * b5 +
a8 * b4 +
a9 * b3 +
a10 * b2 +
a11 * b1);
s13 = (a2 * b11 +
a3 * b10 +
a4 * b9 +
a5 * b8 +
a6 * b7 +
a7 * b6 +
a8 * b5 +
a9 * b4 +
a10 * b3 +
a11 * b2);
s14 = (a3 * b11 +
a4 * b10 +
a5 * b9 +
a6 * b8 +
a7 * b7 +
a8 * b6 +
a9 * b5 +
a10 * b4 +
a11 * b3);
s15 = (a4 * b11 +
a5 * b10 +
a6 * b9 +
a7 * b8 +
a8 * b7 +
a9 * b6 +
a10 * b5 +
a11 * b4);
s16 = (a5 * b11 +
a6 * b10 +
a7 * b9 +
a8 * b8 +
a9 * b7 +
a10 * b6 +
a11 * b5);
s17 = (a6 * b11 + a7 * b10 + a8 * b9 + a9 * b8 + a10 * b7 + a11 * b6);
s18 = (a7 * b11 + a8 * b10 + a9 * b9 + a10 * b8 + a11 * b7);
s19 = (a8 * b11 + a9 * b10 + a10 * b9 + a11 * b8);
s20 = (a9 * b11 + a10 * b10 + a11 * b9);
s21 = (a10 * b11 + a11 * b10);
s22 = a11 * b11;
s23 = BigInt.zero;
carry0 = (s0 + _bitMaskFor20) >> 21;
s1 += carry0;
s0 -= carry0 << 21;
carry2 = (s2 + _bitMaskFor20) >> 21;
s3 += carry2;
s2 -= carry2 << 21;
carry4 = (s4 + _bitMaskFor20) >> 21;
s5 += carry4;
s4 -= carry4 << 21;
carry6 = (s6 + _bitMaskFor20) >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry8 = (s8 + _bitMaskFor20) >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry10 = (s10 + _bitMaskFor20) >> 21;
s11 += carry10;
s10 -= carry10 << 21;
carry12 = (s12 + _bitMaskFor20) >> 21;
s13 += carry12;
s12 -= carry12 << 21;
carry14 = (s14 + _bitMaskFor20) >> 21;
s15 += carry14;
s14 -= carry14 << 21;
carry16 = (s16 + _bitMaskFor20) >> 21;
s17 += carry16;
s16 -= carry16 << 21;
carry18 = (s18 + _bitMaskFor20) >> 21;
s19 += carry18;
s18 -= carry18 << 21;
carry20 = (s20 + _bitMaskFor20) >> 21;
s21 += carry20;
s20 -= carry20 << 21;
carry22 = (s22 + _bitMaskFor20) >> 21;
s23 += carry22;
s22 -= carry22 << 21;
carry1 = (s1 + _bitMaskFor20) >> 21;
s2 += carry1;
s1 -= carry1 << 21;
carry3 = (s3 + _bitMaskFor20) >> 21;
s4 += carry3;
s3 -= carry3 << 21;
carry5 = (s5 + _bitMaskFor20) >> 21;
s6 += carry5;
s5 -= carry5 << 21;
carry7 = (s7 + _bitMaskFor20) >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry9 = (s9 + _bitMaskFor20) >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry11 = (s11 + _bitMaskFor20) >> 21;
s12 += carry11;
s11 -= carry11 << 21;
carry13 = (s13 + _bitMaskFor20) >> 21;
s14 += carry13;
s13 -= carry13 << 21;
carry15 = (s15 + _bitMaskFor20) >> 21;
s16 += carry15;
s15 -= carry15 << 21;
carry17 = (s17 + _bitMaskFor20) >> 21;
s18 += carry17;
s17 -= carry17 << 21;
carry19 = (s19 + _bitMaskFor20) >> 21;
s20 += carry19;
s19 -= carry19 << 21;
carry21 = (s21 + _bitMaskFor20) >> 21;
s22 += carry21;
s21 -= carry21 << 21;
s11 += s23 * 666643.toBig;
s12 += s23 * 470296.toBig;
s13 += s23 * 654183.toBig;
s14 -= s23 * 997805.toBig;
s15 += s23 * 136657.toBig;
s16 -= s23 * 683901.toBig;
s10 += s22 * 666643.toBig;
s11 += s22 * 470296.toBig;
s12 += s22 * 654183.toBig;
s13 -= s22 * 997805.toBig;
s14 += s22 * 136657.toBig;
s15 -= s22 * 683901.toBig;
s9 += s21 * 666643.toBig;
s10 += s21 * 470296.toBig;
s11 += s21 * 654183.toBig;
s12 -= s21 * 997805.toBig;
s13 += s21 * 136657.toBig;
s14 -= s21 * 683901.toBig;
s8 += s20 * 666643.toBig;
s9 += s20 * 470296.toBig;
s10 += s20 * 654183.toBig;
s11 -= s20 * 997805.toBig;
s12 += s20 * 136657.toBig;
s13 -= s20 * 683901.toBig;
s7 += s19 * 666643.toBig;
s8 += s19 * 470296.toBig;
s9 += s19 * 654183.toBig;
s10 -= s19 * 997805.toBig;
s11 += s19 * 136657.toBig;
s12 -= s19 * 683901.toBig;
s6 += s18 * 666643.toBig;
s7 += s18 * 470296.toBig;
s8 += s18 * 654183.toBig;
s9 -= s18 * 997805.toBig;
s10 += s18 * 136657.toBig;
s11 -= s18 * 683901.toBig;
carry6 = (s6 + _bitMaskFor20) >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry8 = (s8 + _bitMaskFor20) >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry10 = (s10 + _bitMaskFor20) >> 21;
s11 += carry10;
s10 -= carry10 << 21;
carry12 = (s12 + _bitMaskFor20) >> 21;
s13 += carry12;
s12 -= carry12 << 21;
carry14 = (s14 + _bitMaskFor20) >> 21;
s15 += carry14;
s14 -= carry14 << 21;
carry16 = (s16 + _bitMaskFor20) >> 21;
s17 += carry16;
s16 -= carry16 << 21;
carry7 = (s7 + _bitMaskFor20) >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry9 = (s9 + _bitMaskFor20) >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry11 = (s11 + _bitMaskFor20) >> 21;
s12 += carry11;
s11 -= carry11 << 21;
carry13 = (s13 + _bitMaskFor20) >> 21;
s14 += carry13;
s13 -= carry13 << 21;
carry15 = (s15 + _bitMaskFor20) >> 21;
s16 += carry15;
s15 -= carry15 << 21;
s5 += s17 * 666643.toBig;
s6 += s17 * 470296.toBig;
s7 += s17 * 654183.toBig;
s8 -= s17 * 997805.toBig;
s9 += s17 * 136657.toBig;
s10 -= s17 * 683901.toBig;
s4 += s16 * 666643.toBig;
s5 += s16 * 470296.toBig;
s6 += s16 * 654183.toBig;
s7 -= s16 * 997805.toBig;
s8 += s16 * 136657.toBig;
s9 -= s16 * 683901.toBig;
s3 += s15 * 666643.toBig;
s4 += s15 * 470296.toBig;
s5 += s15 * 654183.toBig;
s6 -= s15 * 997805.toBig;
s7 += s15 * 136657.toBig;
s8 -= s15 * 683901.toBig;
s2 += s14 * 666643.toBig;
s3 += s14 * 470296.toBig;
s4 += s14 * 654183.toBig;
s5 -= s14 * 997805.toBig;
s6 += s14 * 136657.toBig;
s7 -= s14 * 683901.toBig;
s1 += s13 * 666643.toBig;
s2 += s13 * 470296.toBig;
s3 += s13 * 654183.toBig;
s4 -= s13 * 997805.toBig;
s5 += s13 * 136657.toBig;
s6 -= s13 * 683901.toBig;
s0 += s12 * 666643.toBig;
s1 += s12 * 470296.toBig;
s2 += s12 * 654183.toBig;
s3 -= s12 * 997805.toBig;
s4 += s12 * 136657.toBig;
s5 -= s12 * 683901.toBig;
s12 = BigInt.zero;
carry0 = (s0 + _bitMaskFor20) >> 21;
s1 += carry0;
s0 -= carry0 << 21;
carry2 = (s2 + _bitMaskFor20) >> 21;
s3 += carry2;
s2 -= carry2 << 21;
carry4 = (s4 + _bitMaskFor20) >> 21;
s5 += carry4;
s4 -= carry4 << 21;
carry6 = (s6 + _bitMaskFor20) >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry8 = (s8 + _bitMaskFor20) >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry10 = (s10 + _bitMaskFor20) >> 21;
s11 += carry10;
s10 -= carry10 << 21;
carry1 = (s1 + _bitMaskFor20) >> 21;
s2 += carry1;
s1 -= carry1 << 21;
carry3 = (s3 + _bitMaskFor20) >> 21;
s4 += carry3;
s3 -= carry3 << 21;
carry5 = (s5 + _bitMaskFor20) >> 21;
s6 += carry5;
s5 -= carry5 << 21;
carry7 = (s7 + _bitMaskFor20) >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry9 = (s9 + _bitMaskFor20) >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry11 = (s11 + _bitMaskFor20) >> 21;
s12 += carry11;
s11 -= carry11 << 21;
s0 += s12 * 666643.toBig;
s1 += s12 * 470296.toBig;
s2 += s12 * 654183.toBig;
s3 -= s12 * 997805.toBig;
s4 += s12 * 136657.toBig;
s5 -= s12 * 683901.toBig;
s12 = 0.toBig;
carry0 = s0 >> 21;
s1 += carry0;
s0 -= carry0 << 21;
carry1 = s1 >> 21;
s2 += carry1;
s1 -= carry1 << 21;
carry2 = s2 >> 21;
s3 += carry2;
s2 -= carry2 << 21;
carry3 = s3 >> 21;
s4 += carry3;
s3 -= carry3 << 21;
carry4 = s4 >> 21;
s5 += carry4;
s4 -= carry4 << 21;
carry5 = s5 >> 21;
s6 += carry5;
s5 -= carry5 << 21;
carry6 = s6 >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry7 = s7 >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry8 = s8 >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry9 = s9 >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry10 = s10 >> 21;
s11 += carry10;
s10 -= carry10 << 21;
carry11 = s11 >> 21;
s12 += carry11;
s11 -= carry11 << 21;
s0 += s12 * 666643.toBig;
s1 += s12 * 470296.toBig;
s2 += s12 * 654183.toBig;
s3 -= s12 * 997805.toBig;
s4 += s12 * 136657.toBig;
s5 -= s12 * 683901.toBig;
carry0 = s0 >> 21;
s1 += carry0;
s0 -= carry0 << 21;
carry1 = s1 >> 21;
s2 += carry1;
s1 -= carry1 << 21;
carry2 = s2 >> 21;
s3 += carry2;
s2 -= carry2 << 21;
carry3 = s3 >> 21;
s4 += carry3;
s3 -= carry3 << 21;
carry4 = s4 >> 21;
s5 += carry4;
s4 -= carry4 << 21;
carry5 = s5 >> 21;
s6 += carry5;
s5 -= carry5 << 21;
carry6 = s6 >> 21;
s7 += carry6;
s6 -= carry6 << 21;
carry7 = s7 >> 21;
s8 += carry7;
s7 -= carry7 << 21;
carry8 = s8 >> 21;
s9 += carry8;
s8 -= carry8 << 21;
carry9 = s9 >> 21;
s10 += carry9;
s9 -= carry9 << 21;
carry10 = s10 >> 21;
s11 += carry10;
s10 -= carry10 << 21;
List<BigInt> sBig = List<BigInt>.filled(32, BigInt.zero);
sBig[0] = s0 >> 0;
sBig[1] = s0 >> 8;
sBig[2] = (s0 >> 16) | (s1 << 5);
sBig[3] = s1 >> 3;
sBig[4] = s1 >> 11;
sBig[5] = (s1 >> 19) | (s2 << 2);
sBig[6] = s2 >> 6;
sBig[7] = (s2 >> 14) | (s3 << 7);
sBig[8] = s3 >> 1;
sBig[9] = s3 >> 9;
sBig[10] = (s3 >> 17) | (s4 << 4);
sBig[11] = s4 >> 4;
sBig[12] = s4 >> 12;
sBig[13] = (s4 >> 20) | (s5 << 1);
sBig[14] = s5 >> 7;
sBig[15] = (s5 >> 15) | (s6 << 6);
sBig[16] = s6 >> 2;
sBig[17] = s6 >> 10;
sBig[18] = (s6 >> 18) | (s7 << 3);
sBig[19] = s7 >> 5;
sBig[20] = s7 >> 13;
sBig[21] = s8 >> 0;
sBig[22] = s8 >> 8;
sBig[23] = (s8 >> 16) | (s9 << 5);
sBig[24] = s9 >> 3;
sBig[25] = s9 >> 11;
sBig[26] = (s9 >> 19) | (s10 << 2);
sBig[27] = s10 >> 6;
sBig[28] = (s10 >> 14) | (s11 << 7);
sBig[29] = s11 >> 1;
sBig[30] = s11 >> 9;
sBig[31] = s11 >> 17;
for (int i = 0; i < sBig.length; i++) {
s[i] = sBig[i].toUnsigned8;
}
}