crypto_sign_open static method

int crypto_sign_open(
  1. Uint8List m,
  2. int dummy,
  3. Uint8List sm,
  4. int smoff,
  5. int n,
  6. Uint8List pk,
)

TBD 64bits of mlen int crypto_sign_open(Uint8Listm,long *mlen,Uint8Listsm,long n,Uint8Listpk)

Implementation

static int crypto_sign_open(Uint8List m, int dummy /* *mlen not used*/,
    Uint8List sm, final int smoff, int /*long*/ n, Uint8List pk) {
  int i;
  Uint8List t = Uint8List(32), h = Uint8List(64);
  List<Int64List> p = List<Int64List>(4);

  p[0] = Int64List(16);
  p[1] = Int64List(16);
  p[2] = Int64List(16);
  p[3] = Int64List(16);

  List<Int64List> q = List<Int64List>(4);
  q[0] = Int64List(16);
  q[1] = Int64List(16);
  q[2] = Int64List(16);
  q[3] = Int64List(16);

  ///*mlen = -1;

  if (n < 64) return -1;

  if (_unpackneg(q, pk) != 0) return -1;

  for (i = 0; i < n; i++) m[i] = sm[i + smoff];

  for (i = 0; i < 32; i++) m[i + 32] = pk[i];

  crypto_hash_off(h, m, 0, n);

  _reduce(h);
  _scalarmult(p, q, h, 0);

  _scalarbase(q, sm, 32 + smoff);
  _add(p, q);
  _pack(t, p);

  n -= 64;
  if (_crypto_verify_32(sm, smoff, t, 0) != 0) {
// optimizing it
    ///for (i = 0; i < n; i ++) m[i] = 0;
    return -1;
  }

// TBD optimizing ...
  ///for (i = 0; i < n; i ++) m[i] = sm[i + 64 + smoff];
  ///*mlen = n;

  return 0;
}