{
    "Function": "slitherConstructorConstantVariables",
    "File": "contracts/auth/AxelarAuthWeighted.sol",
    "Parent Contracts": [
        "contracts/interfaces/IAxelarAuthWeighted.sol",
        "contracts/interfaces/IAxelarAuth.sol",
        "contracts/Ownable.sol",
        "contracts/interfaces/IOwnable.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract AxelarAuthWeighted is Ownable, IAxelarAuthWeighted {\n    uint256 public currentEpoch;\n    mapping(uint256 => bytes32) public hashForEpoch;\n    mapping(bytes32 => uint256) public epochForHash;\n\n    uint8 internal constant OLD_KEY_RETENTION = 16;\n\n    constructor(bytes[] memory recentOperators) {\n        for (uint256 i; i < recentOperators.length; ++i) {\n            _transferOperatorship(recentOperators[i]);\n        }\n    }\n\n    /**************************\\\n    |* External Functionality *|\n    \\**************************/\n\n    function validateProof(bytes32 messageHash, bytes calldata proof) external view returns (bool currentOperators) {\n        (address[] memory operators, uint256[] memory weights, uint256 threshold, bytes[] memory signatures) = abi.decode(\n            proof,\n            (address[], uint256[], uint256, bytes[])\n        );\n\n        bytes32 operatorsHash = keccak256(abi.encode(operators, weights, threshold));\n        uint256 operatorsEpoch = epochForHash[operatorsHash];\n        uint256 epoch = currentEpoch;\n\n        if (operatorsEpoch == 0 || epoch - operatorsEpoch >= OLD_KEY_RETENTION) revert InvalidOperators();\n\n        _validateSignatures(messageHash, operators, weights, threshold, signatures);\n\n        currentOperators = operatorsEpoch == epoch;\n    }\n\n    /***********************\\\n    |* Owner Functionality *|\n    \\***********************/\n\n    function transferOperatorship(bytes calldata params) external onlyOwner {\n        _transferOperatorship(params);\n    }\n\n    /**************************\\\n    |* Internal Functionality *|\n    \\**************************/\n\n    function _transferOperatorship(bytes memory params) internal {\n        (address[] memory newOperators, uint256[] memory newWeights, uint256 newThreshold) = abi.decode(\n            params,\n            (address[], uint256[], uint256)\n        );\n        uint256 operatorsLength = newOperators.length;\n        uint256 weightsLength = newWeights.length;\n\n        // operators must be sorted binary or alphabetically in lower case\n        if (operatorsLength == 0 || !_isSortedAscAndContainsNoDuplicate(newOperators)) revert InvalidOperators();\n\n        if (weightsLength != operatorsLength) revert InvalidWeights();\n\n        uint256 totalWeight = 0;\n        for (uint256 i = 0; i < weightsLength; ++i) {\n            totalWeight += newWeights[i];\n        }\n        if (newThreshold == 0 || totalWeight < newThreshold) revert InvalidThreshold();\n\n        bytes32 newOperatorsHash = keccak256(params);\n\n        if (epochForHash[newOperatorsHash] > 0) revert SameOperators();\n\n        uint256 epoch = currentEpoch + 1;\n        currentEpoch = epoch;\n        hashForEpoch[epoch] = newOperatorsHash;\n        epochForHash[newOperatorsHash] = epoch;\n\n        emit OperatorshipTransferred(newOperators, newWeights, newThreshold);\n    }\n\n    function _validateSignatures(\n        bytes32 messageHash,\n        address[] memory operators,\n        uint256[] memory weights,\n        uint256 threshold,\n        bytes[] memory signatures\n    ) internal pure {\n        uint256 operatorsLength = operators.length;\n        uint256 operatorIndex = 0;\n        uint256 weight = 0;\n        // looking for signers within operators\n        // assuming that both operators and signatures are sorted\n        for (uint256 i = 0; i < signatures.length; ++i) {\n            address signer = ECDSA.recover(messageHash, signatures[i]);\n            // looping through remaining operators to find a match\n            for (; operatorIndex < operatorsLength && signer != operators[operatorIndex]; ++operatorIndex) {}\n            // checking if we are out of operators\n            if (operatorIndex == operatorsLength) revert MalformedSigners();\n            // return if weight sum above threshold\n            weight += weights[operatorIndex];\n            // weight needs to reach or surpass threshold\n            if (weight >= threshold) return;\n            // increasing operators index if match was found\n            ++operatorIndex;\n        }\n        // if weight sum below threshold\n        revert MalformedSigners();\n    }\n\n    function _isSortedAscAndContainsNoDuplicate(address[] memory accounts) internal pure returns (bool) {\n        for (uint256 i; i < accounts.length - 1; ++i) {\n            if (accounts[i] >= accounts[i + 1]) {\n                return false;\n            }\n        }\n\n        return accounts[0] != address(0);\n    }\n}"
}