{
    "Function": "recover",
    "File": "contracts/ECDSA.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [
        "byte(uint256,uint256)",
        "revert InvalidS()",
        "ecrecover(bytes32,uint8,bytes32,bytes32)",
        "revert InvalidSignature()",
        "revert InvalidV()",
        "mload(uint256)",
        "revert InvalidSignatureLength()",
        "mload(uint256)",
        "mload(uint256)"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function recover(bytes32 hash, bytes memory signature) internal pure returns (address signer) {\n        // Check the signature length\n        if (signature.length != 65) revert InvalidSignatureLength();\n\n        // Divide the signature in r, s and v variables\n        bytes32 r;\n        bytes32 s;\n        uint8 v;\n\n        // ecrecover takes the signature parameters, and the only way to get them\n        // currently is to use assembly.\n        // solhint-disable-next-line no-inline-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\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (281): 0 < s < secp256k1n \u00f7 2 + 1, and for v in (282): v \u2208 {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) revert InvalidS();\n\n        if (v != 27 && v != 28) revert InvalidV();\n\n        // If the signature is valid (and not malleable), return the signer address\n        if ((signer = ecrecover(hash, v, r, s)) == address(0)) revert InvalidSignature();\n    }"
}