{ "contractName": "ECRecovery", "abi": [], "bytecode": "0x604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f30073000000000000000000000000000000000000000030146080604052600080fd00a165627a7a7230582095f4276bbe910450a81a9f24c9666db9e203894c52a3fdbade54b3b5738e695e0029", "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fd00a165627a7a7230582095f4276bbe910450a81a9f24c9666db9e203894c52a3fdbade54b3b5738e695e0029", "sourceMap": "309:1640:1:-;;132:2:-1;166:7;155:9;146:7;137:37;252:7;246:14;243:1;238:23;232:4;229:33;270:1;265:20;;;;222:63;;265:20;274:9;222:63;;298:9;295:1;288:20;328:4;319:7;311:22;352:7;343;336:24", "deployedSourceMap": "309:1640:1:-;;;;;;;;", "source": "pragma solidity ^0.4.21;\n\n\n/**\n * @title Eliptic curve signature operations\n *\n * @dev Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d\n *\n * TODO Remove this library once solidity supports passing a signature to ecrecover.\n * See https://github.com/ethereum/solidity/issues/864\n *\n */\n\nlibrary ECRecovery {\n\n /**\n * @dev Recover signer address from a message by using their signature\n * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address.\n * @param sig bytes signature, the signature is generated using web3.eth.sign()\n */\n function recover(bytes32 hash, bytes sig)\n internal\n pure\n returns (address)\n {\n bytes32 r;\n bytes32 s;\n uint8 v;\n\n // Check the signature length\n if (sig.length != 65) {\n return (address(0));\n }\n\n // Divide the signature in r, s and v variables\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n r := mload(add(sig, 32))\n s := mload(add(sig, 64))\n v := byte(0, mload(add(sig, 96)))\n }\n\n // Version of signature should be 27 or 28, but 0 and 1 are also possible versions\n if (v < 27) {\n v += 27;\n }\n\n // If the version is correct return the signer address\n if (v != 27 && v != 28) {\n return (address(0));\n } else {\n // solium-disable-next-line arg-overflow\n return ecrecover(hash, v, r, s);\n }\n }\n\n /**\n * toEthSignedMessageHash\n * @dev prefix a bytes32 value with \"\\x19Ethereum Signed Message:\"\n * @dev and hash the result\n */\n function toEthSignedMessageHash(bytes32 hash)\n internal\n pure\n returns (bytes32)\n {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(\n \"\\x19Ethereum Signed Message:\\n32\",\n hash\n );\n }\n}\n", "sourcePath": "/home/spalladino/Projects/openzeppelin-zos/contracts/ECRecovery.sol", "ast": { "absolutePath": "/home/spalladino/Projects/openzeppelin-zos/contracts/ECRecovery.sol", "exportedSymbols": { "ECRecovery": [ 96 ] }, "id": 97, "nodeType": "SourceUnit", "nodes": [ { "id": 20, "literals": [ "solidity", "^", "0.4", ".21" ], "nodeType": "PragmaDirective", "src": "0:24:1" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": "@title Eliptic curve signature operations\n * @dev Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d\n * TODO Remove this library once solidity supports passing a signature to ecrecover.\nSee https://github.com/ethereum/solidity/issues/864\n ", "fullyImplemented": true, "id": 96, "linearizedBaseContracts": [ 96 ], "name": "ECRecovery", "nodeType": "ContractDefinition", "nodes": [ { "body": { "id": 81, "nodeType": "Block", "src": "695:844:1", "statements": [ { "assignments": [], "declarations": [ { "constant": false, "id": 30, "name": "r", "nodeType": "VariableDeclaration", "scope": 82, "src": "701:9:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 29, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "701:7:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": null, "visibility": "internal" } ], "id": 31, "initialValue": null, "nodeType": "VariableDeclarationStatement", "src": "701:9:1" }, { "assignments": [], "declarations": [ { "constant": false, "id": 33, "name": "s", "nodeType": "VariableDeclaration", "scope": 82, "src": "716:9:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 32, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "716:7:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": null, "visibility": "internal" } ], "id": 34, "initialValue": null, "nodeType": "VariableDeclarationStatement", "src": "716:9:1" }, { "assignments": [], "declarations": [ { "constant": false, "id": 36, "name": "v", "nodeType": "VariableDeclaration", "scope": 82, "src": "731:7:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" }, "typeName": { "id": 35, "name": "uint8", "nodeType": "ElementaryTypeName", "src": "731:5:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "value": null, "visibility": "internal" } ], "id": 37, "initialValue": null, "nodeType": "VariableDeclarationStatement", "src": "731:7:1" }, { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 41, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 38, "name": "sig", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 24, "src": "783:3:1", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } }, "id": 39, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "length", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "783:10:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "hexValue": "3635", "id": 40, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "797:2:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_65_by_1", "typeString": "int_const 65" }, "value": "65" }, "src": "783:16:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 48, "nodeType": "IfStatement", "src": "779:56:1", "trueBody": { "id": 47, "nodeType": "Block", "src": "801:34:1", "statements": [ { "expression": { "argumentTypes": null, "components": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "30", "id": 43, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "825:1:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" } ], "id": 42, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "817:7:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": "address" }, "id": 44, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "817:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "id": 45, "isConstant": false, "isInlineArray": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "TupleExpression", "src": "816:12:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "functionReturnParameters": 28, "id": 46, "nodeType": "Return", "src": "809:19:1" } ] } }, { "externalReferences": [ { "sig": { "declaration": 24, "isOffset": false, "isSlot": false, "src": "1100:3:1", "valueSize": 1 } }, { "r": { "declaration": 30, "isOffset": false, "isSlot": false, "src": "1085:1:1", "valueSize": 1 } }, { "sig": { "declaration": 24, "isOffset": false, "isSlot": false, "src": "1131:3:1", "valueSize": 1 } }, { "s": { "declaration": 33, "isOffset": false, "isSlot": false, "src": "1116:1:1", "valueSize": 1 } }, { "sig": { "declaration": 24, "isOffset": false, "isSlot": false, "src": "1170:3:1", "valueSize": 1 } }, { "v": { "declaration": 36, "isOffset": false, "isSlot": false, "src": "1147:1:1", "valueSize": 1 } } ], "id": 49, "nodeType": "InlineAssembly", "operations": "{\n r := mload(add(sig, 32))\n s := mload(add(sig, 64))\n v := byte(0, mload(add(sig, 96)))\n}", "src": "1068:213:1" }, { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint8", "typeString": "uint8" }, "id": 52, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 50, "name": "v", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 36, "src": "1283:1:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "nodeType": "BinaryOperation", "operator": "<", "rightExpression": { "argumentTypes": null, "hexValue": "3237", "id": 51, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1287:2:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_27_by_1", "typeString": "int_const 27" }, "value": "27" }, "src": "1283:6:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 58, "nodeType": "IfStatement", "src": "1279:34:1", "trueBody": { "id": 57, "nodeType": "Block", "src": "1291:22:1", "statements": [ { "expression": { "argumentTypes": null, "id": 55, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 53, "name": "v", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 36, "src": "1299:1:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "nodeType": "Assignment", "operator": "+=", "rightHandSide": { "argumentTypes": null, "hexValue": "3237", "id": 54, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1304:2:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_27_by_1", "typeString": "int_const 27" }, "value": "27" }, "src": "1299:7:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "id": 56, "nodeType": "ExpressionStatement", "src": "1299:7:1" } ] } }, { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_bool", "typeString": "bool" }, "id": 65, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint8", "typeString": "uint8" }, "id": 61, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 59, "name": "v", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 36, "src": "1382:1:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "hexValue": "3237", "id": 60, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1387:2:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_27_by_1", "typeString": "int_const 27" }, "value": "27" }, "src": "1382:7:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "nodeType": "BinaryOperation", "operator": "&&", "rightExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint8", "typeString": "uint8" }, "id": 64, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 62, "name": "v", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 36, "src": "1393:1:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "hexValue": "3238", "id": 63, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1398:2:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_28_by_1", "typeString": "int_const 28" }, "value": "28" }, "src": "1393:7:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "src": "1382:18:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": { "id": 79, "nodeType": "Block", "src": "1442:93:1", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 73, "name": "hash", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 22, "src": "1514:4:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, { "argumentTypes": null, "id": 74, "name": "v", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 36, "src": "1520:1:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, { "argumentTypes": null, "id": 75, "name": "r", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 30, "src": "1523:1:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, { "argumentTypes": null, "id": 76, "name": "s", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 33, "src": "1526:1:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, { "typeIdentifier": "t_uint8", "typeString": "uint8" }, { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } ], "id": 72, "name": "ecrecover", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4776, "src": "1504:9:1", "typeDescriptions": { "typeIdentifier": "t_function_ecrecover_pure$_t_bytes32_$_t_uint8_$_t_bytes32_$_t_bytes32_$returns$_t_address_$", "typeString": "function (bytes32,uint8,bytes32,bytes32) pure returns (address)" } }, "id": 77, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1504:24:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "functionReturnParameters": 28, "id": 78, "nodeType": "Return", "src": "1497:31:1" } ] }, "id": 80, "nodeType": "IfStatement", "src": "1378:157:1", "trueBody": { "id": 71, "nodeType": "Block", "src": "1402:34:1", "statements": [ { "expression": { "argumentTypes": null, "components": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "30", "id": 67, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1426:1:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" } ], "id": 66, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1418:7:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": "address" }, "id": 68, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1418:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "id": 69, "isConstant": false, "isInlineArray": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "TupleExpression", "src": "1417:12:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "functionReturnParameters": 28, "id": 70, "nodeType": "Return", "src": "1410:19:1" } ] } } ] }, "documentation": "@dev Recover signer address from a message by using their signature\n@param hash bytes32 message, the hash is the signed message. What is recovered is the signer address.\n@param sig bytes signature, the signature is generated using web3.eth.sign()", "id": 82, "implemented": true, "isConstructor": false, "isDeclaredConst": true, "modifiers": [], "name": "recover", "nodeType": "FunctionDefinition", "parameters": { "id": 25, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 22, "name": "hash", "nodeType": "VariableDeclaration", "scope": 82, "src": "624:12:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 21, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "624:7:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 24, "name": "sig", "nodeType": "VariableDeclaration", "scope": 82, "src": "638:9:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes" }, "typeName": { "id": 23, "name": "bytes", "nodeType": "ElementaryTypeName", "src": "638:5:1", "typeDescriptions": { "typeIdentifier": "t_bytes_storage_ptr", "typeString": "bytes" } }, "value": null, "visibility": "internal" } ], "src": "623:25:1" }, "payable": false, "returnParameters": { "id": 28, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 27, "name": "", "nodeType": "VariableDeclaration", "scope": 82, "src": "684:7:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 26, "name": "address", "nodeType": "ElementaryTypeName", "src": "684:7:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" } ], "src": "683:9:1" }, "scope": 96, "src": "607:932:1", "stateMutability": "pure", "superFunction": null, "visibility": "internal" }, { "body": { "id": 94, "nodeType": "Block", "src": "1774:173:1", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "19457468657265756d205369676e6564204d6573736167653a0a3332", "id": 90, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "1890:34:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_stringliteral_178a2411ab6fbc1ba11064408972259c558d0e82fd48b0aba3ad81d14f065e73", "typeString": "literal_string \"\u0019Ethereum Signed Message:\n32\"" }, "value": "\u0019Ethereum Signed Message:\n32" }, { "argumentTypes": null, "id": 91, "name": "hash", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 84, "src": "1932:4:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_stringliteral_178a2411ab6fbc1ba11064408972259c558d0e82fd48b0aba3ad81d14f065e73", "typeString": "literal_string \"\u0019Ethereum Signed Message:\n32\"" }, { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } ], "id": 89, "name": "keccak256", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4778, "src": "1873:9:1", "typeDescriptions": { "typeIdentifier": "t_function_sha3_pure$__$returns$_t_bytes32_$", "typeString": "function () pure returns (bytes32)" } }, "id": 92, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1873:69:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "functionReturnParameters": 88, "id": 93, "nodeType": "Return", "src": "1866:76:1" } ] }, "documentation": "toEthSignedMessageHash\n@dev prefix a bytes32 value with \"\\x19Ethereum Signed Message:\"\n@dev and hash the result", "id": 95, "implemented": true, "isConstructor": false, "isDeclaredConst": true, "modifiers": [], "name": "toEthSignedMessageHash", "nodeType": "FunctionDefinition", "parameters": { "id": 85, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 84, "name": "hash", "nodeType": "VariableDeclaration", "scope": 95, "src": "1714:12:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 83, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "1714:7:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": null, "visibility": "internal" } ], "src": "1713:14:1" }, "payable": false, "returnParameters": { "id": 88, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 87, "name": "", "nodeType": "VariableDeclaration", "scope": 95, "src": "1763:7:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 86, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "1763:7:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": null, "visibility": "internal" } ], "src": "1762:9:1" }, "scope": 96, "src": "1682:265:1", "stateMutability": "pure", "superFunction": null, "visibility": "internal" } ], "scope": 97, "src": "309:1640:1" } ], "src": "0:1950:1" }, "legacyAST": { "absolutePath": "/home/spalladino/Projects/openzeppelin-zos/contracts/ECRecovery.sol", "exportedSymbols": { "ECRecovery": [ 96 ] }, "id": 97, "nodeType": "SourceUnit", "nodes": [ { "id": 20, "literals": [ "solidity", "^", "0.4", ".21" ], "nodeType": "PragmaDirective", "src": "0:24:1" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": "@title Eliptic curve signature operations\n * @dev Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d\n * TODO Remove this library once solidity supports passing a signature to ecrecover.\nSee https://github.com/ethereum/solidity/issues/864\n ", "fullyImplemented": true, "id": 96, "linearizedBaseContracts": [ 96 ], "name": "ECRecovery", "nodeType": "ContractDefinition", "nodes": [ { "body": { "id": 81, "nodeType": "Block", "src": "695:844:1", "statements": [ { "assignments": [], "declarations": [ { "constant": false, "id": 30, "name": "r", "nodeType": "VariableDeclaration", "scope": 82, "src": "701:9:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 29, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "701:7:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": null, "visibility": "internal" } ], "id": 31, "initialValue": null, "nodeType": "VariableDeclarationStatement", "src": "701:9:1" }, { "assignments": [], "declarations": [ { "constant": false, "id": 33, "name": "s", "nodeType": "VariableDeclaration", "scope": 82, "src": "716:9:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 32, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "716:7:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": null, "visibility": "internal" } ], "id": 34, "initialValue": null, "nodeType": "VariableDeclarationStatement", "src": "716:9:1" }, { "assignments": [], "declarations": [ { "constant": false, "id": 36, "name": "v", "nodeType": "VariableDeclaration", "scope": 82, "src": "731:7:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" }, "typeName": { "id": 35, "name": "uint8", "nodeType": "ElementaryTypeName", "src": "731:5:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "value": null, "visibility": "internal" } ], "id": 37, "initialValue": null, "nodeType": "VariableDeclarationStatement", "src": "731:7:1" }, { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 41, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 38, "name": "sig", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 24, "src": "783:3:1", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } }, "id": 39, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "length", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "783:10:1", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "hexValue": "3635", "id": 40, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "797:2:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_65_by_1", "typeString": "int_const 65" }, "value": "65" }, "src": "783:16:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 48, "nodeType": "IfStatement", "src": "779:56:1", "trueBody": { "id": 47, "nodeType": "Block", "src": "801:34:1", "statements": [ { "expression": { "argumentTypes": null, "components": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "30", "id": 43, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "825:1:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" } ], "id": 42, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "817:7:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": "address" }, "id": 44, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "817:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "id": 45, "isConstant": false, "isInlineArray": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "TupleExpression", "src": "816:12:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "functionReturnParameters": 28, "id": 46, "nodeType": "Return", "src": "809:19:1" } ] } }, { "externalReferences": [ { "sig": { "declaration": 24, "isOffset": false, "isSlot": false, "src": "1100:3:1", "valueSize": 1 } }, { "r": { "declaration": 30, "isOffset": false, "isSlot": false, "src": "1085:1:1", "valueSize": 1 } }, { "sig": { "declaration": 24, "isOffset": false, "isSlot": false, "src": "1131:3:1", "valueSize": 1 } }, { "s": { "declaration": 33, "isOffset": false, "isSlot": false, "src": "1116:1:1", "valueSize": 1 } }, { "sig": { "declaration": 24, "isOffset": false, "isSlot": false, "src": "1170:3:1", "valueSize": 1 } }, { "v": { "declaration": 36, "isOffset": false, "isSlot": false, "src": "1147:1:1", "valueSize": 1 } } ], "id": 49, "nodeType": "InlineAssembly", "operations": "{\n r := mload(add(sig, 32))\n s := mload(add(sig, 64))\n v := byte(0, mload(add(sig, 96)))\n}", "src": "1068:213:1" }, { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint8", "typeString": "uint8" }, "id": 52, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 50, "name": "v", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 36, "src": "1283:1:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "nodeType": "BinaryOperation", "operator": "<", "rightExpression": { "argumentTypes": null, "hexValue": "3237", "id": 51, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1287:2:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_27_by_1", "typeString": "int_const 27" }, "value": "27" }, "src": "1283:6:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 58, "nodeType": "IfStatement", "src": "1279:34:1", "trueBody": { "id": 57, "nodeType": "Block", "src": "1291:22:1", "statements": [ { "expression": { "argumentTypes": null, "id": 55, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 53, "name": "v", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 36, "src": "1299:1:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "nodeType": "Assignment", "operator": "+=", "rightHandSide": { "argumentTypes": null, "hexValue": "3237", "id": 54, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1304:2:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_27_by_1", "typeString": "int_const 27" }, "value": "27" }, "src": "1299:7:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "id": 56, "nodeType": "ExpressionStatement", "src": "1299:7:1" } ] } }, { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_bool", "typeString": "bool" }, "id": 65, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint8", "typeString": "uint8" }, "id": 61, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 59, "name": "v", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 36, "src": "1382:1:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "hexValue": "3237", "id": 60, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1387:2:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_27_by_1", "typeString": "int_const 27" }, "value": "27" }, "src": "1382:7:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "nodeType": "BinaryOperation", "operator": "&&", "rightExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint8", "typeString": "uint8" }, "id": 64, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 62, "name": "v", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 36, "src": "1393:1:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "hexValue": "3238", "id": 63, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1398:2:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_28_by_1", "typeString": "int_const 28" }, "value": "28" }, "src": "1393:7:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "src": "1382:18:1", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": { "id": 79, "nodeType": "Block", "src": "1442:93:1", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 73, "name": "hash", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 22, "src": "1514:4:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, { "argumentTypes": null, "id": 74, "name": "v", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 36, "src": "1520:1:1", "typeDescriptions": { "typeIdentifier": "t_uint8", "typeString": "uint8" } }, { "argumentTypes": null, "id": 75, "name": "r", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 30, "src": "1523:1:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, { "argumentTypes": null, "id": 76, "name": "s", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 33, "src": "1526:1:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, { "typeIdentifier": "t_uint8", "typeString": "uint8" }, { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } ], "id": 72, "name": "ecrecover", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4776, "src": "1504:9:1", "typeDescriptions": { "typeIdentifier": "t_function_ecrecover_pure$_t_bytes32_$_t_uint8_$_t_bytes32_$_t_bytes32_$returns$_t_address_$", "typeString": "function (bytes32,uint8,bytes32,bytes32) pure returns (address)" } }, "id": 77, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1504:24:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "functionReturnParameters": 28, "id": 78, "nodeType": "Return", "src": "1497:31:1" } ] }, "id": 80, "nodeType": "IfStatement", "src": "1378:157:1", "trueBody": { "id": 71, "nodeType": "Block", "src": "1402:34:1", "statements": [ { "expression": { "argumentTypes": null, "components": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "30", "id": 67, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1426:1:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" } ], "id": 66, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1418:7:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": "address" }, "id": 68, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1418:10:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "id": 69, "isConstant": false, "isInlineArray": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "TupleExpression", "src": "1417:12:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "functionReturnParameters": 28, "id": 70, "nodeType": "Return", "src": "1410:19:1" } ] } } ] }, "documentation": "@dev Recover signer address from a message by using their signature\n@param hash bytes32 message, the hash is the signed message. What is recovered is the signer address.\n@param sig bytes signature, the signature is generated using web3.eth.sign()", "id": 82, "implemented": true, "isConstructor": false, "isDeclaredConst": true, "modifiers": [], "name": "recover", "nodeType": "FunctionDefinition", "parameters": { "id": 25, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 22, "name": "hash", "nodeType": "VariableDeclaration", "scope": 82, "src": "624:12:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 21, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "624:7:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 24, "name": "sig", "nodeType": "VariableDeclaration", "scope": 82, "src": "638:9:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes" }, "typeName": { "id": 23, "name": "bytes", "nodeType": "ElementaryTypeName", "src": "638:5:1", "typeDescriptions": { "typeIdentifier": "t_bytes_storage_ptr", "typeString": "bytes" } }, "value": null, "visibility": "internal" } ], "src": "623:25:1" }, "payable": false, "returnParameters": { "id": 28, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 27, "name": "", "nodeType": "VariableDeclaration", "scope": 82, "src": "684:7:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 26, "name": "address", "nodeType": "ElementaryTypeName", "src": "684:7:1", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "value": null, "visibility": "internal" } ], "src": "683:9:1" }, "scope": 96, "src": "607:932:1", "stateMutability": "pure", "superFunction": null, "visibility": "internal" }, { "body": { "id": 94, "nodeType": "Block", "src": "1774:173:1", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "19457468657265756d205369676e6564204d6573736167653a0a3332", "id": 90, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "1890:34:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_stringliteral_178a2411ab6fbc1ba11064408972259c558d0e82fd48b0aba3ad81d14f065e73", "typeString": "literal_string \"\u0019Ethereum Signed Message:\n32\"" }, "value": "\u0019Ethereum Signed Message:\n32" }, { "argumentTypes": null, "id": 91, "name": "hash", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 84, "src": "1932:4:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_stringliteral_178a2411ab6fbc1ba11064408972259c558d0e82fd48b0aba3ad81d14f065e73", "typeString": "literal_string \"\u0019Ethereum Signed Message:\n32\"" }, { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } ], "id": 89, "name": "keccak256", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4778, "src": "1873:9:1", "typeDescriptions": { "typeIdentifier": "t_function_sha3_pure$__$returns$_t_bytes32_$", "typeString": "function () pure returns (bytes32)" } }, "id": 92, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1873:69:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "functionReturnParameters": 88, "id": 93, "nodeType": "Return", "src": "1866:76:1" } ] }, "documentation": "toEthSignedMessageHash\n@dev prefix a bytes32 value with \"\\x19Ethereum Signed Message:\"\n@dev and hash the result", "id": 95, "implemented": true, "isConstructor": false, "isDeclaredConst": true, "modifiers": [], "name": "toEthSignedMessageHash", "nodeType": "FunctionDefinition", "parameters": { "id": 85, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 84, "name": "hash", "nodeType": "VariableDeclaration", "scope": 95, "src": "1714:12:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 83, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "1714:7:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": null, "visibility": "internal" } ], "src": "1713:14:1" }, "payable": false, "returnParameters": { "id": 88, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 87, "name": "", "nodeType": "VariableDeclaration", "scope": 95, "src": "1763:7:1", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 86, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "1763:7:1", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "value": null, "visibility": "internal" } ], "src": "1762:9:1" }, "scope": 96, "src": "1682:265:1", "stateMutability": "pure", "superFunction": null, "visibility": "internal" } ], "scope": 97, "src": "309:1640:1" } ], "src": "0:1950:1" }, "compiler": { "name": "solc", "version": "0.4.24+commit.e67f0147.Emscripten.clang" }, "networks": {}, "schemaVersion": "2.0.1", "updatedAt": "2018-08-23T14:35:50.612Z" }