creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/OperationsCoordinator.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\nimport { PufferOracleV2 } from \"puffer/PufferOracleV2.sol\";\nimport { AccessManaged } from \"openzeppelin/access/manager/AccessManaged.sol\";\n\n/**\n * @title OperationsCoordinator\n * @author Puffer Finance\n * @custom:security-contact security@puffer.fi\n */\ncontract OperationsCoordinator is AccessManaged {\n    /**\n     * @notice Thrown if the new price is out of range\n     */\n    error InvalidPrice();\n\n    /**\n     * @notice Thrown if the new price change tolerance is out of range\n     */\n    error InvalidPriceChangeToleranceBPS();\n\n    /**\n     * @dev Emitted when the price change tolerance is updated\n     * @param oldValue the old tolerance value\n     * @param newValue the new tolerance value\n     */\n    event PriceChangeToleranceBPSUpdated(uint256 oldValue, uint256 newValue);\n\n    uint256 internal constant _BPS_DECIMALS = 1e4; // 100%\n\n    PufferOracleV2 internal immutable _ORACLE;\n\n    uint256 internal _priceChangeToleranceBps;\n\n    constructor(PufferOracleV2 oracle, address accessManager, uint256 priceChangeToleranceBps)\n        AccessManaged(accessManager)\n    {\n        _ORACLE = oracle;\n        _priceChangeToleranceBps = priceChangeToleranceBps;\n    }\n\n    /**\n     * @notice Updates the allowed price change tolerance percentage\n     * @dev Restricted to the Operations Multisig\n     */\n    function setPriceChangeToleranceBps(uint256 newValue) external restricted {\n        if (newValue > _BPS_DECIMALS) {\n            revert InvalidPriceChangeToleranceBPS();\n        }\n\n        emit PriceChangeToleranceBPSUpdated(_priceChangeToleranceBps, newValue);\n\n        _priceChangeToleranceBps = newValue;\n    }\n\n    /**\n     * @notice Updates the VT mint price on the PufferOracle\n     * @dev Restricted to the Puffer Paymaster\n     */\n    function setValidatorTicketMintPrice(uint256 newPrice) external restricted {\n        if (newPrice == 0) {\n            revert InvalidPrice();\n        }\n\n        if (!isWithinRange(newPrice)) {\n            revert InvalidPrice();\n        }\n\n        _ORACLE.setMintPrice(newPrice);\n    }\n\n    /**\n     * @notice Returns the current price change tolerance in basis points\n     * @return the current price change tolerance\n     */\n    function getPriceChangeToleranceBps() external view returns (uint256) {\n        return _priceChangeToleranceBps;\n    }\n\n    /**\n     * @notice Checks if the new price is within the allowed range\n     * @param newPrice The new price to set for minting VT\n     * @return true if the new price is within the allowed range\n     */\n    function isWithinRange(uint256 newPrice) public view returns (bool) {\n        uint256 oldPrice = _ORACLE.getValidatorTicketPrice();\n        uint256 allowedDifference = (oldPrice * _priceChangeToleranceBps) / _BPS_DECIMALS;\n\n        // Addition and subtraction have bigger precedence than comparison\n        // https://docs.soliditylang.org/en/latest/cheatsheet.html\n        if (newPrice > oldPrice) {\n            return newPrice <= oldPrice + allowedDifference;\n        }\n\n        return newPrice >= oldPrice - allowedDifference;\n    }\n}\n"
      },
      "src/PufferOracleV2.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\nimport { IGuardianModule } from \"puffer/interface/IGuardianModule.sol\";\nimport { IPufferOracleV2 } from \"puffer/interface/IPufferOracleV2.sol\";\nimport { IPufferOracle } from \"pufETH/interface/IPufferOracle.sol\";\nimport { AccessManaged } from \"@openzeppelin/contracts/access/manager/AccessManaged.sol\";\n\n/**\n * @title PufferOracle\n * @author Puffer Finance\n * @custom:security-contact security@puffer.fi\n */\ncontract PufferOracleV2 is IPufferOracleV2, AccessManaged {\n    /**\n     * @dev Burst threshold\n     */\n    uint256 internal constant _BURST_THRESHOLD = 22;\n\n    /**\n     * @notice Guardian Module\n     */\n    IGuardianModule public immutable GUARDIAN_MODULE;\n\n    /**\n     * @notice Puffer Vault\n     */\n    address payable public immutable PUFFER_VAULT;\n\n    /**\n     * @dev Number of active Puffer validators\n     * Slot 0\n     */\n    uint64 internal _numberOfActivePufferValidators;\n\n    /**\n     * @dev Total number of Validators\n     * Slot 0\n     */\n    uint64 internal _totalNumberOfValidators;\n    /**\n     * @dev Epoch number of the update\n     * Slot 0\n     */\n    uint64 internal _epochNumber;\n\n    /**\n     * @dev Price in wei to mint one Validator Ticket\n     * Slot 1\n     */\n    uint256 internal _validatorTicketPrice;\n\n    constructor(IGuardianModule guardianModule, address payable vault, address accessManager)\n        AccessManaged(accessManager)\n    {\n        GUARDIAN_MODULE = guardianModule;\n        PUFFER_VAULT = vault;\n        _totalNumberOfValidators = 927122; // Oracle will be updated with the correct value\n        _epochNumber = 268828; // Oracle will be updated with the correct value\n        _setMintPrice(0.01 ether);\n    }\n\n    /**\n     * @notice Exits the validator from the Beacon chain\n     * @dev Restricted to PufferProtocol contract\n     */\n    function exitValidators(uint256 numberOfExits) public restricted {\n        _numberOfActivePufferValidators -= uint64(numberOfExits);\n        emit NumberOfActiveValidators(_numberOfActivePufferValidators);\n    }\n\n    /**\n     * @notice Increases the locked eth amount amount on the Oracle by 32 ETH\n     * It is called when the Beacon chain receives a new deposit from PufferProtocol\n     * The PufferVault balance is decreased by the same amount\n     * @dev Restricted to PufferProtocol contract\n     */\n    function provisionNode() external restricted {\n        unchecked {\n            ++_numberOfActivePufferValidators;\n        }\n        emit NumberOfActiveValidators(_numberOfActivePufferValidators);\n    }\n\n    /**\n     * @notice Updates the price to mint VT\n     * @param newPrice The new price to set for minting VT\n     * @dev Restricted to the DAO\n     */\n    function setMintPrice(uint256 newPrice) external restricted {\n        _setMintPrice(newPrice);\n    }\n\n    /**\n     * @notice Updates the total number of validators\n     * @param newTotalNumberOfValidators The new number of validators\n     */\n    function setTotalNumberOfValidators(\n        uint256 newTotalNumberOfValidators,\n        uint256 epochNumber,\n        bytes[] calldata guardianEOASignatures\n    ) external restricted {\n        if (epochNumber <= _epochNumber) {\n            revert InvalidUpdate();\n        }\n        GUARDIAN_MODULE.validateTotalNumberOfValidators(newTotalNumberOfValidators, epochNumber, guardianEOASignatures);\n        emit TotalNumberOfValidatorsUpdated(_totalNumberOfValidators, newTotalNumberOfValidators, epochNumber);\n        _totalNumberOfValidators = uint64(newTotalNumberOfValidators);\n        _epochNumber = uint64(epochNumber);\n    }\n\n    /**\n     * @inheritdoc IPufferOracle\n     */\n    function getLockedEthAmount() external view returns (uint256) {\n        return _numberOfActivePufferValidators * 32 ether;\n    }\n\n    /**\n     * @inheritdoc IPufferOracleV2\n     */\n    function getTotalNumberOfValidators() external view returns (uint256) {\n        return _totalNumberOfValidators;\n    }\n\n    /**\n     * @inheritdoc IPufferOracle\n     */\n    function isOverBurstThreshold() external view returns (bool) {\n        return ((_numberOfActivePufferValidators * 100 / _totalNumberOfValidators) > _BURST_THRESHOLD);\n    }\n\n    /**\n     * @inheritdoc IPufferOracle\n     */\n    function getValidatorTicketPrice() external view returns (uint256) {\n        return _validatorTicketPrice;\n    }\n\n    function _setMintPrice(uint256 newPrice) internal {\n        emit ValidatorTicketMintPriceUpdated(_validatorTicketPrice, newPrice);\n        _validatorTicketPrice = newPrice;\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/access/manager/AccessManaged.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/manager/AccessManaged.sol)\n\npragma solidity ^0.8.20;\n\nimport {IAuthority} from \"./IAuthority.sol\";\nimport {AuthorityUtils} from \"./AuthorityUtils.sol\";\nimport {IAccessManager} from \"./IAccessManager.sol\";\nimport {IAccessManaged} from \"./IAccessManaged.sol\";\nimport {Context} from \"../../utils/Context.sol\";\n\n/**\n * @dev This contract module makes available a {restricted} modifier. Functions decorated with this modifier will be\n * permissioned according to an \"authority\": a contract like {AccessManager} that follows the {IAuthority} interface,\n * implementing a policy that allows certain callers to access certain functions.\n *\n * IMPORTANT: The `restricted` modifier should never be used on `internal` functions, judiciously used in `public`\n * functions, and ideally only used in `external` functions. See {restricted}.\n */\nabstract contract AccessManaged is Context, IAccessManaged {\n    address private _authority;\n\n    bool private _consumingSchedule;\n\n    /**\n     * @dev Initializes the contract connected to an initial authority.\n     */\n    constructor(address initialAuthority) {\n        _setAuthority(initialAuthority);\n    }\n\n    /**\n     * @dev Restricts access to a function as defined by the connected Authority for this contract and the\n     * caller and selector of the function that entered the contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * In general, this modifier should only be used on `external` functions. It is okay to use it on `public`\n     * functions that are used as external entry points and are not called internally. Unless you know what you're\n     * doing, it should never be used on `internal` functions. Failure to follow these rules can have critical security\n     * implications! This is because the permissions are determined by the function that entered the contract, i.e. the\n     * function at the bottom of the call stack, and not the function where the modifier is visible in the source code.\n     * ====\n     *\n     * [WARNING]\n     * ====\n     * Avoid adding this modifier to the https://docs.soliditylang.org/en/v0.8.20/contracts.html#receive-ether-function[`receive()`]\n     * function or the https://docs.soliditylang.org/en/v0.8.20/contracts.html#fallback-function[`fallback()`]. These\n     * functions are the only execution paths where a function selector cannot be unambiguosly determined from the calldata\n     * since the selector defaults to `0x00000000` in the `receive()` function and similarly in the `fallback()` function\n     * if no calldata is provided. (See {_checkCanCall}).\n     *\n     * The `receive()` function will always panic whereas the `fallback()` may panic depending on the calldata length.\n     * ====\n     */\n    modifier restricted() {\n        _checkCanCall(_msgSender(), _msgData());\n        _;\n    }\n\n    /// @inheritdoc IAccessManaged\n    function authority() public view virtual returns (address) {\n        return _authority;\n    }\n\n    /// @inheritdoc IAccessManaged\n    function setAuthority(address newAuthority) public virtual {\n        address caller = _msgSender();\n        if (caller != authority()) {\n            revert AccessManagedUnauthorized(caller);\n        }\n        if (newAuthority.code.length == 0) {\n            revert AccessManagedInvalidAuthority(newAuthority);\n        }\n        _setAuthority(newAuthority);\n    }\n\n    /// @inheritdoc IAccessManaged\n    function isConsumingScheduledOp() public view returns (bytes4) {\n        return _consumingSchedule ? this.isConsumingScheduledOp.selector : bytes4(0);\n    }\n\n    /**\n     * @dev Transfers control to a new authority. Internal function with no access restriction. Allows bypassing the\n     * permissions set by the current authority.\n     */\n    function _setAuthority(address newAuthority) internal virtual {\n        _authority = newAuthority;\n        emit AuthorityUpdated(newAuthority);\n    }\n\n    /**\n     * @dev Reverts if the caller is not allowed to call the function identified by a selector. Panics if the calldata\n     * is less than 4 bytes long.\n     */\n    function _checkCanCall(address caller, bytes calldata data) internal virtual {\n        (bool immediate, uint32 delay) = AuthorityUtils.canCallWithDelay(\n            authority(),\n            caller,\n            address(this),\n            bytes4(data[0:4])\n        );\n        if (!immediate) {\n            if (delay > 0) {\n                _consumingSchedule = true;\n                IAccessManager(authority()).consumeScheduledOp(caller, data);\n                _consumingSchedule = false;\n            } else {\n                revert AccessManagedUnauthorized(caller);\n            }\n        }\n    }\n}\n"
      },
      "src/interface/IGuardianModule.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\nimport { RaveEvidence } from \"puffer/struct/RaveEvidence.sol\";\nimport { IEnclaveVerifier } from \"puffer/EnclaveVerifier.sol\";\nimport { StoppedValidatorInfo } from \"puffer/struct/StoppedValidatorInfo.sol\";\n\n/**\n * @title IGuardianModule interface\n * @author Puffer Finance\n */\ninterface IGuardianModule {\n    /**\n     * @notice Thrown when the ECDSA public key is not valid\n     * @dev Signature \"0xe3eece5a\"\n     */\n    error InvalidECDSAPubKey();\n\n    /**\n     * @notice Thrown when the RAVE evidence is not valid\n     * @dev Signature \"0x2b3c629b\"\n     */\n    error InvalidRAVE();\n\n    /**\n     * @notice Thrown if the threshold value is not valid\n     * @dev Signature \"0x651a749b\"\n     */\n    error InvalidThreshold(uint256 threshold);\n\n    /**\n     * @notice Emitted when the ejection threshold is changed\n     * @param oldThreshold is the old threshold value\n     * @param newThreshold is the new threshold value\n     * @dev Signature \"0x4ae5122a691bf14917d273c6a81956e1f521b3e39f2d0c6d963117bf9c820e83\"\n     */\n    event EjectionThresholdChanged(uint256 oldThreshold, uint256 newThreshold);\n\n    /**\n     * @notice Emitted when the threshold value for guardian signatures is changed\n     * @param oldThreshold is the old threshold value\n     * @param newThreshold is the new threshold value\n     * @dev Signature \"0x3164947cf0f49f08dd0cd80e671535b1e11590d347c55dcaa97ba3c24a96b33a\"\n     */\n    event ThresholdChanged(uint256 oldThreshold, uint256 newThreshold);\n\n    /**\n     * @notice Emitted when a guardian is added to the module\n     * @param guardian The address of the guardian added\n     * @dev Signature \"0x038596bb31e2e7d3d9f184d4c98b310103f6d7f5830e5eec32bffe6f1728f969\"\n     */\n    event GuardianAdded(address guardian);\n\n    /**\n     * @notice Emitted when a guardian is removed from the module\n     * @param guardian The address of the guardian removed\n     * @dev Signature \"0xb8107d0c6b40be480ce3172ee66ba6d64b71f6b1685a851340036e6e2e3e3c52\"\n     */\n    event GuardianRemoved(address guardian);\n\n    /**\n     * @notice Emitted when the guardian changes guardian enclave address\n     * @param guardian is the address outside of the enclave\n     * @param guardianEnclave is the enclave address\n     * @param pubKey is the public key\n     * @dev Signature \"0x14720919b20fceff2a396c4973d37c6087e4619d40c8f4003d8e44ee127461a2\"\n     */\n    event RotatedGuardianKey(address guardian, address guardianEnclave, bytes pubKey);\n\n    /**\n     * @notice Emitted when the mrenclave value is changed\n     * @dev Signature \"0x1ff2c57ef9a384cea0c482d61fec8d708967d266f03266e301c6786f7209904a\"\n     */\n    event MrEnclaveChanged(bytes32 oldMrEnclave, bytes32 newMrEnclave);\n\n    /**\n     * @notice Emitted when the mrsigner value is changed\n     * @dev Signature \"0x1a1fe271c5533136fccd1c6df515ca1f227d95822bfe78b9dd93debf3d709ae6\"\n     */\n    event MrSignerChanged(bytes32 oldMrSigner, bytes32 newMrSigner);\n\n    /**\n     * @notice Returns the enclave address registered to `guardian`\n     */\n    function getGuardiansEnclaveAddress(address guardian) external view returns (address);\n\n    /**\n     * @notice Returns the ejection threshold ETH value\n     * @dev The ejection threshold is the minimum amount of ETH on the beacon chain required do the validation duties\n     * If it drops below this value, the validator will be ejected\n     * It is more likely that the validator will run out of Validator Tickets before its balance drops below this value\n     * @return The ejection threshold value\n     */\n    function getEjectionThreshold() external view returns (uint256);\n\n    /**\n     * @notice Sets the values for mrEnclave and mrSigner to `newMrenclave` and `newMrsigner`\n     */\n    function setGuardianEnclaveMeasurements(bytes32 newMrenclave, bytes32 newMrsigner) external;\n\n    /**\n     * @notice Validates the update of the number of validators\n     */\n    function validateTotalNumberOfValidators(\n        uint256 newNumberOfValidators,\n        uint256 epochNumber,\n        bytes[] calldata guardianEOASignatures\n    ) external view;\n\n    /**\n     * @notice Returns the enclave verifier\n     */\n    function ENCLAVE_VERIFIER() external view returns (IEnclaveVerifier);\n\n    /**\n     * @notice Validates the batch withdrawals calldata\n     * @dev The order of the signatures is important\n     * The order of the signatures MUST the same as the order of the validators in the validator module\n     * @param validatorInfos The information of the stopped validators\n     * @param guardianEOASignatures The guardian EOA signatures\n     */\n    function validateBatchWithdrawals(\n        StoppedValidatorInfo[] calldata validatorInfos,\n        bytes[] calldata guardianEOASignatures\n    ) external;\n\n    /**\n     * @notice Validates the node provisioning calldata\n     * @dev The order of the signatures is important\n     * The order of the signatures MUST the same as the order of the guardians in the guardian module\n     * @param pufferModuleIndex is the validator index in Puffer\n     * @param pubKey The public key\n     * @param signature The signature\n     * @param withdrawalCredentials The withdrawal credentials\n     * @param depositDataRoot The deposit data root\n     * @param guardianEnclaveSignatures The guardian enclave signatures\n     */\n    function validateProvisionNode(\n        uint256 pufferModuleIndex,\n        bytes memory pubKey,\n        bytes calldata signature,\n        bytes calldata withdrawalCredentials,\n        bytes32 depositDataRoot,\n        bytes[] calldata guardianEnclaveSignatures\n    ) external view;\n\n    /**\n     * @notice Validates the skipping of provisioning for a specific module\n     * @param moduleName The name of the module\n     * @param skippedIndex The index of the skipped provisioning\n     * @param guardianEOASignatures The guardian EOA signatures\n     */\n    function validateSkipProvisioning(bytes32 moduleName, uint256 skippedIndex, bytes[] calldata guardianEOASignatures)\n        external\n        view;\n\n    /**\n     * @notice Returns the threshold value for guardian signatures\n     * @dev The threshold value is the minimum number of guardian signatures required for a transaction to be considered valid\n     * @return The threshold value\n     */\n    function getThreshold() external view returns (uint256);\n\n    /**\n     * @notice Returns the list of guardians\n     * @dev This function returns an array of addresses representing the guardians\n     * @return An array of addresses representing the guardians\n     */\n    function getGuardians() external view returns (address[] memory);\n\n    /**\n     * @notice Adds a new guardian to the module\n     * @dev Restricted to the DAO\n     * @param newGuardian The address of the new guardian to add\n     */\n    function addGuardian(address newGuardian) external;\n\n    /**\n     * @notice Removes a guardian from the module\n     * @dev Restricted to the DAO\n     * @param guardian The address of the guardian to remove\n     */\n    function removeGuardian(address guardian) external;\n\n    /**\n     * @notice Changes the threshold value for the guardian signatures\n     * @dev Restricted to the DAO\n     * @param newThreshold The new threshold value\n     */\n    function setThreshold(uint256 newThreshold) external;\n\n    /**\n     * @notice Changes the ejection threshold value\n     * @dev Restricted to the DAO\n     * @param newThreshold The new threshold value\n     */\n    function setEjectionThreshold(uint256 newThreshold) external;\n\n    /**\n     * @dev Validates the signatures of the guardians' enclave signatures\n     * @param enclaveSignatures The array of enclave signatures\n     * @param signedMessageHash The hash of the signed message\n     * @return A boolean indicating whether the signatures are valid\n     */\n    function validateGuardiansEnclaveSignatures(bytes[] calldata enclaveSignatures, bytes32 signedMessageHash)\n        external\n        view\n        returns (bool);\n\n    /**\n     * @dev Validates the signatures of the guardians' EOAs.\n     * @param eoaSignatures The array of EOAs' signatures.\n     * @param signedMessageHash The hash of the signed message.\n     * @return A boolean indicating whether the signatures are valid.\n     */\n    function validateGuardiansEOASignatures(bytes[] calldata eoaSignatures, bytes32 signedMessageHash)\n        external\n        view\n        returns (bool);\n\n    /**\n     * @notice Rotates guardian's key\n     * @dev If he caller is not a valid guardian or if the RAVE evidence is not valid the tx will revert\n     * @param blockNumber is the block number\n     * @param pubKey is the public key of the new signature\n     * @param evidence is the RAVE evidence\n     */\n    function rotateGuardianKey(uint256 blockNumber, bytes calldata pubKey, RaveEvidence calldata evidence) external;\n\n    /**\n     * @notice Returns the guardians enclave addresses\n     */\n    function getGuardiansEnclaveAddresses() external view returns (address[] memory);\n\n    /**\n     * @notice Returns the guardians enclave public keys\n     */\n    function getGuardiansEnclavePubkeys() external view returns (bytes[] memory);\n\n    /**\n     * @notice Checks if an account is a guardian\n     * @param account The address to check\n     * @return A boolean indicating whether the account is a guardian\n     */\n    function isGuardian(address account) external view returns (bool);\n\n    /**\n     * @notice Returns the mrenclave value\n     */\n    function getMrenclave() external view returns (bytes32);\n\n    /**\n     * @notice Returns the mrsigner value\n     */\n    function getMrsigner() external view returns (bytes32);\n}\n"
      },
      "src/interface/IPufferOracleV2.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\nimport { IPufferOracle } from \"pufETH/interface/IPufferOracle.sol\";\n\n/**\n * @title IPufferOracle\n * @author Puffer Finance\n * @custom:security-contact security@puffer.fi\n */\ninterface IPufferOracleV2 is IPufferOracle {\n    error InvalidUpdate();\n    /**\n     * @notice Emitted when the number of active Puffer validators is updated\n     * @param numberOfActivePufferValidators is the number of active Puffer validators\n     */\n\n    event NumberOfActiveValidators(uint256 numberOfActivePufferValidators);\n\n    /**\n     * @notice Emitted when the total number of validators is updated\n     * @param oldNumberOfValidators is the old number of validators\n     * @param newNumberOfValidators is the new number of validators\n     */\n    event TotalNumberOfValidatorsUpdated(\n        uint256 oldNumberOfValidators, uint256 newNumberOfValidators, uint256 epochNumber\n    );\n\n    /**\n     * @notice Returns the total number of active validators on Ethereum\n     */\n    function getTotalNumberOfValidators() external view returns (uint256);\n\n    /**\n     * @notice Exits `validatorNumber` validators, decreasing the `lockedETHAmount` by validatorNumber * 32 ETH.\n     * It is called when when the validator exits the system in the `batchHandleWithdrawals` on the PufferProtocol.\n     * In the same transaction, we are transferring full withdrawal ETH from the PufferModule to the Vault\n     * Decrementing the `lockedETHAmount` by 32 ETH and we burn the Node Operator's pufETH (bond) if we need to cover up the loss.\n     * @dev Restricted to PufferProtocol contract\n     */\n    function exitValidators(uint256 validatorNumber) external;\n\n    /**\n     * @notice Increases the `lockedETHAmount` on the PufferOracle by 32 ETH to account for a new deposit.\n     * It is called when the Beacon chain receives a new deposit from the PufferProtocol.\n     * The PufferVault's balance will simultaneously decrease by 32 ETH as the deposit is made.\n     * @dev Restricted to PufferProtocol contract\n     */\n    function provisionNode() external;\n}\n"
      },
      "lib/pufETH/src/interface/IPufferOracle.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\n/**\n * @title IPufferOracle\n * @author Puffer Finance\n * @custom:security-contact security@puffer.fi\n */\ninterface IPufferOracle {\n    /**\n     * @notice Thrown if the new ValidatorTicket mint price is invalid\n     */\n    error InvalidValidatorTicketPrice();\n\n    /**\n     * @notice Emitted when the price to mint ValidatorTicket is updated\n     * @dev Signature \"0xf76811fec27423d0853e6bf49d7ea78c666629c2f67e29647d689954021ae0ea\"\n     */\n    event ValidatorTicketMintPriceUpdated(uint256 oldPrice, uint256 newPrice);\n\n    /**\n     * @notice Retrieves the current mint price for minting one ValidatorTicket\n     * @return pricePerVT The current ValidatorTicket mint price\n     */\n    function getValidatorTicketPrice() external view returns (uint256 pricePerVT);\n\n    /**\n     * @notice Returns true if the number of active Puffer Validators is over the burst threshold\n     */\n    function isOverBurstThreshold() external view returns (bool);\n\n    /**\n     * @notice Returns the locked ETH amount\n     * @return lockedEthAmount The amount of ETH locked in Beacon chain\n     */\n    function getLockedEthAmount() external view returns (uint256 lockedEthAmount);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/access/manager/IAuthority.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/manager/IAuthority.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard interface for permissioning originally defined in Dappsys.\n */\ninterface IAuthority {\n    /**\n     * @dev Returns true if the caller can invoke on a target the function identified by a function selector.\n     */\n    function canCall(address caller, address target, bytes4 selector) external view returns (bool allowed);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/access/manager/AuthorityUtils.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/manager/AuthorityUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {IAuthority} from \"./IAuthority.sol\";\n\nlibrary AuthorityUtils {\n    /**\n     * @dev Since `AccessManager` implements an extended IAuthority interface, invoking `canCall` with backwards compatibility\n     * for the preexisting `IAuthority` interface requires special care to avoid reverting on insufficient return data.\n     * This helper function takes care of invoking `canCall` in a backwards compatible way without reverting.\n     */\n    function canCallWithDelay(\n        address authority,\n        address caller,\n        address target,\n        bytes4 selector\n    ) internal view returns (bool immediate, uint32 delay) {\n        (bool success, bytes memory data) = authority.staticcall(\n            abi.encodeCall(IAuthority.canCall, (caller, target, selector))\n        );\n        if (success) {\n            if (data.length >= 0x40) {\n                (immediate, delay) = abi.decode(data, (bool, uint32));\n            } else if (data.length >= 0x20) {\n                immediate = abi.decode(data, (bool));\n            }\n        }\n        return (immediate, delay);\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/access/manager/IAccessManager.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/manager/IAccessManager.sol)\n\npragma solidity ^0.8.20;\n\nimport {IAccessManaged} from \"./IAccessManaged.sol\";\nimport {Time} from \"../../utils/types/Time.sol\";\n\ninterface IAccessManager {\n    /**\n     * @dev A delayed operation was scheduled.\n     */\n    event OperationScheduled(\n        bytes32 indexed operationId,\n        uint32 indexed nonce,\n        uint48 schedule,\n        address caller,\n        address target,\n        bytes data\n    );\n\n    /**\n     * @dev A scheduled operation was executed.\n     */\n    event OperationExecuted(bytes32 indexed operationId, uint32 indexed nonce);\n\n    /**\n     * @dev A scheduled operation was canceled.\n     */\n    event OperationCanceled(bytes32 indexed operationId, uint32 indexed nonce);\n\n    /**\n     * @dev Informational labelling for a roleId.\n     */\n    event RoleLabel(uint64 indexed roleId, string label);\n\n    /**\n     * @dev Emitted when `account` is granted `roleId`.\n     *\n     * NOTE: The meaning of the `since` argument depends on the `newMember` argument.\n     * If the role is granted to a new member, the `since` argument indicates when the account becomes a member of the role,\n     * otherwise it indicates the execution delay for this account and roleId is updated.\n     */\n    event RoleGranted(uint64 indexed roleId, address indexed account, uint32 delay, uint48 since, bool newMember);\n\n    /**\n     * @dev Emitted when `account` membership or `roleId` is revoked. Unlike granting, revoking is instantaneous.\n     */\n    event RoleRevoked(uint64 indexed roleId, address indexed account);\n\n    /**\n     * @dev Role acting as admin over a given `roleId` is updated.\n     */\n    event RoleAdminChanged(uint64 indexed roleId, uint64 indexed admin);\n\n    /**\n     * @dev Role acting as guardian over a given `roleId` is updated.\n     */\n    event RoleGuardianChanged(uint64 indexed roleId, uint64 indexed guardian);\n\n    /**\n     * @dev Grant delay for a given `roleId` will be updated to `delay` when `since` is reached.\n     */\n    event RoleGrantDelayChanged(uint64 indexed roleId, uint32 delay, uint48 since);\n\n    /**\n     * @dev Target mode is updated (true = closed, false = open).\n     */\n    event TargetClosed(address indexed target, bool closed);\n\n    /**\n     * @dev Role required to invoke `selector` on `target` is updated to `roleId`.\n     */\n    event TargetFunctionRoleUpdated(address indexed target, bytes4 selector, uint64 indexed roleId);\n\n    /**\n     * @dev Admin delay for a given `target` will be updated to `delay` when `since` is reached.\n     */\n    event TargetAdminDelayUpdated(address indexed target, uint32 delay, uint48 since);\n\n    error AccessManagerAlreadyScheduled(bytes32 operationId);\n    error AccessManagerNotScheduled(bytes32 operationId);\n    error AccessManagerNotReady(bytes32 operationId);\n    error AccessManagerExpired(bytes32 operationId);\n    error AccessManagerLockedAccount(address account);\n    error AccessManagerLockedRole(uint64 roleId);\n    error AccessManagerBadConfirmation();\n    error AccessManagerUnauthorizedAccount(address msgsender, uint64 roleId);\n    error AccessManagerUnauthorizedCall(address caller, address target, bytes4 selector);\n    error AccessManagerUnauthorizedConsume(address target);\n    error AccessManagerUnauthorizedCancel(address msgsender, address caller, address target, bytes4 selector);\n    error AccessManagerInvalidInitialAdmin(address initialAdmin);\n\n    /**\n     * @dev Check if an address (`caller`) is authorised to call a given function on a given contract directly (with\n     * no restriction). Additionally, it returns the delay needed to perform the call indirectly through the {schedule}\n     * & {execute} workflow.\n     *\n     * This function is usually called by the targeted contract to control immediate execution of restricted functions.\n     * Therefore we only return true if the call can be performed without any delay. If the call is subject to a\n     * previously set delay (not zero), then the function should return false and the caller should schedule the operation\n     * for future execution.\n     *\n     * If `immediate` is true, the delay can be disregarded and the operation can be immediately executed, otherwise\n     * the operation can be executed if and only if delay is greater than 0.\n     *\n     * NOTE: The IAuthority interface does not include the `uint32` delay. This is an extension of that interface that\n     * is backward compatible. Some contracts may thus ignore the second return argument. In that case they will fail\n     * to identify the indirect workflow, and will consider calls that require a delay to be forbidden.\n     *\n     * NOTE: This function does not report the permissions of this manager itself. These are defined by the\n     * {_canCallSelf} function instead.\n     */\n    function canCall(\n        address caller,\n        address target,\n        bytes4 selector\n    ) external view returns (bool allowed, uint32 delay);\n\n    /**\n     * @dev Expiration delay for scheduled proposals. Defaults to 1 week.\n     *\n     * IMPORTANT: Avoid overriding the expiration with 0. Otherwise every contract proposal will be expired immediately,\n     * disabling any scheduling usage.\n     */\n    function expiration() external view returns (uint32);\n\n    /**\n     * @dev Minimum setback for all delay updates, with the exception of execution delays. It\n     * can be increased without setback (and reset via {revokeRole} in the case event of an\n     * accidental increase). Defaults to 5 days.\n     */\n    function minSetback() external view returns (uint32);\n\n    /**\n     * @dev Get whether the contract is closed disabling any access. Otherwise role permissions are applied.\n     */\n    function isTargetClosed(address target) external view returns (bool);\n\n    /**\n     * @dev Get the role required to call a function.\n     */\n    function getTargetFunctionRole(address target, bytes4 selector) external view returns (uint64);\n\n    /**\n     * @dev Get the admin delay for a target contract. Changes to contract configuration are subject to this delay.\n     */\n    function getTargetAdminDelay(address target) external view returns (uint32);\n\n    /**\n     * @dev Get the id of the role that acts as an admin for the given role.\n     *\n     * The admin permission is required to grant the role, revoke the role and update the execution delay to execute\n     * an operation that is restricted to this role.\n     */\n    function getRoleAdmin(uint64 roleId) external view returns (uint64);\n\n    /**\n     * @dev Get the role that acts as a guardian for a given role.\n     *\n     * The guardian permission allows canceling operations that have been scheduled under the role.\n     */\n    function getRoleGuardian(uint64 roleId) external view returns (uint64);\n\n    /**\n     * @dev Get the role current grant delay.\n     *\n     * Its value may change at any point without an event emitted following a call to {setGrantDelay}.\n     * Changes to this value, including effect timepoint are notified in advance by the {RoleGrantDelayChanged} event.\n     */\n    function getRoleGrantDelay(uint64 roleId) external view returns (uint32);\n\n    /**\n     * @dev Get the access details for a given account for a given role. These details include the timepoint at which\n     * membership becomes active, and the delay applied to all operation by this user that requires this permission\n     * level.\n     *\n     * Returns:\n     * [0] Timestamp at which the account membership becomes valid. 0 means role is not granted.\n     * [1] Current execution delay for the account.\n     * [2] Pending execution delay for the account.\n     * [3] Timestamp at which the pending execution delay will become active. 0 means no delay update is scheduled.\n     */\n    function getAccess(uint64 roleId, address account) external view returns (uint48, uint32, uint32, uint48);\n\n    /**\n     * @dev Check if a given account currently has the permission level corresponding to a given role. Note that this\n     * permission might be associated with an execution delay. {getAccess} can provide more details.\n     */\n    function hasRole(uint64 roleId, address account) external view returns (bool, uint32);\n\n    /**\n     * @dev Give a label to a role, for improved role discoverability by UIs.\n     *\n     * Requirements:\n     *\n     * - the caller must be a global admin\n     *\n     * Emits a {RoleLabel} event.\n     */\n    function labelRole(uint64 roleId, string calldata label) external;\n\n    /**\n     * @dev Add `account` to `roleId`, or change its execution delay.\n     *\n     * This gives the account the authorization to call any function that is restricted to this role. An optional\n     * execution delay (in seconds) can be set. If that delay is non 0, the user is required to schedule any operation\n     * that is restricted to members of this role. The user will only be able to execute the operation after the delay has\n     * passed, before it has expired. During this period, admin and guardians can cancel the operation (see {cancel}).\n     *\n     * If the account has already been granted this role, the execution delay will be updated. This update is not\n     * immediate and follows the delay rules. For example, if a user currently has a delay of 3 hours, and this is\n     * called to reduce that delay to 1 hour, the new delay will take some time to take effect, enforcing that any\n     * operation executed in the 3 hours that follows this update was indeed scheduled before this update.\n     *\n     * Requirements:\n     *\n     * - the caller must be an admin for the role (see {getRoleAdmin})\n     * - granted role must not be the `PUBLIC_ROLE`\n     *\n     * Emits a {RoleGranted} event.\n     */\n    function grantRole(uint64 roleId, address account, uint32 executionDelay) external;\n\n    /**\n     * @dev Remove an account from a role, with immediate effect. If the account does not have the role, this call has\n     * no effect.\n     *\n     * Requirements:\n     *\n     * - the caller must be an admin for the role (see {getRoleAdmin})\n     * - revoked role must not be the `PUBLIC_ROLE`\n     *\n     * Emits a {RoleRevoked} event if the account had the role.\n     */\n    function revokeRole(uint64 roleId, address account) external;\n\n    /**\n     * @dev Renounce role permissions for the calling account with immediate effect. If the sender is not in\n     * the role this call has no effect.\n     *\n     * Requirements:\n     *\n     * - the caller must be `callerConfirmation`.\n     *\n     * Emits a {RoleRevoked} event if the account had the role.\n     */\n    function renounceRole(uint64 roleId, address callerConfirmation) external;\n\n    /**\n     * @dev Change admin role for a given role.\n     *\n     * Requirements:\n     *\n     * - the caller must be a global admin\n     *\n     * Emits a {RoleAdminChanged} event\n     */\n    function setRoleAdmin(uint64 roleId, uint64 admin) external;\n\n    /**\n     * @dev Change guardian role for a given role.\n     *\n     * Requirements:\n     *\n     * - the caller must be a global admin\n     *\n     * Emits a {RoleGuardianChanged} event\n     */\n    function setRoleGuardian(uint64 roleId, uint64 guardian) external;\n\n    /**\n     * @dev Update the delay for granting a `roleId`.\n     *\n     * Requirements:\n     *\n     * - the caller must be a global admin\n     *\n     * Emits a {RoleGrantDelayChanged} event.\n     */\n    function setGrantDelay(uint64 roleId, uint32 newDelay) external;\n\n    /**\n     * @dev Set the role required to call functions identified by the `selectors` in the `target` contract.\n     *\n     * Requirements:\n     *\n     * - the caller must be a global admin\n     *\n     * Emits a {TargetFunctionRoleUpdated} event per selector.\n     */\n    function setTargetFunctionRole(address target, bytes4[] calldata selectors, uint64 roleId) external;\n\n    /**\n     * @dev Set the delay for changing the configuration of a given target contract.\n     *\n     * Requirements:\n     *\n     * - the caller must be a global admin\n     *\n     * Emits a {TargetAdminDelayUpdated} event.\n     */\n    function setTargetAdminDelay(address target, uint32 newDelay) external;\n\n    /**\n     * @dev Set the closed flag for a contract.\n     *\n     * Requirements:\n     *\n     * - the caller must be a global admin\n     *\n     * Emits a {TargetClosed} event.\n     */\n    function setTargetClosed(address target, bool closed) external;\n\n    /**\n     * @dev Return the timepoint at which a scheduled operation will be ready for execution. This returns 0 if the\n     * operation is not yet scheduled, has expired, was executed, or was canceled.\n     */\n    function getSchedule(bytes32 id) external view returns (uint48);\n\n    /**\n     * @dev Return the nonce for the latest scheduled operation with a given id. Returns 0 if the operation has never\n     * been scheduled.\n     */\n    function getNonce(bytes32 id) external view returns (uint32);\n\n    /**\n     * @dev Schedule a delayed operation for future execution, and return the operation identifier. It is possible to\n     * choose the timestamp at which the operation becomes executable as long as it satisfies the execution delays\n     * required for the caller. The special value zero will automatically set the earliest possible time.\n     *\n     * Returns the `operationId` that was scheduled. Since this value is a hash of the parameters, it can reoccur when\n     * the same parameters are used; if this is relevant, the returned `nonce` can be used to uniquely identify this\n     * scheduled operation from other occurrences of the same `operationId` in invocations of {execute} and {cancel}.\n     *\n     * Emits a {OperationScheduled} event.\n     *\n     * NOTE: It is not possible to concurrently schedule more than one operation with the same `target` and `data`. If\n     * this is necessary, a random byte can be appended to `data` to act as a salt that will be ignored by the target\n     * contract if it is using standard Solidity ABI encoding.\n     */\n    function schedule(address target, bytes calldata data, uint48 when) external returns (bytes32, uint32);\n\n    /**\n     * @dev Execute a function that is delay restricted, provided it was properly scheduled beforehand, or the\n     * execution delay is 0.\n     *\n     * Returns the nonce that identifies the previously scheduled operation that is executed, or 0 if the\n     * operation wasn't previously scheduled (if the caller doesn't have an execution delay).\n     *\n     * Emits an {OperationExecuted} event only if the call was scheduled and delayed.\n     */\n    function execute(address target, bytes calldata data) external payable returns (uint32);\n\n    /**\n     * @dev Cancel a scheduled (delayed) operation. Returns the nonce that identifies the previously scheduled\n     * operation that is cancelled.\n     *\n     * Requirements:\n     *\n     * - the caller must be the proposer, a guardian of the targeted function, or a global admin\n     *\n     * Emits a {OperationCanceled} event.\n     */\n    function cancel(address caller, address target, bytes calldata data) external returns (uint32);\n\n    /**\n     * @dev Consume a scheduled operation targeting the caller. If such an operation exists, mark it as consumed\n     * (emit an {OperationExecuted} event and clean the state). Otherwise, throw an error.\n     *\n     * This is useful for contract that want to enforce that calls targeting them were scheduled on the manager,\n     * with all the verifications that it implies.\n     *\n     * Emit a {OperationExecuted} event.\n     */\n    function consumeScheduledOp(address caller, bytes calldata data) external;\n\n    /**\n     * @dev Hashing function for delayed operations.\n     */\n    function hashOperation(address caller, address target, bytes calldata data) external view returns (bytes32);\n\n    /**\n     * @dev Changes the authority of a target managed by this manager instance.\n     *\n     * Requirements:\n     *\n     * - the caller must be a global admin\n     */\n    function updateAuthority(address target, address newAuthority) external;\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/access/manager/IAccessManaged.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/manager/IAccessManaged.sol)\n\npragma solidity ^0.8.20;\n\ninterface IAccessManaged {\n    /**\n     * @dev Authority that manages this contract was updated.\n     */\n    event AuthorityUpdated(address authority);\n\n    error AccessManagedUnauthorized(address caller);\n    error AccessManagedRequiredDelay(address caller, uint32 delay);\n    error AccessManagedInvalidAuthority(address authority);\n\n    /**\n     * @dev Returns the current authority.\n     */\n    function authority() external view returns (address);\n\n    /**\n     * @dev Transfers control to a new authority. The caller must be the current authority.\n     */\n    function setAuthority(address) external;\n\n    /**\n     * @dev Returns true only in the context of a delayed restricted call, at the moment that the scheduled operation is\n     * being consumed. Prevents denial of service for delayed restricted calls in the case that the contract performs\n     * attacker controlled calls.\n     */\n    function isConsumingScheduledOp() external view returns (bytes4);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"
      },
      "src/struct/RaveEvidence.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\nstruct RaveEvidence {\n    // Preprocessed remote attestation report\n    bytes report;\n    // Preprocessed RSA signature over the report\n    bytes signature;\n    // The hash of a whitelisted Intel-signed leaf x509 certificate\n    bytes32 leafX509CertDigest;\n}\n"
      },
      "src/EnclaveVerifier.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\nimport { RAVE } from \"rave/RAVE.sol\";\nimport { X509Verifier } from \"rave/X509Verifier.sol\";\nimport { IEnclaveVerifier } from \"puffer/interface/IEnclaveVerifier.sol\";\nimport { RaveEvidence } from \"puffer/struct/RaveEvidence.sol\";\nimport { AccessManaged } from \"openzeppelin/access/manager/AccessManaged.sol\";\nimport { InvalidAddress } from \"puffer/Errors.sol\";\n\n/**\n * @title EnclaveVerifier\n * @author Puffer Finance\n * @custom:security-contact security@puffer.fi\n */\ncontract EnclaveVerifier is IEnclaveVerifier, AccessManaged, RAVE {\n    /**\n     * @dev RSA Public key for Intel: https://api.portal.trustedservices.intel.com/content/documentation.html\n     */\n    bytes internal constant _INTEL_RSA_MODULUS =\n        hex\"9F3C647EB5773CBB512D2732C0D7415EBB55A0FA9EDE2E649199E6821DB910D53177370977466A6A5E4786CCD2DDEBD4149D6A2F6325529DD10CC98737B0779C1A07E29C47A1AE004948476C489F45A5A15D7AC8ECC6ACC645ADB43D87679DF59C093BC5A2E9696C5478541B979E754B573914BE55D32FF4C09DDF27219934CD990527B3F92ED78FBF29246ABECB71240EF39C2D7107B447545A7FFB10EB060A68A98580219E36910952683892D6A5E2A80803193E407531404E36B315623799AA825074409754A2DFE8F5AFD5FE631E1FC2AF3808906F28A790D9DD9FE060939B125790C5805D037DF56A99531B96DE69DE33ED226CC1207D1042B5C9AB7F404FC711C0FE4769FB9578B1DC0EC469EA1A25E0FF9914886EF2699B235BB4847DD6FF40B606E6170793C2FB98B314587F9CFD257362DFEAB10B3BD2D97673A1A4BD44C453AAF47FC1F2D3D0F384F74A06F89C089F0DA6CDB7FCEEE8C9821A8E54F25C0416D18C46839A5F8012FBDD3DC74D256279ADC2C0D55AFF6F0622425D1B\";\n    bytes internal constant _INTEL_EXPONENT = hex\"010001\";\n\n    /**\n     * @notice Freshness number of blocks\n     */\n    uint256 public immutable FRESHNESS_BLOCKS;\n\n    /**\n     * @dev Mapping from keccak'd leaf x509 to RSA pub key components\n     * leafHash -> pubKey\n     */\n    mapping(bytes32 leafHash => RSAPubKey pubKey) internal _validLeafX509s;\n\n    constructor(uint256 freshnessBlocks, address accessManager) AccessManaged(accessManager) {\n        if (address(accessManager) == address(0)) {\n            revert InvalidAddress();\n        }\n        FRESHNESS_BLOCKS = freshnessBlocks;\n    }\n\n    /**\n     * @inheritdoc IEnclaveVerifier\n     */\n    function getIntelRootCAPubKey() external pure returns (RSAPubKey memory) {\n        return RSAPubKey({ modulus: _INTEL_RSA_MODULUS, exponent: _INTEL_EXPONENT });\n    }\n\n    /**\n     * @inheritdoc IEnclaveVerifier\n     */\n    function addLeafX509(bytes calldata leafX509Cert) external {\n        (bytes memory leafCertModulus, bytes memory leafCertExponent) =\n            X509Verifier.verifySignedX509(leafX509Cert, _INTEL_RSA_MODULUS, _INTEL_EXPONENT);\n\n        bytes32 hashedCert = keccak256(leafX509Cert);\n\n        _validLeafX509s[hashedCert] = RSAPubKey({ modulus: leafCertModulus, exponent: leafCertExponent });\n\n        emit AddedPubKey(hashedCert);\n    }\n\n    /**\n     * @notice Removes a whitelisted leaf x509 RSA public key\n     */\n    function removeLeafX509(bytes32 hashedCert) external restricted {\n        delete _validLeafX509s[hashedCert].modulus;\n        delete _validLeafX509s[hashedCert].exponent;\n        emit RemovedPubKey(hashedCert);\n    }\n\n    /**\n     * @inheritdoc IEnclaveVerifier\n     */\n    function verifyEvidence(\n        uint256 blockNumber,\n        bytes32 raveCommitment,\n        RaveEvidence calldata evidence,\n        bytes32 mrenclave,\n        bytes32 mrsigner\n    ) external view returns (bool) {\n        // Check for freshness\n        if ((block.number - blockNumber) > FRESHNESS_BLOCKS) {\n            revert StaleEvidence();\n        }\n\n        RSAPubKey memory leafX509 = _validLeafX509s[evidence.leafX509CertDigest];\n\n        // Recover a remote attestation payload if everything is valid\n        bytes memory recoveredPayload = verifyRemoteAttestation({\n            report: evidence.report,\n            sig: evidence.signature,\n            signingMod: leafX509.modulus,\n            signingExp: leafX509.exponent,\n            mrenclave: mrenclave,\n            mrsigner: mrsigner\n        });\n\n        // Remote attestation payloads are expected to be in the form (32B_Commitment || 32B_BlockHash)\n        bytes memory expectedPayload = abi.encode(raveCommitment, blockhash(blockNumber));\n\n        // Compare with the expected payload\n        return (keccak256(expectedPayload) == keccak256(recoveredPayload));\n    }\n}\n"
      },
      "src/struct/StoppedValidatorInfo.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\n/**\n * @dev Stopped validator info\n */\nstruct StoppedValidatorInfo {\n    ///@dev Module address.\n    address module;\n    ///@dev Validator start epoch.\n    uint256 startEpoch;\n    ///@dev Validator stop epoch.\n    uint256 endEpoch;\n    /// @dev Indicates whether the validator was slashed before stopping.\n    bool wasSlashed;\n    /// @dev Name of the module where the validator was participating.\n    bytes32 moduleName;\n    /// @dev Index of the validator in the module's validator list.\n    uint256 pufferModuleIndex;\n    /// @dev Amount of funds withdrawn upon validator stoppage.\n    uint256 withdrawalAmount;\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/types/Time.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/types/Time.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"../math/Math.sol\";\nimport {SafeCast} from \"../math/SafeCast.sol\";\n\n/**\n * @dev This library provides helpers for manipulating time-related objects.\n *\n * It uses the following types:\n * - `uint48` for timepoints\n * - `uint32` for durations\n *\n * While the library doesn't provide specific types for timepoints and duration, it does provide:\n * - a `Delay` type to represent duration that can be programmed to change value automatically at a given point\n * - additional helper functions\n */\nlibrary Time {\n    using Time for *;\n\n    /**\n     * @dev Get the block timestamp as a Timepoint.\n     */\n    function timestamp() internal view returns (uint48) {\n        return SafeCast.toUint48(block.timestamp);\n    }\n\n    /**\n     * @dev Get the block number as a Timepoint.\n     */\n    function blockNumber() internal view returns (uint48) {\n        return SafeCast.toUint48(block.number);\n    }\n\n    // ==================================================== Delay =====================================================\n    /**\n     * @dev A `Delay` is a uint32 duration that can be programmed to change value automatically at a given point in the\n     * future. The \"effect\" timepoint describes when the transitions happens from the \"old\" value to the \"new\" value.\n     * This allows updating the delay applied to some operation while keeping some guarantees.\n     *\n     * In particular, the {update} function guarantees that if the delay is reduced, the old delay still applies for\n     * some time. For example if the delay is currently 7 days to do an upgrade, the admin should not be able to set\n     * the delay to 0 and upgrade immediately. If the admin wants to reduce the delay, the old delay (7 days) should\n     * still apply for some time.\n     *\n     *\n     * The `Delay` type is 112 bits long, and packs the following:\n     *\n     * ```\n     *   | [uint48]: effect date (timepoint)\n     *   |           | [uint32]: value before (duration)\n     *   ↓           ↓       ↓ [uint32]: value after (duration)\n     * 0xAAAAAAAAAAAABBBBBBBBCCCCCCCC\n     * ```\n     *\n     * NOTE: The {get} and {withUpdate} functions operate using timestamps. Block number based delays are not currently\n     * supported.\n     */\n    type Delay is uint112;\n\n    /**\n     * @dev Wrap a duration into a Delay to add the one-step \"update in the future\" feature\n     */\n    function toDelay(uint32 duration) internal pure returns (Delay) {\n        return Delay.wrap(duration);\n    }\n\n    /**\n     * @dev Get the value at a given timepoint plus the pending value and effect timepoint if there is a scheduled\n     * change after this timepoint. If the effect timepoint is 0, then the pending value should not be considered.\n     */\n    function _getFullAt(Delay self, uint48 timepoint) private pure returns (uint32, uint32, uint48) {\n        (uint32 valueBefore, uint32 valueAfter, uint48 effect) = self.unpack();\n        return effect <= timepoint ? (valueAfter, 0, 0) : (valueBefore, valueAfter, effect);\n    }\n\n    /**\n     * @dev Get the current value plus the pending value and effect timepoint if there is a scheduled change. If the\n     * effect timepoint is 0, then the pending value should not be considered.\n     */\n    function getFull(Delay self) internal view returns (uint32, uint32, uint48) {\n        return _getFullAt(self, timestamp());\n    }\n\n    /**\n     * @dev Get the current value.\n     */\n    function get(Delay self) internal view returns (uint32) {\n        (uint32 delay, , ) = self.getFull();\n        return delay;\n    }\n\n    /**\n     * @dev Update a Delay object so that it takes a new duration after a timepoint that is automatically computed to\n     * enforce the old delay at the moment of the update. Returns the updated Delay object and the timestamp when the\n     * new delay becomes effective.\n     */\n    function withUpdate(\n        Delay self,\n        uint32 newValue,\n        uint32 minSetback\n    ) internal view returns (Delay updatedDelay, uint48 effect) {\n        uint32 value = self.get();\n        uint32 setback = uint32(Math.max(minSetback, value > newValue ? value - newValue : 0));\n        effect = timestamp() + setback;\n        return (pack(value, newValue, effect), effect);\n    }\n\n    /**\n     * @dev Split a delay into its components: valueBefore, valueAfter and effect (transition timepoint).\n     */\n    function unpack(Delay self) internal pure returns (uint32 valueBefore, uint32 valueAfter, uint48 effect) {\n        uint112 raw = Delay.unwrap(self);\n\n        valueAfter = uint32(raw);\n        valueBefore = uint32(raw >> 32);\n        effect = uint48(raw >> 64);\n\n        return (valueBefore, valueAfter, effect);\n    }\n\n    /**\n     * @dev pack the components into a Delay object.\n     */\n    function pack(uint32 valueBefore, uint32 valueAfter, uint48 effect) internal pure returns (Delay) {\n        return Delay.wrap((uint112(effect) << 64) | (uint112(valueBefore) << 32) | uint112(valueAfter));\n    }\n}\n"
      },
      "lib/rave/src/RAVE.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0 <0.9.0;\n\nimport { X509Verifier } from \"rave/X509Verifier.sol\";\nimport { JSONBuilder } from \"rave/JSONBuilder.sol\";\nimport { BytesUtils } from \"ens-contracts/dnssec-oracle/BytesUtils.sol\";\nimport { Base64 } from \"openzeppelin/utils/Base64.sol\";\nimport { RAVEBase } from \"rave/RAVEBase.sol\";\n\n/**\n * @title RAVE\n * @author PufferFinance\n * @custom:security-contact security@puffer.fi\n * @notice RAVe is a smart contract for verifying Remote Attestation evidence.\n */\ncontract RAVE is RAVEBase, JSONBuilder {\n    using BytesUtils for *;\n\n    constructor() { }\n\n    /**\n     * @inheritdoc RAVEBase\n     */\n    function verifyRemoteAttestation(\n        bytes calldata report,\n        bytes calldata sig,\n        bytes memory signingMod,\n        bytes memory signingExp,\n        bytes32 mrenclave,\n        bytes32 mrsigner\n    ) public view override returns (bytes memory payload) {\n        // Decode the encoded report JSON values to a Values struct and reconstruct the original JSON string\n        (Values memory reportValues, bytes memory reportBytes) = _buildReportBytes(report);\n\n        // Verify the report was signed by the SigningPK\n        if (!verifyReportSignature(reportBytes, sig, signingMod, signingExp)) {\n            revert BadReportSignature();\n        }\n\n        // Verify the report's contents match the expected\n        payload = _verifyReportContents(reportValues, mrenclave, mrsigner);\n    }\n\n    /**\n     * @inheritdoc RAVEBase\n     */\n    function rave(\n        bytes calldata report,\n        bytes calldata sig,\n        bytes memory leafX509Cert,\n        bytes memory signingMod,\n        bytes memory signingExp,\n        bytes32 mrenclave,\n        bytes32 mrsigner\n    ) public view override returns (bytes memory payload) {\n        // Verify the leafX509Cert was signed with signingMod and signingExp\n        (bytes memory leafCertModulus, bytes memory leafCertExponent) =\n            X509Verifier.verifySignedX509(leafX509Cert, signingMod, signingExp);\n\n        // Verify report has expected fields then extract its payload\n        payload = verifyRemoteAttestation(report, sig, leafCertModulus, leafCertExponent, mrenclave, mrsigner);\n    }\n\n    /*\n    * @dev Builds the JSON report string from the abi-encoded `encodedReportValues`. The assumption is that `isvEnclaveQuoteBody` value was previously base64 decoded off-chain and needs to be base64 encoded to produce the message-to-be-signed.\n    * @param encodedReportValues The values from the attestation evidence report JSON from IAS.\n    * @return reportValues The JSON values as a Values struct for easier processing downstream\n    * @return reportBytes The exact message-to-be-signed\n    */\n    function _buildReportBytes(bytes memory encodedReportValues)\n        internal\n        view\n        returns (Values memory reportValues, bytes memory reportBytes)\n    {\n        // Decode the report JSON values\n        (\n            bytes memory id,\n            bytes memory timestamp,\n            bytes memory version,\n            bytes memory epidPseudonym,\n            bytes memory advisoryURL,\n            bytes memory advisoryIDs,\n            bytes memory isvEnclaveQuoteStatus,\n            bytes memory isvEnclaveQuoteBody\n        ) = abi.decode(encodedReportValues, (bytes, bytes, bytes, bytes, bytes, bytes, bytes, bytes));\n\n        // Assumes the quote body was already decoded off-chain\n        bytes memory encBody = bytes(Base64.encode(isvEnclaveQuoteBody));\n\n        // Pack values to struct\n        reportValues = JSONBuilder.Values(\n            id, timestamp, version, epidPseudonym, advisoryURL, advisoryIDs, isvEnclaveQuoteStatus, encBody\n        );\n\n        // Reconstruct the JSON report that was signed\n        reportBytes = bytes(buildJSON(reportValues));\n\n        // Pass on the decoded value for later processing\n        reportValues.isvEnclaveQuoteBody = isvEnclaveQuoteBody;\n    }\n\n    /*\n    * @dev Parses a report, verifies the fields are correctly set, and extracts the enclave' 64 byte commitment.\n    * @param reportValues The values from the attestation evidence report JSON from IAS.\n    * @param mrenclave The expected enclave measurement.\n    * @param mrsigner The expected enclave signer.\n    * @return The 64 byte payload if the mrenclave and mrsigner values were correctly set.\n    */\n    function _verifyReportContents(Values memory reportValues, bytes32 mrenclave, bytes32 mrsigner)\n        internal\n        pure\n        returns (bytes memory payload)\n    {\n        // check enclave status\n        bytes32 status = keccak256(reportValues.isvEnclaveQuoteStatus);\n        require(status == OK_STATUS || status == HARDENING_STATUS, \"bad isvEnclaveQuoteStatus\");\n\n        // quote body is already base64 decoded\n        bytes memory quoteBody = reportValues.isvEnclaveQuoteBody;\n        assert(quoteBody.length == QUOTE_BODY_LENGTH);\n\n        // Verify report's MRENCLAVE matches the expected\n        bytes32 mre = quoteBody.readBytes32(MRENCLAVE_OFFSET);\n        require(mre == mrenclave);\n\n        // Verify report's MRSIGNER matches the expected\n        bytes32 mrs = quoteBody.readBytes32(MRSIGNER_OFFSET);\n        require(mrs == mrsigner);\n\n        // Verify report's <= 64B payload matches the expected\n        payload = quoteBody.substring(PAYLOAD_OFFSET, PAYLOAD_SIZE);\n    }\n}\n"
      },
      "lib/rave/src/X509Verifier.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0 <0.9.0;\n\nimport { Asn1Decode, NodePtr } from \"rave/ASN1Decode.sol\";\nimport { RSAVerify } from \"ens-contracts/dnssec-oracle/algorithms/RSAVerify.sol\";\nimport { BytesUtils } from \"ens-contracts/dnssec-oracle/BytesUtils.sol\";\n\nlibrary X509Verifier {\n    using Asn1Decode for bytes;\n    using BytesUtils for bytes;\n\n    /*\n     * @dev Verifies an x509 certificate was signed (RSASHA256) by the supplied public key. \n     * @param childCertBody The DER-encoded body (preimage) of the x509   child certificate\n     * @param certSig The RSASHA256 signature of the childCertBody\n     * @param parentMod The modulus of the parent certificate's public RSA key\n     * @param parentExp The exponent of the parent certificate's public RSA key\n     * @return Returns true if this childCertBody was signed by the parent's RSA private key\n     */\n    function verifyChildCert(\n        bytes memory childCertBody,\n        bytes memory certSig,\n        bytes memory parentMod,\n        bytes memory parentExp\n    ) public view returns (bool) {\n        // Recover the digest using parent's public key\n        (bool success, bytes memory res) = RSAVerify.rsarecover(parentMod, parentExp, certSig);\n        // Digest is last 32 bytes of res\n        bytes32 recovered = res.readBytes32(res.length - 32);\n        return success && recovered == sha256(childCertBody);\n    }\n\n    /*\n     * @dev specs: https://www.ietf.org/rfc/rfc5280.txt\n     * @dev     Certificate  ::=  SEQUENCE  {\n     * @dev         tbsCertificate       TBSCertificate,\n     * @dev         signatureAlgorithm   AlgorithmIdentifier,\n     * @dev         signatureValue       BIT STRING  }\n     * @dev\n     * @dev     TBSCertificate  ::=  SEQUENCE  {\n     * @dev         version         [0]  EXPLICIT Version DEFAULT v1,\n     * @dev         serialNumber         CertificateSerialNumber,\n     * @dev         signature            AlgorithmIdentifier,\n     * @dev         issuer               Name,\n     * @dev         validity             Validity,\n     * @dev         subject              Name,\n     * @dev         subjectPublicKeyInfo SubjectPublicKeyInfo,\n     * @dev         issuerUniqueID  [1]  IMPLICIT UniqueIdentifier OPTIONAL,\n     * @dev                              -- If present, version MUST be v2 or v3\n     * @dev         subjectUniqueID [2]  IMPLICIT UniqueIdentifier OPTIONAL,\n     * @dev                              -- If present, version MUST be v2 or v3\n     * @dev         extensions      [3]  EXPLICIT Extensions OPTIONAL\n     * @dev                              -- If present, version MUST be v3\n     * @dev         }\n     * @dev Verifies an x509 certificate was signed (RSASHA256) by the parent's\n     * @dev supplied modulus and exponent, then returns the child x509's modulus and exponent.\n     * @param cert The DER-encoded signed x509 certificate.\n     * @param parentMod The parent RSA modulus.\n     * @param parentExp The parent RSA exponent.\n     * @return Returns the RSA modulus and exponent of the signed x509 certificate iff it was signed by the parent.\n     */\n    function verifySignedX509(bytes memory cert, bytes memory parentMod, bytes memory parentExp)\n        public\n        view\n        returns (bytes memory, bytes memory)\n    {\n        // Pointer to top level asn1 object: Sequence{tbsCertificate, signatureAlgorithm, signatureValue}\n        uint256 root = cert.root();\n\n        // Traverse to first in sequence (the tbsCertificate)\n        uint256 tbsPtr = cert.firstChildOf(root);\n\n        // Extracts the TBSCerificate (what is used as input to RSA-SHA256)\n        bytes memory certBody = cert.allBytesAt(tbsPtr);\n\n        // Top level traverse to signatureAlgorithm\n        uint256 sigAlgPtr = cert.nextSiblingOf(tbsPtr);\n\n        // Top level traverse to signatureValue\n        uint256 sigPtr = cert.nextSiblingOf(sigAlgPtr);\n\n        // Extracts the signed certificate body\n        bytes memory signature = cert.bytesAt(sigPtr);\n\n        // Verify the parent signed the certBody\n        require(verifyChildCert(certBody, signature, parentMod, parentExp), \"verifyChildCert fail\");\n\n        //  ----------------\n        // Begin traversing the tbsCertificate\n        //  ----------------\n\n        // Traverse to first child of tbsCertificate\n        uint256 ptr = cert.firstChildOf(tbsPtr);\n\n        // Account for v1 vs v3\n        if (cert[NodePtr.ixs(ptr)] == 0xa0) {\n            ptr = cert.nextSiblingOf(ptr);\n        }\n\n        // Extract serialNumber (CertificateSerialNumber)\n        // uint256 serialNumber = uint160(cert.uintAt(ptr));\n\n        // Skip the next 3 fields (signature, issuer, validity, subject)\n        ptr = cert.nextSiblingOf(ptr); // point to signature\n        ptr = cert.nextSiblingOf(ptr); // point to issuer\n        ptr = cert.nextSiblingOf(ptr); // point to validity\n\n        // Arrive at the validity field\n        // todo verifiy validity timestamps\n        // uint256 validityPtr = ptr;\n        // bytes memory validNotBefore = cert.bytesAt(validityPtr);\n        // console.logBytes(validNotBefore);\n        // uint40 validNotBefore = uint40(toTimestamp(cert.bytesAt(validityPtr)));\n        // console.log(\"validNotBefore: %s\", validNotBefore);\n        // validityPtr = cert.nextSiblingOf(validityPtr);\n        // bytes memory validNotAfter = cert.bytesAt(validityPtr);\n        // console.logBytes(validNotAfter);\n        // uint40 validNotAfter = uint40(toTimestamp(cert.bytesAt(validityPtr)));\n        // console.log(\"validNotAfter: %s\", validNotAfter);\n\n        // Traverse until the subjectPublicKeyInfo field\n        ptr = cert.nextSiblingOf(ptr); // point to subject\n        ptr = cert.nextSiblingOf(ptr); // point to subjectPublicKeyInfo\n\n        // Enter subjectPublicKeyInfo\n        ptr = cert.firstChildOf(ptr); // point to subjectPublicKeyInfo.algorithm\n        ptr = cert.nextSiblingOf(ptr); // point to subjectPublicKeyInfo.subjectPublicKey\n\n        // Extract DER-encoded RSA public key\n        bytes memory pubKey = cert.bitstringAt(ptr);\n\n        // Extract RSA modulus\n        uint256 pkPtr = pubKey.root();\n        pkPtr = pubKey.firstChildOf(pkPtr);\n        bytes memory modulus = pubKey.bytesAt(pkPtr);\n\n        // Extract RSA exponent\n        pkPtr = pubKey.nextSiblingOf(pkPtr);\n        bytes memory exponent = pubKey.bytesAt(pkPtr);\n\n        return (modulus, exponent);\n    }\n\n    /*\n     * @dev Verifies the x509 certificate hasn't expired\n     * @param certBody The DER-encoded body (preimage) of the x509 \n     * @return Returns ...\n     */\n    function notExpired(bytes calldata certBody) public view returns (bool) {\n        // TODO\n        return true;\n    }\n}\n"
      },
      "src/interface/IEnclaveVerifier.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\nimport { RaveEvidence } from \"puffer/struct/RaveEvidence.sol\";\n\n/**\n * @title IEnclaveVerifier interface\n * @author Puffer Finance\n * @custom:security-contact security@puffer.fi\n */\ninterface IEnclaveVerifier {\n    struct RSAPubKey {\n        bytes modulus;\n        bytes exponent;\n    }\n\n    /**\n     * @notice Thrown if the Evidence that we're trying to verify is stale\n     * Evidence should be submitted for the recent block < `FRESHNESS_BLOCKS`\n     * @dev Signature \"0x5d4ad9a9\"\n     */\n    error StaleEvidence();\n\n    /**\n     * @notice Emitted when the `pubKeyHash` is added to valid pubKeys\n     * @dev Signature \"0x13b85b042d2bb270091da7111e3b3cc407f6b86c85882cf48ae94123cae22b17\"\n     */\n    event AddedPubKey(bytes32 indexed pubKeyHash);\n\n    /**\n     * @notice Emitted when the `pubKeyHash` is removed from valid pubKeys\n     * @dev Signature \"0x0ebd07953ae533bded7d9b0715fa49e0a0ed0a6cef4638a685737ffef8b86254\"\n     */\n    event RemovedPubKey(bytes32 indexed pubKeyHash);\n\n    /**\n     * @notice Getter for intelRootCAPubKey\n     */\n    function getIntelRootCAPubKey() external pure returns (RSAPubKey memory);\n\n    /**\n     * @notice Adds a leaf x509 RSA public key if the x509 was signed by Intel's root CA\n     * @param leafX509Cert certificate\n     */\n    function addLeafX509(bytes calldata leafX509Cert) external;\n\n    /**\n     * @notice Verifies remote attestation evidence: the report contains the expected MRENCLAVE/MRSIGNER values, a valid TCB status, and was signed by an Intel-issued x509 certificate. The report will contain a 64B payload in the form (32B_Commitment || 32B_BlockHash), where 32B_Blockhash is a recent L1 blockhash and 32B_Commitment is a keccak256 hash that the enclave is committing to. The calling contract is expected to precompute raveCommitment from public inputs. The function returns true if the report is valid and the extracted payload matches the expected.\n     * @param blockNumber is the block number to fetch 32B_Blockhash\n     * @param raveCommitment is the keccak256 hash commitment 32B_Commitment\n     * @param evidence is the remote attestation evidence\n     * @param mrenclave is the MRENCLAVE value expected by the calling contract\n     * @param mrsigner is the MRSIGNER value expected by the calling contract\n     * @return true if evidence verification is a success\n     */\n    function verifyEvidence(\n        uint256 blockNumber,\n        bytes32 raveCommitment,\n        RaveEvidence calldata evidence,\n        bytes32 mrenclave,\n        bytes32 mrsigner\n    ) external view returns (bool);\n}\n"
      },
      "src/Errors.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\n/**\n * @notice Thrown when the operation is not authorized\n * @dev Signature \"0x82b42900\"\n */\nerror Unauthorized();\n\n/**\n * @notice Thrown if the address supplied is not valid\n * @dev Signature \"0xe6c4247b\"\n */\nerror InvalidAddress();\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/math/Math.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    /**\n     * @dev Muldiv operation overflow.\n     */\n    error MathOverflowedMulDiv();\n\n    enum Rounding {\n        Floor, // Toward negative infinity\n        Ceil, // Toward positive infinity\n        Trunc, // Toward zero\n        Expand // Away from zero\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, with an overflow flag.\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            uint256 c = a + b;\n            if (c < a) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b > a) return (false, 0);\n            return (true, a - b);\n        }\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n            // benefit is lost if 'b' is also tested.\n            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n            if (a == 0) return (true, 0);\n            uint256 c = a * b;\n            if (c / a != b) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a division by zero flag.\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a / b);\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a % b);\n        }\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds towards infinity instead\n     * of rounding towards zero.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        if (b == 0) {\n            // Guarantee the same behavior as in a regular Solidity division.\n            return a / b;\n        }\n\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n     * denominator == 0.\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n     * Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0 = x * y; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            if (denominator <= prod1) {\n                revert MathOverflowedMulDiv();\n            }\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n            uint256 twos = denominator & (0 - denominator);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n            // works in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n     * towards zero.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n     */\n    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n        return uint8(rounding) % 2 == 1;\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeCast {\n    /**\n     * @dev Value doesn't fit in an uint of `bits` size.\n     */\n    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\n\n    /**\n     * @dev An int value doesn't fit in an uint of `bits` size.\n     */\n    error SafeCastOverflowedIntToUint(int256 value);\n\n    /**\n     * @dev Value doesn't fit in an int of `bits` size.\n     */\n    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\n\n    /**\n     * @dev An uint value doesn't fit in an int of `bits` size.\n     */\n    error SafeCastOverflowedUintToInt(uint256 value);\n\n    /**\n     * @dev Returns the downcasted uint248 from uint256, reverting on\n     * overflow (when the input is greater than largest uint248).\n     *\n     * Counterpart to Solidity's `uint248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     */\n    function toUint248(uint256 value) internal pure returns (uint248) {\n        if (value > type(uint248).max) {\n            revert SafeCastOverflowedUintDowncast(248, value);\n        }\n        return uint248(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint240 from uint256, reverting on\n     * overflow (when the input is greater than largest uint240).\n     *\n     * Counterpart to Solidity's `uint240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     */\n    function toUint240(uint256 value) internal pure returns (uint240) {\n        if (value > type(uint240).max) {\n            revert SafeCastOverflowedUintDowncast(240, value);\n        }\n        return uint240(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint232 from uint256, reverting on\n     * overflow (when the input is greater than largest uint232).\n     *\n     * Counterpart to Solidity's `uint232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     */\n    function toUint232(uint256 value) internal pure returns (uint232) {\n        if (value > type(uint232).max) {\n            revert SafeCastOverflowedUintDowncast(232, value);\n        }\n        return uint232(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint224 from uint256, reverting on\n     * overflow (when the input is greater than largest uint224).\n     *\n     * Counterpart to Solidity's `uint224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     */\n    function toUint224(uint256 value) internal pure returns (uint224) {\n        if (value > type(uint224).max) {\n            revert SafeCastOverflowedUintDowncast(224, value);\n        }\n        return uint224(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint216 from uint256, reverting on\n     * overflow (when the input is greater than largest uint216).\n     *\n     * Counterpart to Solidity's `uint216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     */\n    function toUint216(uint256 value) internal pure returns (uint216) {\n        if (value > type(uint216).max) {\n            revert SafeCastOverflowedUintDowncast(216, value);\n        }\n        return uint216(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint208 from uint256, reverting on\n     * overflow (when the input is greater than largest uint208).\n     *\n     * Counterpart to Solidity's `uint208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     */\n    function toUint208(uint256 value) internal pure returns (uint208) {\n        if (value > type(uint208).max) {\n            revert SafeCastOverflowedUintDowncast(208, value);\n        }\n        return uint208(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint200 from uint256, reverting on\n     * overflow (when the input is greater than largest uint200).\n     *\n     * Counterpart to Solidity's `uint200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     */\n    function toUint200(uint256 value) internal pure returns (uint200) {\n        if (value > type(uint200).max) {\n            revert SafeCastOverflowedUintDowncast(200, value);\n        }\n        return uint200(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint192 from uint256, reverting on\n     * overflow (when the input is greater than largest uint192).\n     *\n     * Counterpart to Solidity's `uint192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     */\n    function toUint192(uint256 value) internal pure returns (uint192) {\n        if (value > type(uint192).max) {\n            revert SafeCastOverflowedUintDowncast(192, value);\n        }\n        return uint192(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint184 from uint256, reverting on\n     * overflow (when the input is greater than largest uint184).\n     *\n     * Counterpart to Solidity's `uint184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     */\n    function toUint184(uint256 value) internal pure returns (uint184) {\n        if (value > type(uint184).max) {\n            revert SafeCastOverflowedUintDowncast(184, value);\n        }\n        return uint184(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint176 from uint256, reverting on\n     * overflow (when the input is greater than largest uint176).\n     *\n     * Counterpart to Solidity's `uint176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     */\n    function toUint176(uint256 value) internal pure returns (uint176) {\n        if (value > type(uint176).max) {\n            revert SafeCastOverflowedUintDowncast(176, value);\n        }\n        return uint176(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint168 from uint256, reverting on\n     * overflow (when the input is greater than largest uint168).\n     *\n     * Counterpart to Solidity's `uint168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     */\n    function toUint168(uint256 value) internal pure returns (uint168) {\n        if (value > type(uint168).max) {\n            revert SafeCastOverflowedUintDowncast(168, value);\n        }\n        return uint168(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint160 from uint256, reverting on\n     * overflow (when the input is greater than largest uint160).\n     *\n     * Counterpart to Solidity's `uint160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     */\n    function toUint160(uint256 value) internal pure returns (uint160) {\n        if (value > type(uint160).max) {\n            revert SafeCastOverflowedUintDowncast(160, value);\n        }\n        return uint160(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint152 from uint256, reverting on\n     * overflow (when the input is greater than largest uint152).\n     *\n     * Counterpart to Solidity's `uint152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     */\n    function toUint152(uint256 value) internal pure returns (uint152) {\n        if (value > type(uint152).max) {\n            revert SafeCastOverflowedUintDowncast(152, value);\n        }\n        return uint152(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint144 from uint256, reverting on\n     * overflow (when the input is greater than largest uint144).\n     *\n     * Counterpart to Solidity's `uint144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     */\n    function toUint144(uint256 value) internal pure returns (uint144) {\n        if (value > type(uint144).max) {\n            revert SafeCastOverflowedUintDowncast(144, value);\n        }\n        return uint144(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint136 from uint256, reverting on\n     * overflow (when the input is greater than largest uint136).\n     *\n     * Counterpart to Solidity's `uint136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     */\n    function toUint136(uint256 value) internal pure returns (uint136) {\n        if (value > type(uint136).max) {\n            revert SafeCastOverflowedUintDowncast(136, value);\n        }\n        return uint136(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint128 from uint256, reverting on\n     * overflow (when the input is greater than largest uint128).\n     *\n     * Counterpart to Solidity's `uint128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     */\n    function toUint128(uint256 value) internal pure returns (uint128) {\n        if (value > type(uint128).max) {\n            revert SafeCastOverflowedUintDowncast(128, value);\n        }\n        return uint128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint120 from uint256, reverting on\n     * overflow (when the input is greater than largest uint120).\n     *\n     * Counterpart to Solidity's `uint120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     */\n    function toUint120(uint256 value) internal pure returns (uint120) {\n        if (value > type(uint120).max) {\n            revert SafeCastOverflowedUintDowncast(120, value);\n        }\n        return uint120(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint112 from uint256, reverting on\n     * overflow (when the input is greater than largest uint112).\n     *\n     * Counterpart to Solidity's `uint112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     */\n    function toUint112(uint256 value) internal pure returns (uint112) {\n        if (value > type(uint112).max) {\n            revert SafeCastOverflowedUintDowncast(112, value);\n        }\n        return uint112(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint104 from uint256, reverting on\n     * overflow (when the input is greater than largest uint104).\n     *\n     * Counterpart to Solidity's `uint104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     */\n    function toUint104(uint256 value) internal pure returns (uint104) {\n        if (value > type(uint104).max) {\n            revert SafeCastOverflowedUintDowncast(104, value);\n        }\n        return uint104(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint96 from uint256, reverting on\n     * overflow (when the input is greater than largest uint96).\n     *\n     * Counterpart to Solidity's `uint96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     */\n    function toUint96(uint256 value) internal pure returns (uint96) {\n        if (value > type(uint96).max) {\n            revert SafeCastOverflowedUintDowncast(96, value);\n        }\n        return uint96(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint88 from uint256, reverting on\n     * overflow (when the input is greater than largest uint88).\n     *\n     * Counterpart to Solidity's `uint88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     */\n    function toUint88(uint256 value) internal pure returns (uint88) {\n        if (value > type(uint88).max) {\n            revert SafeCastOverflowedUintDowncast(88, value);\n        }\n        return uint88(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint80 from uint256, reverting on\n     * overflow (when the input is greater than largest uint80).\n     *\n     * Counterpart to Solidity's `uint80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     */\n    function toUint80(uint256 value) internal pure returns (uint80) {\n        if (value > type(uint80).max) {\n            revert SafeCastOverflowedUintDowncast(80, value);\n        }\n        return uint80(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint72 from uint256, reverting on\n     * overflow (when the input is greater than largest uint72).\n     *\n     * Counterpart to Solidity's `uint72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     */\n    function toUint72(uint256 value) internal pure returns (uint72) {\n        if (value > type(uint72).max) {\n            revert SafeCastOverflowedUintDowncast(72, value);\n        }\n        return uint72(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint64 from uint256, reverting on\n     * overflow (when the input is greater than largest uint64).\n     *\n     * Counterpart to Solidity's `uint64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     */\n    function toUint64(uint256 value) internal pure returns (uint64) {\n        if (value > type(uint64).max) {\n            revert SafeCastOverflowedUintDowncast(64, value);\n        }\n        return uint64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint56 from uint256, reverting on\n     * overflow (when the input is greater than largest uint56).\n     *\n     * Counterpart to Solidity's `uint56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     */\n    function toUint56(uint256 value) internal pure returns (uint56) {\n        if (value > type(uint56).max) {\n            revert SafeCastOverflowedUintDowncast(56, value);\n        }\n        return uint56(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint48 from uint256, reverting on\n     * overflow (when the input is greater than largest uint48).\n     *\n     * Counterpart to Solidity's `uint48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     */\n    function toUint48(uint256 value) internal pure returns (uint48) {\n        if (value > type(uint48).max) {\n            revert SafeCastOverflowedUintDowncast(48, value);\n        }\n        return uint48(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint40 from uint256, reverting on\n     * overflow (when the input is greater than largest uint40).\n     *\n     * Counterpart to Solidity's `uint40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     */\n    function toUint40(uint256 value) internal pure returns (uint40) {\n        if (value > type(uint40).max) {\n            revert SafeCastOverflowedUintDowncast(40, value);\n        }\n        return uint40(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint32 from uint256, reverting on\n     * overflow (when the input is greater than largest uint32).\n     *\n     * Counterpart to Solidity's `uint32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     */\n    function toUint32(uint256 value) internal pure returns (uint32) {\n        if (value > type(uint32).max) {\n            revert SafeCastOverflowedUintDowncast(32, value);\n        }\n        return uint32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint24 from uint256, reverting on\n     * overflow (when the input is greater than largest uint24).\n     *\n     * Counterpart to Solidity's `uint24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     */\n    function toUint24(uint256 value) internal pure returns (uint24) {\n        if (value > type(uint24).max) {\n            revert SafeCastOverflowedUintDowncast(24, value);\n        }\n        return uint24(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint16 from uint256, reverting on\n     * overflow (when the input is greater than largest uint16).\n     *\n     * Counterpart to Solidity's `uint16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     */\n    function toUint16(uint256 value) internal pure returns (uint16) {\n        if (value > type(uint16).max) {\n            revert SafeCastOverflowedUintDowncast(16, value);\n        }\n        return uint16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint8 from uint256, reverting on\n     * overflow (when the input is greater than largest uint8).\n     *\n     * Counterpart to Solidity's `uint8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     */\n    function toUint8(uint256 value) internal pure returns (uint8) {\n        if (value > type(uint8).max) {\n            revert SafeCastOverflowedUintDowncast(8, value);\n        }\n        return uint8(value);\n    }\n\n    /**\n     * @dev Converts a signed int256 into an unsigned uint256.\n     *\n     * Requirements:\n     *\n     * - input must be greater than or equal to 0.\n     */\n    function toUint256(int256 value) internal pure returns (uint256) {\n        if (value < 0) {\n            revert SafeCastOverflowedIntToUint(value);\n        }\n        return uint256(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int248 from int256, reverting on\n     * overflow (when the input is less than smallest int248 or\n     * greater than largest int248).\n     *\n     * Counterpart to Solidity's `int248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     */\n    function toInt248(int256 value) internal pure returns (int248 downcasted) {\n        downcasted = int248(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(248, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int240 from int256, reverting on\n     * overflow (when the input is less than smallest int240 or\n     * greater than largest int240).\n     *\n     * Counterpart to Solidity's `int240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     */\n    function toInt240(int256 value) internal pure returns (int240 downcasted) {\n        downcasted = int240(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(240, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int232 from int256, reverting on\n     * overflow (when the input is less than smallest int232 or\n     * greater than largest int232).\n     *\n     * Counterpart to Solidity's `int232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     */\n    function toInt232(int256 value) internal pure returns (int232 downcasted) {\n        downcasted = int232(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(232, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int224 from int256, reverting on\n     * overflow (when the input is less than smallest int224 or\n     * greater than largest int224).\n     *\n     * Counterpart to Solidity's `int224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     */\n    function toInt224(int256 value) internal pure returns (int224 downcasted) {\n        downcasted = int224(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(224, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int216 from int256, reverting on\n     * overflow (when the input is less than smallest int216 or\n     * greater than largest int216).\n     *\n     * Counterpart to Solidity's `int216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     */\n    function toInt216(int256 value) internal pure returns (int216 downcasted) {\n        downcasted = int216(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(216, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int208 from int256, reverting on\n     * overflow (when the input is less than smallest int208 or\n     * greater than largest int208).\n     *\n     * Counterpart to Solidity's `int208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     */\n    function toInt208(int256 value) internal pure returns (int208 downcasted) {\n        downcasted = int208(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(208, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int200 from int256, reverting on\n     * overflow (when the input is less than smallest int200 or\n     * greater than largest int200).\n     *\n     * Counterpart to Solidity's `int200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     */\n    function toInt200(int256 value) internal pure returns (int200 downcasted) {\n        downcasted = int200(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(200, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int192 from int256, reverting on\n     * overflow (when the input is less than smallest int192 or\n     * greater than largest int192).\n     *\n     * Counterpart to Solidity's `int192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     */\n    function toInt192(int256 value) internal pure returns (int192 downcasted) {\n        downcasted = int192(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(192, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int184 from int256, reverting on\n     * overflow (when the input is less than smallest int184 or\n     * greater than largest int184).\n     *\n     * Counterpart to Solidity's `int184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     */\n    function toInt184(int256 value) internal pure returns (int184 downcasted) {\n        downcasted = int184(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(184, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int176 from int256, reverting on\n     * overflow (when the input is less than smallest int176 or\n     * greater than largest int176).\n     *\n     * Counterpart to Solidity's `int176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     */\n    function toInt176(int256 value) internal pure returns (int176 downcasted) {\n        downcasted = int176(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(176, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int168 from int256, reverting on\n     * overflow (when the input is less than smallest int168 or\n     * greater than largest int168).\n     *\n     * Counterpart to Solidity's `int168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     */\n    function toInt168(int256 value) internal pure returns (int168 downcasted) {\n        downcasted = int168(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(168, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int160 from int256, reverting on\n     * overflow (when the input is less than smallest int160 or\n     * greater than largest int160).\n     *\n     * Counterpart to Solidity's `int160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     */\n    function toInt160(int256 value) internal pure returns (int160 downcasted) {\n        downcasted = int160(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(160, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int152 from int256, reverting on\n     * overflow (when the input is less than smallest int152 or\n     * greater than largest int152).\n     *\n     * Counterpart to Solidity's `int152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     */\n    function toInt152(int256 value) internal pure returns (int152 downcasted) {\n        downcasted = int152(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(152, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int144 from int256, reverting on\n     * overflow (when the input is less than smallest int144 or\n     * greater than largest int144).\n     *\n     * Counterpart to Solidity's `int144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     */\n    function toInt144(int256 value) internal pure returns (int144 downcasted) {\n        downcasted = int144(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(144, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int136 from int256, reverting on\n     * overflow (when the input is less than smallest int136 or\n     * greater than largest int136).\n     *\n     * Counterpart to Solidity's `int136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     */\n    function toInt136(int256 value) internal pure returns (int136 downcasted) {\n        downcasted = int136(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(136, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int128 from int256, reverting on\n     * overflow (when the input is less than smallest int128 or\n     * greater than largest int128).\n     *\n     * Counterpart to Solidity's `int128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     */\n    function toInt128(int256 value) internal pure returns (int128 downcasted) {\n        downcasted = int128(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(128, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int120 from int256, reverting on\n     * overflow (when the input is less than smallest int120 or\n     * greater than largest int120).\n     *\n     * Counterpart to Solidity's `int120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     */\n    function toInt120(int256 value) internal pure returns (int120 downcasted) {\n        downcasted = int120(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(120, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int112 from int256, reverting on\n     * overflow (when the input is less than smallest int112 or\n     * greater than largest int112).\n     *\n     * Counterpart to Solidity's `int112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     */\n    function toInt112(int256 value) internal pure returns (int112 downcasted) {\n        downcasted = int112(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(112, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int104 from int256, reverting on\n     * overflow (when the input is less than smallest int104 or\n     * greater than largest int104).\n     *\n     * Counterpart to Solidity's `int104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     */\n    function toInt104(int256 value) internal pure returns (int104 downcasted) {\n        downcasted = int104(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(104, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int96 from int256, reverting on\n     * overflow (when the input is less than smallest int96 or\n     * greater than largest int96).\n     *\n     * Counterpart to Solidity's `int96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     */\n    function toInt96(int256 value) internal pure returns (int96 downcasted) {\n        downcasted = int96(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(96, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int88 from int256, reverting on\n     * overflow (when the input is less than smallest int88 or\n     * greater than largest int88).\n     *\n     * Counterpart to Solidity's `int88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     */\n    function toInt88(int256 value) internal pure returns (int88 downcasted) {\n        downcasted = int88(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(88, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int80 from int256, reverting on\n     * overflow (when the input is less than smallest int80 or\n     * greater than largest int80).\n     *\n     * Counterpart to Solidity's `int80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     */\n    function toInt80(int256 value) internal pure returns (int80 downcasted) {\n        downcasted = int80(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(80, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int72 from int256, reverting on\n     * overflow (when the input is less than smallest int72 or\n     * greater than largest int72).\n     *\n     * Counterpart to Solidity's `int72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     */\n    function toInt72(int256 value) internal pure returns (int72 downcasted) {\n        downcasted = int72(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(72, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int64 from int256, reverting on\n     * overflow (when the input is less than smallest int64 or\n     * greater than largest int64).\n     *\n     * Counterpart to Solidity's `int64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     */\n    function toInt64(int256 value) internal pure returns (int64 downcasted) {\n        downcasted = int64(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(64, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int56 from int256, reverting on\n     * overflow (when the input is less than smallest int56 or\n     * greater than largest int56).\n     *\n     * Counterpart to Solidity's `int56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     */\n    function toInt56(int256 value) internal pure returns (int56 downcasted) {\n        downcasted = int56(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(56, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int48 from int256, reverting on\n     * overflow (when the input is less than smallest int48 or\n     * greater than largest int48).\n     *\n     * Counterpart to Solidity's `int48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     */\n    function toInt48(int256 value) internal pure returns (int48 downcasted) {\n        downcasted = int48(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(48, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int40 from int256, reverting on\n     * overflow (when the input is less than smallest int40 or\n     * greater than largest int40).\n     *\n     * Counterpart to Solidity's `int40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     */\n    function toInt40(int256 value) internal pure returns (int40 downcasted) {\n        downcasted = int40(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(40, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int32 from int256, reverting on\n     * overflow (when the input is less than smallest int32 or\n     * greater than largest int32).\n     *\n     * Counterpart to Solidity's `int32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     */\n    function toInt32(int256 value) internal pure returns (int32 downcasted) {\n        downcasted = int32(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(32, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int24 from int256, reverting on\n     * overflow (when the input is less than smallest int24 or\n     * greater than largest int24).\n     *\n     * Counterpart to Solidity's `int24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     */\n    function toInt24(int256 value) internal pure returns (int24 downcasted) {\n        downcasted = int24(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(24, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int16 from int256, reverting on\n     * overflow (when the input is less than smallest int16 or\n     * greater than largest int16).\n     *\n     * Counterpart to Solidity's `int16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     */\n    function toInt16(int256 value) internal pure returns (int16 downcasted) {\n        downcasted = int16(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(16, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int8 from int256, reverting on\n     * overflow (when the input is less than smallest int8 or\n     * greater than largest int8).\n     *\n     * Counterpart to Solidity's `int8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     */\n    function toInt8(int256 value) internal pure returns (int8 downcasted) {\n        downcasted = int8(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(8, value);\n        }\n    }\n\n    /**\n     * @dev Converts an unsigned uint256 into a signed int256.\n     *\n     * Requirements:\n     *\n     * - input must be less than or equal to maxInt256.\n     */\n    function toInt256(uint256 value) internal pure returns (int256) {\n        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n        if (value > uint256(type(int256).max)) {\n            revert SafeCastOverflowedUintToInt(value);\n        }\n        return int256(value);\n    }\n}\n"
      },
      "lib/rave/src/JSONBuilder.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0 <0.9.0;\n\ncontract JSONBuilder {\n    struct Values {\n        bytes id;\n        bytes timestamp;\n        bytes version;\n        bytes epidPseudonym;\n        bytes advisoryURL;\n        bytes advisoryIDs;\n        bytes isvEnclaveQuoteStatus;\n        bytes isvEnclaveQuoteBody;\n    }\n\n    function buildJSON(Values memory values) public pure returns (string memory json) {\n        json = string(\n            abi.encodePacked(\n                '{\"id\":\"',\n                values.id,\n                '\",\"timestamp\":\"',\n                values.timestamp,\n                '\",\"version\":',\n                values.version,\n                ',\"epidPseudonym\":\"',\n                values.epidPseudonym\n            )\n        );\n        json = string(\n            abi.encodePacked(\n                json,\n                '\",\"advisoryURL\":\"',\n                values.advisoryURL,\n                '\",\"advisoryIDs\":',\n                values.advisoryIDs,\n                ',\"isvEnclaveQuoteStatus\":\"',\n                values.isvEnclaveQuoteStatus,\n                '\",\"isvEnclaveQuoteBody\":\"',\n                values.isvEnclaveQuoteBody,\n                '\"}'\n            )\n        );\n    }\n}\n\ncontract CustomJSONBuilder {\n    string[] public keys;\n\n    constructor(string[] memory _keys) {\n        keys = _keys;\n    }\n\n    function buildJSON(string[] memory values) public view returns (string memory) {\n        require(values.length == keys.length);\n        string memory json = \"\";\n        for (uint256 i = 0; i < keys.length; i++) {\n            json = string(abi.encodePacked(json, keys[i], values[i]));\n        }\n        return string(abi.encodePacked(\"{\", json, '\"}'));\n    }\n}\n"
      },
      "lib/rave/lib/ens-contracts/contracts/dnssec-oracle/BytesUtils.sol": {
        "content": "pragma solidity ^0.8.4;\n\nlibrary BytesUtils {\n    error OffsetOutOfBoundsError(uint256 offset, uint256 length);\n\n    /*\n     * @dev Returns the keccak-256 hash of a byte range.\n     * @param self The byte string to hash.\n     * @param offset The position to start hashing at.\n     * @param len The number of bytes to hash.\n     * @return The hash of the byte range.\n     */\n    function keccak(\n        bytes memory self,\n        uint256 offset,\n        uint256 len\n    ) internal pure returns (bytes32 ret) {\n        require(offset + len <= self.length);\n        assembly {\n            ret := keccak256(add(add(self, 32), offset), len)\n        }\n    }\n\n    /*\n     * @dev Returns a positive number if `other` comes lexicographically after\n     *      `self`, a negative number if it comes before, or zero if the\n     *      contents of the two bytes are equal.\n     * @param self The first bytes to compare.\n     * @param other The second bytes to compare.\n     * @return The result of the comparison.\n     */\n    function compare(\n        bytes memory self,\n        bytes memory other\n    ) internal pure returns (int256) {\n        return compare(self, 0, self.length, other, 0, other.length);\n    }\n\n    /*\n     * @dev Returns a positive number if `other` comes lexicographically after\n     *      `self`, a negative number if it comes before, or zero if the\n     *      contents of the two bytes are equal. Comparison is done per-rune,\n     *      on unicode codepoints.\n     * @param self The first bytes to compare.\n     * @param offset The offset of self.\n     * @param len    The length of self.\n     * @param other The second bytes to compare.\n     * @param otheroffset The offset of the other string.\n     * @param otherlen    The length of the other string.\n     * @return The result of the comparison.\n     */\n    function compare(\n        bytes memory self,\n        uint256 offset,\n        uint256 len,\n        bytes memory other,\n        uint256 otheroffset,\n        uint256 otherlen\n    ) internal pure returns (int256) {\n        if (offset + len > self.length) {\n            revert OffsetOutOfBoundsError(offset + len, self.length);\n        }\n        if (otheroffset + otherlen > other.length) {\n            revert OffsetOutOfBoundsError(otheroffset + otherlen, other.length);\n        }\n\n        uint256 shortest = len;\n        if (otherlen < len) shortest = otherlen;\n\n        uint256 selfptr;\n        uint256 otherptr;\n\n        assembly {\n            selfptr := add(self, add(offset, 32))\n            otherptr := add(other, add(otheroffset, 32))\n        }\n        for (uint256 idx = 0; idx < shortest; idx += 32) {\n            uint256 a;\n            uint256 b;\n            assembly {\n                a := mload(selfptr)\n                b := mload(otherptr)\n            }\n            if (a != b) {\n                // Mask out irrelevant bytes and check again\n                uint256 mask;\n                if (shortest - idx >= 32) {\n                    mask = type(uint256).max;\n                } else {\n                    mask = ~(2 ** (8 * (idx + 32 - shortest)) - 1);\n                }\n                int256 diff = int256(a & mask) - int256(b & mask);\n                if (diff != 0) return diff;\n            }\n            selfptr += 32;\n            otherptr += 32;\n        }\n\n        return int256(len) - int256(otherlen);\n    }\n\n    /*\n     * @dev Returns true if the two byte ranges are equal.\n     * @param self The first byte range to compare.\n     * @param offset The offset into the first byte range.\n     * @param other The second byte range to compare.\n     * @param otherOffset The offset into the second byte range.\n     * @param len The number of bytes to compare\n     * @return True if the byte ranges are equal, false otherwise.\n     */\n    function equals(\n        bytes memory self,\n        uint256 offset,\n        bytes memory other,\n        uint256 otherOffset,\n        uint256 len\n    ) internal pure returns (bool) {\n        return keccak(self, offset, len) == keccak(other, otherOffset, len);\n    }\n\n    /*\n     * @dev Returns true if the two byte ranges are equal with offsets.\n     * @param self The first byte range to compare.\n     * @param offset The offset into the first byte range.\n     * @param other The second byte range to compare.\n     * @param otherOffset The offset into the second byte range.\n     * @return True if the byte ranges are equal, false otherwise.\n     */\n    function equals(\n        bytes memory self,\n        uint256 offset,\n        bytes memory other,\n        uint256 otherOffset\n    ) internal pure returns (bool) {\n        return\n            keccak(self, offset, self.length - offset) ==\n            keccak(other, otherOffset, other.length - otherOffset);\n    }\n\n    /*\n     * @dev Compares a range of 'self' to all of 'other' and returns True iff\n     *      they are equal.\n     * @param self The first byte range to compare.\n     * @param offset The offset into the first byte range.\n     * @param other The second byte range to compare.\n     * @return True if the byte ranges are equal, false otherwise.\n     */\n    function equals(\n        bytes memory self,\n        uint256 offset,\n        bytes memory other\n    ) internal pure returns (bool) {\n        return\n            self.length == offset + other.length &&\n            equals(self, offset, other, 0, other.length);\n    }\n\n    /*\n     * @dev Returns true if the two byte ranges are equal.\n     * @param self The first byte range to compare.\n     * @param other The second byte range to compare.\n     * @return True if the byte ranges are equal, false otherwise.\n     */\n    function equals(\n        bytes memory self,\n        bytes memory other\n    ) internal pure returns (bool) {\n        return\n            self.length == other.length &&\n            equals(self, 0, other, 0, self.length);\n    }\n\n    /*\n     * @dev Returns the 8-bit number at the specified index of self.\n     * @param self The byte string.\n     * @param idx The index into the bytes\n     * @return The specified 8 bits of the string, interpreted as an integer.\n     */\n    function readUint8(\n        bytes memory self,\n        uint256 idx\n    ) internal pure returns (uint8 ret) {\n        return uint8(self[idx]);\n    }\n\n    /*\n     * @dev Returns the 16-bit number at the specified index of self.\n     * @param self The byte string.\n     * @param idx The index into the bytes\n     * @return The specified 16 bits of the string, interpreted as an integer.\n     */\n    function readUint16(\n        bytes memory self,\n        uint256 idx\n    ) internal pure returns (uint16 ret) {\n        require(idx + 2 <= self.length);\n        assembly {\n            ret := and(mload(add(add(self, 2), idx)), 0xFFFF)\n        }\n    }\n\n    /*\n     * @dev Returns the 32-bit number at the specified index of self.\n     * @param self The byte string.\n     * @param idx The index into the bytes\n     * @return The specified 32 bits of the string, interpreted as an integer.\n     */\n    function readUint32(\n        bytes memory self,\n        uint256 idx\n    ) internal pure returns (uint32 ret) {\n        require(idx + 4 <= self.length);\n        assembly {\n            ret := and(mload(add(add(self, 4), idx)), 0xFFFFFFFF)\n        }\n    }\n\n    /*\n     * @dev Returns the 32 byte value at the specified index of self.\n     * @param self The byte string.\n     * @param idx The index into the bytes\n     * @return The specified 32 bytes of the string.\n     */\n    function readBytes32(\n        bytes memory self,\n        uint256 idx\n    ) internal pure returns (bytes32 ret) {\n        require(idx + 32 <= self.length);\n        assembly {\n            ret := mload(add(add(self, 32), idx))\n        }\n    }\n\n    /*\n     * @dev Returns the 32 byte value at the specified index of self.\n     * @param self The byte string.\n     * @param idx The index into the bytes\n     * @return The specified 32 bytes of the string.\n     */\n    function readBytes20(\n        bytes memory self,\n        uint256 idx\n    ) internal pure returns (bytes20 ret) {\n        require(idx + 20 <= self.length);\n        assembly {\n            ret := and(\n                mload(add(add(self, 32), idx)),\n                0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000\n            )\n        }\n    }\n\n    /*\n     * @dev Returns the n byte value at the specified index of self.\n     * @param self The byte string.\n     * @param idx The index into the bytes.\n     * @param len The number of bytes.\n     * @return The specified 32 bytes of the string.\n     */\n    function readBytesN(\n        bytes memory self,\n        uint256 idx,\n        uint256 len\n    ) internal pure returns (bytes32 ret) {\n        require(len <= 32);\n        require(idx + len <= self.length);\n        assembly {\n            let mask := not(sub(exp(256, sub(32, len)), 1))\n            ret := and(mload(add(add(self, 32), idx)), mask)\n        }\n    }\n\n    function memcpy(uint256 dest, uint256 src, uint256 len) private pure {\n        // Copy word-length chunks while possible\n        for (; len >= 32; len -= 32) {\n            assembly {\n                mstore(dest, mload(src))\n            }\n            dest += 32;\n            src += 32;\n        }\n\n        // Copy remaining bytes\n        unchecked {\n            uint256 mask = (256 ** (32 - len)) - 1;\n            assembly {\n                let srcpart := and(mload(src), not(mask))\n                let destpart := and(mload(dest), mask)\n                mstore(dest, or(destpart, srcpart))\n            }\n        }\n    }\n\n    /*\n     * @dev Copies a substring into a new byte string.\n     * @param self The byte string to copy from.\n     * @param offset The offset to start copying at.\n     * @param len The number of bytes to copy.\n     */\n    function substring(\n        bytes memory self,\n        uint256 offset,\n        uint256 len\n    ) internal pure returns (bytes memory) {\n        require(offset + len <= self.length);\n\n        bytes memory ret = new bytes(len);\n        uint256 dest;\n        uint256 src;\n\n        assembly {\n            dest := add(ret, 32)\n            src := add(add(self, 32), offset)\n        }\n        memcpy(dest, src, len);\n\n        return ret;\n    }\n\n    // Maps characters from 0x30 to 0x7A to their base32 values.\n    // 0xFF represents invalid characters in that range.\n    bytes constant base32HexTable =\n        hex\"00010203040506070809FFFFFFFFFFFFFF0A0B0C0D0E0F101112131415161718191A1B1C1D1E1FFFFFFFFFFFFFFFFFFFFF0A0B0C0D0E0F101112131415161718191A1B1C1D1E1F\";\n\n    /**\n     * @dev Decodes unpadded base32 data of up to one word in length.\n     * @param self The data to decode.\n     * @param off Offset into the string to start at.\n     * @param len Number of characters to decode.\n     * @return The decoded data, left aligned.\n     */\n    function base32HexDecodeWord(\n        bytes memory self,\n        uint256 off,\n        uint256 len\n    ) internal pure returns (bytes32) {\n        require(len <= 52);\n\n        uint256 ret = 0;\n        uint8 decoded;\n        for (uint256 i = 0; i < len; i++) {\n            bytes1 char = self[off + i];\n            require(char >= 0x30 && char <= 0x7A);\n            decoded = uint8(base32HexTable[uint256(uint8(char)) - 0x30]);\n            require(decoded <= 0x20);\n            if (i == len - 1) {\n                break;\n            }\n            ret = (ret << 5) | decoded;\n        }\n\n        uint256 bitlen = len * 5;\n        if (len % 8 == 0) {\n            // Multiple of 8 characters, no padding\n            ret = (ret << 5) | decoded;\n        } else if (len % 8 == 2) {\n            // Two extra characters - 1 byte\n            ret = (ret << 3) | (decoded >> 2);\n            bitlen -= 2;\n        } else if (len % 8 == 4) {\n            // Four extra characters - 2 bytes\n            ret = (ret << 1) | (decoded >> 4);\n            bitlen -= 4;\n        } else if (len % 8 == 5) {\n            // Five extra characters - 3 bytes\n            ret = (ret << 4) | (decoded >> 1);\n            bitlen -= 1;\n        } else if (len % 8 == 7) {\n            // Seven extra characters - 4 bytes\n            ret = (ret << 2) | (decoded >> 3);\n            bitlen -= 3;\n        } else {\n            revert();\n        }\n\n        return bytes32(ret << (256 - bitlen));\n    }\n\n    /**\n     * @dev Finds the first occurrence of the byte `needle` in `self`.\n     * @param self The string to search\n     * @param off The offset to start searching at\n     * @param len The number of bytes to search\n     * @param needle The byte to search for\n     * @return The offset of `needle` in `self`, or 2**256-1 if it was not found.\n     */\n    function find(\n        bytes memory self,\n        uint256 off,\n        uint256 len,\n        bytes1 needle\n    ) internal pure returns (uint256) {\n        for (uint256 idx = off; idx < off + len; idx++) {\n            if (self[idx] == needle) {\n                return idx;\n            }\n        }\n        return type(uint256).max;\n    }\n\n    /**\n     * @dev Attempts to parse an address from a hex string\n     * @param str The string to parse\n     * @param idx The offset to start parsing at\n     * @param lastIdx The (exclusive) last index in `str` to consider. Use `str.length` to scan the whole string.\n     */\n    function hexToAddress(\n        bytes memory str,\n        uint256 idx,\n        uint256 lastIdx\n    ) internal pure returns (address, bool) {\n        if (lastIdx - idx < 40) return (address(0x0), false);\n        uint256 ret = 0;\n        for (uint256 i = idx; i < idx + 40; i++) {\n            ret <<= 4;\n            uint256 x = readUint8(str, i);\n            if (x >= 48 && x < 58) {\n                ret |= x - 48;\n            } else if (x >= 65 && x < 71) {\n                ret |= x - 55;\n            } else if (x >= 97 && x < 103) {\n                ret |= x - 87;\n            } else {\n                return (address(0x0), false);\n            }\n        }\n        return (address(uint160(ret)), true);\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/Base64.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Base64.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n */\nlibrary Base64 {\n    /**\n     * @dev Base64 Encoding/Decoding Table\n     */\n    string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n    /**\n     * @dev Converts a `bytes` to its Bytes64 `string` representation.\n     */\n    function encode(bytes memory data) internal pure returns (string memory) {\n        /**\n         * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n         * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n         */\n        if (data.length == 0) return \"\";\n\n        // Loads the table into memory\n        string memory table = _TABLE;\n\n        // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n        // and split into 4 numbers of 6 bits.\n        // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n        // - `data.length + 2`  -> Round up\n        // - `/ 3`              -> Number of 3-bytes chunks\n        // - `4 *`              -> 4 characters for each chunk\n        string memory result = new string(4 * ((data.length + 2) / 3));\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Prepare the lookup table (skip the first \"length\" byte)\n            let tablePtr := add(table, 1)\n\n            // Prepare result pointer, jump over length\n            let resultPtr := add(result, 32)\n\n            // Run over the input, 3 bytes at a time\n            for {\n                let dataPtr := data\n                let endPtr := add(data, mload(data))\n            } lt(dataPtr, endPtr) {\n\n            } {\n                // Advance 3 bytes\n                dataPtr := add(dataPtr, 3)\n                let input := mload(dataPtr)\n\n                // To write each character, shift the 3 bytes (18 bits) chunk\n                // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n                // and apply logical AND with 0x3F which is the number of\n                // the previous character in the ASCII table prior to the Base64 Table\n                // The result is then added to the table to get the character to write,\n                // and finally write it in the result pointer but with a left shift\n                // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n                mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n                resultPtr := add(resultPtr, 1) // Advance\n\n                mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n                resultPtr := add(resultPtr, 1) // Advance\n\n                mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n                resultPtr := add(resultPtr, 1) // Advance\n\n                mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n                resultPtr := add(resultPtr, 1) // Advance\n            }\n\n            // When data `bytes` is not exactly 3 bytes long\n            // it is padded with `=` characters at the end\n            switch mod(mload(data), 3)\n            case 1 {\n                mstore8(sub(resultPtr, 1), 0x3d)\n                mstore8(sub(resultPtr, 2), 0x3d)\n            }\n            case 2 {\n                mstore8(sub(resultPtr, 1), 0x3d)\n            }\n        }\n\n        return result;\n    }\n}\n"
      },
      "lib/rave/src/RAVEBase.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0 <0.9.0;\n\nimport { BytesUtils } from \"ens-contracts/dnssec-oracle/BytesUtils.sol\";\nimport { RSAVerify } from \"ens-contracts/dnssec-oracle/algorithms/RSAVerify.sol\";\nimport { IRave } from \"rave/IRave.sol\";\n\nabstract contract RAVEBase is IRave {\n    using BytesUtils for *;\n\n    uint256 constant MAX_JSON_ELEMENTS = 19;\n    uint256 constant QUOTE_BODY_LENGTH = 432;\n    uint256 constant MRENCLAVE_OFFSET = 112;\n    uint256 constant MRSIGNER_OFFSET = 176;\n    uint256 constant PAYLOAD_OFFSET = 368;\n    uint256 constant PAYLOAD_SIZE = 64;\n\n    bytes32 constant OK_STATUS = keccak256(\"OK\");\n    bytes32 constant HARDENING_STATUS = keccak256(\"SW_HARDENING_NEEDED\");\n\n    constructor() { }\n\n    /**\n     * @inheritdoc IRave\n     */\n    function verifyReportSignature(\n        bytes memory report,\n        bytes calldata sig,\n        bytes memory signingMod,\n        bytes memory signingExp\n    ) public view returns (bool) {\n        // Use signingPK to verify sig is the RSA signature over sha256(report)\n        (bool success, bytes memory got) = RSAVerify.rsarecover(signingMod, signingExp, sig);\n        // Last 32 bytes is recovered signed digest\n        bytes32 recovered = got.readBytes32(got.length - 32);\n        return success && recovered == sha256(report);\n    }\n\n    /**\n     * @inheritdoc IRave\n     */\n    function verifyRemoteAttestation(\n        bytes calldata report,\n        bytes calldata sig,\n        bytes memory signingMod,\n        bytes memory signingExp,\n        bytes32 mrenclave,\n        bytes32 mrsigner\n    ) public view virtual returns (bytes memory payload) { }\n\n    /**\n     * @inheritdoc IRave\n     */\n    function rave(\n        bytes calldata report,\n        bytes calldata sig,\n        bytes memory leafX509Cert,\n        bytes memory signingMod,\n        bytes memory signingExp,\n        bytes32 mrenclave,\n        bytes32 mrsigner\n    ) external view virtual returns (bytes memory payload) { }\n}\n"
      },
      "lib/rave/src/ASN1Decode.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// Original source: https://github.com/JonahGroendal/asn1-decode\npragma solidity >=0.8.0 <0.9.0;\n\nimport { BytesUtils } from \"ens-contracts/dnssec-oracle/BytesUtils.sol\";\n\nlibrary NodePtr {\n    // Unpack first byte index\n    function ixs(uint256 self) internal pure returns (uint256) {\n        return uint80(self);\n    }\n    // Unpack first content byte index\n\n    function ixf(uint256 self) internal pure returns (uint256) {\n        return uint80(self >> 80);\n    }\n    // Unpack last content byte index\n\n    function ixl(uint256 self) internal pure returns (uint256) {\n        return uint80(self >> 160);\n    }\n    // Pack 3 uint80s into a uint256\n\n    function getPtr(uint256 _ixs, uint256 _ixf, uint256 _ixl) internal pure returns (uint256) {\n        _ixs |= _ixf << 80;\n        _ixs |= _ixl << 160;\n        return _ixs;\n    }\n}\n\nlibrary Asn1Decode {\n    using NodePtr for uint256;\n    using BytesUtils for bytes;\n\n    /*\n    * @dev Get the root node. First step in traversing an ASN1 structure\n    * @param der The DER-encoded ASN1 structure\n    * @return A pointer to the outermost node\n    */\n    function root(bytes memory der) internal pure returns (uint256) {\n        return readNodeLength(der, 0);\n    }\n\n    /*\n    * @dev Get the root node of an ASN1 structure that's within a bit string value\n    * @param der The DER-encoded ASN1 structure\n    * @return A pointer to the outermost node\n    */\n    function rootOfBitStringAt(bytes memory der, uint256 ptr) internal pure returns (uint256) {\n        require(der[ptr.ixs()] == 0x03, \"Not type BIT STRING\");\n        return readNodeLength(der, ptr.ixf() + 1);\n    }\n\n    /*\n    * @dev Get the root node of an ASN1 structure that's within an octet string value\n    * @param der The DER-encoded ASN1 structure\n    * @return A pointer to the outermost node\n    */\n    function rootOfOctetStringAt(bytes memory der, uint256 ptr) internal pure returns (uint256) {\n        require(der[ptr.ixs()] == 0x04, \"Not type OCTET STRING\");\n        return readNodeLength(der, ptr.ixf());\n    }\n\n    /*\n    * @dev Get the next sibling node\n    * @param der The DER-encoded ASN1 structure\n    * @param ptr Points to the indices of the current node\n    * @return A pointer to the next sibling node\n    */\n    function nextSiblingOf(bytes memory der, uint256 ptr) internal pure returns (uint256) {\n        return readNodeLength(der, ptr.ixl() + 1);\n    }\n\n    /*\n    * @dev Get the first child node of the current node\n    * @param der The DER-encoded ASN1 structure\n    * @param ptr Points to the indices of the current node\n    * @return A pointer to the first child node\n    */\n    function firstChildOf(bytes memory der, uint256 ptr) internal pure returns (uint256) {\n        require(der[ptr.ixs()] & 0x20 == 0x20, \"Not a constructed type\");\n        return readNodeLength(der, ptr.ixf());\n    }\n\n    /*\n    * @dev Use for looping through children of a node (either i or j).\n    * @param i Pointer to an ASN1 node\n    * @param j Pointer to another ASN1 node of the same ASN1 structure\n    * @return True iff j is child of i or i is child of j.\n    */\n    function isChildOf(uint256 i, uint256 j) internal pure returns (bool) {\n        return (((i.ixf() <= j.ixs()) && (j.ixl() <= i.ixl())) || ((j.ixf() <= i.ixs()) && (i.ixl() <= j.ixl())));\n    }\n\n    /*\n    * @dev Extract value of node from DER-encoded structure\n    * @param der The der-encoded ASN1 structure\n    * @param ptr Points to the indices of the current node\n    * @return Value bytes of node\n    */\n    function bytesAt(bytes memory der, uint256 ptr) internal pure returns (bytes memory) {\n        return der.substring(ptr.ixf(), ptr.ixl() + 1 - ptr.ixf());\n    }\n\n    /*\n    * @dev Extract entire node from DER-encoded structure\n    * @param der The DER-encoded ASN1 structure\n    * @param ptr Points to the indices of the current node\n    * @return All bytes of node\n    */\n    function allBytesAt(bytes memory der, uint256 ptr) internal pure returns (bytes memory) {\n        return der.substring(ptr.ixs(), ptr.ixl() + 1 - ptr.ixs());\n    }\n\n    /*\n    * @dev Extract value of node from DER-encoded structure\n    * @param der The DER-encoded ASN1 structure\n    * @param ptr Points to the indices of the current node\n    * @return Value bytes of node as bytes32\n    */\n    function bytes32At(bytes memory der, uint256 ptr) internal pure returns (bytes32) {\n        return der.readBytesN(ptr.ixf(), ptr.ixl() + 1 - ptr.ixf());\n    }\n\n    /*\n    * @dev Extract value of node from DER-encoded structure\n    * @param der The der-encoded ASN1 structure\n    * @param ptr Points to the indices of the current node\n    * @return Uint value of node\n    */\n    function uintAt(bytes memory der, uint256 ptr) internal pure returns (uint256) {\n        require(der[ptr.ixs()] == 0x02, \"Not type INTEGER\");\n        require(der[ptr.ixf()] & 0x80 == 0, \"Not positive\");\n        uint256 len = ptr.ixl() + 1 - ptr.ixf();\n        return uint256(der.readBytesN(ptr.ixf(), len) >> (32 - len) * 8);\n    }\n\n    /*\n    * @dev Extract value of a positive integer node from DER-encoded structure\n    * @param der The DER-encoded ASN1 structure\n    * @param ptr Points to the indices of the current node\n    * @return Value bytes of a positive integer node\n    */\n    function uintBytesAt(bytes memory der, uint256 ptr) internal pure returns (bytes memory) {\n        require(der[ptr.ixs()] == 0x02, \"Not type INTEGER\");\n        require(der[ptr.ixf()] & 0x80 == 0, \"Not positive\");\n        uint256 valueLength = ptr.ixl() + 1 - ptr.ixf();\n        if (der[ptr.ixf()] == 0) {\n            return der.substring(ptr.ixf() + 1, valueLength - 1);\n        } else {\n            return der.substring(ptr.ixf(), valueLength);\n        }\n    }\n\n    function keccakOfBytesAt(bytes memory der, uint256 ptr) internal pure returns (bytes32) {\n        return der.keccak(ptr.ixf(), ptr.ixl() + 1 - ptr.ixf());\n    }\n\n    function keccakOfAllBytesAt(bytes memory der, uint256 ptr) internal pure returns (bytes32) {\n        return der.keccak(ptr.ixs(), ptr.ixl() + 1 - ptr.ixs());\n    }\n\n    /*\n    * @dev Extract value of bitstring node from DER-encoded structure\n    * @param der The DER-encoded ASN1 structure\n    * @param ptr Points to the indices of the current node\n    * @return Value of bitstring converted to bytes\n    */\n    function bitstringAt(bytes memory der, uint256 ptr) internal pure returns (bytes memory) {\n        require(der[ptr.ixs()] == 0x03, \"Not type BIT STRING\");\n        // Only 00 padded bitstr can be converted to bytestr!\n        require(der[ptr.ixf()] == 0x00);\n        uint256 valueLength = ptr.ixl() + 1 - ptr.ixf();\n        return der.substring(ptr.ixf() + 1, valueLength - 1);\n    }\n\n    function readNodeLength(bytes memory der, uint256 ix) private pure returns (uint256) {\n        uint256 length;\n        uint80 ixFirstContentByte;\n        uint80 ixLastContentByte;\n        if ((der[ix + 1] & 0x80) == 0) {\n            length = uint8(der[ix + 1]);\n            ixFirstContentByte = uint80(ix + 2);\n            ixLastContentByte = uint80(ixFirstContentByte + length - 1);\n        } else {\n            uint8 lengthbytesLength = uint8(der[ix + 1] & 0x7F);\n            if (lengthbytesLength == 1) {\n                length = der.readUint8(ix + 2);\n            } else if (lengthbytesLength == 2) {\n                length = der.readUint16(ix + 2);\n            } else {\n                length = uint256(der.readBytesN(ix + 2, lengthbytesLength) >> (32 - lengthbytesLength) * 8);\n            }\n            ixFirstContentByte = uint80(ix + 2 + lengthbytesLength);\n            ixLastContentByte = uint80(ixFirstContentByte + length - 1);\n        }\n        return NodePtr.getPtr(ix, ixFirstContentByte, ixLastContentByte);\n    }\n}\n"
      },
      "lib/rave/lib/ens-contracts/contracts/dnssec-oracle/algorithms/RSAVerify.sol": {
        "content": "pragma solidity ^0.8.4;\n\nimport \"../BytesUtils.sol\";\nimport \"./ModexpPrecompile.sol\";\n\nlibrary RSAVerify {\n    /**\n     * @dev Recovers the input data from an RSA signature, returning the result in S.\n     * @param N The RSA public modulus.\n     * @param E The RSA public exponent.\n     * @param S The signature to recover.\n     * @return True if the recovery succeeded.\n     */\n    function rsarecover(\n        bytes memory N,\n        bytes memory E,\n        bytes memory S\n    ) internal view returns (bool, bytes memory) {\n        return ModexpPrecompile.modexp(S, E, N);\n    }\n}\n"
      },
      "lib/rave/src/IRave.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0 <0.9.0;\n\n/**\n * @title IRave interface\n * @author Puffer finance\n * @custom:security-contact security@puffer.fi\n * @notice IRave interface\n */\ninterface IRave {\n    /**\n     * Bad report signature\n     */\n    error BadReportSignature();\n\n    /*\n    * @dev Verifies the RSA-SHA256 signature of the attestation report.\n    * @param report The attestation evidence report from IAS.\n    * @param sig The RSA-SHA256 signature over the report.\n    * @param signingMod The expected signer's RSA modulus\n    * @param signingExp The expected signer's RSA exponent\n    * @return True if the signature is valid\n    */\n    function verifyReportSignature(\n        bytes memory report,\n        bytes calldata sig,\n        bytes memory signingMod,\n        bytes memory signingExp\n    ) external view returns (bool);\n\n    /*\n    * @dev Verifies that the leafX509Cert was signed by the expected signer (signingMod, signingExp). \n        Then uses leafX509Cert RSA public key to verify the signature over the report, sig. \n        The trusted report is verified for correct fields and then the enclave' 64 byte commitment is extracted. \n    * @param report The attestation evidence report from IAS.\n    * @param sig The RSA-SHA256 signature over the report.\n    * @param leafX509Cert The signed leaf x509 certificate.\n    * @param signingMod The expected signer's RSA modulus\n    * @param signingExp The expected signer's RSA exponent\n    * @param mrenclave The expected enclave measurement.\n    * @param mrsigner The expected enclave signer.\n    * @return The 64 byte payload from the report.\n    */\n    function rave(\n        bytes calldata report,\n        bytes memory sig,\n        bytes memory leafX509Cert,\n        bytes memory signingMod,\n        bytes memory signingExp,\n        bytes32 mrenclave,\n        bytes32 mrsigner\n    ) external view returns (bytes memory payload);\n\n    /*\n    * @dev Verifies that this report was signed by the expected signer, then extracts out the report's 64 byte payload.\n    * @param report The attestation evidence report from IAS.\n    * @param sig The RSA-SHA256 signature over the report.\n    * @param signingMod The expected signer's RSA modulus\n    * @param signingExp The expected signer's RSA exponent\n    * @param mrenclave The expected enclave measurement.\n    * @param mrsigner The expected enclave signer.\n    * @return The 64 byte payload from the report.\n    */\n    function verifyRemoteAttestation(\n        bytes calldata report,\n        bytes memory sig,\n        bytes memory signingMod,\n        bytes memory signingExp,\n        bytes32 mrenclave,\n        bytes32 mrsigner\n    ) external view returns (bytes memory payload);\n}\n"
      },
      "lib/rave/lib/ens-contracts/contracts/dnssec-oracle/algorithms/ModexpPrecompile.sol": {
        "content": "pragma solidity ^0.8.4;\n\nlibrary ModexpPrecompile {\n    /**\n     * @dev Computes (base ^ exponent) % modulus over big numbers.\n     */\n    function modexp(\n        bytes memory base,\n        bytes memory exponent,\n        bytes memory modulus\n    ) internal view returns (bool success, bytes memory output) {\n        bytes memory input = abi.encodePacked(\n            uint256(base.length),\n            uint256(exponent.length),\n            uint256(modulus.length),\n            base,\n            exponent,\n            modulus\n        );\n\n        output = new bytes(modulus.length);\n\n        assembly {\n            success := staticcall(\n                gas(),\n                5,\n                add(input, 32),\n                mload(input),\n                add(output, 32),\n                mload(modulus)\n            )\n        }\n    }\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
        "forge-std/=lib/forge-std/src/",
        "openzeppelin/=lib/openzeppelin-contracts/contracts/",
        "@openzeppelin/=lib/openzeppelin-contracts/",
        "openzeppelin-upgrades/=lib/openzeppelin-contracts-upgradeable/contracts/",
        "@openzeppelin-upgrades/=lib/openzeppelin-contracts-upgradeable/",
        "eigenlayer/=lib/eigenlayer-contracts/src/contracts/",
        "eigenlayer-middleware/=lib/eigenlayer-middleware/src/",
        "eigenlayer-test/=lib/eigenlayer-contracts/src/test/",
        "openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
        "puffer/=src/",
        "script/=script/",
        "rave/=lib/rave/src/",
        "rave-test/=lib/rave/test/",
        "murky/=lib/murky/src/",
        "pufETH/=lib/pufETH/src/",
        "pufETHTest/=lib/pufETH/test/",
        "pufETHScript/=lib/pufETH/script/",
        "@openzeppelin-contracts-upgradeable/=lib/pufETH/lib/openzeppelin-contracts-upgradeable/contracts/",
        "@openzeppelin-upgrades/=lib/eigenlayer-contracts/lib/openzeppelin-contracts-upgradeable/",
        "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
        "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
        "ERC4626/=lib/pufETH/lib/properties/lib/ERC4626/contracts/",
        "eigenlayer-contracts/=lib/eigenlayer-contracts/",
        "ens-contracts/=lib/rave/lib/ens-contracts/contracts/",
        "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
        "openzeppelin-contracts/=lib/openzeppelin-contracts/",
        "properties/=lib/pufETH/lib/properties/contracts/",
        "solady/=lib/pufETH/lib/solady/src/",
        "solmate/=lib/pufETH/lib/properties/lib/solmate/src/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "none",
        "appendCBOR": false
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "cancun",
      "viaIR": false,
      "libraries": {}
    }
  }}