verify function

bool verify(
  1. Uint8List msg,
  2. Uint8List sig,
  3. Uint8List publicKey,
  4. String hashMode,
)

Implementation

bool verify(
    Uint8List msg, Uint8List sig, Uint8List publicKey, String hashMode) {
  if (sig.length != crypto_sign_BYTES) {
    throw Exception('bad signature size');
  }
  if (publicKey.length != crypto_sign_PUBLICKEYBYTES) {
    throw Exception('bad public key size');
  }
  var sm = Uint8List(crypto_sign_BYTES + msg.length);
  var m = Uint8List(crypto_sign_BYTES + msg.length);
  for (var i = 0; i < crypto_sign_BYTES; i++) {
    sm[i] = sig[i];
  }
  for (var i = 0; i < msg.length; i++) {
    sm[i + crypto_sign_BYTES] = msg[i];
  }
  return cryptoSignOpen(m, sm, sm.length, publicKey, hashMode) >= 0;
}