AFAIK, to verify a message, I need three things - message, signer wallet address and signature which is the signed message. Like when I use MyEtherWallet signing tool.

But in function isValidSignature, there's a hash of bytes32 type.

function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);

How do I actually get the hash and what is the algorithm used (MD5, SHA, etc)? I'm actually using this SignatureChecker library now but can't see to know how I can generate the hash.

1 Answer 1


The hash necessary for the function isValidSignature is the hash of the message and the values that is used for signature.

The Solidity code for signing a message is as follows, the value in the variable digest is the hash used for verification.

bytes32 digest = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32",

The code was taken from the following article, which provides more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.