Skip to content

Conversation

@jeffsmale90
Copy link
Contributor

EIP-7702 defines a new struct Authorization which represents authority to set a pointer to a contract address at an EOA - effectively making the EOA perform as a smart contract.

This change adds methods to hash and sign authorizations, and to recover signer address.

Although the EIP defines the signed authorization as [chain_id, address, nonce, y_parity, r, s], the utility method returns the signature as a standard r|s|v signature for consistency with other signing methods.

See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7702.md for details

@jeffsmale90 jeffsmale90 force-pushed the feat/sign-authorization branch from 5c46e25 to bb5e268 Compare December 19, 2024 04:13
@jeffsmale90 jeffsmale90 force-pushed the feat/sign-authorization branch from bb5e268 to b50bc64 Compare December 19, 2024 04:14
@jeffsmale90 jeffsmale90 requested a review from a team December 19, 2024 19:41
…shuffled non-exported members to the bottom of the file, and renamed a few test constants to aid readability. Also used it.each for multiple test cases.
@jeffsmale90
Copy link
Contributor Author

jeffsmale90 commented Jan 13, 2025

@matthewwalsh0 thanks for the review! I made all of the changes you recommended, except for validating chainId !== 0, as I think this should be an API concern, rather than a utility concern, and the redundant "should" in the test names 👀

@jeffsmale90 jeffsmale90 merged commit 0f3013b into main Jan 26, 2025
16 checks passed
@jeffsmale90 jeffsmale90 deleted the feat/sign-authorization branch January 26, 2025 22:22
github-merge-queue bot pushed a commit to MetaMask/accounts that referenced this pull request Feb 5, 2025
… Eth keyrings (#182)

EIP-7702 defines a new struct Authorization which represents authority
to set a pointer to a contract address at an EOA - effectively making
the EOA perform as a smart contract.

This change integrates the new `signEIP7702Authorization` added to
eth-sig-util in MetaMask/eth-sig-util#407 to the
eth-simple and eth-hd keyrings.

See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7702.md for
details

---------

Co-authored-by: Daniel Rocha <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants