[Ethereum] Should signed text messages use the “\x19Ethereum Signed Message” prefix

signature

Background: I want to implement sign message feature in Trezor.

Is there a standard for signing text messages?

So far I found out that etherscan.io signs messages without the prefix, i.e. it signs keccak(msg), but also accepts signatures "with Geth prefix" of keccak("\x19Ethereum Signed Message\n32"+keccak(msg)). Signed messages of the form keccak("\x19Ethereum Signed Message\n"+strlen(msg)+msg) are not accepted.

MyEtherWallet only accepts messages signed without any prefix.

Without the prefix one can misuse the sign message feature to sign a transaction, though. Is this intentional?

Best Answer

There's no official standard (at the time of this writing) and has been debated for a while in this EIP thread EIP #683

According to issue #3731:

Geth prepends the string \x19Ethereum Signed Message:\n<length of message> to all data before signing it (https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign). If you want to verify such a signature from Solidity, you'll have to prepend the same string in solidity before doing the ecrecovery.

Related