cryptoScalarmult static method
Implementation
static int cryptoScalarmult(Uint8List q, Uint8List n, Uint8List p) {
Uint8List z = Uint8List(32);
Uint64List x = Uint64List(80);
int r, i;
Uint64List a = Uint64List(16),
b = Uint64List(16),
c = Uint64List(16),
d = Uint64List(16),
e = Uint64List(16),
f = Uint64List(16);
for (i = 0; i < 31; i++) z[i] = n[i];
z[31] = (n[31] & 127) | 64;
z[0] &= 248;
unpack25519(x, p);
for (i = 0; i < 16; i++) {
b[i] = x[i];
d[i] = a[i] = c[i] = 0;
}
a[0] = d[0] = 1;
for (i = 254; i >= 0; --i) {
r = (Int32(z[Int32(i).shiftRightUnsigned(3).toInt()])
.shiftRightUnsigned(i & 7))
.toInt() &
1;
_sel25519(a, b, r);
_sel25519(c, d, r);
_a(e, a, c);
_z(a, a, c);
_a(c, b, d);
_z(b, b, d);
_s(d, e);
_s(f, a);
_m(a, c, a);
_m(c, b, e);
_a(e, a, c);
_z(a, a, c);
_s(b, a);
_z(c, d, f);
_m(a, c, one21665);
_a(a, a, d);
_m(c, c, a);
_m(a, d, f);
_m(d, b, x);
_s(b, e);
_sel25519(a, b, r);
_sel25519(c, d, r);
}
for (i = 0; i < 16; i++) {
x[i + 16] = a[i];
x[i + 32] = c[i];
x[i + 48] = b[i];
x[i + 64] = d[i];
}
_inv25519(x, 32, x, 32);
_mOff(x, 16, x, 16, x, 32);
_pack25519(q, x, 16);
return 0;
}