signverifynearprotocol

Verify signature in smart contract near_sdk rust


In ethereum, we can sign a message and verify it onchain if the signer is correct. How can we do this in smart contract near_sdk_rs?


Solution

  • Use the environment function env::ecrecover(hash, signature, v, malleability_flag), to get the signer's public key from his signed message hash and signature.

    https://docs.near.org/develop/contracts/environment/#environment-functions