SignatureChecker
Title: SignatureChecker
Author: Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/SignatureChecker.sol)
Utility library for verifying signatures from both EOAs and ERC-1271 contracts.
Implements the ERC-1271 magic value check with a safe staticcall fallback so
non-1271 contracts (or EOAs) never revert unexpectedly.
Constants
ERC1271_MAGIC_VALUE
ERC-1271 magic value returned by valid contract signatures.
bytes4 private constant ERC1271_MAGIC_VALUE = 0x1626ba7e;Functions
isValidSignatureNow
Returns true if signer signed hash with signature.
If signer is an EOA: uses ECDSA recovery and checks address match.
If signer is a contract: tries ERC-1271 isValidSignature; falls back
to ECDSA if the contract call reverts (e.g. non-1271 contracts).
function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| signer | address | The expected signer (EOA or contract). |
| hash | bytes32 | The signed data hash. |
| signature | bytes | The signature bytes. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool | True if the signature is valid for the given signer and hash. |
isValidERC1271SignatureNow
Returns true if the contract signer accepts signature for hash via ERC-1271.
Calls signer.isValidSignature(hash, signature) via staticcall and checks the
magic return value. Never reverts — returns false if the call fails.
function isValidERC1271SignatureNow(address signer, bytes32 hash, bytes memory signature)
internal
view
returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| signer | address | The contract that implements (or should implement) ERC-1271. |
| hash | bytes32 | The signed data hash. |
| signature | bytes | The signature bytes. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool | True if the contract returns the ERC-1271 magic value. |