Skip to content

Commit

Permalink
Rename ERC7739Signer to ERC7739
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Jan 13, 2025
1 parent 32e3c49 commit e30bd56
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 43 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 13-01-2025

- Rename `ERC7739Signer` into `ERC7739` to avoid confusion with the `AbstractSigner` family of contracts.

## 23-12-2024

- `AccountERC7821`: Account implementation that implements ERC-7821 for minimal batch execution interface. No support for additional `opData` is included.
Expand Down
8 changes: 4 additions & 4 deletions 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 {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import {ERC1155Holder} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import {ERC7739Signer} from "../utils/cryptography/ERC7739Signer.sol";
import {ERC7739} from "../utils/cryptography/ERC7739.sol";
import {AccountCore} from "./AccountCore.sol";
import {AccountERC7821} from "./extensions/AccountERC7821.sol";

Expand All @@ -13,9 +13,9 @@ import {AccountERC7821} from "./extensions/AccountERC7821.sol";
*
* * {AccountERC7821} for performing external calls in batches.
* * {ERC721Holder} and {ERC1155Holder} to accept ERC-712 and ERC-1155 token transfers transfers.
* * {ERC7739Signer} for ERC-1271 signature support with ERC-7739 replay protection
* * {ERC7739} for ERC-1271 signature support with ERC-7739 replay protection
*
* NOTE: To use this contract, the {ERC7739Signer-_rawSignatureValidation} function must be
* NOTE: To use this contract, the {ERC7739-_rawSignatureValidation} function must be
* implemented using a specific signature verification algorithm. See {SignerECDSA}, {SignerP256} or {SignerRSA}.
*/
abstract contract Account is AccountCore, AccountERC7821, ERC721Holder, ERC1155Holder, ERC7739Signer {}
abstract contract Account is AccountCore, AccountERC7821, ERC721Holder, ERC1155Holder, ERC7739 {}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// contracts/ERC7739SignerECDSA.sol
// contracts/ERC7739ECDSA.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";

import {ERC7739Signer} from "../../../../utils/cryptography/ERC7739Signer.sol";
import {ERC7739} from "../../../../utils/cryptography/ERC7739.sol";

contract ERC7739SignerECDSA is ERC7739Signer {
contract ERC7739ECDSA is ERC7739 {
address private immutable _signer;

constructor(address signerAddr) EIP712("ERC7739SignerECDSA", "1") {
constructor(address signerAddr) EIP712("ERC7739ECDSA", "1") {
_signer = signerAddr;
}

Expand Down
6 changes: 3 additions & 3 deletions contracts/mocks/utils/cryptography/ERC7739SignerECDSAMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ pragma solidity ^0.8.20;

import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {ERC7739Signer} from "../../../utils/cryptography/ERC7739Signer.sol";
import {ERC7739} from "../../../utils/cryptography/ERC7739.sol";
import {SignerECDSA} from "../../../utils/cryptography/SignerECDSA.sol";

contract ERC7739SignerECDSAMock is ERC7739Signer, SignerECDSA {
constructor(address signerAddr) EIP712("ERC7739SignerECDSA", "1") {
contract ERC7739ECDSAMock is ERC7739, SignerECDSA {
constructor(address signerAddr) EIP712("ERC7739ECDSA", "1") {
_initializeSigner(signerAddr);
}
}
6 changes: 3 additions & 3 deletions contracts/mocks/utils/cryptography/ERC7739SignerP256Mock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
pragma solidity ^0.8.20;

import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {ERC7739Signer} from "../../../utils/cryptography/ERC7739Signer.sol";
import {ERC7739} from "../../../utils/cryptography/ERC7739.sol";
import {SignerP256} from "../../../utils/cryptography/SignerP256.sol";

contract ERC7739SignerP256Mock is ERC7739Signer, SignerP256 {
constructor(bytes32 qx, bytes32 qy) EIP712("ERC7739SignerP256", "1") {
contract ERC7739P256Mock is ERC7739, SignerP256 {
constructor(bytes32 qx, bytes32 qy) EIP712("ERC7739P256", "1") {
_initializeSigner(qx, qy);
}
}
6 changes: 3 additions & 3 deletions contracts/mocks/utils/cryptography/ERC7739SignerRSAMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
pragma solidity ^0.8.20;

import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {ERC7739Signer} from "../../../utils/cryptography/ERC7739Signer.sol";
import {ERC7739} from "../../../utils/cryptography/ERC7739.sol";
import {SignerRSA} from "../../../utils/cryptography/SignerRSA.sol";

contract ERC7739SignerRSAMock is ERC7739Signer, SignerRSA {
constructor(bytes memory e, bytes memory n) EIP712("ERC7739SignerRSA", "1") {
contract ERC7739RSAMock is ERC7739, SignerRSA {
constructor(bytes memory e, bytes memory n) EIP712("ERC7739RSA", "1") {
_initializeSigner(e, n);
}
}
4 changes: 2 additions & 2 deletions contracts/utils/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ NOTE: This document is better viewed at https://docs.openzeppelin.com/community-
Miscellaneous contracts and libraries containing utility functions you can use to improve security, work with new data types, or safely use low-level primitives.

* {AbstractSigner}: Abstract contract for internal signature validation in smart contracts.
* {ERC7739Signer}: An abstract contract to validate signatures following the rehashing scheme from `ERC7739Utils`.
* {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.
* {Masks}: Library to handle `bytes32` masks.
Expand All @@ -15,7 +15,7 @@ Miscellaneous contracts and libraries containing utility functions you can use t

{{AbstractSigner}}

{{ERC7739Signer}}
{{ERC7739}}

{{ERC7739Utils}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {ERC7739Utils} from "./ERC7739Utils.sol";
* may limit the ability of the signer to be used within the ERC-4337 validation phase (due to
* https://eips.ethereum.org/EIPS/eip-7562#storage-rules[ERC-7562 storage access rules]).
*/
abstract contract ERC7739Signer is AbstractSigner, EIP712, IERC1271 {
abstract contract ERC7739 is AbstractSigner, EIP712, IERC1271 {
using ERC7739Utils for *;
using MessageHashUtils for bytes32;

Expand Down
6 changes: 3 additions & 3 deletions test/account/AccountECDSA.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
shouldBehaveLikeAccountERC7821,
shouldBehaveLikeAccountHolder,
} = require('./Account.behavior');
const { shouldBehaveLikeERC7739Signer } = require('../utils/cryptography/ERC7739Signer.behavior');
const { shouldBehaveLikeERC7739 } = require('../utils/cryptography/ERC7739.behavior');

async function fixture() {
// EOAs and environment
Expand Down Expand Up @@ -48,12 +48,12 @@ describe('AccountECDSA', function () {
shouldBehaveLikeAccountERC7821();
shouldBehaveLikeAccountHolder();

describe('ERC7739Signer', function () {
describe('ERC7739', function () {
beforeEach(async function () {
this.mock = await this.mock.deploy();
this.signTypedData = this.signer.signTypedData.bind(this.signer);
});

shouldBehaveLikeERC7739Signer();
shouldBehaveLikeERC7739();
});
});
6 changes: 3 additions & 3 deletions test/account/AccountERC7702.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
shouldBehaveLikeAccountERC7821,
shouldBehaveLikeAccountHolder,
} = require('./Account.behavior');
const { shouldBehaveLikeERC7739Signer } = require('../utils/cryptography/ERC7739Signer.behavior');
const { shouldBehaveLikeERC7739 } = require('../utils/cryptography/ERC7739.behavior');

async function fixture() {
// EOAs and environment
Expand Down Expand Up @@ -48,12 +48,12 @@ describe('AccountERC7702', function () {
shouldBehaveLikeAccountERC7821({ deployable: false });
shouldBehaveLikeAccountHolder();

describe('ERC7739Signer', function () {
describe('ERC7739', function () {
beforeEach(async function () {
this.mock = await this.mock.deploy();
this.signTypedData = this.signer.signTypedData.bind(this.signer);
});

shouldBehaveLikeERC7739Signer();
shouldBehaveLikeERC7739();
});
});
6 changes: 3 additions & 3 deletions test/account/AccountP256.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {
shouldBehaveLikeAccountERC7821,
shouldBehaveLikeAccountHolder,
} = require('./Account.behavior');
const { shouldBehaveLikeERC7739Signer } = require('../utils/cryptography/ERC7739Signer.behavior');
const { shouldBehaveLikeERC7739 } = require('../utils/cryptography/ERC7739.behavior');

async function fixture() {
// EOAs and environment
Expand Down Expand Up @@ -54,12 +54,12 @@ describe('AccountP256', function () {
shouldBehaveLikeAccountERC7821();
shouldBehaveLikeAccountHolder();

describe('ERC7739Signer', function () {
describe('ERC7739', function () {
beforeEach(async function () {
this.mock = await this.mock.deploy();
this.signTypedData = this.signer.signTypedData.bind(this.signer);
});

shouldBehaveLikeERC7739Signer();
shouldBehaveLikeERC7739();
});
});
6 changes: 3 additions & 3 deletions test/account/AccountRSA.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {
shouldBehaveLikeAccountERC7821,
shouldBehaveLikeAccountHolder,
} = require('./Account.behavior');
const { shouldBehaveLikeERC7739Signer } = require('../utils/cryptography/ERC7739Signer.behavior');
const { shouldBehaveLikeERC7739 } = require('../utils/cryptography/ERC7739.behavior');

async function fixture() {
// EOAs and environment
Expand Down Expand Up @@ -54,12 +54,12 @@ describe('AccountRSA', function () {
shouldBehaveLikeAccountERC7821();
shouldBehaveLikeAccountHolder();

describe('ERC7739Signer', function () {
describe('ERC7739', function () {
beforeEach(async function () {
this.mock = await this.mock.deploy();
this.signTypedData = this.signer.signTypedData.bind(this.signer);
});

shouldBehaveLikeERC7739Signer();
shouldBehaveLikeERC7739();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { expect } = require('chai');
const { Permit, formatType, getDomain } = require('../../../lib/@openzeppelin-contracts/test/helpers/eip712');
const { PersonalSignHelper, TypedDataSignHelper } = require('../../helpers/erc7739');

function shouldBehaveLikeERC7739Signer() {
function shouldBehaveLikeERC7739() {
const MAGIC_VALUE = '0x1626ba7e';

describe('isValidSignature', function () {
Expand Down Expand Up @@ -32,7 +32,7 @@ function shouldBehaveLikeERC7739Signer() {

describe('TypedDataSign', function () {
beforeEach(async function () {
// Dummy app domain, different from the ERC7739Signer's domain
// Dummy app domain, different from the ERC7739's domain
// Note the difference of format (signer domain doesn't include a salt, but app domain does)
this.appDomain = {
name: 'SomeApp',
Expand Down Expand Up @@ -101,5 +101,5 @@ function shouldBehaveLikeERC7739Signer() {
}

module.exports = {
shouldBehaveLikeERC7739Signer,
shouldBehaveLikeERC7739,
};
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
const { ethers } = require('hardhat');
const { shouldBehaveLikeERC7739Signer } = require('./ERC7739Signer.behavior');
const { shouldBehaveLikeERC7739 } = require('./ERC7739.behavior');
const { NonNativeSigner, P256SigningKey, RSASHA256SigningKey } = require('../../helpers/signers');

describe('ERC7739Signer', function () {
describe('ERC7739', function () {
describe('for an ECDSA signer', function () {
before(async function () {
this.signer = ethers.Wallet.createRandom();
this.mock = await ethers.deployContract('ERC7739SignerECDSAMock', [this.signer.address]);
this.mock = await ethers.deployContract('ERC7739ECDSAMock', [this.signer.address]);
});

shouldBehaveLikeERC7739Signer();
shouldBehaveLikeERC7739();
});

describe('for a P256 signer', function () {
before(async function () {
this.signer = new NonNativeSigner(P256SigningKey.random());
this.mock = await ethers.deployContract('ERC7739SignerP256Mock', [
this.mock = await ethers.deployContract('ERC7739P256Mock', [
this.signer.signingKey.publicKey.qx,
this.signer.signingKey.publicKey.qy,
]);
});

shouldBehaveLikeERC7739Signer();
shouldBehaveLikeERC7739();
});

describe('for an RSA signer', function () {
before(async function () {
this.signer = new NonNativeSigner(RSASHA256SigningKey.random());
this.mock = await ethers.deployContract('ERC7739SignerRSAMock', [
this.mock = await ethers.deployContract('ERC7739RSAMock', [
this.signer.signingKey.publicKey.e,
this.signer.signingKey.publicKey.n,
]);
});

shouldBehaveLikeERC7739Signer();
shouldBehaveLikeERC7739();
});
});

0 comments on commit e30bd56

Please sign in to comment.