verify method

  1. @override
Future<bool> verify(
  1. List<int> data, {
  2. required Signature signature,
})
override

Verifies the signature.

Implementation

@override
Future<bool> verify(List<int> data, {required Signature signature}) async {
  if (usePlugin) {
    try {
      final publicKey = signature.publicKey;
      if (publicKey is! EcPublicKey) {
        throw ArgumentError.value(
          signature,
          'signature',
        );
      }
      final result = await invokeMethod(
        'Ecdsa.verify',
        {
          'algo': algorithmName,
          'data': Uint8List.fromList(data),
          'signature': Uint8List.fromList(signature.bytes),
          'publicKeyX': Uint8List.fromList(publicKey.x),
          'publicKeyY': Uint8List.fromList(publicKey.y),
        },
      );
      final error = result['error'];
      if (error != null) {
        throw StateError(
            'error in "package:better_cryptography_flutter": $error');
      }
      return result['result'] as bool;
    } catch (error, stackTrace) {
      usePlugin = false;
      reportError(error, stackTrace);
    }
  }
  return super.verify(data, signature: signature);
}