I've just discovered that with b59c839 geth is now pre-appending the string:
*\x19Ethereum Signed Message:\n<length of message>*
before signing the passed message. I've read here that to use ecrecover on Soldity side it must be pre-appended the same string on the contract. Do you have any working example on how to correctly manage this pre-appending on a Solidity contract?
Thank you
----- ----- ----- UPDATE
I'm trying to pre-append the signature locally in geth with something like this:
test = web3.sha3("hello")
eth.sign(eth.accounts[0], test)
hash_preamble = web3.sha3("\x19Ethereum Signed Message:\n" + test.length + test)
Then on the contract side I'm trying to test something as simple as this:
function test(bytes32 r, bytes32 s, uint8 v, bytes32 hash_preamble) constant returns (address) {
address signer = ecrecover(hash_preamble, v, r, s);
return signer;
}
The bytes32
values passed to the contract are in the form of "0x1234" while the uint8
is 27 or 28. The hash passed to the contract is the composed hash with the preamble, length of my message (which is an hash) and my message.
Unfortunately I'm not able to get the same address as the signing one. Can you see some mistakes in my code?