-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Update EIP-7702: add "hash" to tuple, to allow single-signature for first eip-7702 tx initialization. #9032
base: master
Are you sure you want to change the base?
Conversation
Add an optional "hash" field to the auth tuple, to support single signature when submitted through a wrapper protocol (such as ERC-4337's UserOperation)
File
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand this change. How do you observe the hash from within the execution of the transaction?
update encoding of hash for signature validation
During ERC-4337 validation, the account's method is called with the signature function validateUserOp(UserOperation userop, bytes32 userOpHash) {
(bytes32 nonce, bytes32 chainid, bytes32 r, bytes32 s, uint8 v) = abi.decode(userop.signature, (bytes32,bytes32,bytes32,bytes32,uint8));
bytes32 hash = keccak256(eip7702_rlp_encode(nonce, address(this), chainid, userOpHash));
if ( address(this) == ecrecover(hash, v,r,s) ) return 0;
return SIG_FAILED
} This way we achieve the UX goal: a single signature by the end user for this transaction is used to validate both the eip-7702 tuple, and also outer transaction (erc-4337) for gas sponsorhip. |
added initcode use-case for using the hash
The commit 72213fb (as a parent of 8f3465a) contains errors. |
Another use-case for hash: applying initcode to initialize a proxy: _fallback() {
if (_implementation() != address(0) {
_delegate(_implementation());
return;
}
//this is the first call, so calldata contains implementation, target calldata and everything to reuse eip7702 signature)
(address impl, bytes memory data, bytes32 nonce, bytes32 chainid, bytes32 r, bytes32 s, uint8 v) = abi.decode(msg.data,
(address, bytes, bytes32,bytes32,bytes32,bytes32,uint8));
bytes32 datahash = keccak256(abi.encodePacked(impl,data);
bytes32 hash = keccak256(eip7702_rlp_encode(nonce, address(this), chainid, datahash));
require(address(this) == ecrecover(hash, v,r,s) );
_setImplementation(impl);
_deletate(data);
} |
Add an optional "hash" field to the auth tuple, to support single signature when submitted through a wrapper protocol (such as ERC-4337's UserOperation)