I'm aware of these posts
How do you sign an verify a message in javascript proving you own an Ethereum address?
How does one properly use ecrecover to verify Ethereum signatures?
I'd like to sign a message and then verify it. I use the following command line in the geth terminal.
var msg = web3.sha3('Schoolbus')
var signature = web3.eth.sign(web3.eth.accounts[0], msg)
var r = signature.slice(0, 66)
var s = '0x' + signature.slice(66, 130)
var v = '0x' + signature.slice(130, 132)
v = web3.toDecimal(v)
Then I use the smart contract below, and call:
call_ecover(r, s, v, msg)
But what i get is: 0x0000000000000000000000000000000000000000
pragma solidity ^0.5.0;
contract Call_verify{
function call_ecover(bytes32 r, bytes32 s, uint8 v,
bytes32 hash)external pure returns (address){
bytes memory prefix = "\x19Ethereum Signed
Message:\n32";
bytes32 prefixedHash =
keccak256(abi.encodePacked(prefix,hash));
return ecrecover(prefixedHash, v, r, s);
}
}
Note that I'm using compiler version 0.5.3 on remix.
Question: Why cannot I get the return value of ecrecover() function in my contract? Am I missing anything?