ecVerify static method

bool ecVerify(
  1. ECPublicKey publicKey,
  2. Uint8List signedData,
  3. ECSignature signature, {
  4. String algorithm = 'SHA-1/ECDSA',
})

Verifying the given signedData with the given publicKey and the given signature. Will return true if the given signature matches the signedData.

The default algorithm used is SHA-1/ECDSA. All supported algorihms are :

  • SHA-1/ECDSA
  • SHA-224/ECDSA
  • SHA-256/ECDSA
  • SHA-384/ECDSA
  • SHA-512/ECDSA
  • SHA-1/DET-ECDSA
  • SHA-224/DET-ECDSA
  • SHA-256/DET-ECDSA
  • SHA-384/DET-ECDSA
  • SHA-512/DET-ECDSA

Implementation

static bool ecVerify(
    ECPublicKey publicKey, Uint8List signedData, ECSignature signature,
    {String algorithm = 'SHA-1/ECDSA'}) {
  final verifier = Signer(algorithm) as ECDSASigner;

  verifier.init(false, PublicKeyParameter<ECPublicKey>(publicKey));

  try {
    return verifier.verifySignature(signedData, signature);
  } on ArgumentError {
    return false;
  }
}