mirror of
https://github.com/luxfhe/example-smart-wallet.git
synced 2026-11-03 05:51:38 +00:00
96 lines
353 KiB
JSON
96 lines
353 KiB
JSON
{
|
||
"language": "Solidity",
|
||
"sources": {
|
||
"@luxfheprotocol/contracts/access/EIP712.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\";\nimport {ShortStrings, ShortString} from \"@openzeppelin/contracts/utils/ShortStrings.sol\";\nimport {IERC5267} from \"@openzeppelin/contracts/interfaces/IERC5267.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n *\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable\n *\n * NOTE: luxfhe read access Permits are intended to be used in multiple contracts simultaneously, therefor the\n * `verifyingContract` which is by default address(this) has been replaced with address(0).\n */\nabstract contract EIP712 is IERC5267 {\n using ShortStrings for *;\n\n bytes32 private constant TYPE_HASH =\n keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _cachedDomainSeparator;\n uint256 private immutable _cachedChainId;\n\n bytes32 private immutable _hashedName;\n bytes32 private immutable _hashedVersion;\n\n ShortString private immutable _name;\n ShortString private immutable _version;\n string private _nameFallback;\n string private _versionFallback;\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n _name = name.toShortStringWithFallback(_nameFallback);\n _version = version.toShortStringWithFallback(_versionFallback);\n _hashedName = keccak256(bytes(name));\n _hashedVersion = keccak256(bytes(version));\n\n _cachedChainId = block.chainid;\n _cachedDomainSeparator = _buildDomainSeparator();\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (block.chainid == _cachedChainId) {\n return _cachedDomainSeparator;\n } else {\n return _buildDomainSeparator();\n }\n }\n\n function _buildDomainSeparator() private view returns (bytes32) {\n return\n keccak256(\n abi.encode(\n TYPE_HASH,\n _hashedName,\n _hashedVersion,\n block.chainid,\n address(0)\n )\n );\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(\n bytes32 structHash\n ) internal view virtual returns (bytes32) {\n return\n MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev See {IERC-5267}.\n */\n function eip712Domain()\n public\n view\n virtual\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n )\n {\n return (\n hex\"0f\", // 01111\n _EIP712Name(),\n _EIP712Version(),\n block.chainid,\n address(0),\n bytes32(0),\n new uint256[](0)\n );\n }\n\n /**\n * @dev The name parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _name which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Name() internal view returns (string memory) {\n return _name.toStringWithFallback(_nameFallback);\n }\n\n /**\n * @dev The version parameter for the EIP712 domain.\n *\n * NOTE: By default this function reads _version which is an immutable value.\n * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n */\n // solhint-disable-next-line func-name-mixedcase\n function _EIP712Version() internal view returns (string memory) {\n return _version.toStringWithFallback(_versionFallback);\n }\n}\n"
|
||
},
|
||
"@luxfheprotocol/contracts/access/PermissionedV2.sol": {
|
||
"content": "// solhint-disable func-name-mixedcase\n// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19 <0.9.0;\n\nimport {SignatureChecker} from \"@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol\";\nimport {EIP712} from \"./EIP712.sol\";\n\n/**\n * @dev Permission body that must be passed to a contract to allow access to sensitive data.\n * \n * The minimum permission to access a user's own data requires the fields\n * < issuer, expiration, contracts, projects, sealingKey, issuerSignature >\n *\n * `contracts` and `projects` are lists defining which contracts can be accessed with this permission.\n * `projects` is a list of strings, each of which defines and provides access to a group of contracts.\n *\n * ---\n *\n * If not sharing the permission, `issuer` signs a signature using the fields:\n * < issuer, expiration, contracts, projects, recipient, validatorId, validatorContract, sealingKey >\n * This signature can now be used by `issuer` to access their own encrypted data.\n *\n * ---\n *\n * Sharing a permission is a two step process: `issuer` completes step 1, and `recipient` completes step 2.\n *\n * 1:\n * `issuer` creates a permission with `recipient` populated with the address of the user to give access to.\n * `issuer` does not include a `sealingKey` in the permission, it will be populated by the `recipient`.\n * `issuer` is still responsible for defining the permission's access through `contracts` and `projects`.\n * `issuer` signs a signature including the fields: (note: `sealingKey` is absent in this signature)\n * < issuer, expiration, contracts, projects, recipient, validatorId, validatorContract >\n * `issuer` packages the permission data and `issuerSignature` and shares it with `recipient`\n * ** None of this data is sensitive, and can be shared as cleartext **\n *\n * 2:\n * `recipient` adds their `sealingKey` to the data received from `issuer`\n * `recipient` signs a signature including the fields:\n * < sealingKey, issuerSignature >\n * `recipient` can now use the completed Permission to access `issuer`s encrypted data.\n *\n * ---\n *\n * `validatorId` and `validatorContract` are optional and can be used together to \n * increase security and control by disabling a permission after it has been created.\n * Useful when sharing permits to provide external access to sensitive data (eg auditors).\n */\nstruct PermissionV2 {\n // (base) User that initially created the permission, target of data fetching\n address issuer;\n // (base) Expiration timestamp\n uint64 expiration;\n // (base) List of contract addresses that can be accessed with this permission\n address[] contracts;\n // (base) List of project identifiers (strings) that can be accessed\n string[] projects;\n // (sharing) The user that this permission will be shared with\n // ** optional, use `address(0)` to disable **\n address recipient;\n // (issuer defined validation) An id used to query a contract to check this permissions validity\n // ** optional, use `0` to disable **\n uint256 validatorId;\n // (issuer defined validation) The contract to query to determine permission validity\n // ** optional, user `address(0)` to disable **\n address validatorContract;\n // (base) The publicKey of a sealingPair used to re-encrypt `issuer`s confidential data\n // (non-sharing) Populated by `issuer`\n // (sharing) Populated by `recipient` \n bytes32 sealingKey;\n // (base) `signTypedData` signature created by `issuer`.\n // (base) Shared- and Self- permissions differ in signature format: (`sealingKey` absent in shared signature)\n // (non-sharing) < issuer, expiration, contracts, projects, recipient, validatorId, validatorContract, sealingKey >\n // (sharing) < issuer, expiration, contracts, projects, recipient, validatorId, validatorContract >\n bytes issuerSignature;\n // (sharing) `signTypedData` signature created by `recipient` with format:\n // (sharing) < sealingKey, issuerSignature>\n // ** required for shared permits **\n bytes recipientSignature;\n}\n\n\n/// @dev Minimum required interface to create a custom permission validator.\n/// Permission validators are optional, and provide extra security and control when sharing permits.\ninterface IPermissionValidator {\n /// @dev Checks whether a permission is valid, returning `false` disables the permission.\n function disabled(\n address issuer,\n uint256 id\n ) external view returns (bool);\n}\n\n/// @dev Uses a modified version of openzeppelin's EIP712 contract which disables the `verifyingContract`.\n/// Instead, access is checked using the `contracts` and `projects` fields of the `PermissionV2` struct.\n/// This allows a single signed permission to be used to access multiple contracts encrypted data.\ncontract PermissionedV2 is EIP712 {\n using PermissionV2Utils for PermissionV2;\n\n /// @notice Version of the luxfhe permission signature\n string public version = \"v2.0.0\";\n\n /// @notice This contract's project identifier string. Used in permissions to grant access to all contracts with this identifier.\n string public project;\n\n /// @dev Constructor that initializes the EIP712 domain. The EIP712 implementation used has `verifyingContract` disabled\n /// by replacing it with `address(0)`. Ensure that `verifyingContract` is the ZeroAddress when creating a user's signature.\n ///\n /// @param proj The project identifier string to be associated with this contract. Any Permission with this project identifier\n /// in `permission.projects` list will be granted access to this contract's data. Use an empty string for no project identifier.\n constructor(\n string memory proj\n ) EIP712(string.concat(\"luxfhe Permission \", version), version) {\n project = proj;\n }\n\n /// @dev Emitted when `project` is not in `permission.projects` nor `address(this)` in `permission.contracts`\n error PermissionInvalid_ContractUnauthorized();\n\n /// @dev Emitted when `permission.expiration` is in the past (< block.timestamp)\n error PermissionInvalid_Expired();\n\n /// @dev Emitted when `issuerSignature` is malformed or was not signed by `permission.issuer`\n error PermissionInvalid_IssuerSignature();\n\n /// @dev Emitted when `recipientSignature` is malformed or was not signed by `permission.recipient`\n error PermissionInvalid_RecipientSignature();\n\n /// @dev Emitted when `validatorContract` returned `false` indicating that this permission has been externally disabled\n error PermissionInvalid_Disabled();\n\n /// @dev Validate's a `permissions` access of sensitive data.\n /// `permission` may be invalid or unauthorized for the following reasons:\n /// - Contract unauthorized: `project` is not in `permission.projects` nor address(this) in `permission.contracts`\n /// - Expired: `permission.expiration` is in the past (< block.timestamp)\n /// - Issuer signature: `issuerSignature` is malformed or was not signed by `permission.issuer`\n /// - Recipient signature: `recipientSignature` is malformed or was not signed by `permission.recipient`\n /// - Disabled: `validatorContract` returned `false` indicating that this permission has been externally disabled\n /// @param permission PermissionV2 struct containing data necessary to validate data access and seal for return.\n ///\n /// NOTE: Functions protected by `withPermission` should return ONLY the sensitive data of `permission.issuer`.\n /// !! Returning data of `msg.sender` will leak sensitive values - `msg.sender` cannot be trusted in view functions !!\n modifier withPermission(PermissionV2 memory permission) {\n // Access\n if (!permission.satisfies(address(this), project))\n revert PermissionInvalid_ContractUnauthorized();\n\n // Expiration\n if (permission.expiration < block.timestamp)\n revert PermissionInvalid_Expired();\n\n // Issuer signature\n if (\n !SignatureChecker.isValidSignatureNow(\n permission.issuer,\n _hashTypedDataV4(permission.issuerHash()),\n permission.issuerSignature\n )\n ) revert PermissionInvalid_IssuerSignature();\n\n // (if applicable) Recipient signature\n if (\n permission.recipient != address(0) &&\n !SignatureChecker.isValidSignatureNow(\n permission.recipient,\n _hashTypedDataV4(permission.recipientHash()),\n permission.recipientSignature\n )\n ) revert PermissionInvalid_RecipientSignature();\n\n // (if applicable) Externally disabled\n if (\n permission.validatorId != 0 &&\n permission.validatorContract != address(0) &&\n IPermissionValidator(permission.validatorContract).disabled(\n permission.issuer,\n permission.validatorId\n )\n ) revert PermissionInvalid_Disabled();\n\n _;\n }\n\n /// @dev Utility function used to check whether a permission provides access to this contract.\n /// Intended to be used before real data is fetched to preempt a reversion, but is not necessary to use.\n function checkPermissionSatisfies(\n PermissionV2 memory permission\n ) external view returns (bool) {\n return permission.satisfies(address(this), project);\n }\n}\n\n/// @dev Internal utility library to improve the readability of PermissionedV2\n/// Primarily focused on signature type hashes\nlibrary PermissionV2Utils {\n function issuerHash(\n PermissionV2 memory permission\n ) internal pure returns (bytes32) {\n if (permission.recipient == address(0))\n return issuerSelfHash(permission);\n return issuerSharedHash(permission);\n }\n\n function issuerSelfHash(\n PermissionV2 memory permission\n ) internal pure returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\n \"PermissionedV2IssuerSelf(address issuer,uint64 expiration,address[] contracts,string[] projects,address recipient,uint256 validatorId,address validatorContract,bytes32 sealingKey)\"\n ),\n permission.issuer,\n permission.expiration,\n encodeArray(permission.contracts),\n encodeArray(permission.projects),\n permission.recipient,\n permission.validatorId,\n permission.validatorContract,\n permission.sealingKey\n )\n );\n }\n\n function issuerSharedHash(\n PermissionV2 memory permission\n ) internal pure returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\n \"PermissionedV2IssuerShared(address issuer,uint64 expiration,address[] contracts,string[] projects,address recipient,uint256 validatorId,address validatorContract)\"\n ),\n permission.issuer,\n permission.expiration,\n encodeArray(permission.contracts),\n encodeArray(permission.projects),\n permission.recipient,\n permission.validatorId,\n permission.validatorContract\n )\n );\n }\n\n function recipientHash(\n PermissionV2 memory permission\n ) internal pure returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\n \"PermissionedV2Recipient(bytes32 sealingKey,bytes issuerSignature)\"\n ),\n permission.sealingKey,\n keccak256(permission.issuerSignature)\n )\n );\n }\n\n function satisfies(\n PermissionV2 memory permission,\n address addr,\n string memory proj\n ) internal pure returns (bool) {\n for (uint256 i = 0; i < permission.projects.length; i++) {\n if (\n keccak256(abi.encodePacked(proj)) ==\n keccak256(abi.encodePacked(permission.projects[i]))\n ) return true;\n }\n for (uint256 i = 0; i < permission.contracts.length; i++) {\n if (addr == permission.contracts[i]) return true;\n }\n return false;\n }\n\n function encodeArray(\n address[] memory items\n ) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(items));\n }\n\n function encodeArray(\n string[] memory items\n ) internal pure returns (bytes32) {\n bytes32[] memory result = new bytes32[](items.length);\n for (uint256 i = 0; i < items.length; i++) {\n result[i] = keccak256(bytes(items[i]));\n }\n return keccak256(abi.encodePacked(result));\n }\n}\n"
|
||
},
|
||
"@luxfheprotocol/contracts/FHE.sol": {
|
||
"content": "// SPDX-License-Identifier: BSD-3-Clause-Clear\n// solhint-disable one-contract-per-file\n\npragma solidity >=0.8.19 <0.9.0;\n\nimport {Precompiles, FheOps} from \"./FheOS.sol\";\n\ntype ebool is uint256;\ntype euint8 is uint256;\ntype euint16 is uint256;\ntype euint32 is uint256;\ntype euint64 is uint256;\ntype euint128 is uint256;\ntype euint256 is uint256;\ntype eaddress is uint256;\n\nstruct inEbool {\n bytes data;\n int32 securityZone;\n}\nstruct inEuint8 {\n bytes data;\n int32 securityZone;\n}\nstruct inEuint16 {\n bytes data;\n int32 securityZone;\n}\nstruct inEuint32 {\n bytes data;\n int32 securityZone;\n}\nstruct inEuint64 {\n bytes data;\n int32 securityZone;\n}\nstruct inEuint128 {\n bytes data;\n int32 securityZone;\n}\nstruct inEuint256 {\n bytes data;\n int32 securityZone;\n}\nstruct inEaddress {\n bytes data;\n int32 securityZone;\n}\n\nstruct SealedArray {\n bytes[] data;\n}\n\n\n/// @dev Utility structure providing clients with type context of a sealed output string.\n/// Return type of `FHE.sealoutputTyped` and `sealTyped` within the binding libraries.\n/// `utype` representing Bool is 13. See `FHE.sol` for more.\nstruct SealedBool {\n string data;\n uint8 utype;\n}\n\n/// @dev Utility structure providing clients with type context of a sealed output string.\n/// Return type of `FHE.sealoutputTyped` and `sealTyped` within the binding libraries.\n/// `utype` representing Uints is 0-5. See `FHE.sol` for more.\n/// `utype` map: {uint8: 0} {uint16: 1} {uint32: 2} {uint64: 3} {uint128: 4} {uint256: 5}.\nstruct SealedUint {\n string data;\n uint8 utype;\n}\n\n/// @dev Utility structure providing clients with type context of a sealed output string.\n/// Return type of `FHE.sealoutputTyped` and `sealTyped` within the binding libraries.\n/// `utype` representing Address is 12. See `FHE.sol` for more.\nstruct SealedAddress {\n string data;\n uint8 utype;\n}\n\n\nlibrary Common {\n // Values used to communicate types to the runtime.\n // Must match values defined in warp-drive protobufs for everything to \n // make sense\n uint8 internal constant EUINT8_TFHE = 0;\n uint8 internal constant EUINT16_TFHE = 1;\n uint8 internal constant EUINT32_TFHE = 2;\n uint8 internal constant EUINT64_TFHE = 3;\n uint8 internal constant EUINT128_TFHE = 4;\n uint8 internal constant EUINT256_TFHE = 5;\n uint8 internal constant EADDRESS_TFHE = 12;\n // uint8 internal constant INT_BGV = 12;\n uint8 internal constant EBOOL_TFHE = 13;\n \n function bigIntToBool(uint256 i) internal pure returns (bool) {\n return (i > 0);\n }\n\n function bigIntToUint8(uint256 i) internal pure returns (uint8) {\n return uint8(i);\n }\n\n function bigIntToUint16(uint256 i) internal pure returns (uint16) {\n return uint16(i);\n }\n\n function bigIntToUint32(uint256 i) internal pure returns (uint32) {\n return uint32(i);\n }\n\n function bigIntToUint64(uint256 i) internal pure returns (uint64) {\n return uint64(i);\n }\n\n function bigIntToUint128(uint256 i) internal pure returns (uint128) {\n return uint128(i);\n }\n\n function bigIntToUint256(uint256 i) internal pure returns (uint256) {\n return i;\n }\n\n function bigIntToAddress(uint256 i) internal pure returns (address) {\n return address(uint160(i));\n }\n \n function toBytes(uint256 x) internal pure returns (bytes memory b) {\n b = new bytes(32);\n assembly { mstore(add(b, 32), x) }\n }\n}\n\nlibrary Impl {\n function sealoutput(uint8 utype, uint256 ciphertext, bytes32 publicKey) internal pure returns (string memory reencrypted) {\n // Call the sealoutput precompile.\n reencrypted = FheOps(Precompiles.Fheos).sealOutput(utype, Common.toBytes(ciphertext), bytes.concat(publicKey));\n\n return reencrypted;\n }\n\n function verify(bytes memory _ciphertextBytes, uint8 _toType, int32 securityZone) internal pure returns (uint256 result) {\n bytes memory output;\n\n // Call the verify precompile.\n output = FheOps(Precompiles.Fheos).verify(_toType, _ciphertextBytes, securityZone);\n result = getValue(output);\n }\n\n function cast(uint8 utype, uint256 ciphertext, uint8 toType) internal pure returns (uint256 result) {\n bytes memory output;\n\n // Call the cast precompile.\n output = FheOps(Precompiles.Fheos).cast(utype, Common.toBytes(ciphertext), toType);\n result = getValue(output);\n }\n\n function getValue(bytes memory a) internal pure returns (uint256 value) {\n assembly {\n value := mload(add(a, 0x20))\n }\n }\n\n function trivialEncrypt(uint256 value, uint8 toType, int32 securityZone) internal pure returns (uint256 result) {\n bytes memory output;\n\n // Call the trivialEncrypt precompile.\n output = FheOps(Precompiles.Fheos).trivialEncrypt(Common.toBytes(value), toType, securityZone);\n\n result = getValue(output);\n }\n\n function select(uint8 utype, uint256 control, uint256 ifTrue, uint256 ifFalse) internal pure returns (uint256 result) {\n bytes memory output;\n\n // Call the trivialEncrypt precompile.\n output = FheOps(Precompiles.Fheos).select(utype, Common.toBytes(control), Common.toBytes(ifTrue), Common.toBytes(ifFalse));\n\n result = getValue(output);\n }\n}\n\nlibrary FHE {\n euint8 public constant NIL8 = euint8.wrap(0);\n euint16 public constant NIL16 = euint16.wrap(0);\n euint32 public constant NIL32 = euint32.wrap(0);\n\n // Return true if the encrypted integer is initialized and false otherwise.\n function isInitialized(ebool v) internal pure returns (bool) {\n return ebool.unwrap(v) != 0;\n }\n\n // Return true if the encrypted integer is initialized and false otherwise.\n function isInitialized(euint8 v) internal pure returns (bool) {\n return euint8.unwrap(v) != 0;\n }\n\n // Return true if the encrypted integer is initialized and false otherwise.\n function isInitialized(euint16 v) internal pure returns (bool) {\n return euint16.unwrap(v) != 0;\n }\n\n // Return true if the encrypted integer is initialized and false otherwise.\n function isInitialized(euint32 v) internal pure returns (bool) {\n return euint32.unwrap(v) != 0;\n }\n \n // Return true if the encrypted integer is initialized and false otherwise.\n function isInitialized(euint64 v) internal pure returns (bool) {\n return euint64.unwrap(v) != 0;\n }\n \n // Return true if the encrypted integer is initialized and false otherwise.\n function isInitialized(euint128 v) internal pure returns (bool) {\n return euint128.unwrap(v) != 0;\n }\n \n // Return true if the encrypted integer is initialized and false otherwise.\n function isInitialized(euint256 v) internal pure returns (bool) {\n return euint256.unwrap(v) != 0;\n }\n\n function isInitialized(eaddress v) internal pure returns (bool) {\n return eaddress.unwrap(v) != 0;\n }\n\n function getValue(bytes memory a) private pure returns (uint256 value) {\n assembly {\n value := mload(add(a, 0x20))\n }\n }\n \n function mathHelper(\n uint8 utype,\n uint256 lhs,\n uint256 rhs,\n function(uint8, bytes memory, bytes memory) external pure returns (bytes memory) impl\n ) internal pure returns (uint256 result) {\n bytes memory output;\n output = impl(utype, Common.toBytes(lhs), Common.toBytes(rhs));\n result = getValue(output);\n }\n \n /// @notice This function performs the add operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function add(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).add);\n return euint8.wrap(result);\n }\n /// @notice This function performs the add operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function add(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).add);\n return euint16.wrap(result);\n }\n /// @notice This function performs the add operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function add(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).add);\n return euint32.wrap(result);\n }\n /// @notice This function performs the add operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function add(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).add);\n return euint64.wrap(result);\n }\n /// @notice This function performs the add operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function add(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).add);\n return euint128.wrap(result);\n }\n /// @notice performs the sealoutput function on a ebool ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return Plaintext input, sealed for the owner of `publicKey`\n function sealoutput(ebool value, bytes32 publicKey) internal pure returns (string memory) {\n if (!isInitialized(value)) {\n value = asEbool(0);\n }\n uint256 unwrapped = ebool.unwrap(value);\n\n return Impl.sealoutput(Common.EBOOL_TFHE, unwrapped, publicKey);\n }\n /// @notice performs the sealoutput function on a euint8 ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return Plaintext input, sealed for the owner of `publicKey`\n function sealoutput(euint8 value, bytes32 publicKey) internal pure returns (string memory) {\n if (!isInitialized(value)) {\n value = asEuint8(0);\n }\n uint256 unwrapped = euint8.unwrap(value);\n\n return Impl.sealoutput(Common.EUINT8_TFHE, unwrapped, publicKey);\n }\n /// @notice performs the sealoutput function on a euint16 ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return Plaintext input, sealed for the owner of `publicKey`\n function sealoutput(euint16 value, bytes32 publicKey) internal pure returns (string memory) {\n if (!isInitialized(value)) {\n value = asEuint16(0);\n }\n uint256 unwrapped = euint16.unwrap(value);\n\n return Impl.sealoutput(Common.EUINT16_TFHE, unwrapped, publicKey);\n }\n /// @notice performs the sealoutput function on a euint32 ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return Plaintext input, sealed for the owner of `publicKey`\n function sealoutput(euint32 value, bytes32 publicKey) internal pure returns (string memory) {\n if (!isInitialized(value)) {\n value = asEuint32(0);\n }\n uint256 unwrapped = euint32.unwrap(value);\n\n return Impl.sealoutput(Common.EUINT32_TFHE, unwrapped, publicKey);\n }\n /// @notice performs the sealoutput function on a euint64 ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return Plaintext input, sealed for the owner of `publicKey`\n function sealoutput(euint64 value, bytes32 publicKey) internal pure returns (string memory) {\n if (!isInitialized(value)) {\n value = asEuint64(0);\n }\n uint256 unwrapped = euint64.unwrap(value);\n\n return Impl.sealoutput(Common.EUINT64_TFHE, unwrapped, publicKey);\n }\n /// @notice performs the sealoutput function on a euint128 ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return Plaintext input, sealed for the owner of `publicKey`\n function sealoutput(euint128 value, bytes32 publicKey) internal pure returns (string memory) {\n if (!isInitialized(value)) {\n value = asEuint128(0);\n }\n uint256 unwrapped = euint128.unwrap(value);\n\n return Impl.sealoutput(Common.EUINT128_TFHE, unwrapped, publicKey);\n }\n /// @notice performs the sealoutput function on a euint256 ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return Plaintext input, sealed for the owner of `publicKey`\n function sealoutput(euint256 value, bytes32 publicKey) internal pure returns (string memory) {\n if (!isInitialized(value)) {\n value = asEuint256(0);\n }\n uint256 unwrapped = euint256.unwrap(value);\n\n return Impl.sealoutput(Common.EUINT256_TFHE, unwrapped, publicKey);\n }\n /// @notice performs the sealoutput function on a eaddress ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return Plaintext input, sealed for the owner of `publicKey`\n function sealoutput(eaddress value, bytes32 publicKey) internal pure returns (string memory) {\n if (!isInitialized(value)) {\n value = asEaddress(0);\n }\n uint256 unwrapped = eaddress.unwrap(value);\n\n return Impl.sealoutput(Common.EADDRESS_TFHE, unwrapped, publicKey);\n }\n /// @notice performs the sealoutputTyped function on a ebool ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return SealedBool({ data: Plaintext input, sealed for the owner of `publicKey`, utype: Common.EBOOL_TFHE })\n function sealoutputTyped(ebool value, bytes32 publicKey) internal pure returns (SealedBool memory) {\n return SealedBool({ data: sealoutput(value, publicKey), utype: Common.EBOOL_TFHE });\n }\n /// @notice performs the sealoutputTyped function on a euint8 ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return SealedUint({ data: Plaintext input, sealed for the owner of `publicKey`, utype: Common.EUINT8_TFHE })\n function sealoutputTyped(euint8 value, bytes32 publicKey) internal pure returns (SealedUint memory) {\n return SealedUint({ data: sealoutput(value, publicKey), utype: Common.EUINT8_TFHE });\n }\n /// @notice performs the sealoutputTyped function on a euint16 ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return SealedUint({ data: Plaintext input, sealed for the owner of `publicKey`, utype: Common.EUINT16_TFHE })\n function sealoutputTyped(euint16 value, bytes32 publicKey) internal pure returns (SealedUint memory) {\n return SealedUint({ data: sealoutput(value, publicKey), utype: Common.EUINT16_TFHE });\n }\n /// @notice performs the sealoutputTyped function on a euint32 ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return SealedUint({ data: Plaintext input, sealed for the owner of `publicKey`, utype: Common.EUINT32_TFHE })\n function sealoutputTyped(euint32 value, bytes32 publicKey) internal pure returns (SealedUint memory) {\n return SealedUint({ data: sealoutput(value, publicKey), utype: Common.EUINT32_TFHE });\n }\n /// @notice performs the sealoutputTyped function on a euint64 ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return SealedUint({ data: Plaintext input, sealed for the owner of `publicKey`, utype: Common.EUINT64_TFHE })\n function sealoutputTyped(euint64 value, bytes32 publicKey) internal pure returns (SealedUint memory) {\n return SealedUint({ data: sealoutput(value, publicKey), utype: Common.EUINT64_TFHE });\n }\n /// @notice performs the sealoutputTyped function on a euint128 ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return SealedUint({ data: Plaintext input, sealed for the owner of `publicKey`, utype: Common.EUINT128_TFHE })\n function sealoutputTyped(euint128 value, bytes32 publicKey) internal pure returns (SealedUint memory) {\n return SealedUint({ data: sealoutput(value, publicKey), utype: Common.EUINT128_TFHE });\n }\n /// @notice performs the sealoutputTyped function on a euint256 ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return SealedUint({ data: Plaintext input, sealed for the owner of `publicKey`, utype: Common.EUINT256_TFHE })\n function sealoutputTyped(euint256 value, bytes32 publicKey) internal pure returns (SealedUint memory) {\n return SealedUint({ data: sealoutput(value, publicKey), utype: Common.EUINT256_TFHE });\n }\n /// @notice performs the sealoutputTyped function on a eaddress ciphertext. This operation returns the plaintext value, sealed for the public key provided \n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param value Ciphertext to decrypt and seal\n /// @param publicKey Public Key that will receive the sealed plaintext\n /// @return SealedAddress({ data: Plaintext input, sealed for the owner of `publicKey`, utype: Common.EADDRESS_TFHE })\n function sealoutputTyped(eaddress value, bytes32 publicKey) internal pure returns (SealedAddress memory) {\n return SealedAddress({ data: sealoutput(value, publicKey), utype: Common.EADDRESS_TFHE });\n }\n /// @notice Performs the decrypt operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function decrypt(ebool input1) internal pure returns (bool) {\n return FHE.decrypt(input1, false);\n }\n /// @notice Performs the decrypt operation on a ciphertext with default value for gas estimation\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n /// @param defaultValue default value to be returned on gas estimation\n function decrypt(ebool input1, bool defaultValue) internal pure returns (bool) {\n if (!isInitialized(input1)) {\n input1 = asEbool(0);\n }\n uint256 gasDefaultValue;\n \n if (defaultValue) {\n gasDefaultValue = 1;\n } else {\n gasDefaultValue = 0;\n }\n \n uint256 unwrappedInput1 = ebool.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n uint256 result = FheOps(Precompiles.Fheos).decrypt(Common.EBOOL_TFHE, inputAsBytes, gasDefaultValue);\n return Common.bigIntToBool(result);\n }\n /// @notice Performs the decrypt operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function decrypt(euint8 input1) internal pure returns (uint8) {\n return FHE.decrypt(input1, (2 ** 8) / 2);\n }\n /// @notice Performs the decrypt operation on a ciphertext with default value for gas estimation\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n /// @param defaultValue default value to be returned on gas estimation\n function decrypt(euint8 input1, uint8 defaultValue) internal pure returns (uint8) {\n if (!isInitialized(input1)) {\n input1 = asEuint8(0);\n }\n uint256 gasDefaultValue;\n \n gasDefaultValue = uint256(defaultValue);\n\n uint256 unwrappedInput1 = euint8.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n uint256 result = FheOps(Precompiles.Fheos).decrypt(Common.EUINT8_TFHE, inputAsBytes, gasDefaultValue);\n return Common.bigIntToUint8(result);\n }\n /// @notice Performs the decrypt operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function decrypt(euint16 input1) internal pure returns (uint16) {\n return FHE.decrypt(input1, (2 ** 16) / 2);\n }\n /// @notice Performs the decrypt operation on a ciphertext with default value for gas estimation\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n /// @param defaultValue default value to be returned on gas estimation\n function decrypt(euint16 input1, uint16 defaultValue) internal pure returns (uint16) {\n if (!isInitialized(input1)) {\n input1 = asEuint16(0);\n }\n uint256 gasDefaultValue;\n \n gasDefaultValue = uint256(defaultValue);\n\n uint256 unwrappedInput1 = euint16.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n uint256 result = FheOps(Precompiles.Fheos).decrypt(Common.EUINT16_TFHE, inputAsBytes, gasDefaultValue);\n return Common.bigIntToUint16(result);\n }\n /// @notice Performs the decrypt operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function decrypt(euint32 input1) internal pure returns (uint32) {\n return FHE.decrypt(input1, (2 ** 32) / 2);\n }\n /// @notice Performs the decrypt operation on a ciphertext with default value for gas estimation\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n /// @param defaultValue default value to be returned on gas estimation\n function decrypt(euint32 input1, uint32 defaultValue) internal pure returns (uint32) {\n if (!isInitialized(input1)) {\n input1 = asEuint32(0);\n }\n uint256 gasDefaultValue;\n \n gasDefaultValue = uint256(defaultValue);\n\n uint256 unwrappedInput1 = euint32.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n uint256 result = FheOps(Precompiles.Fheos).decrypt(Common.EUINT32_TFHE, inputAsBytes, gasDefaultValue);\n return Common.bigIntToUint32(result);\n }\n /// @notice Performs the decrypt operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function decrypt(euint64 input1) internal pure returns (uint64) {\n return FHE.decrypt(input1, (2 ** 64) / 2);\n }\n /// @notice Performs the decrypt operation on a ciphertext with default value for gas estimation\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n /// @param defaultValue default value to be returned on gas estimation\n function decrypt(euint64 input1, uint64 defaultValue) internal pure returns (uint64) {\n if (!isInitialized(input1)) {\n input1 = asEuint64(0);\n }\n uint256 gasDefaultValue;\n \n gasDefaultValue = uint256(defaultValue);\n\n uint256 unwrappedInput1 = euint64.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n uint256 result = FheOps(Precompiles.Fheos).decrypt(Common.EUINT64_TFHE, inputAsBytes, gasDefaultValue);\n return Common.bigIntToUint64(result);\n }\n /// @notice Performs the decrypt operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function decrypt(euint128 input1) internal pure returns (uint128) {\n return FHE.decrypt(input1, (2 ** 128) / 2);\n }\n /// @notice Performs the decrypt operation on a ciphertext with default value for gas estimation\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n /// @param defaultValue default value to be returned on gas estimation\n function decrypt(euint128 input1, uint128 defaultValue) internal pure returns (uint128) {\n if (!isInitialized(input1)) {\n input1 = asEuint128(0);\n }\n uint256 gasDefaultValue;\n \n gasDefaultValue = uint256(defaultValue);\n\n uint256 unwrappedInput1 = euint128.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n uint256 result = FheOps(Precompiles.Fheos).decrypt(Common.EUINT128_TFHE, inputAsBytes, gasDefaultValue);\n return Common.bigIntToUint128(result);\n }\n /// @notice Performs the decrypt operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function decrypt(euint256 input1) internal pure returns (uint256) {\n return FHE.decrypt(input1, (2 ** 256) / 2);\n }\n /// @notice Performs the decrypt operation on a ciphertext with default value for gas estimation\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n /// @param defaultValue default value to be returned on gas estimation\n function decrypt(euint256 input1, uint256 defaultValue) internal pure returns (uint256) {\n if (!isInitialized(input1)) {\n input1 = asEuint256(0);\n }\n uint256 gasDefaultValue;\n \n gasDefaultValue = uint256(defaultValue);\n\n uint256 unwrappedInput1 = euint256.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n uint256 result = FheOps(Precompiles.Fheos).decrypt(Common.EUINT256_TFHE, inputAsBytes, gasDefaultValue);\n return Common.bigIntToUint256(result);\n }\n /// @notice Performs the decrypt operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function decrypt(eaddress input1) internal pure returns (address) {\n return FHE.decrypt(input1, address(0));\n }\n /// @notice Performs the decrypt operation on a ciphertext with default value for gas estimation\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n /// @param defaultValue default value to be returned on gas estimation\n function decrypt(eaddress input1, address defaultValue) internal pure returns (address) {\n if (!isInitialized(input1)) {\n input1 = asEaddress(0);\n }\n uint256 gasDefaultValue;\n \n gasDefaultValue = uint256(uint160(defaultValue));\n\n uint256 unwrappedInput1 = eaddress.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n uint256 result = FheOps(Precompiles.Fheos).decrypt(Common.EADDRESS_TFHE, inputAsBytes, gasDefaultValue);\n return Common.bigIntToAddress(result);\n }\n /// @notice This function performs the lte operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function lte(euint8 lhs, euint8 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).lte);\n return ebool.wrap(result);\n }\n /// @notice This function performs the lte operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function lte(euint16 lhs, euint16 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).lte);\n return ebool.wrap(result);\n }\n /// @notice This function performs the lte operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function lte(euint32 lhs, euint32 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).lte);\n return ebool.wrap(result);\n }\n /// @notice This function performs the lte operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function lte(euint64 lhs, euint64 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).lte);\n return ebool.wrap(result);\n }\n /// @notice This function performs the lte operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function lte(euint128 lhs, euint128 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).lte);\n return ebool.wrap(result);\n }\n /// @notice This function performs the sub operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function sub(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).sub);\n return euint8.wrap(result);\n }\n /// @notice This function performs the sub operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function sub(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).sub);\n return euint16.wrap(result);\n }\n /// @notice This function performs the sub operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function sub(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).sub);\n return euint32.wrap(result);\n }\n /// @notice This function performs the sub operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function sub(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).sub);\n return euint64.wrap(result);\n }\n /// @notice This function performs the sub operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function sub(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).sub);\n return euint128.wrap(result);\n }\n /// @notice This function performs the mul operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function mul(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).mul);\n return euint8.wrap(result);\n }\n /// @notice This function performs the mul operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function mul(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).mul);\n return euint16.wrap(result);\n }\n /// @notice This function performs the mul operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function mul(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).mul);\n return euint32.wrap(result);\n }\n /// @notice This function performs the mul operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function mul(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).mul);\n return euint64.wrap(result);\n }\n /// @notice This function performs the lt operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function lt(euint8 lhs, euint8 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).lt);\n return ebool.wrap(result);\n }\n /// @notice This function performs the lt operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function lt(euint16 lhs, euint16 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).lt);\n return ebool.wrap(result);\n }\n /// @notice This function performs the lt operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function lt(euint32 lhs, euint32 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).lt);\n return ebool.wrap(result);\n }\n /// @notice This function performs the lt operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function lt(euint64 lhs, euint64 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).lt);\n return ebool.wrap(result);\n }\n /// @notice This function performs the lt operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function lt(euint128 lhs, euint128 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).lt);\n return ebool.wrap(result);\n }\n\n function select(ebool input1, ebool input2, ebool input3) internal pure returns (ebool) {\n if (!isInitialized(input1)) {\n input1 = asEbool(0);\n }\n if (!isInitialized(input2)) {\n input2 = asEbool(0);\n }\n if (!isInitialized(input3)) {\n input3 = asEbool(0);\n }\n\n uint256 unwrappedInput1 = ebool.unwrap(input1);\n uint256 unwrappedInput2 = ebool.unwrap(input2);\n uint256 unwrappedInput3 = ebool.unwrap(input3);\n\n uint256 result = Impl.select(Common.EBOOL_TFHE, unwrappedInput1, unwrappedInput2, unwrappedInput3);\n return ebool.wrap(result);\n }\n\n function select(ebool input1, euint8 input2, euint8 input3) internal pure returns (euint8) {\n if (!isInitialized(input1)) {\n input1 = asEbool(0);\n }\n if (!isInitialized(input2)) {\n input2 = asEuint8(0);\n }\n if (!isInitialized(input3)) {\n input3 = asEuint8(0);\n }\n\n uint256 unwrappedInput1 = ebool.unwrap(input1);\n uint256 unwrappedInput2 = euint8.unwrap(input2);\n uint256 unwrappedInput3 = euint8.unwrap(input3);\n\n uint256 result = Impl.select(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, unwrappedInput3);\n return euint8.wrap(result);\n }\n\n function select(ebool input1, euint16 input2, euint16 input3) internal pure returns (euint16) {\n if (!isInitialized(input1)) {\n input1 = asEbool(0);\n }\n if (!isInitialized(input2)) {\n input2 = asEuint16(0);\n }\n if (!isInitialized(input3)) {\n input3 = asEuint16(0);\n }\n\n uint256 unwrappedInput1 = ebool.unwrap(input1);\n uint256 unwrappedInput2 = euint16.unwrap(input2);\n uint256 unwrappedInput3 = euint16.unwrap(input3);\n\n uint256 result = Impl.select(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, unwrappedInput3);\n return euint16.wrap(result);\n }\n\n function select(ebool input1, euint32 input2, euint32 input3) internal pure returns (euint32) {\n if (!isInitialized(input1)) {\n input1 = asEbool(0);\n }\n if (!isInitialized(input2)) {\n input2 = asEuint32(0);\n }\n if (!isInitialized(input3)) {\n input3 = asEuint32(0);\n }\n\n uint256 unwrappedInput1 = ebool.unwrap(input1);\n uint256 unwrappedInput2 = euint32.unwrap(input2);\n uint256 unwrappedInput3 = euint32.unwrap(input3);\n\n uint256 result = Impl.select(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, unwrappedInput3);\n return euint32.wrap(result);\n }\n\n function select(ebool input1, euint64 input2, euint64 input3) internal pure returns (euint64) {\n if (!isInitialized(input1)) {\n input1 = asEbool(0);\n }\n if (!isInitialized(input2)) {\n input2 = asEuint64(0);\n }\n if (!isInitialized(input3)) {\n input3 = asEuint64(0);\n }\n\n uint256 unwrappedInput1 = ebool.unwrap(input1);\n uint256 unwrappedInput2 = euint64.unwrap(input2);\n uint256 unwrappedInput3 = euint64.unwrap(input3);\n\n uint256 result = Impl.select(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, unwrappedInput3);\n return euint64.wrap(result);\n }\n\n function select(ebool input1, euint128 input2, euint128 input3) internal pure returns (euint128) {\n if (!isInitialized(input1)) {\n input1 = asEbool(0);\n }\n if (!isInitialized(input2)) {\n input2 = asEuint128(0);\n }\n if (!isInitialized(input3)) {\n input3 = asEuint128(0);\n }\n\n uint256 unwrappedInput1 = ebool.unwrap(input1);\n uint256 unwrappedInput2 = euint128.unwrap(input2);\n uint256 unwrappedInput3 = euint128.unwrap(input3);\n\n uint256 result = Impl.select(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, unwrappedInput3);\n return euint128.wrap(result);\n }\n\n function select(ebool input1, euint256 input2, euint256 input3) internal pure returns (euint256) {\n if (!isInitialized(input1)) {\n input1 = asEbool(0);\n }\n if (!isInitialized(input2)) {\n input2 = asEuint256(0);\n }\n if (!isInitialized(input3)) {\n input3 = asEuint256(0);\n }\n\n uint256 unwrappedInput1 = ebool.unwrap(input1);\n uint256 unwrappedInput2 = euint256.unwrap(input2);\n uint256 unwrappedInput3 = euint256.unwrap(input3);\n\n uint256 result = Impl.select(Common.EUINT256_TFHE, unwrappedInput1, unwrappedInput2, unwrappedInput3);\n return euint256.wrap(result);\n }\n\n function select(ebool input1, eaddress input2, eaddress input3) internal pure returns (eaddress) {\n if (!isInitialized(input1)) {\n input1 = asEbool(0);\n }\n if (!isInitialized(input2)) {\n input2 = asEaddress(0);\n }\n if (!isInitialized(input3)) {\n input3 = asEaddress(0);\n }\n\n uint256 unwrappedInput1 = ebool.unwrap(input1);\n uint256 unwrappedInput2 = eaddress.unwrap(input2);\n uint256 unwrappedInput3 = eaddress.unwrap(input3);\n\n uint256 result = Impl.select(Common.EADDRESS_TFHE, unwrappedInput1, unwrappedInput2, unwrappedInput3);\n return eaddress.wrap(result);\n }\n /// @notice Performs the req operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function req(ebool input1) internal pure {\n if (!isInitialized(input1)) {\n input1 = asEbool(0);\n }\n uint256 unwrappedInput1 = ebool.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n FheOps(Precompiles.Fheos).req(Common.EBOOL_TFHE, inputAsBytes);\n }\n /// @notice Performs the req operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function req(euint8 input1) internal pure {\n if (!isInitialized(input1)) {\n input1 = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n FheOps(Precompiles.Fheos).req(Common.EUINT8_TFHE, inputAsBytes);\n }\n /// @notice Performs the req operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function req(euint16 input1) internal pure {\n if (!isInitialized(input1)) {\n input1 = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n FheOps(Precompiles.Fheos).req(Common.EUINT16_TFHE, inputAsBytes);\n }\n /// @notice Performs the req operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function req(euint32 input1) internal pure {\n if (!isInitialized(input1)) {\n input1 = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n FheOps(Precompiles.Fheos).req(Common.EUINT32_TFHE, inputAsBytes);\n }\n /// @notice Performs the req operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function req(euint64 input1) internal pure {\n if (!isInitialized(input1)) {\n input1 = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n FheOps(Precompiles.Fheos).req(Common.EUINT64_TFHE, inputAsBytes);\n }\n /// @notice Performs the req operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function req(euint128 input1) internal pure {\n if (!isInitialized(input1)) {\n input1 = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n FheOps(Precompiles.Fheos).req(Common.EUINT128_TFHE, inputAsBytes);\n }\n /// @notice Performs the req operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function req(euint256 input1) internal pure {\n if (!isInitialized(input1)) {\n input1 = asEuint256(0);\n }\n uint256 unwrappedInput1 = euint256.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n FheOps(Precompiles.Fheos).req(Common.EUINT256_TFHE, inputAsBytes);\n }\n /// @notice This function performs the div operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function div(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).div);\n return euint8.wrap(result);\n }\n /// @notice This function performs the div operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function div(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).div);\n return euint16.wrap(result);\n }\n /// @notice This function performs the div operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function div(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).div);\n return euint32.wrap(result);\n }\n /// @notice This function performs the gt operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function gt(euint8 lhs, euint8 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).gt);\n return ebool.wrap(result);\n }\n /// @notice This function performs the gt operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function gt(euint16 lhs, euint16 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).gt);\n return ebool.wrap(result);\n }\n /// @notice This function performs the gt operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function gt(euint32 lhs, euint32 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).gt);\n return ebool.wrap(result);\n }\n /// @notice This function performs the gt operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function gt(euint64 lhs, euint64 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).gt);\n return ebool.wrap(result);\n }\n /// @notice This function performs the gt operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function gt(euint128 lhs, euint128 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).gt);\n return ebool.wrap(result);\n }\n /// @notice This function performs the gte operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function gte(euint8 lhs, euint8 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).gte);\n return ebool.wrap(result);\n }\n /// @notice This function performs the gte operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function gte(euint16 lhs, euint16 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).gte);\n return ebool.wrap(result);\n }\n /// @notice This function performs the gte operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function gte(euint32 lhs, euint32 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).gte);\n return ebool.wrap(result);\n }\n /// @notice This function performs the gte operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function gte(euint64 lhs, euint64 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).gte);\n return ebool.wrap(result);\n }\n /// @notice This function performs the gte operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function gte(euint128 lhs, euint128 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).gte);\n return ebool.wrap(result);\n }\n /// @notice This function performs the rem operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function rem(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).rem);\n return euint8.wrap(result);\n }\n /// @notice This function performs the rem operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function rem(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).rem);\n return euint16.wrap(result);\n }\n /// @notice This function performs the rem operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function rem(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).rem);\n return euint32.wrap(result);\n }\n /// @notice This function performs the and operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function and(ebool lhs, ebool rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEbool(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEbool(0);\n }\n uint256 unwrappedInput1 = ebool.unwrap(lhs);\n uint256 unwrappedInput2 = ebool.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EBOOL_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).and);\n return ebool.wrap(result);\n }\n /// @notice This function performs the and operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function and(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).and);\n return euint8.wrap(result);\n }\n /// @notice This function performs the and operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function and(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).and);\n return euint16.wrap(result);\n }\n /// @notice This function performs the and operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function and(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).and);\n return euint32.wrap(result);\n }\n /// @notice This function performs the and operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function and(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).and);\n return euint64.wrap(result);\n }\n /// @notice This function performs the and operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function and(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).and);\n return euint128.wrap(result);\n }\n /// @notice This function performs the or operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function or(ebool lhs, ebool rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEbool(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEbool(0);\n }\n uint256 unwrappedInput1 = ebool.unwrap(lhs);\n uint256 unwrappedInput2 = ebool.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EBOOL_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).or);\n return ebool.wrap(result);\n }\n /// @notice This function performs the or operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function or(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).or);\n return euint8.wrap(result);\n }\n /// @notice This function performs the or operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function or(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).or);\n return euint16.wrap(result);\n }\n /// @notice This function performs the or operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function or(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).or);\n return euint32.wrap(result);\n }\n /// @notice This function performs the or operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function or(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).or);\n return euint64.wrap(result);\n }\n /// @notice This function performs the or operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function or(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).or);\n return euint128.wrap(result);\n }\n /// @notice This function performs the xor operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function xor(ebool lhs, ebool rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEbool(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEbool(0);\n }\n uint256 unwrappedInput1 = ebool.unwrap(lhs);\n uint256 unwrappedInput2 = ebool.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EBOOL_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).xor);\n return ebool.wrap(result);\n }\n /// @notice This function performs the xor operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function xor(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).xor);\n return euint8.wrap(result);\n }\n /// @notice This function performs the xor operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function xor(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).xor);\n return euint16.wrap(result);\n }\n /// @notice This function performs the xor operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function xor(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).xor);\n return euint32.wrap(result);\n }\n /// @notice This function performs the xor operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function xor(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).xor);\n return euint64.wrap(result);\n }\n /// @notice This function performs the xor operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function xor(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).xor);\n return euint128.wrap(result);\n }\n /// @notice This function performs the eq operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function eq(ebool lhs, ebool rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEbool(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEbool(0);\n }\n uint256 unwrappedInput1 = ebool.unwrap(lhs);\n uint256 unwrappedInput2 = ebool.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EBOOL_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).eq);\n return ebool.wrap(result);\n }\n /// @notice This function performs the eq operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function eq(euint8 lhs, euint8 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).eq);\n return ebool.wrap(result);\n }\n /// @notice This function performs the eq operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function eq(euint16 lhs, euint16 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).eq);\n return ebool.wrap(result);\n }\n /// @notice This function performs the eq operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function eq(euint32 lhs, euint32 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).eq);\n return ebool.wrap(result);\n }\n /// @notice This function performs the eq operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function eq(euint64 lhs, euint64 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).eq);\n return ebool.wrap(result);\n }\n /// @notice This function performs the eq operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function eq(euint128 lhs, euint128 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).eq);\n return ebool.wrap(result);\n }\n /// @notice This function performs the eq operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function eq(euint256 lhs, euint256 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint256(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint256(0);\n }\n uint256 unwrappedInput1 = euint256.unwrap(lhs);\n uint256 unwrappedInput2 = euint256.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT256_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).eq);\n return ebool.wrap(result);\n }\n /// @notice This function performs the eq operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function eq(eaddress lhs, eaddress rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEaddress(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEaddress(0);\n }\n uint256 unwrappedInput1 = eaddress.unwrap(lhs);\n uint256 unwrappedInput2 = eaddress.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EADDRESS_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).eq);\n return ebool.wrap(result);\n }\n /// @notice This function performs the ne operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function ne(ebool lhs, ebool rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEbool(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEbool(0);\n }\n uint256 unwrappedInput1 = ebool.unwrap(lhs);\n uint256 unwrappedInput2 = ebool.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EBOOL_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).ne);\n return ebool.wrap(result);\n }\n /// @notice This function performs the ne operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function ne(euint8 lhs, euint8 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).ne);\n return ebool.wrap(result);\n }\n /// @notice This function performs the ne operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function ne(euint16 lhs, euint16 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).ne);\n return ebool.wrap(result);\n }\n /// @notice This function performs the ne operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function ne(euint32 lhs, euint32 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).ne);\n return ebool.wrap(result);\n }\n /// @notice This function performs the ne operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function ne(euint64 lhs, euint64 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).ne);\n return ebool.wrap(result);\n }\n /// @notice This function performs the ne operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function ne(euint128 lhs, euint128 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).ne);\n return ebool.wrap(result);\n }\n /// @notice This function performs the ne operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function ne(euint256 lhs, euint256 rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEuint256(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint256(0);\n }\n uint256 unwrappedInput1 = euint256.unwrap(lhs);\n uint256 unwrappedInput2 = euint256.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT256_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).ne);\n return ebool.wrap(result);\n }\n /// @notice This function performs the ne operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function ne(eaddress lhs, eaddress rhs) internal pure returns (ebool) {\n if (!isInitialized(lhs)) {\n lhs = asEaddress(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEaddress(0);\n }\n uint256 unwrappedInput1 = eaddress.unwrap(lhs);\n uint256 unwrappedInput2 = eaddress.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EADDRESS_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).ne);\n return ebool.wrap(result);\n }\n /// @notice This function performs the min operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function min(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).min);\n return euint8.wrap(result);\n }\n /// @notice This function performs the min operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function min(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).min);\n return euint16.wrap(result);\n }\n /// @notice This function performs the min operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function min(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).min);\n return euint32.wrap(result);\n }\n /// @notice This function performs the min operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function min(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).min);\n return euint64.wrap(result);\n }\n /// @notice This function performs the min operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function min(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).min);\n return euint128.wrap(result);\n }\n /// @notice This function performs the max operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function max(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).max);\n return euint8.wrap(result);\n }\n /// @notice This function performs the max operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function max(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).max);\n return euint16.wrap(result);\n }\n /// @notice This function performs the max operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function max(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).max);\n return euint32.wrap(result);\n }\n /// @notice This function performs the max operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function max(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).max);\n return euint64.wrap(result);\n }\n /// @notice This function performs the max operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function max(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).max);\n return euint128.wrap(result);\n }\n /// @notice This function performs the shl operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function shl(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).shl);\n return euint8.wrap(result);\n }\n /// @notice This function performs the shl operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function shl(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).shl);\n return euint16.wrap(result);\n }\n /// @notice This function performs the shl operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function shl(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).shl);\n return euint32.wrap(result);\n }\n /// @notice This function performs the shl operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function shl(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).shl);\n return euint64.wrap(result);\n }\n /// @notice This function performs the shl operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function shl(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).shl);\n return euint128.wrap(result);\n }\n /// @notice This function performs the shr operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function shr(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).shr);\n return euint8.wrap(result);\n }\n /// @notice This function performs the shr operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function shr(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).shr);\n return euint16.wrap(result);\n }\n /// @notice This function performs the shr operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function shr(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).shr);\n return euint32.wrap(result);\n }\n /// @notice This function performs the shr operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function shr(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).shr);\n return euint64.wrap(result);\n }\n /// @notice This function performs the shr operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function shr(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).shr);\n return euint128.wrap(result);\n }\n /// @notice This function performs the rol operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function rol(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).rol);\n return euint8.wrap(result);\n }\n /// @notice This function performs the rol operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function rol(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).rol);\n return euint16.wrap(result);\n }\n /// @notice This function performs the rol operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function rol(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).rol);\n return euint32.wrap(result);\n }\n /// @notice This function performs the rol operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function rol(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).rol);\n return euint64.wrap(result);\n }\n /// @notice This function performs the rol operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function rol(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).rol);\n return euint128.wrap(result);\n }\n /// @notice This function performs the ror operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function ror(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n if (!isInitialized(lhs)) {\n lhs = asEuint8(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(lhs);\n uint256 unwrappedInput2 = euint8.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT8_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).ror);\n return euint8.wrap(result);\n }\n /// @notice This function performs the ror operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function ror(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n if (!isInitialized(lhs)) {\n lhs = asEuint16(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(lhs);\n uint256 unwrappedInput2 = euint16.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT16_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).ror);\n return euint16.wrap(result);\n }\n /// @notice This function performs the ror operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function ror(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n if (!isInitialized(lhs)) {\n lhs = asEuint32(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(lhs);\n uint256 unwrappedInput2 = euint32.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT32_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).ror);\n return euint32.wrap(result);\n }\n /// @notice This function performs the ror operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function ror(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n if (!isInitialized(lhs)) {\n lhs = asEuint64(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(lhs);\n uint256 unwrappedInput2 = euint64.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT64_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).ror);\n return euint64.wrap(result);\n }\n /// @notice This function performs the ror operation\n /// @dev If any of the inputs are expected to be a ciphertext, it verifies that the value matches a valid ciphertext\n ///Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs The first input \n /// @param rhs The second input\n /// @return The result of the operation\n function ror(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n if (!isInitialized(lhs)) {\n lhs = asEuint128(0);\n }\n if (!isInitialized(rhs)) {\n rhs = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(lhs);\n uint256 unwrappedInput2 = euint128.unwrap(rhs);\n\n uint256 result = mathHelper(Common.EUINT128_TFHE, unwrappedInput1, unwrappedInput2, FheOps(Precompiles.Fheos).ror);\n return euint128.wrap(result);\n }\n /// @notice Performs the not operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function not(ebool input1) internal pure returns (ebool) {\n if (!isInitialized(input1)) {\n input1 = asEbool(0);\n }\n uint256 unwrappedInput1 = ebool.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n bytes memory b = FheOps(Precompiles.Fheos).not(Common.EBOOL_TFHE, inputAsBytes);\n uint256 result = Impl.getValue(b);\n return ebool.wrap(result);\n }\n /// @notice Performs the not operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function not(euint8 input1) internal pure returns (euint8) {\n if (!isInitialized(input1)) {\n input1 = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n bytes memory b = FheOps(Precompiles.Fheos).not(Common.EUINT8_TFHE, inputAsBytes);\n uint256 result = Impl.getValue(b);\n return euint8.wrap(result);\n }\n /// @notice Performs the not operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function not(euint16 input1) internal pure returns (euint16) {\n if (!isInitialized(input1)) {\n input1 = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n bytes memory b = FheOps(Precompiles.Fheos).not(Common.EUINT16_TFHE, inputAsBytes);\n uint256 result = Impl.getValue(b);\n return euint16.wrap(result);\n }\n /// @notice Performs the not operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function not(euint32 input1) internal pure returns (euint32) {\n if (!isInitialized(input1)) {\n input1 = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n bytes memory b = FheOps(Precompiles.Fheos).not(Common.EUINT32_TFHE, inputAsBytes);\n uint256 result = Impl.getValue(b);\n return euint32.wrap(result);\n }\n /// @notice Performs the not operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function not(euint64 input1) internal pure returns (euint64) {\n if (!isInitialized(input1)) {\n input1 = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n bytes memory b = FheOps(Precompiles.Fheos).not(Common.EUINT64_TFHE, inputAsBytes);\n uint256 result = Impl.getValue(b);\n return euint64.wrap(result);\n }\n /// @notice Performs the not operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function not(euint128 input1) internal pure returns (euint128) {\n if (!isInitialized(input1)) {\n input1 = asEuint128(0);\n }\n uint256 unwrappedInput1 = euint128.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n bytes memory b = FheOps(Precompiles.Fheos).not(Common.EUINT128_TFHE, inputAsBytes);\n uint256 result = Impl.getValue(b);\n return euint128.wrap(result);\n }\n /// @notice Performs the square operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function square(euint8 input1) internal pure returns (euint8) {\n if (!isInitialized(input1)) {\n input1 = asEuint8(0);\n }\n uint256 unwrappedInput1 = euint8.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n bytes memory b = FheOps(Precompiles.Fheos).square(Common.EUINT8_TFHE, inputAsBytes);\n uint256 result = Impl.getValue(b);\n return euint8.wrap(result);\n }\n /// @notice Performs the square operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function square(euint16 input1) internal pure returns (euint16) {\n if (!isInitialized(input1)) {\n input1 = asEuint16(0);\n }\n uint256 unwrappedInput1 = euint16.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n bytes memory b = FheOps(Precompiles.Fheos).square(Common.EUINT16_TFHE, inputAsBytes);\n uint256 result = Impl.getValue(b);\n return euint16.wrap(result);\n }\n /// @notice Performs the square operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function square(euint32 input1) internal pure returns (euint32) {\n if (!isInitialized(input1)) {\n input1 = asEuint32(0);\n }\n uint256 unwrappedInput1 = euint32.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n bytes memory b = FheOps(Precompiles.Fheos).square(Common.EUINT32_TFHE, inputAsBytes);\n uint256 result = Impl.getValue(b);\n return euint32.wrap(result);\n }\n /// @notice Performs the square operation on a ciphertext\n /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param input1 the input ciphertext\n function square(euint64 input1) internal pure returns (euint64) {\n if (!isInitialized(input1)) {\n input1 = asEuint64(0);\n }\n uint256 unwrappedInput1 = euint64.unwrap(input1);\n bytes memory inputAsBytes = Common.toBytes(unwrappedInput1);\n bytes memory b = FheOps(Precompiles.Fheos).square(Common.EUINT64_TFHE, inputAsBytes);\n uint256 result = Impl.getValue(b);\n return euint64.wrap(result);\n }\n /// @notice Generates a random value of a given type with the given seed, for the provided securityZone\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n /// @param uintType the type of the random value to generate\n /// @param seed the seed to use to create a random value from\n /// @param securityZone the security zone to use for the random value\n function random(uint8 uintType, uint64 seed, int32 securityZone) internal pure returns (uint256) {\n bytes memory b = FheOps(Precompiles.Fheos).random(uintType, seed, securityZone);\n return Impl.getValue(b);\n }\n /// @notice Generates a random value of a given type with the given seed\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n /// @param uintType the type of the random value to generate\n /// @param seed the seed to use to create a random value from\n function random(uint8 uintType, uint32 seed) internal pure returns (uint256) {\n return random(uintType, seed, 0);\n }\n /// @notice Generates a random value of a given type\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n /// @param uintType the type of the random value to generate\n function random(uint8 uintType) internal pure returns (uint256) {\n return random(uintType, 0, 0);\n }\n /// @notice Generates a random value of a euint8 type for provided securityZone\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n /// @param securityZone the security zone to use for the random value\n function randomEuint8(int32 securityZone) internal pure returns (euint8) {\n uint256 result = random(Common.EUINT8_TFHE, 0, securityZone);\n return euint8.wrap(result);\n }\n /// @notice Generates a random value of a euint8 type\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n function randomEuint8() internal pure returns (euint8) {\n return randomEuint8(0);\n }\n /// @notice Generates a random value of a euint16 type for provided securityZone\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n /// @param securityZone the security zone to use for the random value\n function randomEuint16(int32 securityZone) internal pure returns (euint16) {\n uint256 result = random(Common.EUINT16_TFHE, 0, securityZone);\n return euint16.wrap(result);\n }\n /// @notice Generates a random value of a euint16 type\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n function randomEuint16() internal pure returns (euint16) {\n return randomEuint16(0);\n }\n /// @notice Generates a random value of a euint32 type for provided securityZone\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n /// @param securityZone the security zone to use for the random value\n function randomEuint32(int32 securityZone) internal pure returns (euint32) {\n uint256 result = random(Common.EUINT32_TFHE, 0, securityZone);\n return euint32.wrap(result);\n }\n /// @notice Generates a random value of a euint32 type\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n function randomEuint32() internal pure returns (euint32) {\n return randomEuint32(0);\n }\n /// @notice Generates a random value of a euint64 type for provided securityZone\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n /// @param securityZone the security zone to use for the random value\n function randomEuint64(int32 securityZone) internal pure returns (euint64) {\n uint256 result = random(Common.EUINT64_TFHE, 0, securityZone);\n return euint64.wrap(result);\n }\n /// @notice Generates a random value of a euint64 type\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n function randomEuint64() internal pure returns (euint64) {\n return randomEuint64(0);\n }\n /// @notice Generates a random value of a euint128 type for provided securityZone\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n /// @param securityZone the security zone to use for the random value\n function randomEuint128(int32 securityZone) internal pure returns (euint128) {\n uint256 result = random(Common.EUINT128_TFHE, 0, securityZone);\n return euint128.wrap(result);\n }\n /// @notice Generates a random value of a euint128 type\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n function randomEuint128() internal pure returns (euint128) {\n return randomEuint128(0);\n }\n /// @notice Generates a random value of a euint256 type for provided securityZone\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n /// @param securityZone the security zone to use for the random value\n function randomEuint256(int32 securityZone) internal pure returns (euint256) {\n uint256 result = random(Common.EUINT256_TFHE, 0, securityZone);\n return euint256.wrap(result);\n }\n /// @notice Generates a random value of a euint256 type\n /// @dev Calls the desired precompile and returns the hash of the ciphertext\n function randomEuint256() internal pure returns (euint256) {\n return randomEuint256(0);\n }\n \n\n // ********** TYPE CASTING ************* //\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an ebool\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEbool(inEbool memory value) internal pure returns (ebool) {\n return FHE.asEbool(value.data, value.securityZone);\n }\n /// @notice Converts a ebool to an euint8\n function asEuint8(ebool value) internal pure returns (euint8) {\n return euint8.wrap(Impl.cast(Common.EBOOL_TFHE, ebool.unwrap(value), Common.EUINT8_TFHE));\n }\n /// @notice Converts a ebool to an euint16\n function asEuint16(ebool value) internal pure returns (euint16) {\n return euint16.wrap(Impl.cast(Common.EBOOL_TFHE, ebool.unwrap(value), Common.EUINT16_TFHE));\n }\n /// @notice Converts a ebool to an euint32\n function asEuint32(ebool value) internal pure returns (euint32) {\n return euint32.wrap(Impl.cast(Common.EBOOL_TFHE, ebool.unwrap(value), Common.EUINT32_TFHE));\n }\n /// @notice Converts a ebool to an euint64\n function asEuint64(ebool value) internal pure returns (euint64) {\n return euint64.wrap(Impl.cast(Common.EBOOL_TFHE, ebool.unwrap(value), Common.EUINT64_TFHE));\n }\n /// @notice Converts a ebool to an euint128\n function asEuint128(ebool value) internal pure returns (euint128) {\n return euint128.wrap(Impl.cast(Common.EBOOL_TFHE, ebool.unwrap(value), Common.EUINT128_TFHE));\n }\n /// @notice Converts a ebool to an euint256\n function asEuint256(ebool value) internal pure returns (euint256) {\n return euint256.wrap(Impl.cast(Common.EBOOL_TFHE, ebool.unwrap(value), Common.EUINT256_TFHE));\n }\n \n /// @notice Converts a euint8 to an ebool\n function asEbool(euint8 value) internal pure returns (ebool) {\n return ne(value, asEuint8(0));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an euint8\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEuint8(inEuint8 memory value) internal pure returns (euint8) {\n return FHE.asEuint8(value.data, value.securityZone);\n }\n /// @notice Converts a euint8 to an euint16\n function asEuint16(euint8 value) internal pure returns (euint16) {\n return euint16.wrap(Impl.cast(Common.EUINT8_TFHE, euint8.unwrap(value), Common.EUINT16_TFHE));\n }\n /// @notice Converts a euint8 to an euint32\n function asEuint32(euint8 value) internal pure returns (euint32) {\n return euint32.wrap(Impl.cast(Common.EUINT8_TFHE, euint8.unwrap(value), Common.EUINT32_TFHE));\n }\n /// @notice Converts a euint8 to an euint64\n function asEuint64(euint8 value) internal pure returns (euint64) {\n return euint64.wrap(Impl.cast(Common.EUINT8_TFHE, euint8.unwrap(value), Common.EUINT64_TFHE));\n }\n /// @notice Converts a euint8 to an euint128\n function asEuint128(euint8 value) internal pure returns (euint128) {\n return euint128.wrap(Impl.cast(Common.EUINT8_TFHE, euint8.unwrap(value), Common.EUINT128_TFHE));\n }\n /// @notice Converts a euint8 to an euint256\n function asEuint256(euint8 value) internal pure returns (euint256) {\n return euint256.wrap(Impl.cast(Common.EUINT8_TFHE, euint8.unwrap(value), Common.EUINT256_TFHE));\n }\n \n /// @notice Converts a euint16 to an ebool\n function asEbool(euint16 value) internal pure returns (ebool) {\n return ne(value, asEuint16(0));\n }\n /// @notice Converts a euint16 to an euint8\n function asEuint8(euint16 value) internal pure returns (euint8) {\n return euint8.wrap(Impl.cast(Common.EUINT16_TFHE, euint16.unwrap(value), Common.EUINT8_TFHE));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an euint16\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEuint16(inEuint16 memory value) internal pure returns (euint16) {\n return FHE.asEuint16(value.data, value.securityZone);\n }\n /// @notice Converts a euint16 to an euint32\n function asEuint32(euint16 value) internal pure returns (euint32) {\n return euint32.wrap(Impl.cast(Common.EUINT16_TFHE, euint16.unwrap(value), Common.EUINT32_TFHE));\n }\n /// @notice Converts a euint16 to an euint64\n function asEuint64(euint16 value) internal pure returns (euint64) {\n return euint64.wrap(Impl.cast(Common.EUINT16_TFHE, euint16.unwrap(value), Common.EUINT64_TFHE));\n }\n /// @notice Converts a euint16 to an euint128\n function asEuint128(euint16 value) internal pure returns (euint128) {\n return euint128.wrap(Impl.cast(Common.EUINT16_TFHE, euint16.unwrap(value), Common.EUINT128_TFHE));\n }\n /// @notice Converts a euint16 to an euint256\n function asEuint256(euint16 value) internal pure returns (euint256) {\n return euint256.wrap(Impl.cast(Common.EUINT16_TFHE, euint16.unwrap(value), Common.EUINT256_TFHE));\n }\n \n /// @notice Converts a euint32 to an ebool\n function asEbool(euint32 value) internal pure returns (ebool) {\n return ne(value, asEuint32(0));\n }\n /// @notice Converts a euint32 to an euint8\n function asEuint8(euint32 value) internal pure returns (euint8) {\n return euint8.wrap(Impl.cast(Common.EUINT32_TFHE, euint32.unwrap(value), Common.EUINT8_TFHE));\n }\n /// @notice Converts a euint32 to an euint16\n function asEuint16(euint32 value) internal pure returns (euint16) {\n return euint16.wrap(Impl.cast(Common.EUINT32_TFHE, euint32.unwrap(value), Common.EUINT16_TFHE));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an euint32\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEuint32(inEuint32 memory value) internal pure returns (euint32) {\n return FHE.asEuint32(value.data, value.securityZone);\n }\n /// @notice Converts a euint32 to an euint64\n function asEuint64(euint32 value) internal pure returns (euint64) {\n return euint64.wrap(Impl.cast(Common.EUINT32_TFHE, euint32.unwrap(value), Common.EUINT64_TFHE));\n }\n /// @notice Converts a euint32 to an euint128\n function asEuint128(euint32 value) internal pure returns (euint128) {\n return euint128.wrap(Impl.cast(Common.EUINT32_TFHE, euint32.unwrap(value), Common.EUINT128_TFHE));\n }\n /// @notice Converts a euint32 to an euint256\n function asEuint256(euint32 value) internal pure returns (euint256) {\n return euint256.wrap(Impl.cast(Common.EUINT32_TFHE, euint32.unwrap(value), Common.EUINT256_TFHE));\n }\n \n /// @notice Converts a euint64 to an ebool\n function asEbool(euint64 value) internal pure returns (ebool) {\n return ne(value, asEuint64(0));\n }\n /// @notice Converts a euint64 to an euint8\n function asEuint8(euint64 value) internal pure returns (euint8) {\n return euint8.wrap(Impl.cast(Common.EUINT64_TFHE, euint64.unwrap(value), Common.EUINT8_TFHE));\n }\n /// @notice Converts a euint64 to an euint16\n function asEuint16(euint64 value) internal pure returns (euint16) {\n return euint16.wrap(Impl.cast(Common.EUINT64_TFHE, euint64.unwrap(value), Common.EUINT16_TFHE));\n }\n /// @notice Converts a euint64 to an euint32\n function asEuint32(euint64 value) internal pure returns (euint32) {\n return euint32.wrap(Impl.cast(Common.EUINT64_TFHE, euint64.unwrap(value), Common.EUINT32_TFHE));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an euint64\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEuint64(inEuint64 memory value) internal pure returns (euint64) {\n return FHE.asEuint64(value.data, value.securityZone);\n }\n /// @notice Converts a euint64 to an euint128\n function asEuint128(euint64 value) internal pure returns (euint128) {\n return euint128.wrap(Impl.cast(Common.EUINT64_TFHE, euint64.unwrap(value), Common.EUINT128_TFHE));\n }\n /// @notice Converts a euint64 to an euint256\n function asEuint256(euint64 value) internal pure returns (euint256) {\n return euint256.wrap(Impl.cast(Common.EUINT64_TFHE, euint64.unwrap(value), Common.EUINT256_TFHE));\n }\n \n /// @notice Converts a euint128 to an ebool\n function asEbool(euint128 value) internal pure returns (ebool) {\n return ne(value, asEuint128(0));\n }\n /// @notice Converts a euint128 to an euint8\n function asEuint8(euint128 value) internal pure returns (euint8) {\n return euint8.wrap(Impl.cast(Common.EUINT128_TFHE, euint128.unwrap(value), Common.EUINT8_TFHE));\n }\n /// @notice Converts a euint128 to an euint16\n function asEuint16(euint128 value) internal pure returns (euint16) {\n return euint16.wrap(Impl.cast(Common.EUINT128_TFHE, euint128.unwrap(value), Common.EUINT16_TFHE));\n }\n /// @notice Converts a euint128 to an euint32\n function asEuint32(euint128 value) internal pure returns (euint32) {\n return euint32.wrap(Impl.cast(Common.EUINT128_TFHE, euint128.unwrap(value), Common.EUINT32_TFHE));\n }\n /// @notice Converts a euint128 to an euint64\n function asEuint64(euint128 value) internal pure returns (euint64) {\n return euint64.wrap(Impl.cast(Common.EUINT128_TFHE, euint128.unwrap(value), Common.EUINT64_TFHE));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an euint128\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEuint128(inEuint128 memory value) internal pure returns (euint128) {\n return FHE.asEuint128(value.data, value.securityZone);\n }\n /// @notice Converts a euint128 to an euint256\n function asEuint256(euint128 value) internal pure returns (euint256) {\n return euint256.wrap(Impl.cast(Common.EUINT128_TFHE, euint128.unwrap(value), Common.EUINT256_TFHE));\n }\n \n /// @notice Converts a euint256 to an ebool\n function asEbool(euint256 value) internal pure returns (ebool) {\n return ne(value, asEuint256(0));\n }\n /// @notice Converts a euint256 to an euint8\n function asEuint8(euint256 value) internal pure returns (euint8) {\n return euint8.wrap(Impl.cast(Common.EUINT256_TFHE, euint256.unwrap(value), Common.EUINT8_TFHE));\n }\n /// @notice Converts a euint256 to an euint16\n function asEuint16(euint256 value) internal pure returns (euint16) {\n return euint16.wrap(Impl.cast(Common.EUINT256_TFHE, euint256.unwrap(value), Common.EUINT16_TFHE));\n }\n /// @notice Converts a euint256 to an euint32\n function asEuint32(euint256 value) internal pure returns (euint32) {\n return euint32.wrap(Impl.cast(Common.EUINT256_TFHE, euint256.unwrap(value), Common.EUINT32_TFHE));\n }\n /// @notice Converts a euint256 to an euint64\n function asEuint64(euint256 value) internal pure returns (euint64) {\n return euint64.wrap(Impl.cast(Common.EUINT256_TFHE, euint256.unwrap(value), Common.EUINT64_TFHE));\n }\n /// @notice Converts a euint256 to an euint128\n function asEuint128(euint256 value) internal pure returns (euint128) {\n return euint128.wrap(Impl.cast(Common.EUINT256_TFHE, euint256.unwrap(value), Common.EUINT128_TFHE));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an euint256\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEuint256(inEuint256 memory value) internal pure returns (euint256) {\n return FHE.asEuint256(value.data, value.securityZone);\n }\n /// @notice Converts a euint256 to an eaddress\n function asEaddress(euint256 value) internal pure returns (eaddress) {\n return eaddress.wrap(Impl.cast(Common.EUINT256_TFHE, euint256.unwrap(value), Common.EADDRESS_TFHE));\n }\n \n /// @notice Converts a eaddress to an ebool\n function asEbool(eaddress value) internal pure returns (ebool) {\n return ne(value, asEaddress(0));\n }\n /// @notice Converts a eaddress to an euint8\n function asEuint8(eaddress value) internal pure returns (euint8) {\n return euint8.wrap(Impl.cast(Common.EADDRESS_TFHE, eaddress.unwrap(value), Common.EUINT8_TFHE));\n }\n /// @notice Converts a eaddress to an euint16\n function asEuint16(eaddress value) internal pure returns (euint16) {\n return euint16.wrap(Impl.cast(Common.EADDRESS_TFHE, eaddress.unwrap(value), Common.EUINT16_TFHE));\n }\n /// @notice Converts a eaddress to an euint32\n function asEuint32(eaddress value) internal pure returns (euint32) {\n return euint32.wrap(Impl.cast(Common.EADDRESS_TFHE, eaddress.unwrap(value), Common.EUINT32_TFHE));\n }\n /// @notice Converts a eaddress to an euint64\n function asEuint64(eaddress value) internal pure returns (euint64) {\n return euint64.wrap(Impl.cast(Common.EADDRESS_TFHE, eaddress.unwrap(value), Common.EUINT64_TFHE));\n }\n /// @notice Converts a eaddress to an euint128\n function asEuint128(eaddress value) internal pure returns (euint128) {\n return euint128.wrap(Impl.cast(Common.EADDRESS_TFHE, eaddress.unwrap(value), Common.EUINT128_TFHE));\n }\n /// @notice Converts a eaddress to an euint256\n function asEuint256(eaddress value) internal pure returns (euint256) {\n return euint256.wrap(Impl.cast(Common.EADDRESS_TFHE, eaddress.unwrap(value), Common.EUINT256_TFHE));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an eaddress\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEaddress(inEaddress memory value) internal pure returns (eaddress) {\n return FHE.asEaddress(value.data, value.securityZone);\n }\n /// @notice Converts a uint256 to an ebool\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEbool(uint256 value) internal pure returns (ebool) {\n return ebool.wrap(Impl.trivialEncrypt(value, Common.EBOOL_TFHE, 0));\n }\n /// @notice Converts a uint256 to an ebool, specifying security zone\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEbool(uint256 value, int32 securityZone) internal pure returns (ebool) {\n return ebool.wrap(Impl.trivialEncrypt(value, Common.EBOOL_TFHE, securityZone));\n }\n /// @notice Converts a uint256 to an euint8\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEuint8(uint256 value) internal pure returns (euint8) {\n return euint8.wrap(Impl.trivialEncrypt(value, Common.EUINT8_TFHE, 0));\n }\n /// @notice Converts a uint256 to an euint8, specifying security zone\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEuint8(uint256 value, int32 securityZone) internal pure returns (euint8) {\n return euint8.wrap(Impl.trivialEncrypt(value, Common.EUINT8_TFHE, securityZone));\n }\n /// @notice Converts a uint256 to an euint16\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEuint16(uint256 value) internal pure returns (euint16) {\n return euint16.wrap(Impl.trivialEncrypt(value, Common.EUINT16_TFHE, 0));\n }\n /// @notice Converts a uint256 to an euint16, specifying security zone\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEuint16(uint256 value, int32 securityZone) internal pure returns (euint16) {\n return euint16.wrap(Impl.trivialEncrypt(value, Common.EUINT16_TFHE, securityZone));\n }\n /// @notice Converts a uint256 to an euint32\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEuint32(uint256 value) internal pure returns (euint32) {\n return euint32.wrap(Impl.trivialEncrypt(value, Common.EUINT32_TFHE, 0));\n }\n /// @notice Converts a uint256 to an euint32, specifying security zone\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEuint32(uint256 value, int32 securityZone) internal pure returns (euint32) {\n return euint32.wrap(Impl.trivialEncrypt(value, Common.EUINT32_TFHE, securityZone));\n }\n /// @notice Converts a uint256 to an euint64\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEuint64(uint256 value) internal pure returns (euint64) {\n return euint64.wrap(Impl.trivialEncrypt(value, Common.EUINT64_TFHE, 0));\n }\n /// @notice Converts a uint256 to an euint64, specifying security zone\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEuint64(uint256 value, int32 securityZone) internal pure returns (euint64) {\n return euint64.wrap(Impl.trivialEncrypt(value, Common.EUINT64_TFHE, securityZone));\n }\n /// @notice Converts a uint256 to an euint128\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEuint128(uint256 value) internal pure returns (euint128) {\n return euint128.wrap(Impl.trivialEncrypt(value, Common.EUINT128_TFHE, 0));\n }\n /// @notice Converts a uint256 to an euint128, specifying security zone\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEuint128(uint256 value, int32 securityZone) internal pure returns (euint128) {\n return euint128.wrap(Impl.trivialEncrypt(value, Common.EUINT128_TFHE, securityZone));\n }\n /// @notice Converts a uint256 to an euint256\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEuint256(uint256 value) internal pure returns (euint256) {\n return euint256.wrap(Impl.trivialEncrypt(value, Common.EUINT256_TFHE, 0));\n }\n /// @notice Converts a uint256 to an euint256, specifying security zone\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEuint256(uint256 value, int32 securityZone) internal pure returns (euint256) {\n return euint256.wrap(Impl.trivialEncrypt(value, Common.EUINT256_TFHE, securityZone));\n }\n /// @notice Converts a uint256 to an eaddress\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEaddress(uint256 value) internal pure returns (eaddress) {\n return eaddress.wrap(Impl.trivialEncrypt(value, Common.EADDRESS_TFHE, 0));\n }\n /// @notice Converts a uint256 to an eaddress, specifying security zone\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n function asEaddress(uint256 value, int32 securityZone) internal pure returns (eaddress) {\n return eaddress.wrap(Impl.trivialEncrypt(value, Common.EADDRESS_TFHE, securityZone));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an ebool\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEbool(bytes memory value, int32 securityZone) internal pure returns (ebool) {\n return ebool.wrap(Impl.verify(value, Common.EBOOL_TFHE, securityZone));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an euint8\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEuint8(bytes memory value, int32 securityZone) internal pure returns (euint8) {\n return euint8.wrap(Impl.verify(value, Common.EUINT8_TFHE, securityZone));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an euint16\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEuint16(bytes memory value, int32 securityZone) internal pure returns (euint16) {\n return euint16.wrap(Impl.verify(value, Common.EUINT16_TFHE, securityZone));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an euint32\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEuint32(bytes memory value, int32 securityZone) internal pure returns (euint32) {\n return euint32.wrap(Impl.verify(value, Common.EUINT32_TFHE, securityZone));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an euint64\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEuint64(bytes memory value, int32 securityZone) internal pure returns (euint64) {\n return euint64.wrap(Impl.verify(value, Common.EUINT64_TFHE, securityZone));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an euint128\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEuint128(bytes memory value, int32 securityZone) internal pure returns (euint128) {\n return euint128.wrap(Impl.verify(value, Common.EUINT128_TFHE, securityZone));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an euint256\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEuint256(bytes memory value, int32 securityZone) internal pure returns (euint256) {\n return euint256.wrap(Impl.verify(value, Common.EUINT256_TFHE, securityZone));\n }\n /// @notice Parses input ciphertexts from the user. Converts from encrypted raw bytes to an eaddress\n /// @dev Also performs validation that the ciphertext is valid and has been encrypted using the network encryption key\n /// @return a ciphertext representation of the input\n function asEaddress(bytes memory value, int32 securityZone) internal pure returns (eaddress) {\n return eaddress.wrap(Impl.verify(value, Common.EADDRESS_TFHE, securityZone));\n }\n /// @notice Converts a address to an eaddress\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n /// Allows for a better user experience when working with eaddresses\n function asEaddress(address value) internal pure returns (eaddress) {\n return eaddress.wrap(Impl.trivialEncrypt(uint256(uint160(value)), Common.EADDRESS_TFHE, 0));\n }\n /// @notice Converts a address to an eaddress, specifying security zone\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n /// Allows for a better user experience when working with eaddresses\n function asEaddress(address value, int32 securityZone) internal pure returns (eaddress) {\n return eaddress.wrap(Impl.trivialEncrypt(uint256(uint160(value)), Common.EADDRESS_TFHE, securityZone));\n }\n /// @notice Converts a plaintext boolean value to a ciphertext ebool\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n /// @return A ciphertext representation of the input\n function asEbool(bool value) internal pure returns (ebool) {\n uint256 sVal = 0;\n if (value) {\n sVal = 1;\n }\n return asEbool(sVal);\n }\n /// @notice Converts a plaintext boolean value to a ciphertext ebool, specifying security zone\n /// @dev Privacy: The input value is public, therefore the resulting ciphertext should be considered public until involved in an fhe operation\n /// @return A ciphertext representation of the input\n function asEbool(bool value, int32 securityZone) internal pure returns (ebool) {\n uint256 sVal = 0;\n if (value) {\n sVal = 1;\n }\n return asEbool(sVal, securityZone);\n }\n}\n\n// ********** OPERATOR OVERLOADING ************* //\n\nusing {operatorAddEuint8 as +} for euint8 global;\n/// @notice Performs the add operation\nfunction operatorAddEuint8(euint8 lhs, euint8 rhs) pure returns (euint8) {\n return FHE.add(lhs, rhs);\n}\n\nusing {operatorAddEuint16 as +} for euint16 global;\n/// @notice Performs the add operation\nfunction operatorAddEuint16(euint16 lhs, euint16 rhs) pure returns (euint16) {\n return FHE.add(lhs, rhs);\n}\n\nusing {operatorAddEuint32 as +} for euint32 global;\n/// @notice Performs the add operation\nfunction operatorAddEuint32(euint32 lhs, euint32 rhs) pure returns (euint32) {\n return FHE.add(lhs, rhs);\n}\n\nusing {operatorAddEuint64 as +} for euint64 global;\n/// @notice Performs the add operation\nfunction operatorAddEuint64(euint64 lhs, euint64 rhs) pure returns (euint64) {\n return FHE.add(lhs, rhs);\n}\n\nusing {operatorAddEuint128 as +} for euint128 global;\n/// @notice Performs the add operation\nfunction operatorAddEuint128(euint128 lhs, euint128 rhs) pure returns (euint128) {\n return FHE.add(lhs, rhs);\n}\n\nusing {operatorSubEuint8 as -} for euint8 global;\n/// @notice Performs the sub operation\nfunction operatorSubEuint8(euint8 lhs, euint8 rhs) pure returns (euint8) {\n return FHE.sub(lhs, rhs);\n}\n\nusing {operatorSubEuint16 as -} for euint16 global;\n/// @notice Performs the sub operation\nfunction operatorSubEuint16(euint16 lhs, euint16 rhs) pure returns (euint16) {\n return FHE.sub(lhs, rhs);\n}\n\nusing {operatorSubEuint32 as -} for euint32 global;\n/// @notice Performs the sub operation\nfunction operatorSubEuint32(euint32 lhs, euint32 rhs) pure returns (euint32) {\n return FHE.sub(lhs, rhs);\n}\n\nusing {operatorSubEuint64 as -} for euint64 global;\n/// @notice Performs the sub operation\nfunction operatorSubEuint64(euint64 lhs, euint64 rhs) pure returns (euint64) {\n return FHE.sub(lhs, rhs);\n}\n\nusing {operatorSubEuint128 as -} for euint128 global;\n/// @notice Performs the sub operation\nfunction operatorSubEuint128(euint128 lhs, euint128 rhs) pure returns (euint128) {\n return FHE.sub(lhs, rhs);\n}\n\nusing {operatorMulEuint8 as *} for euint8 global;\n/// @notice Performs the mul operation\nfunction operatorMulEuint8(euint8 lhs, euint8 rhs) pure returns (euint8) {\n return FHE.mul(lhs, rhs);\n}\n\nusing {operatorMulEuint16 as *} for euint16 global;\n/// @notice Performs the mul operation\nfunction operatorMulEuint16(euint16 lhs, euint16 rhs) pure returns (euint16) {\n return FHE.mul(lhs, rhs);\n}\n\nusing {operatorMulEuint32 as *} for euint32 global;\n/// @notice Performs the mul operation\nfunction operatorMulEuint32(euint32 lhs, euint32 rhs) pure returns (euint32) {\n return FHE.mul(lhs, rhs);\n}\n\nusing {operatorMulEuint64 as *} for euint64 global;\n/// @notice Performs the mul operation\nfunction operatorMulEuint64(euint64 lhs, euint64 rhs) pure returns (euint64) {\n return FHE.mul(lhs, rhs);\n}\n\nusing {operatorDivEuint8 as /} for euint8 global;\n/// @notice Performs the div operation\nfunction operatorDivEuint8(euint8 lhs, euint8 rhs) pure returns (euint8) {\n return FHE.div(lhs, rhs);\n}\n\nusing {operatorDivEuint16 as /} for euint16 global;\n/// @notice Performs the div operation\nfunction operatorDivEuint16(euint16 lhs, euint16 rhs) pure returns (euint16) {\n return FHE.div(lhs, rhs);\n}\n\nusing {operatorDivEuint32 as /} for euint32 global;\n/// @notice Performs the div operation\nfunction operatorDivEuint32(euint32 lhs, euint32 rhs) pure returns (euint32) {\n return FHE.div(lhs, rhs);\n}\n\nusing {operatorOrEbool as |} for ebool global;\n/// @notice Performs the or operation\nfunction operatorOrEbool(ebool lhs, ebool rhs) pure returns (ebool) {\n return FHE.or(lhs, rhs);\n}\n\nusing {operatorOrEuint8 as |} for euint8 global;\n/// @notice Performs the or operation\nfunction operatorOrEuint8(euint8 lhs, euint8 rhs) pure returns (euint8) {\n return FHE.or(lhs, rhs);\n}\n\nusing {operatorOrEuint16 as |} for euint16 global;\n/// @notice Performs the or operation\nfunction operatorOrEuint16(euint16 lhs, euint16 rhs) pure returns (euint16) {\n return FHE.or(lhs, rhs);\n}\n\nusing {operatorOrEuint32 as |} for euint32 global;\n/// @notice Performs the or operation\nfunction operatorOrEuint32(euint32 lhs, euint32 rhs) pure returns (euint32) {\n return FHE.or(lhs, rhs);\n}\n\nusing {operatorOrEuint64 as |} for euint64 global;\n/// @notice Performs the or operation\nfunction operatorOrEuint64(euint64 lhs, euint64 rhs) pure returns (euint64) {\n return FHE.or(lhs, rhs);\n}\n\nusing {operatorOrEuint128 as |} for euint128 global;\n/// @notice Performs the or operation\nfunction operatorOrEuint128(euint128 lhs, euint128 rhs) pure returns (euint128) {\n return FHE.or(lhs, rhs);\n}\n\nusing {operatorAndEbool as &} for ebool global;\n/// @notice Performs the and operation\nfunction operatorAndEbool(ebool lhs, ebool rhs) pure returns (ebool) {\n return FHE.and(lhs, rhs);\n}\n\nusing {operatorAndEuint8 as &} for euint8 global;\n/// @notice Performs the and operation\nfunction operatorAndEuint8(euint8 lhs, euint8 rhs) pure returns (euint8) {\n return FHE.and(lhs, rhs);\n}\n\nusing {operatorAndEuint16 as &} for euint16 global;\n/// @notice Performs the and operation\nfunction operatorAndEuint16(euint16 lhs, euint16 rhs) pure returns (euint16) {\n return FHE.and(lhs, rhs);\n}\n\nusing {operatorAndEuint32 as &} for euint32 global;\n/// @notice Performs the and operation\nfunction operatorAndEuint32(euint32 lhs, euint32 rhs) pure returns (euint32) {\n return FHE.and(lhs, rhs);\n}\n\nusing {operatorAndEuint64 as &} for euint64 global;\n/// @notice Performs the and operation\nfunction operatorAndEuint64(euint64 lhs, euint64 rhs) pure returns (euint64) {\n return FHE.and(lhs, rhs);\n}\n\nusing {operatorAndEuint128 as &} for euint128 global;\n/// @notice Performs the and operation\nfunction operatorAndEuint128(euint128 lhs, euint128 rhs) pure returns (euint128) {\n return FHE.and(lhs, rhs);\n}\n\nusing {operatorXorEbool as ^} for ebool global;\n/// @notice Performs the xor operation\nfunction operatorXorEbool(ebool lhs, ebool rhs) pure returns (ebool) {\n return FHE.xor(lhs, rhs);\n}\n\nusing {operatorXorEuint8 as ^} for euint8 global;\n/// @notice Performs the xor operation\nfunction operatorXorEuint8(euint8 lhs, euint8 rhs) pure returns (euint8) {\n return FHE.xor(lhs, rhs);\n}\n\nusing {operatorXorEuint16 as ^} for euint16 global;\n/// @notice Performs the xor operation\nfunction operatorXorEuint16(euint16 lhs, euint16 rhs) pure returns (euint16) {\n return FHE.xor(lhs, rhs);\n}\n\nusing {operatorXorEuint32 as ^} for euint32 global;\n/// @notice Performs the xor operation\nfunction operatorXorEuint32(euint32 lhs, euint32 rhs) pure returns (euint32) {\n return FHE.xor(lhs, rhs);\n}\n\nusing {operatorXorEuint64 as ^} for euint64 global;\n/// @notice Performs the xor operation\nfunction operatorXorEuint64(euint64 lhs, euint64 rhs) pure returns (euint64) {\n return FHE.xor(lhs, rhs);\n}\n\nusing {operatorXorEuint128 as ^} for euint128 global;\n/// @notice Performs the xor operation\nfunction operatorXorEuint128(euint128 lhs, euint128 rhs) pure returns (euint128) {\n return FHE.xor(lhs, rhs);\n}\n\nusing {operatorRemEuint8 as %} for euint8 global;\n/// @notice Performs the rem operation\nfunction operatorRemEuint8(euint8 lhs, euint8 rhs) pure returns (euint8) {\n return FHE.rem(lhs, rhs);\n}\n\nusing {operatorRemEuint16 as %} for euint16 global;\n/// @notice Performs the rem operation\nfunction operatorRemEuint16(euint16 lhs, euint16 rhs) pure returns (euint16) {\n return FHE.rem(lhs, rhs);\n}\n\nusing {operatorRemEuint32 as %} for euint32 global;\n/// @notice Performs the rem operation\nfunction operatorRemEuint32(euint32 lhs, euint32 rhs) pure returns (euint32) {\n return FHE.rem(lhs, rhs);\n}\n\n// ********** BINDING DEFS ************* //\n\nusing BindingsEbool for ebool global;\nlibrary BindingsEbool {\n \n /// @notice Performs the eq operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type ebool\n /// @param rhs second input of type ebool\n /// @return the result of the eq\n function eq(ebool lhs, ebool rhs) internal pure returns (ebool) {\n return FHE.eq(lhs, rhs);\n }\n \n /// @notice Performs the ne operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type ebool\n /// @param rhs second input of type ebool\n /// @return the result of the ne\n function ne(ebool lhs, ebool rhs) internal pure returns (ebool) {\n return FHE.ne(lhs, rhs);\n }\n \n /// @notice Performs the not operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type ebool\n /// @return the result of the not\n function not(ebool lhs) internal pure returns (ebool) {\n return FHE.not(lhs);\n }\n \n /// @notice Performs the and operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type ebool\n /// @param rhs second input of type ebool\n /// @return the result of the and\n function and(ebool lhs, ebool rhs) internal pure returns (ebool) {\n return FHE.and(lhs, rhs);\n }\n \n /// @notice Performs the or operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type ebool\n /// @param rhs second input of type ebool\n /// @return the result of the or\n function or(ebool lhs, ebool rhs) internal pure returns (ebool) {\n return FHE.or(lhs, rhs);\n }\n \n /// @notice Performs the xor operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type ebool\n /// @param rhs second input of type ebool\n /// @return the result of the xor\n function xor(ebool lhs, ebool rhs) internal pure returns (ebool) {\n return FHE.xor(lhs, rhs);\n }\n function toU8(ebool value) internal pure returns (euint8) {\n return FHE.asEuint8(value);\n }\n function toU16(ebool value) internal pure returns (euint16) {\n return FHE.asEuint16(value);\n }\n function toU32(ebool value) internal pure returns (euint32) {\n return FHE.asEuint32(value);\n }\n function toU64(ebool value) internal pure returns (euint64) {\n return FHE.asEuint64(value);\n }\n function toU128(ebool value) internal pure returns (euint128) {\n return FHE.asEuint128(value);\n }\n function toU256(ebool value) internal pure returns (euint256) {\n return FHE.asEuint256(value);\n }\n function seal(ebool value, bytes32 publicKey) internal pure returns (string memory) {\n return FHE.sealoutput(value, publicKey);\n }\n function sealTyped(ebool value, bytes32 publicKey) internal pure returns (SealedBool memory) {\n return FHE.sealoutputTyped(value, publicKey);\n }\n function decrypt(ebool value) internal pure returns (bool) {\n return FHE.decrypt(value);\n }\n function decrypt(ebool value, bool defaultValue) internal pure returns (bool) {\n return FHE.decrypt(value, defaultValue);\n }\n}\n\nusing BindingsEuint8 for euint8 global;\nlibrary BindingsEuint8 {\n \n /// @notice Performs the add operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the add\n function add(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.add(lhs, rhs);\n }\n \n /// @notice Performs the mul operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the mul\n function mul(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.mul(lhs, rhs);\n }\n \n /// @notice Performs the div operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the div\n function div(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.div(lhs, rhs);\n }\n \n /// @notice Performs the sub operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the sub\n function sub(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.sub(lhs, rhs);\n }\n \n /// @notice Performs the eq operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the eq\n function eq(euint8 lhs, euint8 rhs) internal pure returns (ebool) {\n return FHE.eq(lhs, rhs);\n }\n \n /// @notice Performs the ne operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the ne\n function ne(euint8 lhs, euint8 rhs) internal pure returns (ebool) {\n return FHE.ne(lhs, rhs);\n }\n \n /// @notice Performs the not operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @return the result of the not\n function not(euint8 lhs) internal pure returns (euint8) {\n return FHE.not(lhs);\n }\n \n /// @notice Performs the and operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the and\n function and(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.and(lhs, rhs);\n }\n \n /// @notice Performs the or operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the or\n function or(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.or(lhs, rhs);\n }\n \n /// @notice Performs the xor operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the xor\n function xor(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.xor(lhs, rhs);\n }\n \n /// @notice Performs the gt operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the gt\n function gt(euint8 lhs, euint8 rhs) internal pure returns (ebool) {\n return FHE.gt(lhs, rhs);\n }\n \n /// @notice Performs the gte operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the gte\n function gte(euint8 lhs, euint8 rhs) internal pure returns (ebool) {\n return FHE.gte(lhs, rhs);\n }\n \n /// @notice Performs the lt operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the lt\n function lt(euint8 lhs, euint8 rhs) internal pure returns (ebool) {\n return FHE.lt(lhs, rhs);\n }\n \n /// @notice Performs the lte operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the lte\n function lte(euint8 lhs, euint8 rhs) internal pure returns (ebool) {\n return FHE.lte(lhs, rhs);\n }\n \n /// @notice Performs the rem operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the rem\n function rem(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.rem(lhs, rhs);\n }\n \n /// @notice Performs the max operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the max\n function max(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.max(lhs, rhs);\n }\n \n /// @notice Performs the min operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the min\n function min(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.min(lhs, rhs);\n }\n \n /// @notice Performs the shl operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the shl\n function shl(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.shl(lhs, rhs);\n }\n \n /// @notice Performs the shr operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the shr\n function shr(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.shr(lhs, rhs);\n }\n \n /// @notice Performs the rol operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the rol\n function rol(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.rol(lhs, rhs);\n }\n \n /// @notice Performs the ror operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @param rhs second input of type euint8\n /// @return the result of the ror\n function ror(euint8 lhs, euint8 rhs) internal pure returns (euint8) {\n return FHE.ror(lhs, rhs);\n }\n \n /// @notice Performs the square operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint8\n /// @return the result of the square\n function square(euint8 lhs) internal pure returns (euint8) {\n return FHE.square(lhs);\n }\n function toBool(euint8 value) internal pure returns (ebool) {\n return FHE.asEbool(value);\n }\n function toU16(euint8 value) internal pure returns (euint16) {\n return FHE.asEuint16(value);\n }\n function toU32(euint8 value) internal pure returns (euint32) {\n return FHE.asEuint32(value);\n }\n function toU64(euint8 value) internal pure returns (euint64) {\n return FHE.asEuint64(value);\n }\n function toU128(euint8 value) internal pure returns (euint128) {\n return FHE.asEuint128(value);\n }\n function toU256(euint8 value) internal pure returns (euint256) {\n return FHE.asEuint256(value);\n }\n function seal(euint8 value, bytes32 publicKey) internal pure returns (string memory) {\n return FHE.sealoutput(value, publicKey);\n }\n function sealTyped(euint8 value, bytes32 publicKey) internal pure returns (SealedUint memory) {\n return FHE.sealoutputTyped(value, publicKey);\n }\n function decrypt(euint8 value) internal pure returns (uint8) {\n return FHE.decrypt(value);\n }\n function decrypt(euint8 value, uint8 defaultValue) internal pure returns (uint8) {\n return FHE.decrypt(value, defaultValue);\n }\n}\n\nusing BindingsEuint16 for euint16 global;\nlibrary BindingsEuint16 {\n \n /// @notice Performs the add operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the add\n function add(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.add(lhs, rhs);\n }\n \n /// @notice Performs the mul operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the mul\n function mul(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.mul(lhs, rhs);\n }\n \n /// @notice Performs the div operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the div\n function div(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.div(lhs, rhs);\n }\n \n /// @notice Performs the sub operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the sub\n function sub(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.sub(lhs, rhs);\n }\n \n /// @notice Performs the eq operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the eq\n function eq(euint16 lhs, euint16 rhs) internal pure returns (ebool) {\n return FHE.eq(lhs, rhs);\n }\n \n /// @notice Performs the ne operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the ne\n function ne(euint16 lhs, euint16 rhs) internal pure returns (ebool) {\n return FHE.ne(lhs, rhs);\n }\n \n /// @notice Performs the not operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @return the result of the not\n function not(euint16 lhs) internal pure returns (euint16) {\n return FHE.not(lhs);\n }\n \n /// @notice Performs the and operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the and\n function and(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.and(lhs, rhs);\n }\n \n /// @notice Performs the or operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the or\n function or(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.or(lhs, rhs);\n }\n \n /// @notice Performs the xor operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the xor\n function xor(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.xor(lhs, rhs);\n }\n \n /// @notice Performs the gt operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the gt\n function gt(euint16 lhs, euint16 rhs) internal pure returns (ebool) {\n return FHE.gt(lhs, rhs);\n }\n \n /// @notice Performs the gte operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the gte\n function gte(euint16 lhs, euint16 rhs) internal pure returns (ebool) {\n return FHE.gte(lhs, rhs);\n }\n \n /// @notice Performs the lt operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the lt\n function lt(euint16 lhs, euint16 rhs) internal pure returns (ebool) {\n return FHE.lt(lhs, rhs);\n }\n \n /// @notice Performs the lte operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the lte\n function lte(euint16 lhs, euint16 rhs) internal pure returns (ebool) {\n return FHE.lte(lhs, rhs);\n }\n \n /// @notice Performs the rem operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the rem\n function rem(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.rem(lhs, rhs);\n }\n \n /// @notice Performs the max operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the max\n function max(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.max(lhs, rhs);\n }\n \n /// @notice Performs the min operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the min\n function min(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.min(lhs, rhs);\n }\n \n /// @notice Performs the shl operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the shl\n function shl(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.shl(lhs, rhs);\n }\n \n /// @notice Performs the shr operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the shr\n function shr(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.shr(lhs, rhs);\n }\n \n /// @notice Performs the rol operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the rol\n function rol(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.rol(lhs, rhs);\n }\n \n /// @notice Performs the ror operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @param rhs second input of type euint16\n /// @return the result of the ror\n function ror(euint16 lhs, euint16 rhs) internal pure returns (euint16) {\n return FHE.ror(lhs, rhs);\n }\n \n /// @notice Performs the square operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint16\n /// @return the result of the square\n function square(euint16 lhs) internal pure returns (euint16) {\n return FHE.square(lhs);\n }\n function toBool(euint16 value) internal pure returns (ebool) {\n return FHE.asEbool(value);\n }\n function toU8(euint16 value) internal pure returns (euint8) {\n return FHE.asEuint8(value);\n }\n function toU32(euint16 value) internal pure returns (euint32) {\n return FHE.asEuint32(value);\n }\n function toU64(euint16 value) internal pure returns (euint64) {\n return FHE.asEuint64(value);\n }\n function toU128(euint16 value) internal pure returns (euint128) {\n return FHE.asEuint128(value);\n }\n function toU256(euint16 value) internal pure returns (euint256) {\n return FHE.asEuint256(value);\n }\n function seal(euint16 value, bytes32 publicKey) internal pure returns (string memory) {\n return FHE.sealoutput(value, publicKey);\n }\n function sealTyped(euint16 value, bytes32 publicKey) internal pure returns (SealedUint memory) {\n return FHE.sealoutputTyped(value, publicKey);\n }\n function decrypt(euint16 value) internal pure returns (uint16) {\n return FHE.decrypt(value);\n }\n function decrypt(euint16 value, uint16 defaultValue) internal pure returns (uint16) {\n return FHE.decrypt(value, defaultValue);\n }\n}\n\nusing BindingsEuint32 for euint32 global;\nlibrary BindingsEuint32 {\n \n /// @notice Performs the add operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the add\n function add(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.add(lhs, rhs);\n }\n \n /// @notice Performs the mul operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the mul\n function mul(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.mul(lhs, rhs);\n }\n \n /// @notice Performs the div operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the div\n function div(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.div(lhs, rhs);\n }\n \n /// @notice Performs the sub operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the sub\n function sub(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.sub(lhs, rhs);\n }\n \n /// @notice Performs the eq operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the eq\n function eq(euint32 lhs, euint32 rhs) internal pure returns (ebool) {\n return FHE.eq(lhs, rhs);\n }\n \n /// @notice Performs the ne operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the ne\n function ne(euint32 lhs, euint32 rhs) internal pure returns (ebool) {\n return FHE.ne(lhs, rhs);\n }\n \n /// @notice Performs the not operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @return the result of the not\n function not(euint32 lhs) internal pure returns (euint32) {\n return FHE.not(lhs);\n }\n \n /// @notice Performs the and operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the and\n function and(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.and(lhs, rhs);\n }\n \n /// @notice Performs the or operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the or\n function or(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.or(lhs, rhs);\n }\n \n /// @notice Performs the xor operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the xor\n function xor(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.xor(lhs, rhs);\n }\n \n /// @notice Performs the gt operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the gt\n function gt(euint32 lhs, euint32 rhs) internal pure returns (ebool) {\n return FHE.gt(lhs, rhs);\n }\n \n /// @notice Performs the gte operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the gte\n function gte(euint32 lhs, euint32 rhs) internal pure returns (ebool) {\n return FHE.gte(lhs, rhs);\n }\n \n /// @notice Performs the lt operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the lt\n function lt(euint32 lhs, euint32 rhs) internal pure returns (ebool) {\n return FHE.lt(lhs, rhs);\n }\n \n /// @notice Performs the lte operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the lte\n function lte(euint32 lhs, euint32 rhs) internal pure returns (ebool) {\n return FHE.lte(lhs, rhs);\n }\n \n /// @notice Performs the rem operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the rem\n function rem(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.rem(lhs, rhs);\n }\n \n /// @notice Performs the max operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the max\n function max(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.max(lhs, rhs);\n }\n \n /// @notice Performs the min operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the min\n function min(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.min(lhs, rhs);\n }\n \n /// @notice Performs the shl operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the shl\n function shl(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.shl(lhs, rhs);\n }\n \n /// @notice Performs the shr operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the shr\n function shr(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.shr(lhs, rhs);\n }\n \n /// @notice Performs the rol operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the rol\n function rol(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.rol(lhs, rhs);\n }\n \n /// @notice Performs the ror operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @param rhs second input of type euint32\n /// @return the result of the ror\n function ror(euint32 lhs, euint32 rhs) internal pure returns (euint32) {\n return FHE.ror(lhs, rhs);\n }\n \n /// @notice Performs the square operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint32\n /// @return the result of the square\n function square(euint32 lhs) internal pure returns (euint32) {\n return FHE.square(lhs);\n }\n function toBool(euint32 value) internal pure returns (ebool) {\n return FHE.asEbool(value);\n }\n function toU8(euint32 value) internal pure returns (euint8) {\n return FHE.asEuint8(value);\n }\n function toU16(euint32 value) internal pure returns (euint16) {\n return FHE.asEuint16(value);\n }\n function toU64(euint32 value) internal pure returns (euint64) {\n return FHE.asEuint64(value);\n }\n function toU128(euint32 value) internal pure returns (euint128) {\n return FHE.asEuint128(value);\n }\n function toU256(euint32 value) internal pure returns (euint256) {\n return FHE.asEuint256(value);\n }\n function seal(euint32 value, bytes32 publicKey) internal pure returns (string memory) {\n return FHE.sealoutput(value, publicKey);\n }\n function sealTyped(euint32 value, bytes32 publicKey) internal pure returns (SealedUint memory) {\n return FHE.sealoutputTyped(value, publicKey);\n }\n function decrypt(euint32 value) internal pure returns (uint32) {\n return FHE.decrypt(value);\n }\n function decrypt(euint32 value, uint32 defaultValue) internal pure returns (uint32) {\n return FHE.decrypt(value, defaultValue);\n }\n}\n\nusing BindingsEuint64 for euint64 global;\nlibrary BindingsEuint64 {\n \n /// @notice Performs the add operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the add\n function add(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n return FHE.add(lhs, rhs);\n }\n \n /// @notice Performs the mul operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the mul\n function mul(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n return FHE.mul(lhs, rhs);\n }\n \n /// @notice Performs the sub operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the sub\n function sub(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n return FHE.sub(lhs, rhs);\n }\n \n /// @notice Performs the eq operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the eq\n function eq(euint64 lhs, euint64 rhs) internal pure returns (ebool) {\n return FHE.eq(lhs, rhs);\n }\n \n /// @notice Performs the ne operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the ne\n function ne(euint64 lhs, euint64 rhs) internal pure returns (ebool) {\n return FHE.ne(lhs, rhs);\n }\n \n /// @notice Performs the not operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @return the result of the not\n function not(euint64 lhs) internal pure returns (euint64) {\n return FHE.not(lhs);\n }\n \n /// @notice Performs the and operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the and\n function and(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n return FHE.and(lhs, rhs);\n }\n \n /// @notice Performs the or operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the or\n function or(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n return FHE.or(lhs, rhs);\n }\n \n /// @notice Performs the xor operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the xor\n function xor(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n return FHE.xor(lhs, rhs);\n }\n \n /// @notice Performs the gt operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the gt\n function gt(euint64 lhs, euint64 rhs) internal pure returns (ebool) {\n return FHE.gt(lhs, rhs);\n }\n \n /// @notice Performs the gte operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the gte\n function gte(euint64 lhs, euint64 rhs) internal pure returns (ebool) {\n return FHE.gte(lhs, rhs);\n }\n \n /// @notice Performs the lt operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the lt\n function lt(euint64 lhs, euint64 rhs) internal pure returns (ebool) {\n return FHE.lt(lhs, rhs);\n }\n \n /// @notice Performs the lte operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the lte\n function lte(euint64 lhs, euint64 rhs) internal pure returns (ebool) {\n return FHE.lte(lhs, rhs);\n }\n \n /// @notice Performs the max operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the max\n function max(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n return FHE.max(lhs, rhs);\n }\n \n /// @notice Performs the min operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the min\n function min(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n return FHE.min(lhs, rhs);\n }\n \n /// @notice Performs the shl operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the shl\n function shl(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n return FHE.shl(lhs, rhs);\n }\n \n /// @notice Performs the shr operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the shr\n function shr(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n return FHE.shr(lhs, rhs);\n }\n \n /// @notice Performs the rol operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the rol\n function rol(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n return FHE.rol(lhs, rhs);\n }\n \n /// @notice Performs the ror operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @param rhs second input of type euint64\n /// @return the result of the ror\n function ror(euint64 lhs, euint64 rhs) internal pure returns (euint64) {\n return FHE.ror(lhs, rhs);\n }\n \n /// @notice Performs the square operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint64\n /// @return the result of the square\n function square(euint64 lhs) internal pure returns (euint64) {\n return FHE.square(lhs);\n }\n function toBool(euint64 value) internal pure returns (ebool) {\n return FHE.asEbool(value);\n }\n function toU8(euint64 value) internal pure returns (euint8) {\n return FHE.asEuint8(value);\n }\n function toU16(euint64 value) internal pure returns (euint16) {\n return FHE.asEuint16(value);\n }\n function toU32(euint64 value) internal pure returns (euint32) {\n return FHE.asEuint32(value);\n }\n function toU128(euint64 value) internal pure returns (euint128) {\n return FHE.asEuint128(value);\n }\n function toU256(euint64 value) internal pure returns (euint256) {\n return FHE.asEuint256(value);\n }\n function seal(euint64 value, bytes32 publicKey) internal pure returns (string memory) {\n return FHE.sealoutput(value, publicKey);\n }\n function sealTyped(euint64 value, bytes32 publicKey) internal pure returns (SealedUint memory) {\n return FHE.sealoutputTyped(value, publicKey);\n }\n function decrypt(euint64 value) internal pure returns (uint64) {\n return FHE.decrypt(value);\n }\n function decrypt(euint64 value, uint64 defaultValue) internal pure returns (uint64) {\n return FHE.decrypt(value, defaultValue);\n }\n}\n\nusing BindingsEuint128 for euint128 global;\nlibrary BindingsEuint128 {\n \n /// @notice Performs the add operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the add\n function add(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n return FHE.add(lhs, rhs);\n }\n \n /// @notice Performs the sub operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the sub\n function sub(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n return FHE.sub(lhs, rhs);\n }\n \n /// @notice Performs the eq operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the eq\n function eq(euint128 lhs, euint128 rhs) internal pure returns (ebool) {\n return FHE.eq(lhs, rhs);\n }\n \n /// @notice Performs the ne operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the ne\n function ne(euint128 lhs, euint128 rhs) internal pure returns (ebool) {\n return FHE.ne(lhs, rhs);\n }\n \n /// @notice Performs the not operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @return the result of the not\n function not(euint128 lhs) internal pure returns (euint128) {\n return FHE.not(lhs);\n }\n \n /// @notice Performs the and operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the and\n function and(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n return FHE.and(lhs, rhs);\n }\n \n /// @notice Performs the or operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the or\n function or(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n return FHE.or(lhs, rhs);\n }\n \n /// @notice Performs the xor operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the xor\n function xor(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n return FHE.xor(lhs, rhs);\n }\n \n /// @notice Performs the gt operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the gt\n function gt(euint128 lhs, euint128 rhs) internal pure returns (ebool) {\n return FHE.gt(lhs, rhs);\n }\n \n /// @notice Performs the gte operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the gte\n function gte(euint128 lhs, euint128 rhs) internal pure returns (ebool) {\n return FHE.gte(lhs, rhs);\n }\n \n /// @notice Performs the lt operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the lt\n function lt(euint128 lhs, euint128 rhs) internal pure returns (ebool) {\n return FHE.lt(lhs, rhs);\n }\n \n /// @notice Performs the lte operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the lte\n function lte(euint128 lhs, euint128 rhs) internal pure returns (ebool) {\n return FHE.lte(lhs, rhs);\n }\n \n /// @notice Performs the max operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the max\n function max(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n return FHE.max(lhs, rhs);\n }\n \n /// @notice Performs the min operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the min\n function min(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n return FHE.min(lhs, rhs);\n }\n \n /// @notice Performs the shl operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the shl\n function shl(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n return FHE.shl(lhs, rhs);\n }\n \n /// @notice Performs the shr operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the shr\n function shr(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n return FHE.shr(lhs, rhs);\n }\n \n /// @notice Performs the rol operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the rol\n function rol(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n return FHE.rol(lhs, rhs);\n }\n \n /// @notice Performs the ror operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint128\n /// @param rhs second input of type euint128\n /// @return the result of the ror\n function ror(euint128 lhs, euint128 rhs) internal pure returns (euint128) {\n return FHE.ror(lhs, rhs);\n }\n function toBool(euint128 value) internal pure returns (ebool) {\n return FHE.asEbool(value);\n }\n function toU8(euint128 value) internal pure returns (euint8) {\n return FHE.asEuint8(value);\n }\n function toU16(euint128 value) internal pure returns (euint16) {\n return FHE.asEuint16(value);\n }\n function toU32(euint128 value) internal pure returns (euint32) {\n return FHE.asEuint32(value);\n }\n function toU64(euint128 value) internal pure returns (euint64) {\n return FHE.asEuint64(value);\n }\n function toU256(euint128 value) internal pure returns (euint256) {\n return FHE.asEuint256(value);\n }\n function seal(euint128 value, bytes32 publicKey) internal pure returns (string memory) {\n return FHE.sealoutput(value, publicKey);\n }\n function sealTyped(euint128 value, bytes32 publicKey) internal pure returns (SealedUint memory) {\n return FHE.sealoutputTyped(value, publicKey);\n }\n function decrypt(euint128 value) internal pure returns (uint128) {\n return FHE.decrypt(value);\n }\n function decrypt(euint128 value, uint128 defaultValue) internal pure returns (uint128) {\n return FHE.decrypt(value, defaultValue);\n }\n}\n\nusing BindingsEuint256 for euint256 global;\nlibrary BindingsEuint256 {\n \n /// @notice Performs the eq operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint256\n /// @param rhs second input of type euint256\n /// @return the result of the eq\n function eq(euint256 lhs, euint256 rhs) internal pure returns (ebool) {\n return FHE.eq(lhs, rhs);\n }\n \n /// @notice Performs the ne operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type euint256\n /// @param rhs second input of type euint256\n /// @return the result of the ne\n function ne(euint256 lhs, euint256 rhs) internal pure returns (ebool) {\n return FHE.ne(lhs, rhs);\n }\n function toBool(euint256 value) internal pure returns (ebool) {\n return FHE.asEbool(value);\n }\n function toU8(euint256 value) internal pure returns (euint8) {\n return FHE.asEuint8(value);\n }\n function toU16(euint256 value) internal pure returns (euint16) {\n return FHE.asEuint16(value);\n }\n function toU32(euint256 value) internal pure returns (euint32) {\n return FHE.asEuint32(value);\n }\n function toU64(euint256 value) internal pure returns (euint64) {\n return FHE.asEuint64(value);\n }\n function toU128(euint256 value) internal pure returns (euint128) {\n return FHE.asEuint128(value);\n }\n function toEaddress(euint256 value) internal pure returns (eaddress) {\n return FHE.asEaddress(value);\n }\n function seal(euint256 value, bytes32 publicKey) internal pure returns (string memory) {\n return FHE.sealoutput(value, publicKey);\n }\n function sealTyped(euint256 value, bytes32 publicKey) internal pure returns (SealedUint memory) {\n return FHE.sealoutputTyped(value, publicKey);\n }\n function decrypt(euint256 value) internal pure returns (uint256) {\n return FHE.decrypt(value);\n }\n function decrypt(euint256 value, uint256 defaultValue) internal pure returns (uint256) {\n return FHE.decrypt(value, defaultValue);\n }\n}\n\nusing BindingsEaddress for eaddress global;\nlibrary BindingsEaddress {\n \n /// @notice Performs the eq operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type eaddress\n /// @param rhs second input of type eaddress\n /// @return the result of the eq\n function eq(eaddress lhs, eaddress rhs) internal pure returns (ebool) {\n return FHE.eq(lhs, rhs);\n }\n \n /// @notice Performs the ne operation\n /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access\n /// @param lhs input of type eaddress\n /// @param rhs second input of type eaddress\n /// @return the result of the ne\n function ne(eaddress lhs, eaddress rhs) internal pure returns (ebool) {\n return FHE.ne(lhs, rhs);\n }\n function toBool(eaddress value) internal pure returns (ebool) {\n return FHE.asEbool(value);\n }\n function toU8(eaddress value) internal pure returns (euint8) {\n return FHE.asEuint8(value);\n }\n function toU16(eaddress value) internal pure returns (euint16) {\n return FHE.asEuint16(value);\n }\n function toU32(eaddress value) internal pure returns (euint32) {\n return FHE.asEuint32(value);\n }\n function toU64(eaddress value) internal pure returns (euint64) {\n return FHE.asEuint64(value);\n }\n function toU128(eaddress value) internal pure returns (euint128) {\n return FHE.asEuint128(value);\n }\n function toU256(eaddress value) internal pure returns (euint256) {\n return FHE.asEuint256(value);\n }\n function seal(eaddress value, bytes32 publicKey) internal pure returns (string memory) {\n return FHE.sealoutput(value, publicKey);\n }\n function sealTyped(eaddress value, bytes32 publicKey) internal pure returns (SealedAddress memory) {\n return FHE.sealoutputTyped(value, publicKey);\n }\n function decrypt(eaddress value) internal pure returns (address) {\n return FHE.decrypt(value);\n }\n function decrypt(eaddress value, address defaultValue) internal pure returns (address) {\n return FHE.decrypt(value, defaultValue);\n }\n}"
|
||
},
|
||
"@luxfheprotocol/contracts/FheOS.sol": {
|
||
"content": "// SPDX-License-Identifier: BSD-3-Clause-Clear\n// solhint-disable one-contract-per-file\npragma solidity >=0.8.13 <0.9.0;\n\nlibrary Precompiles {\n //solhint-disable const-name-snakecase\n address public constant Fheos = address(128);\n}\n\ninterface FheOps {\n function log(string memory s) external pure;\n function add(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function verify(uint8 utype, bytes memory input, int32 securityZone) external pure returns (bytes memory);\n function sealOutput(uint8 utype, bytes memory ctHash, bytes memory pk) external pure returns (string memory);\n function decrypt(uint8 utype, bytes memory input, uint256 defaultValue) external pure returns (uint256);\n function lte(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function sub(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function mul(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function lt(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function select(uint8 utype, bytes memory controlHash, bytes memory ifTrueHash, bytes memory ifFalseHash) external pure returns (bytes memory);\n function req(uint8 utype, bytes memory input) external pure returns (bytes memory);\n function cast(uint8 utype, bytes memory input, uint8 toType) external pure returns (bytes memory);\n function trivialEncrypt(bytes memory input, uint8 toType, int32 securityZone) external pure returns (bytes memory);\n function div(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function gt(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function gte(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function rem(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function and(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function or(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function xor(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function eq(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function ne(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function min(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function max(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function shl(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function shr(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function rol(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function ror(uint8 utype, bytes memory lhsHash, bytes memory rhsHash) external pure returns (bytes memory);\n function not(uint8 utype, bytes memory value) external pure returns (bytes memory);\n function random(uint8 utype, uint64 seed, int32 securityZone) external pure returns (bytes memory);\n function getNetworkPublicKey(int32 securityZone) external pure returns (bytes memory);\n function square(uint8 utype, bytes memory value) external pure returns (bytes memory);\n}"
|
||
},
|
||
"@openzeppelin/contracts/interfaces/draft-IERC6093.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n"
|
||
},
|
||
"@openzeppelin/contracts/interfaces/IERC1271.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1271.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC1271 standard signature validation method for\n * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].\n */\ninterface IERC1271 {\n /**\n * @dev Should return whether the signature provided is valid for the provided data\n * @param hash Hash of the data to be signed\n * @param signature Signature byte array associated with _data\n */\n function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);\n}\n"
|
||
},
|
||
"@openzeppelin/contracts/interfaces/IERC5267.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n /**\n * @dev MAY be emitted to signal that the domain could have changed.\n */\n event EIP712DomainChanged();\n\n /**\n * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n * signature.\n */\n function eip712Domain()\n external\n view\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n );\n}\n"
|
||
},
|
||
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n"
|
||
},
|
||
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
|
||
},
|
||
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
|
||
},
|
||
"@openzeppelin/contracts/utils/Context.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (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 function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n"
|
||
},
|
||
"@openzeppelin/contracts/utils/cryptography/ECDSA.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS\n }\n\n /**\n * @dev The signature derives the `address(0)`.\n */\n error ECDSAInvalidSignature();\n\n /**\n * @dev The signature has an invalid length.\n */\n error ECDSAInvalidSignatureLength(uint256 length);\n\n /**\n * @dev The signature has an S value that is in the upper half order.\n */\n error ECDSAInvalidSignatureS(bytes32 s);\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n * and a bytes32 providing additional information about the error.\n *\n * If no error is returned, then the address can be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n unchecked {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n // We do not check for an overflow here since the shift operation results in 0 or 1.\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError, bytes32) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS, s);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature, bytes32(0));\n }\n\n return (signer, RecoverError.NoError, bytes32(0));\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n */\n function _throwError(RecoverError error, bytes32 errorArg) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert ECDSAInvalidSignature();\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert ECDSAInvalidSignatureLength(uint256(errorArg));\n } else if (error == RecoverError.InvalidSignatureS) {\n revert ECDSAInvalidSignatureS(errorArg);\n }\n }\n}\n"
|
||
},
|
||
"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing a bytes32 `messageHash` with\n * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n * keccak256, although any bytes32 value can be safely used because the final digest will\n * be re-hashed.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n }\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing an arbitrary `message` with\n * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n return\n keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x00` (data with intended validator).\n *\n * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n * `validator` address. Then hashing the result.\n *\n * See {ECDSA-recover}.\n */\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).\n *\n * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n *\n * See {ECDSA-recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, hex\"19_01\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n digest := keccak256(ptr, 0x42)\n }\n }\n}\n"
|
||
},
|
||
"@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/SignatureChecker.sol)\n\npragma solidity ^0.8.20;\n\nimport {ECDSA} from \"./ECDSA.sol\";\nimport {IERC1271} from \"../../interfaces/IERC1271.sol\";\n\n/**\n * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA\n * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like\n * Argent and Safe Wallet (previously Gnosis Safe).\n */\nlibrary SignatureChecker {\n /**\n * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the\n * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`.\n *\n * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n * change through time. It could return true at block N and false at block N+1 (or the opposite).\n */\n function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {\n (address recovered, ECDSA.RecoverError error, ) = ECDSA.tryRecover(hash, signature);\n return\n (error == ECDSA.RecoverError.NoError && recovered == signer) ||\n isValidERC1271SignatureNow(signer, hash, signature);\n }\n\n /**\n * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated\n * against the signer smart contract using ERC1271.\n *\n * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n * change through time. It could return true at block N and false at block N+1 (or the opposite).\n */\n function isValidERC1271SignatureNow(\n address signer,\n bytes32 hash,\n bytes memory signature\n ) internal view returns (bool) {\n (bool success, bytes memory result) = signer.staticcall(\n abi.encodeCall(IERC1271.isValidSignature, (hash, signature))\n );\n return (success &&\n result.length >= 32 &&\n abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));\n }\n}\n"
|
||
},
|
||
"@openzeppelin/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"
|
||
},
|
||
"@openzeppelin/contracts/utils/math/SignedMath.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n"
|
||
},
|
||
"@openzeppelin/contracts/utils/ShortStrings.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.20;\n\nimport {StorageSlot} from \"./StorageSlot.sol\";\n\n// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |\n// | length | 0x BB |\ntype ShortString is bytes32;\n\n/**\n * @dev This library provides functions to convert short memory strings\n * into a `ShortString` type that can be used as an immutable variable.\n *\n * Strings of arbitrary length can be optimized using this library if\n * they are short enough (up to 31 bytes) by packing them with their\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\n * fallback mechanism can be used for every other case.\n *\n * Usage example:\n *\n * ```solidity\n * contract Named {\n * using ShortStrings for *;\n *\n * ShortString private immutable _name;\n * string private _nameFallback;\n *\n * constructor(string memory contractName) {\n * _name = contractName.toShortStringWithFallback(_nameFallback);\n * }\n *\n * function name() external view returns (string memory) {\n * return _name.toStringWithFallback(_nameFallback);\n * }\n * }\n * ```\n */\nlibrary ShortStrings {\n // Used as an identifier for strings longer than 31 bytes.\n bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n error StringTooLong(string str);\n error InvalidShortString();\n\n /**\n * @dev Encode a string of at most 31 chars into a `ShortString`.\n *\n * This will trigger a `StringTooLong` error is the input string is too long.\n */\n function toShortString(string memory str) internal pure returns (ShortString) {\n bytes memory bstr = bytes(str);\n if (bstr.length > 31) {\n revert StringTooLong(str);\n }\n return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n }\n\n /**\n * @dev Decode a `ShortString` back to a \"normal\" string.\n */\n function toString(ShortString sstr) internal pure returns (string memory) {\n uint256 len = byteLength(sstr);\n // using `new string(len)` would work locally but is not memory safe.\n string memory str = new string(32);\n /// @solidity memory-safe-assembly\n assembly {\n mstore(str, len)\n mstore(add(str, 0x20), sstr)\n }\n return str;\n }\n\n /**\n * @dev Return the length of a `ShortString`.\n */\n function byteLength(ShortString sstr) internal pure returns (uint256) {\n uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n if (result > 31) {\n revert InvalidShortString();\n }\n return result;\n }\n\n /**\n * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\n */\n function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\n if (bytes(value).length < 32) {\n return toShortString(value);\n } else {\n StorageSlot.getStringSlot(store).value = value;\n return ShortString.wrap(FALLBACK_SENTINEL);\n }\n }\n\n /**\n * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n */\n function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return toString(value);\n } else {\n return store;\n }\n }\n\n /**\n * @dev Return the length of a string that was encoded to `ShortString` or written to storage using\n * {setWithFallback}.\n *\n * WARNING: This will return the \"byte length\" of the string. This may not reflect the actual length in terms of\n * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\n */\n function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n return byteLength(value);\n } else {\n return bytes(store).length;\n }\n }\n}\n"
|
||
},
|
||
"@openzeppelin/contracts/utils/StorageSlot.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(newImplementation.code.length > 0);\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\n */\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n */\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n */\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n */\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n}\n"
|
||
},
|
||
"@openzeppelin/contracts/utils/Strings.sol": {
|
||
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n uint8 private constant ADDRESS_LENGTH = 20;\n\n /**\n * @dev The `value` string doesn't fit in the specified `length`.\n */\n error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toStringSigned(int256 value) internal pure returns (string memory) {\n return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n uint256 localValue = value;\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = HEX_DIGITS[localValue & 0xf];\n localValue >>= 4;\n }\n if (localValue != 0) {\n revert StringsInsufficientHexLength(value, length);\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n * representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n"
|
||
},
|
||
"contracts/FHERC20.sol": {
|
||
"content": "// solhint-disable no-empty-blocks\n// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19 <0.9.0;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport { ERC20 } from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport { IFHERC20 } from \"./IFHERC20.sol\";\nimport { PermissionedV2, PermissionV2 } from \"@luxfheprotocol/contracts/access/PermissionedV2.sol\";\nimport { SealedUint } from \"@luxfheprotocol/contracts/FHE.sol\";\n\n/**\n * Version of the FHERC20 able to be deployed on non-FHE chains\n * All FHE operations and variables have been replaced with cleartext variables\n * Used to test Smart Wallet PermitV2s on sepolia while waiting for Alchemy's\n * smart wallet infrastructure to be deployed on luxfhe Nitrogen testnet\n */\ncontract FHERC20 is IFHERC20, ERC20, PermissionedV2 {\n\t// A mapping from address to an encrypted balance.\n\tmapping(address => uint128) internal _encBalances;\n\t// A mapping from address (owner) to a mapping of address (spender) to an encrypted amount.\n\tmapping(address => mapping(address => uint128)) internal _encAllowances;\n\tuint128 internal _encTotalSupply = 0;\n\tuint8 private _decimals;\n\n\tconstructor(\n\t\tstring memory name,\n\t\tstring memory symbol,\n\t\tuint8 dec\n\t) ERC20(name, symbol) PermissionedV2(\"FHERC20\") {\n\t\t_decimals = dec;\n\t}\n\n\tfunction mint(address to, uint128 amount) public {\n\t\t_mint(to, amount);\n\t}\n\tfunction encMint(address to, uint128 amount) public {\n\t\t_encMint(to, amount);\n\t}\n\tfunction decimals() public view override returns (uint8) {\n\t\treturn _decimals;\n\t}\n\n\t/**\n\t * @dev Returns the encrypted value of tokens in existence.\n\t */\n\tfunction encTotalSupply(\n\t\tPermissionV2 calldata permission\n\t)\n\t\tpublic\n\t\tview\n\t\tvirtual\n\t\toverride\n\t\twithPermission(permission)\n\t\treturns (uint128)\n\t{\n\t\treturn _encTotalSupply;\n\t}\n\n\t/**\n\t * @dev Returns the encrypted value of tokens in existence, sealed for the caller.\n\t */\n\tfunction sealedTotalSupply(\n\t\tPermissionV2 calldata permission\n\t)\n\t\tpublic\n\t\tview\n\t\tvirtual\n\t\toverride\n\t\twithPermission(permission)\n\t\treturns (SealedUint memory)\n\t{\n\t\treturn\n\t\t\tSealedUint({ data: Strings.toString(_encTotalSupply), utype: 4 });\n\t}\n\n\t/**\n\t * @dev Returns the value of the encrypted tokens owned by `account`\n\t */\n\tfunction encBalanceOf(\n\t\tPermissionV2 calldata permission\n\t)\n\t\tpublic\n\t\tview\n\t\tvirtual\n\t\toverride\n\t\twithPermission(permission)\n\t\treturns (uint128)\n\t{\n\t\treturn _encBalances[permission.issuer];\n\t}\n\n\t/**\n\t * @dev Returns the value of the encrypted tokens owned by the issuer of the PermitNft, sealed for the caller\n\t */\n\tfunction sealedBalanceOf(\n\t\tPermissionV2 calldata permission\n\t)\n\t\tpublic\n\t\tview\n\t\tvirtual\n\t\toverride\n\t\twithPermission(permission)\n\t\treturns (SealedUint memory)\n\t{\n\t\treturn\n\t\t\tSealedUint({\n\t\t\t\tdata: Strings.toString(_encBalances[permission.issuer]),\n\t\t\t\tutype: 4\n\t\t\t});\n\t}\n\n\t/**\n\t * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n\t * Accepts the value as inUint128, more convenient for calls from EOAs.\n\t *\n\t * Returns a boolean value indicating whether the operation succeeded.\n\t */\n\tfunction encTransfer(\n\t\taddress to,\n\t\tuint128 ieAmount\n\t) public virtual override returns (bool) {\n\t\t_encTransfer(msg.sender, to, ieAmount);\n\t\treturn true;\n\t}\n\n\t/**\n\t * @dev Returns the remaining number of tokens that `spender` will be\n\t * allowed to spend on behalf of `owner` through {transferFrom}. This is\n\t * zero by default.\n\t *\n\t * This value changes when {approve} or {transferFrom} are called.\n\t */\n\tfunction encAllowance(\n\t\tPermissionV2 calldata permission,\n\t\taddress owner,\n\t\taddress spender\n\t)\n\t\tpublic\n\t\tview\n\t\tvirtual\n\t\toverride\n\t\twithPermission(permission)\n\t\treturns (uint128)\n\t{\n\t\taddress issuer = permission.issuer;\n\t\tif (issuer != owner && issuer != spender) {\n\t\t\trevert FHERC20NotOwnerOrSpender();\n\t\t}\n\t\treturn _encAllowances[owner][spender];\n\t}\n\n\t/**\n\t * @dev Returns the remaining number of tokens that `spender` will be\n\t * allowed to spend on behalf of `owner` through {transferFrom}. This is\n\t * zero by default. Sealed for the caller.\n\t *\n\t * Permission issuer must be either the owner or spender.\n\t *\n\t * This value changes when {approve} or {transferFrom} are called.\n\t */\n\tfunction sealedAllowance(\n\t\tPermissionV2 calldata permission,\n\t\taddress owner,\n\t\taddress spender\n\t)\n\t\tpublic\n\t\tview\n\t\tvirtual\n\t\toverride\n\t\twithPermission(permission)\n\t\treturns (SealedUint memory)\n\t{\n\t\taddress issuer = permission.issuer;\n\t\tif (issuer != owner && issuer != spender) {\n\t\t\trevert FHERC20NotOwnerOrSpender();\n\t\t}\n\t\treturn\n\t\t\tSealedUint({\n\t\t\t\tdata: Strings.toString(_encAllowances[owner][spender]),\n\t\t\t\tutype: 4\n\t\t\t});\n\t}\n\n\t/**\n\t * @dev Sets `ieAmount` tokens as the allowance of `spender` over the\n\t * caller's tokens.\n\t *\n\t * Returns a boolean value indicating whether the operation succeeded.\n\t *\n\t * Emits an {EncApproved} event.\n\t */\n\tfunction encApprove(\n\t\taddress spender,\n\t\tuint128 ieAmount\n\t) public virtual override returns (bool) {\n\t\t_encApprove(msg.sender, spender, ieAmount);\n\t\treturn true;\n\t}\n\n\t/**\n\t * @dev Moves `ieAmount` tokens from `from` to `to` using the\n\t * allowance mechanism. `value` is then deducted from the caller's\n\t * allowance. Accepts the value as inUint128, more convenient for calls from EOAs.\n\t *\n\t * Returns a boolean value indicating whether the operation succeeded.\n\t *\n\t * Emits a {EncTransfer} event.\n\t */\n\tfunction encTransferFrom(\n\t\taddress from,\n\t\taddress to,\n\t\tuint128 ieAmount\n\t) public virtual override returns (bool) {\n\t\tuint128 encSpent = _encSpendAllowance(from, msg.sender, ieAmount);\n\t\t_encTransfer(from, to, encSpent);\n\t\treturn true;\n\t}\n\n\t/**\n\t * @dev Encrypts `amount` tokens, reducing the callers public balance by `amount`,\n\t * and increasing their `encBalance` by `amount`.\n\t *\n\t * Returns a boolean value indicating whether the operation succeeded.\n\t *\n\t * Emits an {Encrypted} event.\n\t */\n\tfunction encrypt(uint128 amount) public virtual override returns (bool) {\n\t\t_burn(msg.sender, amount);\n\t\t_encMint(msg.sender, amount);\n\n\t\temit Encrypted(msg.sender, amount);\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * @dev Decrypts `amount` tokens, reducing the callers `encBalance` by `amount`,\n\t * and increasing their public balance by `amount`.\n\t *\n\t * Returns a boolean value indicating whether the operation succeeded.\n\t *\n\t * Emits a {Decrypted} event.\n\t */\n\tfunction decrypt(uint128 amount) public virtual override returns (bool) {\n\t\tuint128 eAmount = _encBurn(msg.sender, amount);\n\t\tamount = eAmount;\n\t\t_mint(msg.sender, amount);\n\n\t\temit Decrypted(msg.sender, amount);\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * @dev Moves `eAmount` tokens from the caller's account to `to`.\n\t * Accepts the value as uint128, more convenient for calls from other contracts\n\t *\n\t * Returns an `uint128` of the true amount transferred.\n\t *\n\t * Emits an {EncTransfer} event.\n\t */\n\tfunction _encTransfer(\n\t\taddress from,\n\t\taddress to,\n\t\tuint128 eAmount\n\t) internal returns (uint128) {\n\t\tif (from == address(0)) {\n\t\t\trevert ERC20InvalidSender(address(0));\n\t\t}\n\t\tif (to == address(0)) {\n\t\t\trevert ERC20InvalidReceiver(address(0));\n\t\t}\n\n\t\t// Make sure the sender has enough tokens.\n\t\teAmount = eAmount <= _encBalances[from] ? eAmount : 0;\n\n\t\t_encBeforeTokenTransfer(from, to, eAmount);\n\n\t\t// Add to the balance of `to` and subtract from the balance of `from`.\n\t\t_encBalances[to] = _encBalances[to] + eAmount;\n\t\t_encBalances[from] = _encBalances[from] - eAmount;\n\n\t\temit EncTransfer(from, to);\n\n\t\t_encAfterTokenTransfer(from, to, eAmount);\n\n\t\treturn eAmount;\n\t}\n\n\t/**\n\t * @dev Creates `eAmount` encrypted tokens and assigns them to `to`.\n\t * Increases `encTotalSupply` by `eAmount`\n\t * Accepts the value as uint128, more convenient for calls from other contracts\n\t *\n\t * Emits an {EncTransfer} event with `from` set to the zero address.\n\t */\n\tfunction _encMint(address to, uint128 eAmount) internal {\n\t\tif (to == address(0)) {\n\t\t\trevert ERC20InvalidReceiver(address(0));\n\t\t}\n\n\t\t_encBeforeTokenTransfer(address(0), to, eAmount);\n\n\t\t_encBalances[to] = _encBalances[to] + eAmount;\n\t\t_encTotalSupply = _encTotalSupply + eAmount;\n\n\t\temit EncTransfer(address(0), to);\n\n\t\t_encAfterTokenTransfer(address(0), to, eAmount);\n\t}\n\n\t/**\n\t * @dev Destroys `eAmount` encrypted tokens from `to`.\n\t * Decreases `encTotalSupply` by `eAmount`\n\t * Accepts the value as uint128, more convenient for calls from other contracts\n\t *\n\t * Emits an {EncTransfer} event with `to` set to the zero address.\n\t */\n\tfunction _encBurn(\n\t\taddress from,\n\t\tuint128 eAmount\n\t) internal returns (uint128) {\n\t\tif (from == address(0)) {\n\t\t\trevert ERC20InvalidSender(address(0));\n\t\t}\n\n\t\teAmount = _encBalances[msg.sender] >= eAmount ? eAmount : 0;\n\n\t\t_encBeforeTokenTransfer(from, address(0), eAmount);\n\n\t\t_encBalances[from] = _encBalances[from] - eAmount;\n\t\t_encTotalSupply = _encTotalSupply - eAmount;\n\n\t\temit EncTransfer(from, address(0));\n\n\t\t_encAfterTokenTransfer(from, address(0), eAmount);\n\n\t\treturn eAmount;\n\t}\n\n\tfunction _encApprove(\n\t\taddress owner,\n\t\taddress spender,\n\t\tuint128 eAmount\n\t) internal {\n\t\tif (owner == address(0)) {\n\t\t\trevert ERC20InvalidApprover(address(0));\n\t\t}\n\t\tif (spender == address(0)) {\n\t\t\trevert ERC20InvalidSpender(address(0));\n\t\t}\n\t\t_encAllowances[owner][spender] = eAmount;\n\t}\n\n\tfunction _encSpendAllowance(\n\t\taddress owner,\n\t\taddress spender,\n\t\tuint128 eAmount\n\t) internal virtual returns (uint128) {\n\t\tuint128 eCurrentAllowance = _encAllowances[owner][spender];\n\t\tuint128 eSpent = eCurrentAllowance < eAmount\n\t\t\t? eCurrentAllowance\n\t\t\t: eAmount;\n\t\t_encApprove(owner, spender, (eCurrentAllowance - eSpent));\n\n\t\treturn eSpent;\n\t}\n\n\t/**\n\t * @dev Hook that is called before any transfer of encrypted tokens. This includes\n\t * minting and burning.\n\t */\n\tfunction _encBeforeTokenTransfer(\n\t\taddress from,\n\t\taddress to,\n\t\tuint128 eAmount\n\t) internal virtual {}\n\n\t/**\n\t * @dev Hook that is called after any transfer of encrypted tokens. This includes\n\t * minting and burning.\n\t */\n\tfunction _encAfterTokenTransfer(\n\t\taddress from,\n\t\taddress to,\n\t\tuint128 eAmount\n\t) internal virtual {}\n}\n"
|
||
},
|
||
"contracts/IFHERC20.sol": {
|
||
"content": "pragma solidity >=0.8.19 <0.9.0;\n\n// SPDX-License-Identifier: MIT\n// luxfhe Protocol (last updated v0.1.0) (token/FHERC20/IFHERC20.sol)\n// Inspired by OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts) (token/ERC20/IERC20.sol)\n\nimport { PermissionV2 } from \"@luxfheprotocol/contracts/access/PermissionedV2.sol\";\nimport { SealedUint } from \"@luxfheprotocol/contracts/FHE.sol\";\n\n/**\n * @dev Interface of the ERC-20 standard as defined in the ERC.\n */\ninterface IFHERC20 {\n\terror FHERC20NotOwnerOrSpender();\n\n\t/**\n\t * @dev Emitted when `value` tokens are moved from one account (`from`) to\n\t * another (`to`).\n\t *\n\t * Note that `value` may be zero.\n\t */\n\tevent EncTransfer(address indexed from, address indexed to);\n\n\t/**\n\t * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n\t * a call to {approveEncrypted}. `value` is the new allowance.\n\t */\n\tevent EncApproved(address indexed owner, address indexed spender);\n\n\t/**\n\t * @dev Emitted when `amount` tokens are transferred from `_balance[owner]` to `_encBalance[owner]`\n\t * by a call to {encrypt}.\n\t */\n\tevent Encrypted(address indexed owner, uint256 amount);\n\n\t/**\n\t * @dev Emitted when `amount` tokens are transferred from `_encBalance[owner]` to `_balance[owner]`\n\t * by a call to {decrypt}.\n\t */\n\tevent Decrypted(address indexed owner, uint256 amount);\n\n\t/**\n\t * @dev Returns the encrypted value of tokens in existence.\n\t */\n\tfunction encTotalSupply(\n\t\tPermissionV2 calldata permission\n\t) external view returns (uint128);\n\n\t/**\n\t * @dev Returns the encrypted value of tokens in existence, sealed for the caller.\n\t */\n\tfunction sealedTotalSupply(\n\t\tPermissionV2 calldata permission\n\t) external view returns (SealedUint memory);\n\n\t/**\n\t * @dev Returns the value of the encrypted tokens owned by `account`\n\t */\n\tfunction encBalanceOf(\n\t\tPermissionV2 memory permission\n\t) external view returns (uint128);\n\n\t/**\n\t * @dev Returns the value of the encrypted tokens owned by the issuer of the PermitNft, sealed for the caller\n\t */\n\tfunction sealedBalanceOf(\n\t\tPermissionV2 memory permission\n\t) external view returns (SealedUint memory);\n\n\t/**\n\t * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n\t * Accepts the value as uint128, more convenient for calls from EOAs.\n\t *\n\t * Returns a boolean value indicating whether the operation succeeded.\n\t */\n\tfunction encTransfer(address to, uint128 amount) external returns (bool);\n\n\t/**\n\t * @dev Returns the remaining number of tokens that `spender` will be\n\t * allowed to spend on behalf of `owner` through {transferFrom}. This is\n\t * zero by default.\n\t *\n\t * This value changes when {approve} or {transferFrom} are called.\n\t */\n\tfunction encAllowance(\n\t\tPermissionV2 memory permission,\n\t\taddress owner,\n\t\taddress spender\n\t) external view returns (uint128);\n\n\t/**\n\t * @dev Returns the remaining number of tokens that `spender` will be\n\t * allowed to spend on behalf of `owner` through {transferFrom}. This is\n\t * zero by default. Sealed for the caller.\n\t *\n\t * Permission issuer must be either the owner or spender.\n\t *\n\t * This value changes when {approve} or {transferFrom} are called.\n\t */\n\tfunction sealedAllowance(\n\t\tPermissionV2 memory permission,\n\t\taddress owner,\n\t\taddress spender\n\t) external view returns (SealedUint memory);\n\n\t/**\n\t * @dev Sets `ieAmount` tokens as the allowance of `spender` over the\n\t * caller's tokens.\n\t *\n\t * Returns a boolean value indicating whether the operation succeeded.\n\t *\n\t * IMPORTANT: Beware that changing an allowance with this method brings the risk\n\t * that someone may use both the old and the new allowance by unfortunate\n\t * transaction ordering. One possible solution to mitigate this race\n\t * condition is to first reduce the spender's allowance to 0 and set the\n\t * desired value afterwards:\n\t * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n\t *\n\t * Emits an {ApprovalEncrypted} event.\n\t */\n\tfunction encApprove(\n\t\taddress spender,\n\t\tuint128 amount\n\t) external returns (bool);\n\n\t/**\n\t * @dev Moves `ieAmount` tokens from `from` to `to` using the\n\t * allowance mechanism. `value` is then deducted from the caller's\n\t * allowance. Accepts the value as uint128, more convenient for calls from EOAs.\n\t *\n\t * Returns a boolean value indicating whether the operation succeeded.\n\t *\n\t * Emits a {TransferEncrypted} event.\n\t */\n\tfunction encTransferFrom(\n\t\taddress from,\n\t\taddress to,\n\t\tuint128 amount\n\t) external returns (bool);\n\n\t/**\n\t * @dev Encrypts `amount` tokens, reducing the callers public balance by `amount`,\n\t * and increasing their `encBalance` by `amount`.\n\t *\n\t * Returns a boolean value indicating whether the operation succeeded.\n\t *\n\t * Emits a {Encrypted} event.\n\t */\n\tfunction encrypt(uint128 amount) external returns (bool);\n\n\t/**\n\t * @dev Decrypts `amount` tokens, reducing the callers `encBalance` by `amount`,\n\t * and increasing their public balance by `amount`.\n\t *\n\t * Returns a boolean value indicating whether the operation succeeded.\n\t *\n\t * Emits a {Decrypted} event.\n\t */\n\tfunction decrypt(uint128 amount) external returns (bool);\n}\n"
|
||
}
|
||
},
|
||
"settings": {
|
||
"optimizer": {
|
||
"enabled": true,
|
||
"runs": 200
|
||
},
|
||
"evmVersion": "paris",
|
||
"outputSelection": {
|
||
"*": {
|
||
"*": [
|
||
"abi",
|
||
"evm.bytecode",
|
||
"evm.deployedBytecode",
|
||
"evm.methodIdentifiers",
|
||
"metadata",
|
||
"devdoc",
|
||
"userdoc",
|
||
"storageLayout",
|
||
"evm.gasEstimates"
|
||
],
|
||
"": [
|
||
"ast"
|
||
]
|
||
}
|
||
},
|
||
"metadata": {
|
||
"useLiteralContent": true
|
||
}
|
||
}
|
||
} |