-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Add EIP 712 helpers #2418
Add EIP 712 helpers #2418
Conversation
Awesome implementation @frangio! I have two main things I want to discuss:
function digest(dataHash) {
return keccak256(abi.encodePacked("\x19\x01", getDomainSeparator(), dataHash));
} |
SaltI actually designed the API assuming the salt would be different for every signature that gets verified. But now that you mention it I think I was mistaken.
I understand how you reached this conclusion but I find it hard to imagine in what situation this would be used. I looked through the EIP discussions and couldn't find anything. If a contract can receive different types of signed messages they will be different because of the message encoding so a salt isn't necessary. I'm tempted to drop the part about the salt since we don't really understand it and it doesn't seem to be in use. As for exposing DigestYeah, I think this is a good idea, specially because the This one also makes me think we should drop the salt part, so that we can unambiguously use the domain separator without a salt. |
Agree with both! |
I added a |
Curious about this, why don't you like the name? Is it because it lacks specificity? If so, maybe borrowing jargon from https://eips.ethereum.org/EIPS/eip-712#specification we could call it |
+1 to |
Okay, I didn't mean to ignore your suggestions (I almost went with |
Or... maybe it's better to go with |
I've moved the contract to a new |
Looks great @frangio! I think it's good to merge. But there are two things worth looking into after this: 1- Expanding on the usage of this EIP. Though you already briefly covered it in the reference of the 2- Discoverability. Unless you already know that EIP712 is included as a Draft, it's impossible to find it in the docs. I'd suggest adding a mention to it from the |
Actually, from looking at the PR, it seems like it's added in both Drafts and Cryptography, but in the deploy preview it's only listed in Drafts. Not sure what's happening there. |
I left the line in the cryptography readme accidentally. It won't show up in the site because of how solidity-docgen works. (When used in the readme mode, it only makes available in a readme the contracts that are under the same directory.) Placing a link in Cryptography is a great idea though, and having an index page that is a list of all contracts (and maybe even functions) is also a great idea! Adding search might be a similar level of effort though. 😅 |
This adds a contract that implements an efficient calculation of the EIP712 domain separator.
The code I used to measure gas costs is in frangio/domain-separator-gas-report.
The constructor looks ugly but I think it's the price of efficient code!