@inco/lightning 0.6.8 → 0.7.0
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.
- package/CHANGELOG.md +6 -0
- package/README.md +29 -2
- package/manifest.yaml +35 -42
- package/package.json +5 -2
- package/src/CreateXHelper.sol +3 -1
- package/src/DeployUtils.sol +36 -71
- package/src/Errors.sol +1 -1
- package/src/IIncoLightning.sol +2 -0
- package/src/IncoLightning.sol +5 -17
- package/src/IncoVerifier.sol +12 -18
- package/src/Lib.alphanet.sol +1 -1
- package/src/Lib.sol +1 -1
- package/src/Lib.template.sol +35 -153
- package/src/Types.sol +231 -97
- package/src/interfaces/IIncoLightning.sol +2 -0
- package/src/interfaces/IIncoVerifier.sol +6 -12
- package/src/interfaces/automata-interfaces/BELE.sol +2 -0
- package/src/interfaces/automata-interfaces/IAutomataEnclaveIdentityDao.sol +9 -11
- package/src/interfaces/automata-interfaces/IFmspcTcbDao.sol +3 -3
- package/src/interfaces/automata-interfaces/IPCCSRouter.sol +13 -47
- package/src/interfaces/automata-interfaces/IPCCSRouterExtended.sol +2 -0
- package/src/interfaces/automata-interfaces/IPcsDao.sol +6 -11
- package/src/interfaces/automata-interfaces/IQuoteVerifier.sol +4 -7
- package/src/interfaces/automata-interfaces/Types.sol +7 -6
- package/src/libs/incoLightning_alphanet_v2_976644394.sol +478 -0
- package/src/libs/incoLightning_devnet_v1_887305889.sol +5 -3
- package/src/libs/incoLightning_testnet_v1_938327937.sol +5 -3
- package/src/lightning-parts/AccessControl/AdvancedAccessControl.sol +39 -72
- package/src/lightning-parts/AccessControl/BaseAccessControlList.sol +31 -62
- package/src/lightning-parts/AccessControl/interfaces/IAdvancedAccessControl.sol +8 -15
- package/src/lightning-parts/AccessControl/interfaces/IBaseAccessControlList.sol +5 -12
- package/src/lightning-parts/AccessControl/test/TestAdvancedAccessControl.t.sol +44 -84
- package/src/lightning-parts/AccessControl/test/TestBaseAccessControl.t.sol +2 -0
- package/src/lightning-parts/DecryptionAttester.sol +14 -28
- package/src/lightning-parts/EncryptedInput.sol +23 -52
- package/src/lightning-parts/EncryptedOperations.sol +96 -438
- package/src/lightning-parts/Fee.sol +3 -1
- package/src/lightning-parts/TEELifecycle.sol +94 -223
- package/src/lightning-parts/TEELifecycle.types.sol +4 -3
- package/src/lightning-parts/TrivialEncryption.sol +6 -20
- package/src/lightning-parts/interfaces/IDecryptionAttester.sol +7 -2
- package/src/lightning-parts/interfaces/IEncryptedInput.sol +5 -12
- package/src/lightning-parts/interfaces/IEncryptedOperations.sol +17 -61
- package/src/lightning-parts/interfaces/ITEELifecycle.sol +7 -11
- package/src/lightning-parts/interfaces/ITrivialEncryption.sol +2 -0
- package/src/lightning-parts/primitives/EventCounter.sol +7 -8
- package/src/lightning-parts/primitives/HandleGeneration.sol +20 -32
- package/src/lightning-parts/primitives/HandleMetadata.sol +7 -17
- package/src/lightning-parts/primitives/LightningAddressGetter.sol +3 -0
- package/src/lightning-parts/primitives/SignatureVerifier.sol +91 -27
- package/src/lightning-parts/primitives/VerifierAddressGetter.sol +3 -0
- package/src/lightning-parts/primitives/interfaces/IEventCounter.sol +2 -0
- package/src/lightning-parts/primitives/interfaces/IHandleGeneration.sol +10 -2
- package/src/lightning-parts/primitives/interfaces/ISignatureVerifier.sol +4 -2
- package/src/lightning-parts/primitives/interfaces/IVerifierAddressGetter.sol +2 -0
- package/src/lightning-parts/primitives/test/SignatureVerifier.t.sol +838 -0
- package/src/lightning-parts/test/Fee.t.sol +6 -6
- package/src/lightning-parts/test/HandleMetadata.t.sol +21 -76
- package/src/lightning-parts/test/InputsFee.t.sol +7 -28
- package/src/lightning-parts/test/TestDecryptionAttestationInSynchronousFlow.t.sol +16 -48
- package/src/pasted-dependencies/CreateX.sol +154 -455
- package/src/pasted-dependencies/ICreateX.sol +55 -102
- package/src/periphery/SessionVerifier.sol +10 -8
- package/src/shared/IOwnable.sol +3 -0
- package/src/shared/IUUPSUpgradable.sol +5 -1
- package/src/shared/JsonUtils.sol +3 -5
- package/src/shared/TestUtils.sol +15 -13
- package/src/test/AddTwo.sol +9 -7
- package/src/test/FakeIncoInfra/FakeComputeServer.sol +11 -53
- package/src/test/FakeIncoInfra/FakeDecryptionAttester.sol +35 -119
- package/src/test/FakeIncoInfra/FakeIncoInfraBase.sol +31 -48
- package/src/test/FakeIncoInfra/FakeQuoteVerifier.sol +4 -7
- package/src/test/FakeIncoInfra/KVStore.sol +2 -0
- package/src/test/FakeIncoInfra/MockOpHandler.sol +9 -31
- package/src/test/FakeIncoInfra/MockRemoteAttestation.sol +50 -21
- package/src/test/IncoTest.sol +22 -9
- package/src/test/OpsTest.sol +438 -0
- package/src/test/TEELifecycle/TEELifecycleMockTest.t.sol +57 -104
- package/src/test/TestAddTwo.t.sol +4 -3
- package/src/test/TestDeploy.t.sol +5 -6
- package/src/test/TestExtractDataOfEventTooLarge.t.sol +7 -9
- package/src/test/TestFakeInfra.t.sol +15 -38
- package/src/test/TestUpgrade.t.sol +40 -135
- package/src/test/TestVersion.t.sol +6 -5
- package/src/version/IncoLightningConfig.sol +2 -2
- package/src/version/Version.sol +46 -48
- package/src/version/interfaces/IVersion.sol +6 -0
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import {IncoLightning} from "../IncoLightning.sol";
|
|
5
|
+
import {euint256, ebool, eaddress, ETypes} from "../Types.sol";
|
|
6
|
+
import {Fee} from "../lightning-parts/Fee.sol";
|
|
7
|
+
|
|
8
|
+
contract OpsTest is Fee {
|
|
9
|
+
|
|
10
|
+
IncoLightning inco;
|
|
11
|
+
|
|
12
|
+
constructor(IncoLightning _inco) {
|
|
13
|
+
inco = _inco;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// ============ ARITHMETIC OPERATIONS ============
|
|
17
|
+
|
|
18
|
+
function testAdd(euint256 a, euint256 b) external returns (euint256) {
|
|
19
|
+
euint256 result = inco.eAdd(a, b);
|
|
20
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
21
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function testAddScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
26
|
+
euint256 result = inco.eAdd(a, inco.asEuint256(b));
|
|
27
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
28
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function testSub(euint256 a, euint256 b) external returns (euint256) {
|
|
33
|
+
euint256 result = inco.eSub(a, b);
|
|
34
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
35
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function testSubScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
40
|
+
euint256 result = inco.eSub(a, inco.asEuint256(b));
|
|
41
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
42
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function testMul(euint256 a, euint256 b) external returns (euint256) {
|
|
47
|
+
euint256 result = inco.eMul(a, b);
|
|
48
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
49
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function testMulScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
54
|
+
euint256 result = inco.eMul(a, inco.asEuint256(b));
|
|
55
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
56
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function testDiv(euint256 a, euint256 b) external returns (euint256) {
|
|
61
|
+
euint256 result = inco.eDiv(a, b);
|
|
62
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
63
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function testDivScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
68
|
+
euint256 result = inco.eDiv(a, inco.asEuint256(b));
|
|
69
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
70
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function testRem(euint256 a, euint256 b) external returns (euint256) {
|
|
75
|
+
euint256 result = inco.eRem(a, b);
|
|
76
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
77
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function testRemScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
82
|
+
euint256 result = inco.eRem(a, inco.asEuint256(b));
|
|
83
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
84
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ============ BITWISE OPERATIONS ============
|
|
89
|
+
|
|
90
|
+
function testAnd(euint256 a, euint256 b) external returns (euint256) {
|
|
91
|
+
euint256 result = euint256.wrap(inco.eBitAnd(euint256.unwrap(a), euint256.unwrap(b)));
|
|
92
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
93
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function testAndScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
98
|
+
euint256 result = euint256.wrap(inco.eBitAnd(euint256.unwrap(a), euint256.unwrap(inco.asEuint256(b))));
|
|
99
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
100
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function testAndBool(ebool a, ebool b) external returns (ebool) {
|
|
105
|
+
ebool result = ebool.wrap(inco.eBitAnd(ebool.unwrap(a), ebool.unwrap(b)));
|
|
106
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
107
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function testAndBoolScalar(ebool a, bool b) external returns (ebool) {
|
|
112
|
+
ebool result = ebool.wrap(inco.eBitAnd(ebool.unwrap(a), ebool.unwrap(inco.asEbool(b))));
|
|
113
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
114
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function testOr(euint256 a, euint256 b) external returns (euint256) {
|
|
119
|
+
euint256 result = euint256.wrap(inco.eBitOr(euint256.unwrap(a), euint256.unwrap(b)));
|
|
120
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
121
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function testOrScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
126
|
+
euint256 result = euint256.wrap(inco.eBitOr(euint256.unwrap(a), euint256.unwrap(inco.asEuint256(b))));
|
|
127
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
128
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function testOrBool(ebool a, ebool b) external returns (ebool) {
|
|
133
|
+
ebool result = ebool.wrap(inco.eBitOr(ebool.unwrap(a), ebool.unwrap(b)));
|
|
134
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
135
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function testOrBoolScalar(ebool a, bool b) external returns (ebool) {
|
|
140
|
+
ebool result = ebool.wrap(inco.eBitOr(ebool.unwrap(a), ebool.unwrap(inco.asEbool(b))));
|
|
141
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
142
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function testXor(euint256 a, euint256 b) external returns (euint256) {
|
|
147
|
+
euint256 result = euint256.wrap(inco.eBitXor(euint256.unwrap(a), euint256.unwrap(b)));
|
|
148
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
149
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function testXorScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
154
|
+
euint256 result = euint256.wrap(inco.eBitXor(euint256.unwrap(a), euint256.unwrap(inco.asEuint256(b))));
|
|
155
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
156
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function testXorBool(ebool a, ebool b) external returns (ebool) {
|
|
161
|
+
ebool result = ebool.wrap(inco.eBitXor(ebool.unwrap(a), ebool.unwrap(b)));
|
|
162
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
163
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function testXorBoolScalar(ebool a, bool b) external returns (ebool) {
|
|
168
|
+
ebool result = ebool.wrap(inco.eBitXor(ebool.unwrap(a), ebool.unwrap(inco.asEbool(b))));
|
|
169
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
170
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function testShl(euint256 a, euint256 b) external returns (euint256) {
|
|
175
|
+
euint256 result = inco.eShl(a, b);
|
|
176
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
177
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function testShlScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
182
|
+
euint256 result = inco.eShl(a, inco.asEuint256(b));
|
|
183
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
184
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function testShr(euint256 a, euint256 b) external returns (euint256) {
|
|
189
|
+
euint256 result = inco.eShr(a, b);
|
|
190
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
191
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function testShrScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
196
|
+
euint256 result = inco.eShr(a, inco.asEuint256(b));
|
|
197
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
198
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function testRotl(euint256 a, euint256 b) external returns (euint256) {
|
|
203
|
+
euint256 result = inco.eRotl(a, b);
|
|
204
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
205
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
206
|
+
return result;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function testRotlScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
210
|
+
euint256 result = inco.eRotl(a, inco.asEuint256(b));
|
|
211
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
212
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function testRotr(euint256 a, euint256 b) external returns (euint256) {
|
|
217
|
+
euint256 result = inco.eRotr(a, b);
|
|
218
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
219
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function testRotrScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
224
|
+
euint256 result = inco.eRotr(a, inco.asEuint256(b));
|
|
225
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
226
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ============ COMPARISON OPERATIONS ============
|
|
231
|
+
|
|
232
|
+
function testEq(euint256 a, euint256 b) external returns (ebool) {
|
|
233
|
+
ebool result = inco.eEq(euint256.unwrap(a), euint256.unwrap(b));
|
|
234
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
235
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function testEqScalar(euint256 a, uint256 b) external returns (ebool) {
|
|
240
|
+
ebool result = inco.eEq(euint256.unwrap(a), euint256.unwrap(inco.asEuint256(b)));
|
|
241
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
242
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
243
|
+
return result;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function testEqAddress(eaddress a, eaddress b) external returns (ebool) {
|
|
247
|
+
ebool result = inco.eEq(eaddress.unwrap(a), eaddress.unwrap(b));
|
|
248
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
249
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function testEqAddressScalar(eaddress a, address b) external returns (ebool) {
|
|
254
|
+
ebool result = inco.eEq(eaddress.unwrap(a), eaddress.unwrap(inco.asEaddress(b)));
|
|
255
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
256
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
257
|
+
return result;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function testNe(euint256 a, euint256 b) external returns (ebool) {
|
|
261
|
+
ebool result = inco.eNe(euint256.unwrap(a), euint256.unwrap(b));
|
|
262
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
263
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function testNeScalar(euint256 a, uint256 b) external returns (ebool) {
|
|
268
|
+
ebool result = inco.eNe(euint256.unwrap(a), euint256.unwrap(inco.asEuint256(b)));
|
|
269
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
270
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
271
|
+
return result;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function testNeAddress(eaddress a, eaddress b) external returns (ebool) {
|
|
275
|
+
ebool result = inco.eNe(eaddress.unwrap(a), eaddress.unwrap(b));
|
|
276
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
277
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function testNeAddressScalar(eaddress a, address b) external returns (ebool) {
|
|
282
|
+
ebool result = inco.eNe(eaddress.unwrap(a), eaddress.unwrap(inco.asEaddress(b)));
|
|
283
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
284
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function testGe(euint256 a, euint256 b) external returns (ebool) {
|
|
289
|
+
ebool result = inco.eGe(a, b);
|
|
290
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
291
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
292
|
+
return result;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function testGeScalar(euint256 a, uint256 b) external returns (ebool) {
|
|
296
|
+
ebool result = inco.eGe(a, inco.asEuint256(b));
|
|
297
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
298
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
299
|
+
return result;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function testGt(euint256 a, euint256 b) external returns (ebool) {
|
|
303
|
+
ebool result = inco.eGt(a, b);
|
|
304
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
305
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
306
|
+
return result;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function testGtScalar(euint256 a, uint256 b) external returns (ebool) {
|
|
310
|
+
ebool result = inco.eGt(a, inco.asEuint256(b));
|
|
311
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
312
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
313
|
+
return result;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function testLe(euint256 a, euint256 b) external returns (ebool) {
|
|
317
|
+
ebool result = inco.eLe(a, b);
|
|
318
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
319
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
320
|
+
return result;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function testLeScalar(euint256 a, uint256 b) external returns (ebool) {
|
|
324
|
+
ebool result = inco.eLe(a, inco.asEuint256(b));
|
|
325
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
326
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
327
|
+
return result;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function testLt(euint256 a, euint256 b) external returns (ebool) {
|
|
331
|
+
ebool result = inco.eLt(a, b);
|
|
332
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
333
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
334
|
+
return result;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function testLtScalar(euint256 a, uint256 b) external returns (ebool) {
|
|
338
|
+
ebool result = inco.eLt(a, inco.asEuint256(b));
|
|
339
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
340
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
341
|
+
return result;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function testMin(euint256 a, euint256 b) external returns (euint256) {
|
|
345
|
+
euint256 result = inco.eMin(a, b);
|
|
346
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
347
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
348
|
+
return result;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function testMinScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
352
|
+
euint256 result = inco.eMin(a, inco.asEuint256(b));
|
|
353
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
354
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
355
|
+
return result;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function testMax(euint256 a, euint256 b) external returns (euint256) {
|
|
359
|
+
euint256 result = inco.eMax(a, b);
|
|
360
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
361
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
362
|
+
return result;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function testMaxScalar(euint256 a, uint256 b) external returns (euint256) {
|
|
366
|
+
euint256 result = inco.eMax(a, inco.asEuint256(b));
|
|
367
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
368
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
369
|
+
return result;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// ============ LOGICAL OPERATIONS ============
|
|
373
|
+
|
|
374
|
+
function testNot(ebool a) external returns (ebool) {
|
|
375
|
+
ebool result = inco.eNot(a);
|
|
376
|
+
inco.allow(ebool.unwrap(result), address(this));
|
|
377
|
+
inco.allow(ebool.unwrap(result), msg.sender);
|
|
378
|
+
return result;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// ============ RANDOM NUMBER GENERATION ============
|
|
382
|
+
|
|
383
|
+
function testRand() external payable returns (euint256) {
|
|
384
|
+
euint256 result = euint256.wrap(inco.eRand{value: getFee()}(ETypes.Uint256));
|
|
385
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
386
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
387
|
+
return result;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function testRandBounded(uint256 upperBound) external payable returns (euint256) {
|
|
391
|
+
euint256 result = euint256.wrap(
|
|
392
|
+
inco.eRandBounded{value: getFee()}(euint256.unwrap(inco.asEuint256(upperBound)), ETypes.Uint256)
|
|
393
|
+
);
|
|
394
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
395
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
396
|
+
return result;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function testRandBoundedEncrypted(euint256 upperBound) external payable returns (euint256) {
|
|
400
|
+
euint256 result = euint256.wrap(inco.eRandBounded{value: getFee()}(euint256.unwrap(upperBound), ETypes.Uint256));
|
|
401
|
+
inco.allow(euint256.unwrap(result), address(this));
|
|
402
|
+
inco.allow(euint256.unwrap(result), msg.sender);
|
|
403
|
+
return result;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// ============ ENCRYPTED INPUT CREATION ============
|
|
407
|
+
|
|
408
|
+
function testNewEuint256(bytes memory ciphertext, address user) external payable returns (euint256) {
|
|
409
|
+
euint256 encryptedUint256 = inco.newEuint256{value: getFee()}(ciphertext, user);
|
|
410
|
+
inco.allow(euint256.unwrap(encryptedUint256), address(this));
|
|
411
|
+
inco.allow(euint256.unwrap(encryptedUint256), user);
|
|
412
|
+
return encryptedUint256;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function testNewEbool(bytes memory ciphertext, address user) external payable returns (ebool) {
|
|
416
|
+
ebool encryptedBool = inco.newEbool{value: getFee()}(ciphertext, user);
|
|
417
|
+
inco.allow(ebool.unwrap(encryptedBool), address(this));
|
|
418
|
+
inco.allow(ebool.unwrap(encryptedBool), user);
|
|
419
|
+
return encryptedBool;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function testNewEaddress(bytes memory ciphertext, address user) external payable returns (eaddress) {
|
|
423
|
+
eaddress encryptedAddress = inco.newEaddress{value: getFee()}(ciphertext, user);
|
|
424
|
+
inco.allow(eaddress.unwrap(encryptedAddress), address(this));
|
|
425
|
+
inco.allow(eaddress.unwrap(encryptedAddress), user);
|
|
426
|
+
return encryptedAddress;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// ============ CAST OPERATIONS ============
|
|
430
|
+
|
|
431
|
+
function testCast(bytes32 a, ETypes to) external returns (bytes32) {
|
|
432
|
+
bytes32 result = inco.eCast(a, to);
|
|
433
|
+
inco.allow(result, address(this));
|
|
434
|
+
inco.allow(result, msg.sender);
|
|
435
|
+
return result;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
}
|