Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SignatureChecker

Signature verification helper that can be used instead of ECDSA.recover to seamlessly support: ECDSA signatures from externally owned accounts (EOAs) ERC-1271 signatures from smart contract wallets like Argent and Safe Wallet (previously Gnosis Safe) ERC-7913 signatures from keys that do not have an Ethereum address of their own See https://eips.ethereum.org/EIPS/eip-1271[ERC-1271] and https://eips.ethereum.org/EIPS/eip-7913[ERC-7913].

Functions

isValidSignatureNow

Checks if a signature is valid for a given signer and data hash. If the signer has code, the signature is validated against it using ERC-1271, otherwise it's validated using ECDSA.recover. NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus change through time. It could return true at block N and false at block N+1 (or the opposite). NOTE: For an extended version of this function that supports ERC-7913 signatures, see {isValidSignatureNow-bytes-bytes32-bytes-}.

function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool);

isValidERC1271SignatureNow

Checks if a signature is valid for a given signer and data hash. The signature is validated against the signer smart contract using ERC-1271. NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus change through time. It could return true at block N and false at block N+1 (or the opposite).

function isValidERC1271SignatureNow(address signer, bytes32 hash, bytes memory signature)
    internal
    view
    returns (bool);

isValidSignatureNow

Verifies a signature for a given ERC-7913 signer and hash. The signer is a bytes object that is the concatenation of an address and optionally a key: verifier || key. A signer must be at least 20 bytes long. Verification is done as follows: If signer.length < 20: verification fails If signer.length == 20: verification is done using isValidSignatureNow Otherwise: verification is done using {IERC7913SignatureVerifier} NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus change through time. It could return true at block N and false at block N+1 (or the opposite).

function isValidSignatureNow(bytes memory signer, bytes32 hash, bytes memory signature) internal view returns (bool);

areValidSignaturesNow

Verifies multiple ERC-7913 signatures for a given hash using a set of signers. Returns false if the number of signers and signatures is not the same. The signers should be ordered by their keccak256 hash to ensure efficient duplication check. Unordered signers are supported, but the uniqueness check will be more expensive. NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus change through time. It could return true at block N and false at block N+1 (or the opposite).

function areValidSignaturesNow(bytes32 hash, bytes[] memory signers, bytes[] memory signatures)
    internal
    view
    returns (bool);