EIP-191
This ERC proposes a specification about how to handle signed data in Ethereum contracts.
Last updated
This ERC proposes a specification about how to handle signed data in Ethereum contracts.
Last updated
EIP-191 is an Ethereum Improvement Proposal that specifies a standard for signed Ethereum messages. It provides a way to structure data that is signed, so it's clear what the signer's intention was and prevents various potential security issues.
Here are some key points about EIP-191:
Why EIP-191: Before EIP-191, Ethereum already had a defacto standard for signing messages which involved prefixing messages with a known string (\x19Ethereum Signed Message:
followed by the message length). However, this was limited in flexibility and didn't cover various use-cases that applications required. EIP-191 aimed to provide a more structured and flexible way to sign different types of data.
Versioning: EIP-191 introduced versioning to the structure of signed data. It allowed for different types of structures, each identified by a version byte.
Structure: The format of a signed message under EIP-191 is:
0x19
is a magic value that ensures the signed data has a length of at least 1 byte, making it impossible to match the structure with Ethereum transactions.
The <version byte>
specifies the type of structure/data being signed.
<version-specific data>
is the data being signed, structured according to the specified version.
Versions:
0x00
: Signs a typed data structure. This is used by the eth_signTypedData
RPC method.
0x01
: Signs a structured data (EIP-712) provided by an application, often a specific dApp.
0x45
: The old \x19Ethereum Signed Message:
prefix, for signing simple messages. This was included for backward compatibility.
Security: By providing a structured way to sign data, EIP-191 helps in preventing potential misuse where a user might be tricked into signing something they didn't intend to. By making it clear what's being signed and for what purpose, it adds an extra layer of clarity and security.
In short, EIP-191 provides a more flexible and safer way to sign different types of data on the Ethereum network, ensuring that the signer's intent is always clear.