Skip to main content

tempo_contracts/precompiles/
signature_verifier.rs

1pub use ISignatureVerifier::ISignatureVerifierErrors as SignatureVerifierError;
2
3crate::sol! {
4    #[derive(Debug, PartialEq, Eq)]
5    #[sol(abi)]
6    interface ISignatureVerifier {
7
8        /// @notice Recovers the signer of a Tempo signature (secp256k1, P256, WebAuthn).
9        /// @param hash The message hash that was signed
10        /// @param signature The encoded signature (see Tempo Transaction spec for formats)
11        /// @return Address of the signer if valid, reverts otherwise
12        function recover(bytes32 hash, bytes calldata signature) external view returns (address signer);
13
14        /// @notice Verifies a signer against a Tempo signature (secp256k1, P256, WebAuthn).
15        /// @param signer The input address verified against the recovered signer
16        /// @param hash The message hash that was signed
17        /// @param signature The encoded signature (see Tempo Transaction spec for formats)
18        /// @return True if the input address signed, false otherwise. Reverts on invalid signatures.
19        function verify(address signer, bytes32 hash, bytes calldata signature) external view returns (bool);
20
21        error InvalidFormat();
22        error InvalidSignature();
23    }
24}
25
26impl SignatureVerifierError {
27    pub const fn invalid_format() -> Self {
28        Self::InvalidFormat(ISignatureVerifier::InvalidFormat {})
29    }
30
31    pub const fn invalid_signature() -> Self {
32        Self::InvalidSignature(ISignatureVerifier::InvalidSignature {})
33    }
34}