verify method

  1. @override
bool verify({
  1. required SignatureBase signature,
  2. required Uint8List message,
})
override

Implementation

@override
bool verify({required SignatureBase signature, required Uint8List message}) {
  if (signature.length != TweetNaCl.signatureLength) {
    throw Exception(
        'Signature length (${signature.length}) is invalid, expected "${TweetNaCl.signatureLength}"');
  }
  final newmessage = signature.asTypedList + message;

  if (newmessage.length < TweetNaCl.signatureLength) {
    throw Exception(
        'Signature length (${newmessage.length}) is invalid, expected "${TweetNaCl.signatureLength}"');
  }

  var m = Uint8List(newmessage.length);

  final result = TweetNaCl.crypto_sign_open(m, -1,
      Uint8List.fromList(newmessage), 0, newmessage.length, asTypedList);
  if (result != 0) {
    throw Exception(
        'The message is forged or malformed or the signature is invalid');
  }
  return true;
}