ERC7913RSAVerifier.sol 851 B

1234567891011121314151617181920212223
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v5.4.0) (utils/cryptography/verifiers/ERC7913RSAVerifier.sol)
  3. pragma solidity ^0.8.20;
  4. import {RSA} from "../RSA.sol";
  5. import {IERC7913SignatureVerifier} from "../../../interfaces/IERC7913.sol";
  6. /**
  7. * @dev ERC-7913 signature verifier that support RSA keys.
  8. *
  9. * @custom:stateless
  10. */
  11. contract ERC7913RSAVerifier is IERC7913SignatureVerifier {
  12. /// @inheritdoc IERC7913SignatureVerifier
  13. function verify(bytes calldata key, bytes32 hash, bytes calldata signature) public view virtual returns (bytes4) {
  14. (bytes memory e, bytes memory n) = abi.decode(key, (bytes, bytes));
  15. return
  16. RSA.pkcs1Sha256(abi.encodePacked(hash), signature, e, n)
  17. ? IERC7913SignatureVerifier.verify.selector
  18. : bytes4(0xFFFFFFFF);
  19. }
  20. }