{
    "Function": "verifyWithdrawalProofs",
    "File": "src/contracts/libraries/BeaconChainProofs.sol",
    "Parent Contracts": [],
    "High-Level Calls": [
        "Merkle",
        "Merkle",
        "Merkle",
        "Merkle",
        "Merkle",
        "Merkle"
    ],
    "Internal Calls": [
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)"
    ],
    "Library Calls": [
        "verifyInclusionSha256",
        "verifyInclusionSha256",
        "verifyInclusionSha256",
        "merkleizeSha256",
        "verifyInclusionSha256",
        "verifyInclusionSha256"
    ],
    "Low-Level Calls": [],
    "Code": "function verifyWithdrawalProofs(\n        bytes32 beaconStateRoot,\n        WithdrawalProofs calldata proofs,\n        bytes32[] calldata withdrawalFields\n    ) internal view {\n        require(withdrawalFields.length == 2**WITHDRAWAL_FIELD_TREE_HEIGHT, \"BeaconChainProofs.verifyWithdrawalProofs: withdrawalFields has incorrect length\");\n\n        require(proofs.blockHeaderRootIndex < 2**BLOCK_ROOTS_TREE_HEIGHT, \"BeaconChainProofs.verifyWithdrawalProofs: blockRootIndex is too large\");\n        require(proofs.withdrawalIndex < 2**WITHDRAWALS_TREE_HEIGHT, \"BeaconChainProofs.verifyWithdrawalProofs: withdrawalIndex is too large\");\n       \n        // verify the block header proof length\n        require(proofs.blockHeaderProof.length == 32 * (BEACON_STATE_FIELD_TREE_HEIGHT + BLOCK_ROOTS_TREE_HEIGHT),\n            \"BeaconChainProofs.verifyWithdrawalProofs: blockHeaderProof has incorrect length\");\n        require(proofs.withdrawalProof.length == 32 * (EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT + WITHDRAWALS_TREE_HEIGHT + 1),\n            \"BeaconChainProofs.verifyWithdrawalProofs: withdrawalProof has incorrect length\");\n        require(proofs.executionPayloadProof.length == 32 * (BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT + BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT),\n            \"BeaconChainProofs.verifyWithdrawalProofs: executionPayloadProof has incorrect length\");\n\n        /**\n         * Computes the block_header_index relative to the beaconStateRoot.  It concatenates the indexes of all the\n         * intermediate root indexes from the bottom of the sub trees (the block header container) to the top of the tree\n         */\n        uint256 blockHeaderIndex = BLOCK_ROOTS_INDEX << (BLOCK_ROOTS_TREE_HEIGHT)  | uint256(proofs.blockHeaderRootIndex);\n        // Verify the blockHeaderRoot against the beaconStateRoot\n        require(Merkle.verifyInclusionSha256(proofs.blockHeaderProof, beaconStateRoot, proofs.blockHeaderRoot, blockHeaderIndex),\n            \"BeaconChainProofs.verifyWithdrawalProofs: Invalid block header merkle proof\");\n\n        //Next we verify the slot against the blockHeaderRoot\n        require(Merkle.verifyInclusionSha256(proofs.slotProof, proofs.blockHeaderRoot, proofs.slotRoot, SLOT_INDEX), \"BeaconChainProofs.verifyWithdrawalProofs: Invalid slot merkle proof\");\n\n        // Next we verify the executionPayloadRoot against the blockHeaderRoot\n        uint256 executionPayloadIndex = BODY_ROOT_INDEX << (BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT)| EXECUTION_PAYLOAD_INDEX ;\n        require(Merkle.verifyInclusionSha256(proofs.executionPayloadProof, proofs.blockHeaderRoot, proofs.executionPayloadRoot, executionPayloadIndex),\n            \"BeaconChainProofs.verifyWithdrawalProofs: Invalid executionPayload merkle proof\");\n\n        // Next we verify the blockNumberRoot against the executionPayload root\n        require(Merkle.verifyInclusionSha256(proofs.blockNumberProof, proofs.executionPayloadRoot, proofs.blockNumberRoot, BLOCK_NUMBER_INDEX),\n            \"BeaconChainProofs.verifyWithdrawalProofs: Invalid blockNumber merkle proof\");\n\n        /**\n         * Next we verify the withdrawal fields against the blockHeaderRoot:\n         * First we compute the withdrawal_index relative to the blockHeaderRoot by concatenating the indexes of all the \n         * intermediate root indexes from the bottom of the sub trees (the withdrawal container) to the top, the blockHeaderRoot.\n         * Then we calculate merkleize the withdrawalFields container to calculate the the withdrawalRoot.\n         * Finally we verify the withdrawalRoot against the executionPayloadRoot.\n         */\n        uint256 withdrawalIndex = WITHDRAWALS_INDEX << (WITHDRAWALS_TREE_HEIGHT + 1) | uint256(proofs.withdrawalIndex);\n        bytes32 withdrawalRoot = Merkle.merkleizeSha256(withdrawalFields);\n        require(Merkle.verifyInclusionSha256(proofs.withdrawalProof, proofs.executionPayloadRoot, withdrawalRoot, withdrawalIndex),\n            \"BeaconChainProofs.verifyWithdrawalProofs: Invalid withdrawal merkle proof\");\n    }"
}