Skip to content

Conversation

Amxx
Copy link
Collaborator

@Amxx Amxx commented Mar 29, 2025

Includes

  • contracts/interfaces/IERC7913.sol: ERC-7913 interface
  • contracts/utils/cryptography/ERC7913SignatureVerifierP256.sol a stateless verifier for P256 keys. This is unopinionated and production ready, so I don't think it needs to be a mock
  • contracts/utils/cryptography/ERC7913SignatureVerifierRSA.sol a stateless verifier for RSA keys. This is unopinionated and production ready, so I don't think it needs to be a mock
  • contracts/utils/cryptography/ERC7913Utils.sol library for checking signer's signatures using ERC-7913 (with ECDSA/ERC-1271 fallback)
  • contracts/utils/cryptography/SignerERC7913.sol abstract signer that uses an ERC-7913 signer.

@Amxx Amxx requested review from arr00 and ernestognw March 29, 2025 20:15
@Amxx Amxx requested a review from a team as a code owner March 29, 2025 20:15
@Amxx Amxx changed the title Add an ERC-7913 based abstract signer and an ERC-7913 signature verifier for P256 keys ERC-7913: add abstract signer and an ready-to-use signature verifiers Mar 30, 2025
* @dev Helper library to verify key signatures following the ERC-7913 standard, with fallback to ECDSA and ERC-1271
* when the signer's key is empty (as specified in ERC-7913)
*/
library ERC7913Utils {
Copy link
Member

Choose a reason for hiding this comment

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

I think I would prefer having just one implementation of the isValidSignatureNow function. The rationale is that signature always ends up in memory for any valid verification, and a portion of signer will be copied too. So I doubt there's actual benefits in having two versions. I'll simplify for now following #109

Copy link
Collaborator Author

@Amxx Amxx Apr 12, 2025

Choose a reason for hiding this comment

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

The memory version uses a slice, that does a memory copy.

Overall, calldata versions are often cheaper because they don't copy to memory until the very last point (when the Abi call is encoded) contrary to the memory version that copy to memory at least once more (in this case 2 times)

Overall not a big deal. Having a single "memory" version is probably good enough. Just explaining the initial idea

Copy link
Member

@ernestognw ernestognw Apr 12, 2025

Choose a reason for hiding this comment

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

Yeah I saw the memory version is required, so I'd agree with just one "memory" version for now unless there are significant savings measured.

Thanks for answering though, now please you go 👨‍🍼

@ernestognw ernestognw changed the title ERC-7913: add abstract signer and an ready-to-use signature verifiers Add SignerERC7913 and verifiers for P256 and RSA Apr 12, 2025
ernestognw
ernestognw previously approved these changes Apr 12, 2025
@ernestognw ernestognw merged commit 53f590e into master Apr 12, 2025
11 checks passed
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.

2 participants