I think that I can verify a hash of a message using my signature within a Solidity contract, something like this:
contract ecrecover {
function testRecovery(bytes32 hash, bytes signature) returns (address) {
bytes32 r;
bytes32 s;
uint8 v;
assembly {
r := mload(add(signature, 32))
s := mload(add(signature, 64))
v := and(mload(add(signature, 65)), 255)
}
if (v < 27) v += 27;
address addr = ecrecover(hash, v, r, s);
return addr;
}
I am unclear how to generate the hash or signature given my message and private key. For example, say my message is the string: I am Eric
My account data are:
address: 0x9858EfFD232B4033E47d90003D41EC34EcaEda94
Private Key: 0x1ab42cc412b618bdea3a599e3c9bae199ebf030895b039e9db1e30dafb12b727
How would I generate the hash and signature of my message?