crypto_sign static method
int crypto_sign(Uint8List sm, long * smlen, Uint8List m, long n, Uint8List sk)
Implementation
static int crypto_sign(Uint8List sm, int dummy /* *smlen not used*/,
Uint8List m, final int moff, int /*long*/ n, Uint8List sk) {
Uint8List d = Uint8List(64), h = Uint8List(64), r = Uint8List(64);
int i, j;
Int64List x = Int64List(64);
List<Int64List> p = List<Int64List>(4);
p[0] = Int64List(16);
p[1] = Int64List(16);
p[2] = Int64List(16);
p[3] = Int64List(16);
crypto_hash_off(d, sk, 0, 32);
d[0] &= 248;
d[31] &= 127;
d[31] |= 64;
///*smlen = n+64;
for (i = 0; i < n; i++) sm[64 + i] = m[i + moff];
for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
crypto_hash_off(r, sm, 32, n + 32);
_reduce(r);
_scalarbase(p, r, 0);
_pack(sm, p);
for (i = 0; i < 32; i++) sm[i + 32] = sk[i + 32];
crypto_hash_off(h, sm, 0, n + 64);
_reduce(h);
for (i = 0; i < 64; i++) x[i] = 0;
for (i = 0; i < 32; i++) x[i] = (r[i] & 0xff).toInt();
for (i = 0; i < 32; i++)
for (j = 0; j < 32; j++)
x[i + j] += (h[i] & 0xff) * (d[j] & 0xff).toInt();
_modL(sm, 32, x);
return 0;
}