-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathSignatureValidator.sol
43 lines (39 loc) · 1.64 KB
/
SignatureValidator.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.20;
import {ERC1271} from "../libraries/ERC1271.sol";
/**
* @title Signature Validator Base Contract
* @dev A interface for smart contract Safe owners that supports multiple ERC-1271 `isValidSignature` versions.
* @custom:security-contact [email protected]
*/
abstract contract SignatureValidator {
/**
* @dev Validates the signature for the given data.
* @param data The signed data bytes.
* @param signature The signature to be validated.
* @return magicValue The magic value indicating the validity of the signature.
*/
function isValidSignature(bytes memory data, bytes calldata signature) external view returns (bytes4 magicValue) {
if (_verifySignature(keccak256(data), signature)) {
magicValue = ERC1271.LEGACY_MAGIC_VALUE;
}
}
/**
* @dev Validates the signature for a given data hash.
* @param message The signed message.
* @param signature The signature to be validated.
* @return magicValue The magic value indicating the validity of the signature.
*/
function isValidSignature(bytes32 message, bytes calldata signature) external view returns (bytes4 magicValue) {
if (_verifySignature(message, signature)) {
magicValue = ERC1271.MAGIC_VALUE;
}
}
/**
* @dev Verifies a signature.
* @param message The signed message.
* @param signature The signature to be validated.
* @return success Whether the signature is valid.
*/
function _verifySignature(bytes32 message, bytes calldata signature) internal view virtual returns (bool success);
}