ERC-3224 Explainable signature data (Described Data)

Stagnant · Signatures & auth · created 2021-01-23

Lets a contract provide a function that directly computes a human-readable description string for a transaction or message to be signed, so wallets can show users what they are signing.

Why it is needed

Ethereum transactions have a complex structure, so aside from a few specially handled cases like ERC20 transfers, wallets end up asking users to sign raw binary data whose meaning they cannot know. An even bigger problem is data whose values are hidden (blinded) behind a hash, like ENS's commit(bytes32). In that case the original information, such as a name or address, is not present anywhere in the final encoded data, so no description can be constructed from the data alone. This proposal does not solve the problem of a malicious contract displaying a false description, but it standardizes a way for contracts that want to provide descriptions in good faith to convey a meaningful phrase to the wallet.

What to implement

In depth

Simultaneous generation of the description string and signed data

Runs the contract's eipXXXDescribe(bytes describer_inputs) function in a static (view) context to compute description_string and described_data together. Side effects such as logX or sstore, even via indirect calls, may be ignored. During execution, ADDRESS(to), CALLER(from), VALUE, and GASPRICE must match the actual values of the transaction to be signed, and VALUE is always 0 when signing a message. BLOCKHASH, NUMBER, TIMESTAMP, and DIFFICULTY should be matched to the 'latest' block on a best-effort basis, and COINBASE is set to the zero address. If the method reverts, the signing procedure must abort.

Newly added JSON-RPC methods

Clients that manage private keys must provide the three methods eth_signDescribedMessage(address, describer, describerInput), eth_sendDescribedTransaction, and eth_signDescribedTransaction. Message signing computes the data by passing describerInput through an eipXXXDescription(bytes) ABI-encoded call (with VALUE at 0), while a transaction is computed the same way from to, value, nonce, gas, gasPrice, and describerInput. For account operations with no user interface, the description string is ignored and the described data is used as is.

Combining described message signing with EIP-191

If the wallet has a UI, it shows the description string to the user and may optionally offer a way to inspect the described data directly. Once approved, the described data is signed per EIP-191, with the version byte set to 0x00 and the version-specific data set to the describer address. In other words the signing preimage takes the form 0x19 0x00 DESCRIBER_ADDRESS DESCRIBED_DATA, and the return value includes description, data, and signature.

Sending and signing described transactions

Both eth_sendDescribedTransaction and eth_signDescribedTransaction call the describer at the to address together with describerInput to compute the description string and described data. If there is a UI, it shows the description string along with the fee and value information. On approval, the transaction's data is set to the described data and signed; the send method submits it to the network immediately, while the sign method does not submit it and only returns the signed transaction.

Why the contract address is tied into the data

The contract address is tied into both the transaction (the to field) and the message (EIP-191's version-specific data) to prevent data signed for one contract from being reused on another. For this reason the zero address is reserved and never used.

Why the data is described indirectly rather than interpreted directly

The conventional approach of interpreting encoded data directly cannot produce a description when names and addresses are blinded behind a hash, as with ENS's commit(bytes32), because the needed information is not present in the final data. This proposal instead passes the original information (NAME, ADDRESS, SECRET) directly to the describer so it can produce a description such as "Commit NAME to ADDRESS (with SECRET)" while simultaneously computing the actual hashed data to be signed.

The format of the description string

The description string must begin with a mime type followed by a semicolon (;). This EIP only defines the text/plain type, and notes that future EIPs may define additional types, such as text/markdown for displaying addresses as links or types for handling multiple languages.

A proposal that has not yet been finalized

This ERC is in Stagnant status, and remains incomplete, with the reference implementation and the "distinguishable signed data" security considerations section still left as @TODO. Its content may change or development may not continue.

Things to watch out for

Original ERC · ← ERCs