```\nfunction tryRecover(\n    bytes32 hash,\n    bytes memory signature\n) internal pure returns (address, RecoverError) {\n    if (signature.length == 65) {\n        bytes32 r;\n        bytes32 s;\n        uint8 v;\n        // ecrecover takes the signature parameters, and the only way to get them\n        // currently is to use assembly.\n        /// @solidity memory-safe-assembly\n        assembly {\n            r := mload(add(signature, 0x20))\n            s := mload(add(signature, 0x40))\n            v := byte(0, mload(add(signature, 0x60)))\n        }\n        return tryRecover(hash, v, r, s);\n    } else {\n        return (address(0), RecoverError.InvalidSignatureLength);\n    }\n}\n```\n