Hello guys
I am using openzeppelin ECDSA library for signature verification but it is returning the signer address,
it is returning false signer. it breaking on require ( verifyOwnerSignature() ,Invalid Signature)
have a look on code below why its not getting the actual signer address.
this is my JS code is :
var Web3 = require('web3');
const EthCrypto = require("eth-crypto");
var web3 = new Web3();
const message = EthCrypto.hash.keccak256([
{type: "string",value: "Hello"}
]);
console.log(message);
const signature=EthCrypto.sign('43ry4gt4ubfuggbf', message); // first argument is private key
console.log("Signature is:", signature);
Solidity code
// i am passing Hello as a string and _signature produced by above EthCrypto.sign
function newMint(string calldata _message, bytes calldata _signature) external view returns(string memory){
require (verifyOwnerSignature(keccak256(abi.encode(_message)), _signature), "Invalid Signature");
return "no error";
}
function verifyOwnerSignature (bytes32 hash, bytes memory signature) private view returns(bool) {
return hash.toEthSignedMessageHash().recover(signature) == owner();
}