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,
)

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;
  final t = Uint8List(32), h = Uint8List(64);
  final p = List<Int32List>.generate(4, (_) => Int32List(16));

  final q = List<Int32List>.generate(4, (_) => Int32List(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) {
    ///for (i = 0; i < n; i ++) m[i] = 0;
    return -1;
  }

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

  return 0;
}