Skip to content

Alt/5711 2 #5715

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

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog


## 5.3.0 (2025-04-09)

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion contracts/account/Account.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.20;

import {PackedUserOperation, IAccount, IEntryPoint} from "../interfaces/draft-IERC4337.sol";
import {ERC4337Utils} from "./utils/draft-ERC4337Utils.sol";
import {AbstractSigner} from "../utils/cryptography/AbstractSigner.sol";
import {AbstractSigner} from "../utils/cryptography/signers/AbstractSigner.sol";

/**
* @dev A simple ERC4337 account implementation. This base implementation only includes the minimal logic to process
Expand Down
12 changes: 6 additions & 6 deletions contracts/mocks/account/AccountMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import {AccountERC7579Hooked} from "../../account/extensions/AccountERC7579Hooke
import {ERC721Holder} from "../../token/ERC721/utils/ERC721Holder.sol";
import {ERC1155Holder} from "../../token/ERC1155/utils/ERC1155Holder.sol";
import {ERC4337Utils} from "../../account/utils/draft-ERC4337Utils.sol";
import {ERC7739} from "../../utils/cryptography/ERC7739.sol";
import {ERC7739} from "../../utils/cryptography/signers/ERC7739.sol";
import {ERC7821} from "../../account/extensions/ERC7821.sol";
import {MODULE_TYPE_VALIDATOR} from "../../interfaces/draft-IERC7579.sol";
import {PackedUserOperation} from "../../interfaces/draft-IERC4337.sol";
import {AbstractSigner} from "../../utils/cryptography/AbstractSigner.sol";
import {SignerECDSA} from "../../utils/cryptography/SignerECDSA.sol";
import {SignerP256} from "../../utils/cryptography/SignerP256.sol";
import {SignerRSA} from "../../utils/cryptography/SignerRSA.sol";
import {SignerERC7702} from "../../utils/cryptography/SignerERC7702.sol";
import {AbstractSigner} from "../../utils/cryptography/signers/AbstractSigner.sol";
import {SignerECDSA} from "../../utils/cryptography/signers/SignerECDSA.sol";
import {SignerP256} from "../../utils/cryptography/signers/SignerP256.sol";
import {SignerRSA} from "../../utils/cryptography/signers/SignerRSA.sol";
import {SignerERC7702} from "../../utils/cryptography/signers/SignerERC7702.sol";

abstract contract AccountMock is Account, ERC7739, ERC7821, ERC721Holder, ERC1155Holder {
/// Validates a user operation with a boolean signature.
Expand Down
8 changes: 4 additions & 4 deletions contracts/mocks/utils/cryptography/ERC7739Mock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ pragma solidity ^0.8.20;

import {ECDSA} from "../../../utils/cryptography/ECDSA.sol";
import {EIP712} from "../../../utils/cryptography/EIP712.sol";
import {ERC7739} from "../../../utils/cryptography/ERC7739.sol";
import {SignerECDSA} from "../../../utils/cryptography/SignerECDSA.sol";
import {SignerP256} from "../../../utils/cryptography/SignerP256.sol";
import {SignerRSA} from "../../../utils/cryptography/SignerRSA.sol";
import {ERC7739} from "../../../utils/cryptography/signers/ERC7739.sol";
import {SignerECDSA} from "../../../utils/cryptography/signers/SignerECDSA.sol";
import {SignerP256} from "../../../utils/cryptography/signers/SignerP256.sol";
import {SignerRSA} from "../../../utils/cryptography/signers/SignerRSA.sol";

contract ERC7739ECDSAMock is ERC7739, SignerECDSA {
constructor(address signerAddr) EIP712("ERC7739ECDSA", "1") {
Expand Down
46 changes: 0 additions & 46 deletions contracts/utils/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ Miscellaneous contracts and libraries containing utility functions you can use t

* {Math}, {SignedMath}: Implementation of various arithmetic functions.
* {SafeCast}: Checked downcasting functions to avoid silent truncation.
* {ECDSA}, {MessageHashUtils}: Libraries for interacting with ECDSA signatures.
* {P256}: Library for verifying and recovering public keys from secp256r1 signatures.
* {RSA}: Library with RSA PKCS#1 v1.5 signature verification utilities.
* {SignatureChecker}: A library helper to support regular ECDSA from EOAs as well as ERC-1271 signatures for smart contracts.
* {Hashes}: Commonly used hash functions.
* {MerkleProof}: Functions for verifying https://en.wikipedia.org/wiki/Merkle_tree[Merkle Tree] proofs.
* {EIP712}: Contract with functions to allow processing signed typed structure data according to https://eips.ethereum.org/EIPS/eip-712[EIP-712].
* {ReentrancyGuard}: A modifier that can prevent reentrancy during certain functions.
* {ReentrancyGuardTransient}: Variant of {ReentrancyGuard} that uses transient storage (https://eips.ethereum.org/EIPS/eip-1153[EIP-1153]).
* {Pausable}: A common emergency response mechanism that can pause functionality while a remediation is pending.
Expand Down Expand Up @@ -47,11 +40,6 @@ Miscellaneous contracts and libraries containing utility functions you can use t
* {CAIP2}, {CAIP10}: Libraries for formatting and parsing CAIP-2 and CAIP-10 identifiers.
* {Blockhash}: A library for accessing historical block hashes beyond the standard 256 block limit utilizing EIP-2935's historical blockhash functionality.
* {Time}: A library that provides helpers for manipulating time-related objects, including a `Delay` type.
* {AbstractSigner}: Abstract contract for internal signature validation in smart contracts.
* {ERC7739}: An abstract contract to validate signatures following the rehashing scheme from `ERC7739Utils`.
* {ERC7739Utils}: Utilities library that implements a defensive rehashing mechanism to prevent replayability of smart contract signatures based on ERC-7739.
* {SignerECDSA}, {SignerP256}, {SignerRSA}: Implementations of an {AbstractSigner} with specific signature validation algorithms.
* {SignerERC7702}: Implementation of {AbstractSigner} that validates signatures using the contract's own address as the signer, useful for delegated accounts following EIP-7702.

[NOTE]
====
Expand All @@ -66,40 +54,6 @@ Because Solidity does not support generic types, {EnumerableMap} and {Enumerable

{{SafeCast}}

== Cryptography

{{ECDSA}}

{{P256}}

{{RSA}}

{{EIP712}}

{{MessageHashUtils}}

{{SignatureChecker}}

{{Hashes}}

{{MerkleProof}}

{{ERC7739}}

{{ERC7739Utils}}

=== Abstract Signers

{{AbstractSigner}}

{{SignerECDSA}}

{{SignerP256}}

{{SignerERC7702}}

{{SignerRSA}}

== Security

{{ReentrancyGuard}}
Expand Down
53 changes: 53 additions & 0 deletions contracts/utils/cryptography/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
= Cryptography

[.readme-notice]
NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/utils/cryptography

A collection of contracts and libraries that implement various signature validation schemes and cryptographic primitives. These utilities enable secure authentication, multisignature operations, and advanced cryptographic operations in smart contracts.

* {ECDSA}, {MessageHashUtils}: Libraries for interacting with ECDSA signatures.
* {P256}: Library for verifying and recovering public keys from secp256r1 signatures.
* {RSA}: Library with RSA PKCS#1 v1.5 signature verification utilities.
* {SignatureChecker}: A library helper to support regular ECDSA from EOAs as well as ERC-1271 signatures for smart contracts.
* {Hashes}: Commonly used hash functions.
* {MerkleProof}: Functions for verifying https://en.wikipedia.org/wiki/Merkle_tree[Merkle Tree] proofs.
* {EIP712}: Contract with functions to allow processing signed typed structure data according to https://eips.ethereum.org/EIPS/eip-712[EIP-712].
* {ERC7739Utils}: Utilities library that implements a defensive rehashing mechanism to prevent replayability of smart contract signatures based on ERC-7739.
* {AbstractSigner}: Abstract contract for internal signature validation in smart contracts.
* {ERC7739}: An abstract contract to validate signatures following the rehashing scheme from {ERC7739Utils}.
* {SignerECDSA}, {SignerP256}, {SignerRSA}: Implementations of an {AbstractSigner} with specific signature validation algorithms.
* {SignerERC7702}: Implementation of {AbstractSigner} that validates signatures using the contract's own address as the signer, useful for delegated accounts following EIP-7702.

== Utils

{{ECDSA}}

{{MessageHashUtils}}

{{P256}}

{{RSA}}

{{SignatureChecker}}

{{Hashes}}

{{MerkleProof}}

{{EIP712}}

{{ERC7739Utils}}

== Abstract Signers

{{AbstractSigner}}

{{ERC7739}}

{{SignerECDSA}}

{{SignerP256}}

{{SignerRSA}}

{{SignerERC7702}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

pragma solidity ^0.8.20;

import {IERC1271} from "../../interfaces/IERC1271.sol";
import {EIP712} from "../cryptography/EIP712.sol";
import {MessageHashUtils} from "../cryptography/MessageHashUtils.sol";
import {ShortStrings} from "../ShortStrings.sol";
import {AbstractSigner} from "./AbstractSigner.sol";
import {ERC7739Utils} from "./ERC7739Utils.sol";
import {EIP712} from "../EIP712.sol";
import {ERC7739Utils} from "../ERC7739Utils.sol";
import {IERC1271} from "../../../interfaces/IERC1271.sol";
import {MessageHashUtils} from "../MessageHashUtils.sol";
import {ShortStrings} from "../../ShortStrings.sol";

/**
* @dev Validates signatures wrapping the message hash in a nested EIP712 type. See {ERC7739Utils}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

pragma solidity ^0.8.20;

import {ECDSA} from "../cryptography/ECDSA.sol";
import {AbstractSigner} from "./AbstractSigner.sol";
import {ECDSA} from "../ECDSA.sol";

/**
* @dev Implementation of {AbstractSigner} using xref:api:utils#ECDSA[ECDSA] signatures.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

pragma solidity ^0.8.20;

import {ECDSA} from "./ECDSA.sol";
import {AbstractSigner} from "./AbstractSigner.sol";
import {ECDSA} from "../ECDSA.sol";

/**
* @dev Implementation of {AbstractSigner} for implementation for an EOA. Useful for ERC-7702 accounts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

pragma solidity ^0.8.20;

import {P256} from "./P256.sol";
import {AbstractSigner} from "./AbstractSigner.sol";
import {P256} from "../P256.sol";

/**
* @dev Implementation of {AbstractSigner} using xref:api:utils#P256[P256] signatures.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

pragma solidity ^0.8.20;

import {RSA} from "./RSA.sol";
import {AbstractSigner} from "./AbstractSigner.sol";
import {RSA} from "../RSA.sol";

/**
* @dev Implementation of {AbstractSigner} using xref:api:utils#RSA[RSA] signatures.
Expand Down
13 changes: 6 additions & 7 deletions scripts/gen-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ const links = files.map(file => {
const doc = file.replace(baseDir, '');
const title = path.parse(file).name;

return {
xref: `* xref:${doc}[${getPageTitle(title)}]`,
title,
};
const level = doc.split('/').length;

return `${'*'.repeat(level)} xref:${doc}[${getPageTitle(title)}]`;
});

// Case-insensitive sort based on titles (so 'token/ERC20' gets sorted as 'erc20')
// Case-insensitive sort based on xref (so 'token/ERC20' gets sorted as 'token/erc20')
const sortedLinks = links.sort(function (a, b) {
return a.title.toLowerCase().localeCompare(b.title.toLowerCase(), undefined, { numeric: true });
return a.toLowerCase().localeCompare(b.toLowerCase(), undefined, { numeric: true });
});

for (const link of sortedLinks) {
console.log(link.xref);
console.log(link);
}
Loading