Skip to content

Commit f45e915

Browse files
Amxxernestognw
andauthored
Reorder cryptography folder (#5711)
Co-authored-by: ernestognw <[email protected]>
1 parent 784d4f7 commit f45e915

File tree

12 files changed

+130
-83
lines changed

12 files changed

+130
-83
lines changed

contracts/account/Account.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pragma solidity ^0.8.20;
44

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

99
/**
1010
* @dev A simple ERC4337 account implementation. This base implementation only includes the minimal logic to process

contracts/mocks/account/AccountMock.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import {AccountERC7579Hooked} from "../../account/extensions/AccountERC7579Hooke
88
import {ERC721Holder} from "../../token/ERC721/utils/ERC721Holder.sol";
99
import {ERC1155Holder} from "../../token/ERC1155/utils/ERC1155Holder.sol";
1010
import {ERC4337Utils} from "../../account/utils/draft-ERC4337Utils.sol";
11-
import {ERC7739} from "../../utils/cryptography/ERC7739.sol";
11+
import {ERC7739} from "../../utils/cryptography/signers/ERC7739.sol";
1212
import {ERC7821} from "../../account/extensions/ERC7821.sol";
1313
import {MODULE_TYPE_VALIDATOR} from "../../interfaces/draft-IERC7579.sol";
1414
import {PackedUserOperation} from "../../interfaces/draft-IERC4337.sol";
15-
import {AbstractSigner} from "../../utils/cryptography/AbstractSigner.sol";
16-
import {SignerECDSA} from "../../utils/cryptography/SignerECDSA.sol";
17-
import {SignerP256} from "../../utils/cryptography/SignerP256.sol";
18-
import {SignerRSA} from "../../utils/cryptography/SignerRSA.sol";
19-
import {SignerERC7702} from "../../utils/cryptography/SignerERC7702.sol";
15+
import {AbstractSigner} from "../../utils/cryptography/signers/AbstractSigner.sol";
16+
import {SignerECDSA} from "../../utils/cryptography/signers/SignerECDSA.sol";
17+
import {SignerP256} from "../../utils/cryptography/signers/SignerP256.sol";
18+
import {SignerRSA} from "../../utils/cryptography/signers/SignerRSA.sol";
19+
import {SignerERC7702} from "../../utils/cryptography/signers/SignerERC7702.sol";
2020

2121
abstract contract AccountMock is Account, ERC7739, ERC7821, ERC721Holder, ERC1155Holder {
2222
/// Validates a user operation with a boolean signature.

contracts/mocks/utils/cryptography/ERC7739Mock.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ pragma solidity ^0.8.20;
44

55
import {ECDSA} from "../../../utils/cryptography/ECDSA.sol";
66
import {EIP712} from "../../../utils/cryptography/EIP712.sol";
7-
import {ERC7739} from "../../../utils/cryptography/ERC7739.sol";
8-
import {SignerECDSA} from "../../../utils/cryptography/SignerECDSA.sol";
9-
import {SignerP256} from "../../../utils/cryptography/SignerP256.sol";
10-
import {SignerRSA} from "../../../utils/cryptography/SignerRSA.sol";
7+
import {ERC7739} from "../../../utils/cryptography/signers/ERC7739.sol";
8+
import {SignerECDSA} from "../../../utils/cryptography/signers/SignerECDSA.sol";
9+
import {SignerP256} from "../../../utils/cryptography/signers/SignerP256.sol";
10+
import {SignerRSA} from "../../../utils/cryptography/signers/SignerRSA.sol";
1111

1212
contract ERC7739ECDSAMock is ERC7739, SignerECDSA {
1313
constructor(address signerAddr) EIP712("ERC7739ECDSA", "1") {

contracts/utils/README.adoc

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ Miscellaneous contracts and libraries containing utility functions you can use t
77

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

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

6755
{{SafeCast}}
6856

69-
== Cryptography
70-
71-
{{ECDSA}}
72-
73-
{{P256}}
74-
75-
{{RSA}}
76-
77-
{{EIP712}}
78-
79-
{{MessageHashUtils}}
80-
81-
{{SignatureChecker}}
82-
83-
{{Hashes}}
84-
85-
{{MerkleProof}}
86-
87-
{{ERC7739}}
88-
89-
{{ERC7739Utils}}
90-
91-
=== Abstract Signers
92-
93-
{{AbstractSigner}}
94-
95-
{{SignerECDSA}}
96-
97-
{{SignerP256}}
98-
99-
{{SignerERC7702}}
100-
101-
{{SignerRSA}}
102-
10357
== Security
10458

10559
{{ReentrancyGuard}}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
= Cryptography
2+
3+
[.readme-notice]
4+
NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/utils/cryptography
5+
6+
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.
7+
8+
* {ECDSA}, {MessageHashUtils}: Libraries for interacting with ECDSA signatures.
9+
* {P256}: Library for verifying and recovering public keys from secp256r1 signatures.
10+
* {RSA}: Library with RSA PKCS#1 v1.5 signature verification utilities.
11+
* {SignatureChecker}: A library helper to support regular ECDSA from EOAs as well as ERC-1271 signatures for smart contracts.
12+
* {Hashes}: Commonly used hash functions.
13+
* {MerkleProof}: Functions for verifying https://en.wikipedia.org/wiki/Merkle_tree[Merkle Tree] proofs.
14+
* {EIP712}: Contract with functions to allow processing signed typed structure data according to https://eips.ethereum.org/EIPS/eip-712[EIP-712].
15+
* {ERC7739Utils}: Utilities library that implements a defensive rehashing mechanism to prevent replayability of smart contract signatures based on ERC-7739.
16+
* {AbstractSigner}: Abstract contract for internal signature validation in smart contracts.
17+
* {ERC7739}: An abstract contract to validate signatures following the rehashing scheme from {ERC7739Utils}.
18+
* {SignerECDSA}, {SignerP256}, {SignerRSA}: Implementations of an {AbstractSigner} with specific signature validation algorithms.
19+
* {SignerERC7702}: Implementation of {AbstractSigner} that validates signatures using the contract's own address as the signer, useful for delegated accounts following EIP-7702.
20+
21+
== Utils
22+
23+
{{ECDSA}}
24+
25+
{{MessageHashUtils}}
26+
27+
{{P256}}
28+
29+
{{RSA}}
30+
31+
{{SignatureChecker}}
32+
33+
{{Hashes}}
34+
35+
{{MerkleProof}}
36+
37+
{{EIP712}}
38+
39+
{{ERC7739Utils}}
40+
41+
== Abstract Signers
42+
43+
{{AbstractSigner}}
44+
45+
{{ERC7739}}
46+
47+
{{SignerECDSA}}
48+
49+
{{SignerP256}}
50+
51+
{{SignerRSA}}
52+
53+
{{SignerERC7702}}

contracts/utils/cryptography/ERC7739.sol renamed to contracts/utils/cryptography/signers/ERC7739.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
pragma solidity ^0.8.20;
44

5-
import {IERC1271} from "../../interfaces/IERC1271.sol";
6-
import {EIP712} from "../cryptography/EIP712.sol";
7-
import {MessageHashUtils} from "../cryptography/MessageHashUtils.sol";
8-
import {ShortStrings} from "../ShortStrings.sol";
95
import {AbstractSigner} from "./AbstractSigner.sol";
10-
import {ERC7739Utils} from "./ERC7739Utils.sol";
6+
import {EIP712} from "../EIP712.sol";
7+
import {ERC7739Utils} from "../ERC7739Utils.sol";
8+
import {IERC1271} from "../../../interfaces/IERC1271.sol";
9+
import {MessageHashUtils} from "../MessageHashUtils.sol";
10+
import {ShortStrings} from "../../ShortStrings.sol";
1111

1212
/**
1313
* @dev Validates signatures wrapping the message hash in a nested EIP712 type. See {ERC7739Utils}.

contracts/utils/cryptography/SignerECDSA.sol renamed to contracts/utils/cryptography/signers/SignerECDSA.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
pragma solidity ^0.8.20;
44

5-
import {ECDSA} from "../cryptography/ECDSA.sol";
65
import {AbstractSigner} from "./AbstractSigner.sol";
6+
import {ECDSA} from "../ECDSA.sol";
77

88
/**
99
* @dev Implementation of {AbstractSigner} using xref:api:utils#ECDSA[ECDSA] signatures.

contracts/utils/cryptography/SignerERC7702.sol renamed to contracts/utils/cryptography/signers/SignerERC7702.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
pragma solidity ^0.8.20;
44

5-
import {ECDSA} from "./ECDSA.sol";
65
import {AbstractSigner} from "./AbstractSigner.sol";
6+
import {ECDSA} from "../ECDSA.sol";
77

88
/**
99
* @dev Implementation of {AbstractSigner} for implementation for an EOA. Useful for ERC-7702 accounts.

contracts/utils/cryptography/SignerP256.sol renamed to contracts/utils/cryptography/signers/SignerP256.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
pragma solidity ^0.8.20;
44

5-
import {P256} from "./P256.sol";
65
import {AbstractSigner} from "./AbstractSigner.sol";
6+
import {P256} from "../P256.sol";
77

88
/**
99
* @dev Implementation of {AbstractSigner} using xref:api:utils#P256[P256] signatures.

0 commit comments

Comments
 (0)