-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ERC191 v0 signatures #5884
Support ERC191 v0 signatures #5884
Conversation
Hi @NoahZinsmeister, thanks for taking the time to work on this. Apologies of my context is limited, but as I understood it, EIP-191 specifies a general format for handling signed data, and downstream proposals like EIP-712 specify implementations that adhere to this format. For example,
Does EIP-191 actually define a new RPC method that we need to implement, or just a format for handling signed data in a general sense? |
Hi @bitpshr, no problem, happy to help. Thanks for the response! Some context on the PR: You're correct that ERC-712 specifies a particular valid ERC-191 signing format. This specification is actually just the 0x01/v1 version of ERC-191, as you correctly note. My understanding is that In MetaMask, the underlying This PR and the companion PRs adds a third signing version (which is actually ERC-191 0x00/v0, hence the PR title) to the already overloaded I'd be more than happy to get into the implications for smart contracts of each of these three approaches, but for now will just note that:
|
If we do add this fourth message format (not evaluating the merit atm), could we simply number it sequentially ( |
@danfinlay the only reason to keep it as |
Hi @NoahZinsmeister, thanks for the clarification. I see now that EIP-191 specifies a general scheme for signed data to follow, as well as a Regardless, I don't think this method should be implemented as part of the Taking this a bit further, I don't think we should (or can) actively support this signature scheme until a canonical RPC method is either added to EIP-191 or standardized by some other related proposal. For example, what should the method be called across different browsers? What's its signature? How does it handle errors? All such method semantics are defined in other proposals that define new RPC methods like EIP-712, but EIP-191 offers no information. Without a standardized RPC method with known semantics, there's no guarantee if or how other dapp browsers will implement this functionality, making it mostly useless to dapps that want any form of browser portability. I don't think the information in EIP-191 that suggestions a |
Hi @bitpshr thanks for the response. To address some of your concerns:
ERC-712 imposes a non-trivial cost on dApp developers; namely, it requires them to include an unwieldy and error-prone amount of hard-coded strings in their smart contracts. Developers who choose not to do this should not be penalized by clients such as MetaMask for using simpler signature schemes that, along with ERC-712 signatures, have the property of being composed of the hashes of human-readable plaintext data.
That's fair! When it comes to namespaces, there are 3 options:
Personally, I think that option 1 above is robust enough to address these concerns. This is evidenced precisely by the existence of MetaMask's current implementation of And while I agree that it would be great to have a unified and explicit ERC-191 spec (should this be discussed in ERC-191, ERC-712, or another ERC?), the absence of such should not prevent MetaMask from overloading |
Hi @NoahZinsmeister. The only reason MetaMask overloads signing methods right now is for backwards compatibility. This will go away in the future. Of the naming options you listed, the only standards-compliant option is # 2, to come up with a totally unique endpoint for The work in this pull request looks good. I'm not against the implementation, but I do think MetaMask has a responsibility as a major dapp browser to introduce APIs slowly, only when they reach even some form of pseudo-standardization or maturity; otherwise, we run the risk of having major dapps prematurely buy into experimental functionality, a painful issue we're still dealing with today. The only way I could see this landing in MetaMask is behind some obviously-experimental RPC method name so developers know they're using completely proprietary functionality, like
If you think it's important enough, I think it would be great to begin discussion around the need for this RPC method on Ethereum Magicians, either as an addition to EIP-191 or as a new related proposal. If RPC method semantics are discussed, we'd be much more inclined to add this functionality since it's implementable both in MetaMask and other across other browser clients. |
Hey @NoahZinsmeister, thanks for submitting a pull request! As an open source project, we thrive on community contributions, so thank you! While this change may implement some great improvements, our contribution guidelines require that new features first get team buy-in as issues before considering specific pull requests. Since we do not yet have a feature request issue that justifies this particular change, we are closing the pull request for now. Please open an issue, make the case for this change, and reference this pull request in the issue. From there we can discuss whether this is a change that MetaMask would like to incorporate. For changes to our external-facing APIs, we further recommend opening an EIP or at least a post on ethereum-magicians.org, to engage community participation in the development of this proposed standard, before advocating for MetaMask-specific integration. |
This PR adds support for ERC191 v0 signatures via a new
eth_signTypedData_v0
RPC call:An example of what this looks like (pending possible UI improvements):
This PR has two Companion PRs in
eth-sig-util
andeth-json-rpc-middleware
. In this PR, those dependencies were pointed to personal Github packages with the changes applied. This should obviously be changed when those PRs are merged and the updated versions are available on NPM.eth-sig-util
. The temporary package.eth-json-rpc-middleware
. The temporary package.