Skip to content
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 ERC7739 and ERC7739Utils #5243

Closed

Conversation

ernestognw
Copy link
Member

@ernestognw ernestognw commented Oct 9, 2024

Follow up from #5242 (must be reviewed first) and smaller version of #5182

This PR includes the following primitives:

  • ERC7739Utils: A wrapped EIP-712 approach based on @frangio's and @Vectorized's work
  • ERC7739Signer: An ERC1271 abstract contract that implements ERC7739Utils

Both of these will be required for the Account contracts

PR Checklist

  • Tests
  • Documentation
  • Changeset entry (run npx changeset add)

Copy link

changeset-bot bot commented Oct 9, 2024

🦋 Changeset detected

Latest commit: 8a33b80

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ernestognw ernestognw added this to the 5.2 milestone Oct 9, 2024
@ernestognw ernestognw requested review from Amxx and arr00 October 9, 2024 05:37
* - Starts with a-z or (
* - Contains any of the following bytes: , )\x00
* NOTE: This is a looser take on the ERC very strict restrictions. This part appears to be under discussion, and
* therefore the restrictions implemented here may change in a future release.
*/
function tryValidateContentsType(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new logic makes more sense IMO but does not match the ERC so we need the ERC to lift the a-z restriction.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SO what do we do, re-add the lowercase restriction?

Copy link
Contributor

@frangio frangio Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I would keep it in sync with the ERC until that gets changed. But I think it needs to be changed before this code is released.

*/
function _isValidSignature(bytes32 hash, bytes calldata signature) internal view virtual returns (bool) {
return
_isValidNestedPersonalSignSignature(hash, signature) || _isValidNestedTypedDataSignature(hash, signature);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me whether this matches the spec: https://ercs.ethereum.org/ERCS/erc-7739#signature-verification-workflow-deduction

If the signature contains the correct data to reconstruct the hash, the isValidSignature function MUST perform the TypedDataSign workflow. Otherwise, the isValidSignature function MUST perform the PersonalSign workflow.

test/helpers/eip712.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@Amxx Amxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, there are obvious issues in the code that were overlooked because of unapropriate testing.

The testing implements the same bad behavior in javascript as we have in solidity. Trying to write a test that does signing on the JS part using the propoer wallet tools, namely ethers this.signer.signTypedData helps surface obvious issues.

Currently, I don't think this is ready!

I'll work on doing proper testing asap, but considering both work constrains (5.1) and personnal ones, I'm dobting this will be ready for monday's audit.

Amxx added 2 commits October 17, 2024 02:14
- If we want to re-enable the P256 and RSA signers, we need proper JS code. does that bring value?
- Need to fix the utils
bytes32 salt,
uint256[] memory extensions
) internal view returns (bytes32) {
(, bytes calldata contentsTypeName) = tryValidateContentsType(contentsType);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok to throw the boolean away, and still compute the hash if the contentsType is invalid ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's documented above that this function doesn't validate it, but I don't know why.

fields,
keccak256(bytes(name)),
keccak256(bytes(version)),
block.chainid,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any use case where this library is used to perform a verification/validate a typedDataNestedStructHash for another chain ?

@Amxx
Copy link
Collaborator

Amxx commented Oct 18, 2024

Code an tests are making good progress, but the underlying ERC is still subject to a lot of discussion.

Consequently, I don't think we should include that in 5.2. I'd rather wait for to see how the ERC discussion evolve and target a release of this code in 5.3

@Amxx Amxx modified the milestones: 5.2, 5.3 Oct 18, 2024
@Amxx Amxx deleted the branch OpenZeppelin:account-abstraction October 23, 2024 07:19
@Amxx Amxx closed this Oct 23, 2024
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