MetaMask/eth-sig-util

`signTypedData` ambiguous input encoding

Gudahtt opened this issue · 0 comments

EIP-712 does not currently specify how the inputs to the eth_signTypedData JSON-PRC method should be encoded. For example, it doesn't say whether to encode boolean values as true and false, or 0, and 1, or as the strings "true" and "false". Different assumptions have been made about how to interpret inputs between eth_signTypedData implementations, leading to incompatible implementations with no clear "correct" answer for how input data should be interpreted.

It seems clear to me that EIP-712 should be amended to include guidance on the expected input encoding. But in the meantime, we should at least be clear about what our expectations are in this library, so that users don't get a different encoding than they expect. We should clearly document our expectations, eliminate any potential ambiguity about how to interpret inputs, and include validation to help users correctly format their inputs wherever possible.

These changes may not be possible with existing signTypedData versions, so these improvements will be made solely on signTypedData_v5 (at least for now).