isValidSignature function

bool isValidSignature(
  1. Uint8List messageHash,
  2. MsgSignature signatureData,
  3. Uint8List publicKey
)

Given an arbitrary message hash, an Ethereum message signature encoded in bytes and a public key encoded in bytes, confirms whether that public key was used to sign the message or not.

Implementation

bool isValidSignature(
    Uint8List messageHash, MsgSignature signatureData, Uint8List publicKey) {
  final recoveredPublicKey = ecRecover(messageHash, signatureData);
  return bytesToHex(publicKey) == bytesToHex(recoveredPublicKey);
}