smt-rollup
Version:
Sparse Merkle Tree roll up
1,104 lines (1,103 loc) • 537 kB
JSON
{
"contractName": "SMT256",
"abi": [
{
"inputs": [],
"name": "EXIST",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "NON_EXIST",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
}
],
"metadata": "{\"compiler\":{\"version\":\"0.6.0+commit.26b70077\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"EXIST\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NON_EXIST\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Wilson Beam <wilsonbeam@protonmail.com>\",\"details\":\"Append only purpose Sparse Merkle Tree solidity library for optimistic roll up\",\"methods\":{},\"title\":\"Sparse Merkle Tree for optimistic roll up\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/wanseob/Projects/wilsonbeam/smt-rollup/contracts/SMT.sol\":\"SMT256\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/home/wanseob/Projects/wilsonbeam/smt-rollup/contracts/SMT.sol\":{\"keccak256\":\"0x6da0de244d820286121a3dc7149968c8c6e449ac529e28c2c720247b5e4635c5\",\"urls\":[\"bzz-raw://4e3adc3a46b1974a95a58dc7a7b7ef09eb33a4b07e23091c73dd98fef92b8e63\",\"dweb:/ipfs/QmZ21CJPA6utrtUMoL4esHmFa2hAEQFE5eFjqjN4e9ikBh\"]}},\"version\":1}",
"bytecode": "0x60fe610025600b82828239805160001a60731461001857fe5b30600052607381538281f3fe7300000000000000000000000000000000000000003014608060405260043610603d5760003560e01c80633fc4c054146042578063705b79c914605e575b600080fd5b6048607a565b6040518082815260200191505060405180910390f35b606460a1565b6040518082815260200191505060405180910390f35b7f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56360001b81565b7fb0b4e07bb5592f3d3821b2c1331b436763d7be555cf452d6c6836f74d5201e8560001b8156fea264697066735822122054f7d12abd9dde09cccd5bd47d08d8fffaca0dcac8ff2efa9d24d4a0c117c4fe64736f6c63430006000033",
"deployedBytecode": "0x7300000000000000000000000000000000000000003014608060405260043610603d5760003560e01c80633fc4c054146042578063705b79c914605e575b600080fd5b6048607a565b6040518082815260200191505060405180910390f35b606460a1565b6040518082815260200191505060405180910390f35b7f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56360001b81565b7fb0b4e07bb5592f3d3821b2c1331b436763d7be555cf452d6c6836f74d5201e8560001b8156fea264697066735822122054f7d12abd9dde09cccd5bd47d08d8fffaca0dcac8ff2efa9d24d4a0c117c4fe64736f6c63430006000033",
"sourceMap": "229:4709:1:-:0;;132:2:-1;166:7;155:9;146:7;137:37;255:7;249:14;246:1;241:23;235:4;232:33;222:2;;269:9;222:2;293:9;290:1;283:20;323:4;314:7;306:22;347:7;338;331:24",
"deployedSourceMap": "229:4709:1:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;527:102;;;:::i;:::-;;;;;;;;;;;;;;;;;;;329:98;;;:::i;:::-;;;;;;;;;;;;;;;;;;;527:102;563:66;527:102;;;:::o;329:98::-;361:66;329:98;;;:::o",
"source": "pragma solidity >= 0.6.0;\n\n\n/**\n * @author Wilson Beam <wilsonbeam@protonmail.com>\n * @title Sparse Merkle Tree for optimistic roll up\n *\n * @dev Append only purpose Sparse Merkle Tree solidity library for optimistic roll up\n */\nlibrary SMT256 {\n // in Solidity: keccak256('exist')\n // in Web3JS: soliditySha3('exist')\n bytes32 constant public EXIST = 0xb0b4e07bb5592f3d3821b2c1331b436763d7be555cf452d6c6836f74d5201e85;\n // in Solidity: keccak256(abi.encodePacked(bytes32(0)))\n // in Web3JS: soliditySha3(0)\n bytes32 constant public NON_EXIST = 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563;\n\n struct RollUp {\n bytes32 root;\n bytes32[] leaves;\n bytes32[256][] siblings;\n }\n\n struct OPRU {\n bytes32 prev;\n bytes32 next;\n bytes32 mergedLeaves;\n }\n\n function inclusionProof(\n bytes32 root,\n bytes32 leaf,\n bytes32[256] memory siblings\n ) internal pure returns(bool) {\n return merkleProof(root, leaf, EXIST, siblings);\n }\n\n function nonInclusionProof(\n bytes32 root,\n bytes32 leaf,\n bytes32[256] memory siblings\n ) internal pure returns(bool) {\n return merkleProof(root, leaf, NON_EXIST, siblings);\n }\n\n function merkleProof(\n bytes32 root,\n bytes32 leaf,\n bytes32 value,\n bytes32[256] memory siblings\n ) internal pure returns(bool) {\n require(calculateRoot(leaf, value, siblings) == root, \"Invalid merkle proof\");\n return true;\n }\n\n function calculateRoot(\n bytes32 leaf,\n bytes32 value,\n bytes32[256] memory siblings\n ) internal pure returns (bytes32) {\n bytes32 cursor = value;\n uint path = uint(leaf);\n for (uint16 i = 0; i < siblings.length; i++) {\n if (path % 2 == 0) {\n // Right sibling\n cursor = keccak256(abi.encodePacked(cursor, siblings[i]));\n } else {\n // Left sibling\n cursor = keccak256(abi.encodePacked(siblings[i], cursor));\n }\n path = path >> 1;\n }\n return cursor;\n }\n\n function append(\n bytes32 root,\n bytes32 leaf,\n bytes32[256] memory siblings\n ) internal pure returns (bytes32 nextRoot) {\n // Prove that the array of sibling is valid and also the leaf does not exist in the tree\n require(nonInclusionProof(root, leaf, siblings), \"Failed to build the previous root using jthe leaf and its sibling\");\n // Calculate the new root when the leaf exists using its proven siblings\n nextRoot = calculateRoot(leaf, EXIST, siblings);\n // Make sure it has been updated\n require(root != nextRoot, \"Already exisiting leaf\");\n }\n\n function rollUp(RollUp memory proof) internal pure returns (bytes32) {\n // Inspect the RollUp structure\n require(proof.leaves.length == proof.siblings.length, \"Both array should have same length\");\n // Start from the root\n bytes32 root = proof.root;\n // Update the root using append function\n for (uint i = 0; i < proof.leaves.length; i ++) {\n root = append(root, proof.leaves[i], proof.siblings[i]);\n }\n return root;\n }\n\n function rollUp(\n bytes32 root,\n bytes32[] memory leaves,\n bytes32[256][] memory siblings\n ) internal pure returns (bytes32 nextRoot) {\n nextRoot = rollUp(RollUp(root, leaves, siblings));\n }\n\n function rollUpProof(\n bytes32 root,\n bytes32 nextRoot,\n bytes32[] memory leaves,\n bytes32[256][] memory siblings\n ) internal pure returns (bool) {\n require(nextRoot == rollUp(RollUp(root, leaves, siblings)), \"Failed to drive the next root from the proof\");\n }\n\n function newOPRU(bytes32 startingRoot) internal pure returns (OPRU memory opru) {\n opru.prev = startingRoot;\n opru.next = startingRoot;\n opru.mergedLeaves = bytes32(0);\n }\n\n function update(\n OPRU storage opru,\n bytes32[] memory leaves,\n bytes32[256][] memory siblings\n ) internal {\n opru.next = rollUp(opru.next, leaves, siblings);\n opru.mergedLeaves = merge(opru.mergedLeaves, leaves);\n }\n\n function verify(\n OPRU memory opru,\n bytes32 prev,\n bytes32 next,\n bytes32 mergedLeaves\n ) internal pure returns (bool) {\n require(opru.prev == prev, \"Started with different root\");\n require(opru.mergedLeaves == mergedLeaves, \"Appended different leaves\");\n return opru.next == next;\n }\n\n function merge(\n bytes32 base,\n bytes32[] memory leaves\n ) internal pure returns (bytes32 mergedLeaves) {\n mergedLeaves = base;\n for(uint i = 0; i < leaves.length; i++) {\n mergedLeaves = keccak256(abi.encodePacked(mergedLeaves, leaves[i]));\n }\n }\n}\n",
"sourcePath": "/home/wanseob/Projects/wilsonbeam/smt-rollup/contracts/SMT.sol",
"ast": {
"absolutePath": "/home/wanseob/Projects/wilsonbeam/smt-rollup/contracts/SMT.sol",
"exportedSymbols": {
"SMT256": [
522
]
},
"id": 523,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 60,
"literals": [
"solidity",
">=",
"0.6",
".0"
],
"nodeType": "PragmaDirective",
"src": "0:25:1"
},
{
"abstract": false,
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": "@author Wilson Beam <wilsonbeam@protonmail.com>\n@title Sparse Merkle Tree for optimistic roll up\n * @dev Append only purpose Sparse Merkle Tree solidity library for optimistic roll up",
"fullyImplemented": true,
"id": 522,
"linearizedBaseContracts": [
522
],
"name": "SMT256",
"nodeType": "ContractDefinition",
"nodes": [
{
"constant": true,
"functionSelector": "705b79c9",
"id": 63,
"name": "EXIST",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 522,
"src": "329:98:1",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 61,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "329:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": {
"argumentTypes": null,
"hexValue": "307862306234653037626235353932663364333832316232633133333162343336373633643762653535356366343532643663363833366637346435323031653835",
"id": 62,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "361:66:1",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_79926643148668327857624003187591320613790941698683858885579621165613256285829_by_1",
"typeString": "int_const 7992...(69 digits omitted)...5829"
},
"value": "0xb0b4e07bb5592f3d3821b2c1331b436763d7be555cf452d6c6836f74d5201e85"
},
"visibility": "public"
},
{
"constant": true,
"functionSelector": "3fc4c054",
"id": 66,
"name": "NON_EXIST",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 522,
"src": "527:102:1",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 64,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "527:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": {
"argumentTypes": null,
"hexValue": "307832393064656364393534386236326138643630333435613938383338366663383462613662633935343834303038663633363266393331363065663365353633",
"id": 65,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "563:66:1",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_18569430475105882587588266137607568536673111973893317399460219858819262702947_by_1",
"typeString": "int_const 1856...(69 digits omitted)...2947"
},
"value": "0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563"
},
"visibility": "public"
},
{
"canonicalName": "SMT256.RollUp",
"id": 77,
"members": [
{
"constant": false,
"id": 68,
"name": "root",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 77,
"src": "660:12:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 67,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "660:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 71,
"name": "leaves",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 77,
"src": "682:16:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$dyn_storage_ptr",
"typeString": "bytes32[]"
},
"typeName": {
"baseType": {
"id": 69,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "682:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"id": 70,
"length": null,
"nodeType": "ArrayTypeName",
"src": "682:9:1",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$dyn_storage_ptr",
"typeString": "bytes32[]"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 76,
"name": "siblings",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 77,
"src": "708:23:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_array$_t_bytes32_$256_storage_$dyn_storage_ptr",
"typeString": "bytes32[256][]"
},
"typeName": {
"baseType": {
"baseType": {
"id": 72,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "708:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"id": 74,
"length": {
"argumentTypes": null,
"hexValue": "323536",
"id": 73,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "716:3:1",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_256_by_1",
"typeString": "int_const 256"
},
"value": "256"
},
"nodeType": "ArrayTypeName",
"src": "708:12:1",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$256_storage_ptr",
"typeString": "bytes32[256]"
}
},
"id": 75,
"length": null,
"nodeType": "ArrayTypeName",
"src": "708:14:1",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_array$_t_bytes32_$256_storage_$dyn_storage_ptr",
"typeString": "bytes32[256][]"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "RollUp",
"nodeType": "StructDefinition",
"scope": 522,
"src": "636:102:1",
"visibility": "public"
},
{
"canonicalName": "SMT256.OPRU",
"id": 84,
"members": [
{
"constant": false,
"id": 79,
"name": "prev",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 84,
"src": "766:12:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 78,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "766:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 81,
"name": "next",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 84,
"src": "788:12:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 80,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "788:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 83,
"name": "mergedLeaves",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 84,
"src": "810:20:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 82,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "810:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "OPRU",
"nodeType": "StructDefinition",
"scope": 522,
"src": "744:93:1",
"visibility": "public"
},
{
"body": {
"id": 104,
"nodeType": "Block",
"src": "983:64:1",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 98,
"name": "root",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 86,
"src": "1012:4:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
{
"argumentTypes": null,
"id": 99,
"name": "leaf",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 88,
"src": "1018:4:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
{
"argumentTypes": null,
"id": 100,
"name": "EXIST",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 63,
"src": "1024:5:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
{
"argumentTypes": null,
"id": 101,
"name": "siblings",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 92,
"src": "1031:8:1",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$256_memory_ptr",
"typeString": "bytes32[256] memory"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
{
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
{
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
{
"typeIdentifier": "t_array$_t_bytes32_$256_memory_ptr",
"typeString": "bytes32[256] memory"
}
],
"id": 97,
"name": "merkleProof",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 155,
"src": "1000:11:1",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_bytes32_$_t_bytes32_$_t_bytes32_$_t_array$_t_bytes32_$256_memory_ptr_$returns$_t_bool_$",
"typeString": "function (bytes32,bytes32,bytes32,bytes32[256] memory) pure returns (bool)"
}
},
"id": 102,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1000:40:1",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"functionReturnParameters": 96,
"id": 103,
"nodeType": "Return",
"src": "993:47:1"
}
]
},
"documentation": null,
"id": 105,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "inclusionProof",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 93,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 86,
"name": "root",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 105,
"src": "876:12:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 85,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "876:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 88,
"name": "leaf",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 105,
"src": "898:12:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 87,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "898:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 92,
"name": "siblings",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 105,
"src": "920:28:1",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$256_memory_ptr",
"typeString": "bytes32[256]"
},
"typeName": {
"baseType": {
"id": 89,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "920:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"id": 91,
"length": {
"argumentTypes": null,
"hexValue": "323536",
"id": 90,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "928:3:1",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_256_by_1",
"typeString": "int_const 256"
},
"value": "256"
},
"nodeType": "ArrayTypeName",
"src": "920:12:1",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$256_storage_ptr",
"typeString": "bytes32[256]"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "866:88:1"
},
"returnParameters": {
"id": 96,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 95,
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 105,
"src": "977:4:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 94,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "977:4:1",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "976:6:1"
},
"scope": 522,
"src": "843:204:1",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 125,
"nodeType": "Block",
"src": "1196:68:1",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 119,
"name": "root",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 107,
"src": "1225:4:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
{
"argumentTypes": null,
"id": 120,
"name": "leaf",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 109,
"src": "1231:4:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
{
"argumentTypes": null,
"id": 121,
"name": "NON_EXIST",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 66,
"src": "1237:9:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
{
"argumentTypes": null,
"id": 122,
"name": "siblings",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 113,
"src": "1248:8:1",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$256_memory_ptr",
"typeString": "bytes32[256] memory"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
{
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
{
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
{
"typeIdentifier": "t_array$_t_bytes32_$256_memory_ptr",
"typeString": "bytes32[256] memory"
}
],
"id": 118,
"name": "merkleProof",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 155,
"src": "1213:11:1",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_bytes32_$_t_bytes32_$_t_bytes32_$_t_array$_t_bytes32_$256_memory_ptr_$returns$_t_bool_$",
"typeString": "function (bytes32,bytes32,bytes32,bytes32[256] memory) pure returns (bool)"
}
},
"id": 123,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1213:44:1",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"functionReturnParameters": 117,
"id": 124,
"nodeType": "Return",
"src": "1206:51:1"
}
]
},
"documentation": null,
"id": 126,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "nonInclusionProof",
"nodeType": "FunctionDefinition",
"overrides": null,
"parameters": {
"id": 114,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 107,
"name": "root",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 126,
"src": "1089:12:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 106,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "1089:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 109,
"name": "leaf",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 126,
"src": "1111:12:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"typeName": {
"id": 108,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "1111:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 113,
"name": "siblings",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 126,
"src": "1133:28:1",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$256_memory_ptr",
"typeString": "bytes32[256]"
},
"typeName": {
"baseType": {
"id": 110,
"name": "bytes32",
"nodeType": "ElementaryTypeName",
"src": "1133:7:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"id": 112,
"length": {
"argumentTypes": null,
"hexValue": "323536",
"id": 111,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1141:3:1",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_256_by_1",
"typeString": "int_const 256"
},
"value": "256"
},
"nodeType": "ArrayTypeName",
"src": "1133:12:1",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$256_storage_ptr",
"typeString": "bytes32[256]"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1079:88:1"
},
"returnParameters": {
"id": 117,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 116,
"name": "",
"nodeType": "VariableDeclaration",
"overrides": null,
"scope": 126,
"src": "1190:4:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 115,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "1190:4:1",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "1189:6:1"
},
"scope": 522,
"src": "1053:211:1",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
},
{
"body": {
"id": 154,
"nodeType": "Block",
"src": "1430:115:1",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
"id": 148,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 143,
"name": "leaf",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 130,
"src": "1462:4:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
{
"argumentTypes": null,
"id": 144,
"name": "value",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 132,
"src": "1468:5:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
{
"argumentTypes": null,
"id": 145,
"name": "siblings",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 136,
"src": "1475:8:1",
"typeDescriptions": {
"typeIdentifier": "t_array$_t_bytes32_$256_memory_ptr",
"typeString": "bytes32[256] memory"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
{
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
},
{
"typeIdentifier": "t_array$_t_bytes32_$256_memory_ptr",
"typeString": "bytes32[256] memory"
}
],
"id": 142,
"name": "calculateRoot",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 233,
"src": "1448:13:1",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_bytes32_$_t_bytes32_$_t_array$_t_bytes32_$256_memory_ptr_$returns$_t_bytes32_$",
"typeString": "function (bytes32,bytes32,bytes32[256] memory) pure returns (bytes32)"
}
},
"id": 146,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1448:36:1",
"tryCall": false,
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"id": 147,
"name": "root",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 128,
"src": "1488:4:1",
"typeDescriptions": {
"typeIdentifier": "t_bytes32",
"typeString": "bytes32"
}
},
"src": "1448:44:1",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
{
"argumentTypes": null,
"hexValue": "496e76616c6964206d65726b6c652070726f6f66",
"id": 149,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1494:22:1",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_9e0b6a3c3c2892dcc46975fd4747d409a6200f0f6763c4000ee1783c7e6b5410",
"typeString": "literal_string \"Invalid merkle proof\""
},
"value": "Invalid merkle proof"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
},
{
"typeIdentifier": "t_stringliteral_9e0b6a3c3c2892dcc46975fd4747d409a6200f0f6763c4000ee1783c7e6b5410",
"typeString": "literal_string \"Invalid merkle proof\""