0

I have a frontend web application that creates a message and asks the user to sign it via, for example, metamask.

The user signs the message and now I have a signed message hash.

  • Is there a common/correct workflow to check this message signature from a backend service ? (like php/node/python)
  • It is possible to validate the signature by calling a contract that uses ecrecover(hash, v, r, s); , but is this the correct approach ? call from the backend a deployed contract that validates it ?
8
  • the etherjs or web3js libraries has such methods. No calling smart contract to do that is not needed and also wrong because it will cost more time( it is async) and it could fail if the connection to blockchain is not working
    – Majd TL
    Oct 15 '21 at 14:09
  • Thank you @MajdTL I honestly didn't find it in ethers documentation before you pointed it... if you write the answer i'll mark it as solved
    – Stormsson
    Oct 15 '21 at 16:27
  • can u give an example of the raw message, the singed message and the private key and public key of the signer
    – Majd TL
    Oct 15 '21 at 18:09
  • Take also look here docs.ethers.io/v5/api/utils/signing-key/#utils-recoverPublicKey
    – Majd TL
    Oct 15 '21 at 18:11
  • @MajdTL why all those data? I'm using ethereum.stackexchange.com/questions/1777/… as a reference for the frontend part, so I would expect to do something similar in the backend ?
    – Stormsson
    Oct 17 '21 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.