@inco/lightning 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +69 -0
  3. package/dumps/incoLightning_0_1_23__547622051.dump.json +1 -0
  4. package/dumps/incoLightning_0_1_23__547622051.env +15 -0
  5. package/dumps/incoLightning_0_1_23__830342853.dump.json +1 -0
  6. package/dumps/incoLightning_0_1_23__830342853.env +15 -0
  7. package/dumps/incoLightning_0_1_24__266705097.dump.json +1 -0
  8. package/dumps/incoLightning_0_1_24__266705097.env +15 -0
  9. package/dumps/incoLightning_0_1_25__986372984.dump.json +1 -0
  10. package/dumps/incoLightning_0_1_25__986372984.env +15 -0
  11. package/foundry.toml +20 -0
  12. package/package.json +27 -0
  13. package/remappings.txt +4 -0
  14. package/src/DeployUtils.sol +109 -0
  15. package/src/IncoLightning.sol +45 -0
  16. package/src/Lib.sol +389 -0
  17. package/src/Lib.template.sol +464 -0
  18. package/src/Types.sol +74 -0
  19. package/src/libs/incoLightning_0_1_22__761766708.sol +389 -0
  20. package/src/libs/incoLightning_0_1_23__547622051.sol +389 -0
  21. package/src/libs/incoLightning_0_1_23__830342853.sol +389 -0
  22. package/src/libs/incoLightning_0_1_24__266705097.sol +389 -0
  23. package/src/libs/incoLightning_0_1_25__986372984.sol +389 -0
  24. package/src/lightning-parts/AccessControl/BaseAccessControlList.sol +105 -0
  25. package/src/lightning-parts/AccessControl/test/TestBaseAccessControl.t.sol +12 -0
  26. package/src/lightning-parts/DecryptionHandler.sol +164 -0
  27. package/src/lightning-parts/EncryptedInput.sol +61 -0
  28. package/src/lightning-parts/EncryptedOperations.sol +610 -0
  29. package/src/lightning-parts/TrivialEncryption.sol +43 -0
  30. package/src/lightning-parts/primitives/EventCounter.sol +32 -0
  31. package/src/lightning-parts/primitives/HandleGeneration.sol +107 -0
  32. package/src/lightning-parts/primitives/HandleMetadata.sol +38 -0
  33. package/src/lightning-parts/primitives/SignatureVerifier.sol +47 -0
  34. package/src/lightning-parts/test/HandleMetadata.t.sol +87 -0
  35. package/src/pasted-dependencies/CreateX.sol +1293 -0
  36. package/src/pasted-dependencies/ICreateX.sol +187 -0
  37. package/src/test/AddTwo.sol +48 -0
  38. package/src/test/FakeIncoInfra/FakeComputeServer.sol +137 -0
  39. package/src/test/FakeIncoInfra/FakeIncoInfraBase.sol +77 -0
  40. package/src/test/FakeIncoInfra/KVStore.sol +35 -0
  41. package/src/test/FakeIncoInfra/MockOpHandler.sol +140 -0
  42. package/src/test/FakeIncoInfra/getOpForSelector.sol +71 -0
  43. package/src/test/IncoTest.sol +48 -0
  44. package/src/test/TestAddTwo.t.sol +31 -0
  45. package/src/test/TestDeploy.t.sol +39 -0
  46. package/src/test/TestExtractDataOfEventTooLarge.t.sol +43 -0
  47. package/src/test/TestFakeInfra.t.sol +301 -0
  48. package/src/test/TestVersion.t.sol +36 -0
  49. package/src/version/IncoLightningConfig.sol +13 -0
  50. package/src/version/Version.sol +76 -0
@@ -0,0 +1,15 @@
1
+ DEPLOYER_ADDRESS=0x8202D2D747784Cb7D48868E44C42C4bf162a70BC
2
+ STATE_DUMP=incoLightning_0_1_25__986372984.dump.json
3
+ SESSION_VERIFIER_ADDRESS=0x359D300756aBf9dF80A4865399D5B3Ed29c7AE8B
4
+ ADD_TWO_ADDRESS=0x723c2be5E61e7bBec4684DEfEaE63656ad3eaa10
5
+ EXECUTOR_ADDRESS=0xc3c81F7Bf86Af7ed3a5f5Bb1924A063a1c126cDd
6
+ ECIES_PUBLIC_KEY=0x0246392874c73d1a834e7e91a2b103ad3b87ffc2b69c01dacc48f75a6436e222ee
7
+ CALLBACK_ADDRESS=0x2581773F31B13CeEd15413975089768EEA74dCE2
8
+ SENDER_ADDRESS=0x376238EA4D1a46C4C3D95f685b99945C4600c051
9
+ SENDER_PRIVATE_KEY=0x9e47d2a6127a314f4354652ddcb921eafd363777fde6f1e738a650f9f8979d19
10
+ COVALIDATOR_ECIES_PRIVATE_KEY=0x9afa56c8686787717d7b056fd6239b0434b3a589017e59e956c60a01f09dac9e
11
+ COVALIDATOR_CALLBACK_PRIVATE_KEY=0x405dd37d8a291edc8f0ab706a01ba33379ddbf8b2e09d6ff360c8e55ebd9473c
12
+ COVALIDATOR_ACL_ADDR=0xc3c81F7Bf86Af7ed3a5f5Bb1924A063a1c126cDd
13
+ COVALIDATOR_INCO_EXECUTOR_ADDR=0xc3c81F7Bf86Af7ed3a5f5Bb1924A063a1c126cDd
14
+ COVALIDATOR_DECRYPTION_HANDLER_ADDR=0xc3c81F7Bf86Af7ed3a5f5Bb1924A063a1c126cDd
15
+
package/foundry.toml ADDED
@@ -0,0 +1,20 @@
1
+ [profile.default]
2
+ src = 'src'
3
+ test = 'src'
4
+ cache_path = 'out/foundry-cache'
5
+ allow_paths = ['../../', "out/*", "broadcast/*"]
6
+ evm_version = 'cancun'
7
+ solc = '0.8.28'
8
+ extra_output = ["storageLayout", "abi", "evm.methodIdentifiers"]
9
+ ffi = true
10
+ ast = true
11
+ build_info = true
12
+ fs_permissions = [
13
+ { access = "read", path = "./" },
14
+ { access = "read-write", path = "./fixtures" },
15
+ { access = "write", path = "out/" },
16
+ { access = "read-write", path = "deployments/" },
17
+ { access = "read-write", path = "src/generated/" },
18
+ ]
19
+ optimizer = true
20
+ optimizer-runs = 10_000_000
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@inco/lightning",
3
+ "version": "0.1.20",
4
+ "repository": "https://github.com/Inco-fhevm/inco-monorepo",
5
+ "files": [
6
+ "src/",
7
+ "foundry.toml",
8
+ "dumps/",
9
+ "CHANGELOG.md",
10
+ "remappings.txt"
11
+ ],
12
+ "scripts": {
13
+ "generate:libraries": "bun run ../pega/lib/deployment/cmd/generate-libraries.ts",
14
+ "publish:github": "bun publish --registry=https://npm.pkg.github.com",
15
+ "publish:npm": "bun publish --access public"
16
+ },
17
+ "dependencies": {
18
+ "@openzeppelin/contracts": "^5.2.0",
19
+ "@openzeppelin/contracts-upgradeable": "^5.2.0",
20
+ "ds-test": "https://github.com/dapphub/ds-test",
21
+ "forge-std": "https://github.com/foundry-rs/forge-std",
22
+ "tsx": "^4.19.3"
23
+ },
24
+ "publishConfig": {
25
+ "registry": "https://npm.pkg.github.com"
26
+ }
27
+ }
package/remappings.txt ADDED
@@ -0,0 +1,4 @@
1
+ @openzeppelin/=../../node_modules/@openzeppelin/
2
+ forge-std/=../../node_modules/forge-std/src/
3
+ ds-test/=../../node_modules/ds-test/src/
4
+ @inco/=../
@@ -0,0 +1,109 @@
1
+ // SPDX-License-Identifier: No License
2
+ pragma solidity ^0.8;
3
+
4
+ import {IncoLightning} from "../src/IncoLightning.sol";
5
+ import {Script} from "forge-std/Script.sol";
6
+ import {Vm} from "forge-std/Vm.sol";
7
+ import {CreateX, createXAddress, createXDeployer} from "../src/pasted-dependencies/CreateX.sol";
8
+ import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
9
+ import {CONTRACT_NAME, MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION} from "../src/version/IncoLightningConfig.sol";
10
+
11
+ // can be set to 0x01 so the inco address can exist on only one chain, we want the same contract at the same address
12
+ // on all chains
13
+ bytes1 constant crossChainDeployAuthorizedFlag = 0x00;
14
+
15
+ // GLOSSARY
16
+ // Pepper: a deployment-time string mixed into the salt hash function, used to avoid address collision on deploying
17
+ // the same contract twice with the same deployer address, name and version
18
+ // Salt: a hash of the contract name, version, deployer address, and pepper.
19
+ // in the context of deployment using create3 with createX, the salt determines the address of the contract, and
20
+ // using the crossChainDeployAuthorizedFlag, it prevents the contract from being deployed by someone other than
21
+ // the deployer at the expected address
22
+
23
+ /// @dev not a script in itself, use this contract in tests or scripts to get new instances of IncoLightning
24
+ contract DeployUtils is Script {
25
+ /// @dev CreateX is deployed on most chains, use this method for the testing environment
26
+ function deployCreateX() public returns (CreateX createX) {
27
+ vm.prank(createXDeployer);
28
+ createX = new CreateX();
29
+ require(createXAddress == address(createX));
30
+ return createX;
31
+ }
32
+
33
+ function getSalt(
34
+ string memory name,
35
+ uint8 majorVersionNumber,
36
+ uint8 minorVersionNumber,
37
+ uint8 patchVersionNumber,
38
+ address deployer,
39
+ string memory pepper
40
+ ) internal pure returns (bytes32) {
41
+ return
42
+ bytes32(
43
+ abi.encodePacked(
44
+ deployer,
45
+ crossChainDeployAuthorizedFlag,
46
+ bytes11(
47
+ keccak256(
48
+ abi.encodePacked(
49
+ name,
50
+ majorVersionNumber,
51
+ minorVersionNumber,
52
+ patchVersionNumber,
53
+ pepper
54
+ )
55
+ )
56
+ )
57
+ )
58
+ );
59
+ }
60
+
61
+ // todo add a method predicting the deployment address
62
+
63
+ /// @dev wrap in prank or broadcast depending on prod or testing environment
64
+ /// @param deployer MUST be the signer of the transaction
65
+ /// @param pepper a value used to avoid address collision on deploying the same contract twice with the same deployer
66
+ function deployIncoLightningUsingConfig(
67
+ address deployer,
68
+ string memory pepper
69
+ ) internal returns (IncoLightning proxy) {
70
+ bytes32 salt = getSalt(
71
+ CONTRACT_NAME,
72
+ MAJOR_VERSION,
73
+ MINOR_VERSION,
74
+ PATCH_VERSION,
75
+ deployer,
76
+ pepper
77
+ );
78
+ proxy = IncoLightning(
79
+ deployProxy({
80
+ deployer: deployer,
81
+ salt: salt,
82
+ implem: address(new IncoLightning(salt)),
83
+ initFunctionSelector: IncoLightning.initialize.selector
84
+ })
85
+ );
86
+ }
87
+
88
+ /// @notice deploys a ERC1967Proxy contract using CreateX (create3 pattern), gives the deployer the ownership of
89
+ /// the proxy
90
+ /// @dev deployer is made the owner of the contract
91
+ function deployProxy(
92
+ address deployer,
93
+ bytes32 salt,
94
+ address implem,
95
+ bytes4 initFunctionSelector
96
+ ) internal returns (address proxy) {
97
+ CreateX createX = CreateX(createXAddress);
98
+ CreateX.Values memory msgValues = CreateX.Values(0, 0);
99
+ bytes memory initCall = abi.encodeWithSelector(
100
+ initFunctionSelector,
101
+ deployer
102
+ );
103
+ bytes memory bytecode = abi.encodePacked(
104
+ type(ERC1967Proxy).creationCode,
105
+ abi.encode(implem, initCall)
106
+ );
107
+ proxy = createX.deployCreate3AndInit(salt, bytecode, "", msgValues);
108
+ }
109
+ }
@@ -0,0 +1,45 @@
1
+ // SPDX-License-Identifier: No License
2
+ pragma solidity ^0.8;
3
+
4
+ import {EncryptedInput} from "./lightning-parts/EncryptedInput.sol";
5
+ import {EncryptedOperations} from "./lightning-parts/EncryptedOperations.sol";
6
+ import {DecryptionHandler} from "./lightning-parts/DecryptionHandler.sol";
7
+ import {TrivialEncryption} from "./lightning-parts/TrivialEncryption.sol";
8
+ import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
9
+ import {CONTRACT_NAME, MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION} from "./version/IncoLightningConfig.sol";
10
+ import {Version} from "./version/Version.sol";
11
+
12
+ /// @title Inco Lightning
13
+ /// @notice Onchain singleton for Inco Lightning, TEE-based encrypted data and operations over shared state service
14
+ /// @dev implicitly extends BaseAccessControlList, SignatureVerifier, OwnableUpgradeable
15
+ contract IncoLightning is
16
+ EncryptedOperations,
17
+ DecryptionHandler,
18
+ TrivialEncryption,
19
+ UUPSUpgradeable,
20
+ EncryptedInput,
21
+ Version
22
+ {
23
+ // salt embeds the deployer address, the contract name, the version and the pepper
24
+ constructor(
25
+ bytes32 salt
26
+ )
27
+ Version(
28
+ MAJOR_VERSION,
29
+ MINOR_VERSION,
30
+ PATCH_VERSION,
31
+ salt,
32
+ CONTRACT_NAME
33
+ )
34
+ {}
35
+
36
+ function _authorizeUpgrade(address) internal view override {
37
+ require(msg.sender == owner());
38
+ }
39
+
40
+ function initialize(address owner) public initializer {
41
+ __Ownable_init(owner);
42
+ }
43
+
44
+ fallback() external {} // must be included for createX deploy
45
+ }
package/src/Lib.sol ADDED
@@ -0,0 +1,389 @@
1
+ // AUTOGENERATED FILE. DO NOT EDIT.
2
+ // This file was generated by the IncoLightning library generator.
3
+ // The original template is located at Lib.template.sol
4
+
5
+ /// SPDX-License-Identifier: No License
6
+ pragma solidity ^0.8;
7
+
8
+ import "./IncoLightning.sol";
9
+ import { ebool, euint256, ETypes } from "./Types.sol";
10
+
11
+ IncoLightning constant inco = IncoLightning(0xc3c81F7Bf86Af7ed3a5f5Bb1924A063a1c126cDd);
12
+ address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
13
+ uint256 constant defaultDecryptionDelayLimit = 2 hours;
14
+
15
+ library e {
16
+ function sanitize(euint256 a) internal returns (euint256) {
17
+ if (euint256.unwrap(a) == bytes32(0)) {
18
+ return asEuint256(0);
19
+ }
20
+ return a;
21
+ }
22
+
23
+ function sanitize(ebool a) internal returns (ebool) {
24
+ if (ebool.unwrap(a) == bytes32(0)) {
25
+ return asEbool(false);
26
+ }
27
+ return a;
28
+ }
29
+
30
+ function s(euint256 a) internal returns (euint256) {
31
+ return sanitize(a);
32
+ }
33
+
34
+ function s(ebool a) internal returns (ebool) {
35
+ return sanitize(a);
36
+ }
37
+
38
+ function add(euint256 a, euint256 b) internal returns (euint256) {
39
+ return inco.eAdd(s(a), s(b));
40
+ }
41
+
42
+ function add(euint256 a, uint256 b) internal returns (euint256) {
43
+ return inco.eAdd(s(a), asEuint256(b));
44
+ }
45
+
46
+ function add(uint256 a, euint256 b) internal returns (euint256) {
47
+ return inco.eAdd(asEuint256(a), s(b));
48
+ }
49
+
50
+ function sub(euint256 a, euint256 b) internal returns (euint256) {
51
+ return inco.eSub(s(a), s(b));
52
+ }
53
+
54
+ function sub(euint256 a, uint256 b) internal returns (euint256) {
55
+ return inco.eSub(s(a), asEuint256(b));
56
+ }
57
+
58
+ function sub(uint256 a, euint256 b) internal returns (euint256) {
59
+ return inco.eSub(asEuint256(a), s(b));
60
+ }
61
+
62
+ function mul(euint256 a, euint256 b) internal returns (euint256) {
63
+ return inco.eMul(s(a), s(b));
64
+ }
65
+
66
+ function mul(euint256 a, uint256 b) internal returns (euint256) {
67
+ return inco.eMul(s(a), asEuint256(b));
68
+ }
69
+
70
+ function mul(uint256 a, euint256 b) internal returns (euint256) {
71
+ return inco.eMul(asEuint256(a), s(b));
72
+ }
73
+
74
+ function div(euint256 a, euint256 b) internal returns (euint256) {
75
+ return inco.eDiv(s(a), s(b));
76
+ }
77
+
78
+ function div(euint256 a, uint256 b) internal returns (euint256) {
79
+ return inco.eDiv(s(a), asEuint256(b));
80
+ }
81
+
82
+ function div(uint256 a, euint256 b) internal returns (euint256) {
83
+ return inco.eDiv(asEuint256(a), s(b));
84
+ }
85
+
86
+ function rem(euint256 a, euint256 b) internal returns (euint256) {
87
+ return inco.eRem(s(a), s(b));
88
+ }
89
+
90
+ function rem(euint256 a, uint256 b) internal returns (euint256) {
91
+ return inco.eRem(s(a), asEuint256(b));
92
+ }
93
+
94
+ function rem(uint256 a, euint256 b) internal returns (euint256) {
95
+ return inco.eRem(asEuint256(a), s(b));
96
+ }
97
+
98
+ function and(euint256 a, euint256 b) internal returns (euint256) {
99
+ return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
100
+ }
101
+
102
+ function and(euint256 a, uint256 b) internal returns (euint256) {
103
+ return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
104
+ }
105
+
106
+ function and(uint256 a, euint256 b) internal returns (euint256) {
107
+ return euint256.wrap(inco.eBitAnd(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
108
+ }
109
+
110
+ function and(ebool a, ebool b) internal returns (ebool) {
111
+ return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
112
+ }
113
+
114
+ function and(ebool a, bool b) internal returns (ebool) {
115
+ return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
116
+ }
117
+
118
+ function and(bool a, ebool b) internal returns (ebool) {
119
+ return ebool.wrap(inco.eBitAnd(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
120
+ }
121
+
122
+ function or(euint256 a, euint256 b) internal returns (euint256) {
123
+ return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
124
+ }
125
+
126
+ function or(euint256 a, uint256 b) internal returns (euint256) {
127
+ return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
128
+ }
129
+
130
+ function or(uint256 a, euint256 b) internal returns (euint256) {
131
+ return euint256.wrap(inco.eBitOr(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
132
+ }
133
+
134
+ function or(ebool a, ebool b) internal returns (ebool) {
135
+ return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
136
+ }
137
+
138
+ function or(ebool a, bool b) internal returns (ebool) {
139
+ return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
140
+ }
141
+
142
+ function or(bool a, ebool b) internal returns (ebool) {
143
+ return ebool.wrap(inco.eBitOr(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
144
+ }
145
+
146
+ function xor(euint256 a, euint256 b) internal returns (euint256) {
147
+ return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
148
+ }
149
+
150
+ function xor(euint256 a, uint256 b) internal returns (euint256) {
151
+ return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
152
+ }
153
+
154
+ function xor(uint256 a, euint256 b) internal returns (euint256) {
155
+ return euint256.wrap(inco.eBitXor(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
156
+ }
157
+
158
+ function xor(ebool a, ebool b) internal returns (ebool) {
159
+ return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
160
+ }
161
+
162
+ function xor(ebool a, bool b) internal returns (ebool) {
163
+ return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
164
+ }
165
+
166
+ function xor(bool a, ebool b) internal returns (ebool) {
167
+ return ebool.wrap(inco.eBitXor(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
168
+ }
169
+
170
+ function shl(euint256 a, euint256 b) internal returns (euint256) {
171
+ return inco.eShl(s(a), s(b));
172
+ }
173
+
174
+ function shl(euint256 a, uint256 b) internal returns (euint256) {
175
+ return inco.eShl(s(a), asEuint256(b));
176
+ }
177
+
178
+ function shl(uint256 a, euint256 b) internal returns (euint256) {
179
+ return inco.eShl(asEuint256(a), s(b));
180
+ }
181
+
182
+ function shr(euint256 a, euint256 b) internal returns (euint256) {
183
+ return inco.eShr(s(a), s(b));
184
+ }
185
+
186
+ function shr(euint256 a, uint256 b) internal returns (euint256) {
187
+ return inco.eShr(s(a), asEuint256(b));
188
+ }
189
+
190
+ function shr(uint256 a, euint256 b) internal returns (euint256) {
191
+ return inco.eShr(asEuint256(a), s(b));
192
+ }
193
+
194
+ function rotl(euint256 a, euint256 b) internal returns (euint256) {
195
+ return inco.eRotl(s(a), s(b));
196
+ }
197
+
198
+ function rotl(euint256 a, uint256 b) internal returns (euint256) {
199
+ return inco.eRotl(s(a), asEuint256(b));
200
+ }
201
+
202
+ function rotl(uint256 a, euint256 b) internal returns (euint256) {
203
+ return inco.eRotl(asEuint256(a), s(b));
204
+ }
205
+
206
+ function rotr(euint256 a, euint256 b) internal returns (euint256) {
207
+ return inco.eRotr(s(a), s(b));
208
+ }
209
+
210
+ function rotr(euint256 a, uint256 b) internal returns (euint256) {
211
+ return inco.eRotr(s(a), asEuint256(b));
212
+ }
213
+
214
+ function rotr(uint256 a, euint256 b) internal returns (euint256) {
215
+ return inco.eRotr(asEuint256(a), s(b));
216
+ }
217
+
218
+ function eq(euint256 a, euint256 b) internal returns (ebool) {
219
+ return inco.eEq(s(a), s(b));
220
+ }
221
+
222
+ function eq(euint256 a, uint256 b) internal returns (ebool) {
223
+ return inco.eEq(s(a), asEuint256(b));
224
+ }
225
+
226
+ function eq(uint256 a, euint256 b) internal returns (ebool) {
227
+ return inco.eEq(asEuint256(a), s(b));
228
+ }
229
+
230
+ function ne(euint256 a, euint256 b) internal returns (ebool) {
231
+ return inco.eNe(s(a), s(b));
232
+ }
233
+
234
+ function ne(euint256 a, uint256 b) internal returns (ebool) {
235
+ return inco.eNe(s(a), asEuint256(b));
236
+ }
237
+
238
+ function ne(uint256 a, euint256 b) internal returns (ebool) {
239
+ return inco.eNe(asEuint256(a), s(b));
240
+ }
241
+
242
+ function ge(euint256 a, euint256 b) internal returns (ebool) {
243
+ return inco.eGe(s(a), s(b));
244
+ }
245
+
246
+ function ge(euint256 a, uint256 b) internal returns (ebool) {
247
+ return inco.eGe(s(a), asEuint256(b));
248
+ }
249
+
250
+ function ge(uint256 a, euint256 b) internal returns (ebool) {
251
+ return inco.eGe(asEuint256(a), s(b));
252
+ }
253
+
254
+ function gt(euint256 a, euint256 b) internal returns (ebool) {
255
+ return inco.eGt(s(a), s(b));
256
+ }
257
+
258
+ function gt(euint256 a, uint256 b) internal returns (ebool) {
259
+ return inco.eGt(s(a), asEuint256(b));
260
+ }
261
+
262
+ function gt(uint256 a, euint256 b) internal returns (ebool) {
263
+ return inco.eGt(asEuint256(a), s(b));
264
+ }
265
+
266
+ function le(euint256 a, euint256 b) internal returns (ebool) {
267
+ return inco.eLe(s(a), s(b));
268
+ }
269
+
270
+ function le(euint256 a, uint256 b) internal returns (ebool) {
271
+ return inco.eLe(s(a), asEuint256(b));
272
+ }
273
+
274
+ function le(uint256 a, euint256 b) internal returns (ebool) {
275
+ return inco.eLe(asEuint256(a), s(b));
276
+ }
277
+
278
+ function lt(euint256 a, euint256 b) internal returns (ebool) {
279
+ return inco.eLt(s(a), s(b));
280
+ }
281
+
282
+ function lt(euint256 a, uint256 b) internal returns (ebool) {
283
+ return inco.eLt(s(a), asEuint256(b));
284
+ }
285
+
286
+ function lt(uint256 a, euint256 b) internal returns (ebool) {
287
+ return inco.eLt(asEuint256(a), s(b));
288
+ }
289
+
290
+ function min(euint256 a, euint256 b) internal returns (euint256) {
291
+ return inco.eMin(s(a), s(b));
292
+ }
293
+
294
+ function min(euint256 a, uint256 b) internal returns (euint256) {
295
+ return inco.eMin(s(a), asEuint256(b));
296
+ }
297
+
298
+ function min(uint256 a, euint256 b) internal returns (euint256) {
299
+ return inco.eMin(asEuint256(a), s(b));
300
+ }
301
+
302
+ function max(euint256 a, euint256 b) internal returns (euint256) {
303
+ return inco.eMax(s(a), s(b));
304
+ }
305
+
306
+ function max(euint256 a, uint256 b) internal returns (euint256) {
307
+ return inco.eMax(s(a), asEuint256(b));
308
+ }
309
+
310
+ function max(uint256 a, euint256 b) internal returns (euint256) {
311
+ return inco.eMax(asEuint256(a), s(b));
312
+ }
313
+
314
+ function not(ebool a) internal returns (ebool) {
315
+ return inco.eNot(s(a));
316
+ }
317
+
318
+ function rand() internal returns (euint256) {
319
+ return euint256.wrap(inco.eRand(ETypes.Uint256));
320
+ }
321
+
322
+ function randBounded(uint256 upperBound) internal returns (euint256) {
323
+ return euint256.wrap(inco.eRandBounded(euint256.unwrap(asEuint256(upperBound)), ETypes.Uint256));
324
+ }
325
+
326
+ function randBounded(euint256 upperBound) internal returns (euint256) {
327
+ return euint256.wrap(inco.eRandBounded(euint256.unwrap(s(upperBound)), ETypes.Uint256));
328
+ }
329
+
330
+ function asEuint256(uint256 a) internal returns (euint256) {
331
+ return inco.asEuint256(a);
332
+ }
333
+
334
+ function asEbool(bool a) internal returns (ebool) {
335
+ return inco.asEbool(a);
336
+ }
337
+
338
+ function asEbool(euint256 a) internal returns (ebool) {
339
+ return ebool.wrap(inco.eCast(euint256.unwrap(a), ETypes.Bool));
340
+ }
341
+
342
+ function asEuint256(ebool a) internal returns (euint256) {
343
+ return euint256.wrap(inco.eCast(ebool.unwrap(a), ETypes.Uint256));
344
+ }
345
+
346
+ function newEuint256(bytes memory ciphertext, address user) internal returns (euint256) {
347
+ return inco.newEuint256(ciphertext, user);
348
+ }
349
+
350
+ function newEbool(bytes memory ciphertext, address user) internal returns (ebool) {
351
+ return inco.newEbool(ciphertext, user);
352
+ }
353
+
354
+ function allow(euint256 a, address to) internal {
355
+ inco.allow(euint256.unwrap(a), to);
356
+ }
357
+
358
+ function allow(ebool a, address to) internal {
359
+ inco.allow(ebool.unwrap(a), to);
360
+ }
361
+
362
+ function allowThis(euint256 a) internal {
363
+ allow(a, address(this));
364
+ }
365
+
366
+ function allowThis(ebool a) internal {
367
+ allow(a, address(this));
368
+ }
369
+
370
+ function isAllowed(address user, euint256 a) internal view returns (bool) {
371
+ return inco.isAllowed(euint256.unwrap(a), user);
372
+ }
373
+
374
+ function select(ebool control, euint256 ifTrue, euint256 ifFalse) internal returns (euint256) {
375
+ return euint256.wrap(inco.eIfThenElse(s(control), euint256.unwrap(s(ifTrue)), euint256.unwrap(s(ifFalse))));
376
+ }
377
+
378
+ function select(ebool control, ebool ifTrue, ebool ifFalse) internal returns (ebool) {
379
+ return ebool.wrap(inco.eIfThenElse(s(control), ebool.unwrap(s(ifTrue)), ebool.unwrap(s(ifFalse))));
380
+ }
381
+
382
+ function requestDecryption(euint256 a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
383
+ requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, euint256.unwrap(s(a)), callbackData);
384
+ }
385
+
386
+ function requestDecryption(ebool a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
387
+ requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, ebool.unwrap(s(a)), callbackData);
388
+ }
389
+ }