EIP-191, signed data.

November 29, 2024

Background

Already I written a post about EIP-712 on my blog. If you read that post, you can find signTyped data having prefix, \x19. That is relevant with EIP-191, I am writting now.

Why?

In the EIP document, The reason that propose EIP-191 is to improve security in Multi Signature Wallet. Without standard, RLP Transaction can be used as a presigned data. It should need to distinguish RLP transaction and signed data. And there are many chance for attacker to reuse presigned data. So the data requires specefic address for validator.

How to

In proposal, there is a format for signed_data.

0x19 <1 byte version> <version specefic data> <data to sign>

In function, personal_sign, the following is prepended before hashed data.

\x19Ethereum Signed Message:\n" + len(message)

You can see 0x19 almost same as \x19 above. It means that this data is not valid RLP. But you can be wondering why should use prefix 0x19. You can figure out in following image.

the prefix bytes, 0x19

Brefiely, It just the bytes length in the following strings, Ethereum Signed Message:\n

Version Bytes

  • 0x00: This has intended validator field in data
  • 0x01: EIP-712
  • 0x45: Arbitrary data to sign

For EIP-712, you just get the signed data with 0x19 and 0x01. And other things to format signTyped data is noticed in EIP-712. Without EIP-712, you also can use just signed data with 0x45, but it has risks.

EIP-191, signed data.