isValidSignature function
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);
}