-
Notifications
You must be signed in to change notification settings - Fork 121
/
Signatures.sol
25 lines (19 loc) · 1.02 KB
/
Signatures.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.21;
import {SignatureChecker} from "openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
abstract contract Signatures {
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
/// @dev Revert when the signature provided is invalid.
error InvalidSignature();
/// @dev Revert when the block.timestamp is ahead of the signature deadline.
error SignatureExpired();
/*//////////////////////////////////////////////////////////////
SIGNATURE VERIFICATION HELPERS
//////////////////////////////////////////////////////////////*/
function _verifySig(bytes32 digest, address signer, uint256 deadline, bytes memory sig) internal view {
if (block.timestamp >= deadline) revert SignatureExpired();
if (!SignatureChecker.isValidSignatureNow(signer, digest, sig)) revert InvalidSignature();
}
}