@inco/lightning 0.5.2 → 0.6.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/manifest.yaml +23 -9
- package/package.json +1 -2
- package/src/DeployUtils.sol +10 -19
- package/src/Lib.alphanet.sol +12 -6
- package/src/Lib.demonet.sol +12 -6
- package/src/Lib.devnet.sol +13 -7
- package/src/Lib.sol +13 -7
- package/src/Lib.template.sol +12 -6
- package/src/Lib.testnet.sol +12 -6
- package/src/Types.sol +4 -1
- package/src/libs/incoLightning_alphanet_v0_297966649.sol +12 -6
- package/src/libs/incoLightning_demonet_v0_863421733.sol +12 -6
- package/src/libs/incoLightning_devnet_v0_340846814.sol +12 -6
- package/src/libs/incoLightning_devnet_v1_904635675.sol +457 -0
- package/src/libs/incoLightning_testnet_v0_183408998.sol +12 -6
- package/src/lightning-parts/AccessControl/BaseAccessControlList.sol +21 -5
- package/src/lightning-parts/AccessControl/test/TestAdvancedAccessControl.t.sol +1 -0
- package/src/lightning-parts/EncryptedInput.sol +22 -6
- package/src/lightning-parts/EncryptedOperations.sol +6 -6
- package/src/lightning-parts/Fee.sol +41 -0
- package/src/lightning-parts/TEELifecycle.sol +170 -67
- package/src/lightning-parts/TEELifecycle.types.sol +9 -12
- package/src/lightning-parts/TrivialEncryption.sol +1 -1
- package/src/lightning-parts/interfaces/IEncryptedInput.sol +3 -3
- package/src/lightning-parts/interfaces/IEncryptedOperations.sol +48 -1
- package/src/lightning-parts/interfaces/ITEELifecycle.sol +2 -2
- package/src/lightning-parts/test/Fee.t.sol +101 -0
- package/src/lightning-parts/test/HandleMetadata.t.sol +4 -3
- package/src/lightning-parts/test/InputsFee.t.sol +65 -0
- package/src/lightning-parts/test/TestDecryptionAttestationInSynchronousFlow.t.sol +1 -0
- package/src/test/AddTwo.sol +18 -6
- package/src/test/FakeIncoInfra/FakeIncoInfraBase.sol +12 -0
- package/src/test/FakeIncoInfra/MockRemoteAttestation.sol +6 -0
- package/src/test/FakeIncoInfra/getOpForSelector.sol +5 -0
- package/src/test/IncoTest.sol +1 -0
- package/src/test/TEELifecycle/TEELifecycleMockTest.t.sol +21 -26
- package/src/test/TestAddTwo.t.sol +9 -1
- package/src/test/TestFakeInfra.t.sol +12 -3
- package/src/version/IncoLightningConfig.sol +3 -1
- package/src/test/TEELifecycle/README.md +0 -53
|
@@ -0,0 +1,457 @@
|
|
|
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 } from "../IncoLightning.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes } from "../Types.sol";
|
|
10
|
+
|
|
11
|
+
IncoLightning constant inco = IncoLightning(0x3473820DcAa71Af8157b93C7f2bf1c676A2A39A6);
|
|
12
|
+
address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
|
|
13
|
+
|
|
14
|
+
function typeOf(bytes32 handle) pure returns (ETypes) {
|
|
15
|
+
return ETypes(uint8(uint256(handle) >> 8));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
library e {
|
|
19
|
+
function sanitize(euint256 a) internal returns (euint256) {
|
|
20
|
+
if (euint256.unwrap(a) == bytes32(0)) {
|
|
21
|
+
return asEuint256(0);
|
|
22
|
+
}
|
|
23
|
+
return a;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function sanitize(ebool a) internal returns (ebool) {
|
|
27
|
+
if (ebool.unwrap(a) == bytes32(0)) {
|
|
28
|
+
return asEbool(false);
|
|
29
|
+
}
|
|
30
|
+
return a;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function sanitize(eaddress a) internal returns (eaddress) {
|
|
34
|
+
if (eaddress.unwrap(a) == bytes32(0)) {
|
|
35
|
+
return asEaddress(address(0));
|
|
36
|
+
}
|
|
37
|
+
return a;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function s(euint256 a) internal returns (euint256) {
|
|
41
|
+
return sanitize(a);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function s(ebool a) internal returns (ebool) {
|
|
45
|
+
return sanitize(a);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function s(eaddress a) internal returns (eaddress) {
|
|
49
|
+
return sanitize(a);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function add(euint256 a, euint256 b) internal returns (euint256) {
|
|
53
|
+
return inco.eAdd(s(a), s(b));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function add(euint256 a, uint256 b) internal returns (euint256) {
|
|
57
|
+
return inco.eAdd(s(a), asEuint256(b));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function add(uint256 a, euint256 b) internal returns (euint256) {
|
|
61
|
+
return inco.eAdd(asEuint256(a), s(b));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function sub(euint256 a, euint256 b) internal returns (euint256) {
|
|
65
|
+
return inco.eSub(s(a), s(b));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function sub(euint256 a, uint256 b) internal returns (euint256) {
|
|
69
|
+
return inco.eSub(s(a), asEuint256(b));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function sub(uint256 a, euint256 b) internal returns (euint256) {
|
|
73
|
+
return inco.eSub(asEuint256(a), s(b));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function mul(euint256 a, euint256 b) internal returns (euint256) {
|
|
77
|
+
return inco.eMul(s(a), s(b));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function mul(euint256 a, uint256 b) internal returns (euint256) {
|
|
81
|
+
return inco.eMul(s(a), asEuint256(b));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function mul(uint256 a, euint256 b) internal returns (euint256) {
|
|
85
|
+
return inco.eMul(asEuint256(a), s(b));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function div(euint256 a, euint256 b) internal returns (euint256) {
|
|
89
|
+
return inco.eDiv(s(a), s(b));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function div(euint256 a, uint256 b) internal returns (euint256) {
|
|
93
|
+
return inco.eDiv(s(a), asEuint256(b));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function div(uint256 a, euint256 b) internal returns (euint256) {
|
|
97
|
+
return inco.eDiv(asEuint256(a), s(b));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function rem(euint256 a, euint256 b) internal returns (euint256) {
|
|
101
|
+
return inco.eRem(s(a), s(b));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function rem(euint256 a, uint256 b) internal returns (euint256) {
|
|
105
|
+
return inco.eRem(s(a), asEuint256(b));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function rem(uint256 a, euint256 b) internal returns (euint256) {
|
|
109
|
+
return inco.eRem(asEuint256(a), s(b));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function and(euint256 a, euint256 b) internal returns (euint256) {
|
|
113
|
+
return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function and(euint256 a, uint256 b) internal returns (euint256) {
|
|
117
|
+
return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function and(uint256 a, euint256 b) internal returns (euint256) {
|
|
121
|
+
return euint256.wrap(inco.eBitAnd(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function and(ebool a, ebool b) internal returns (ebool) {
|
|
125
|
+
return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function and(ebool a, bool b) internal returns (ebool) {
|
|
129
|
+
return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function and(bool a, ebool b) internal returns (ebool) {
|
|
133
|
+
return ebool.wrap(inco.eBitAnd(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function or(euint256 a, euint256 b) internal returns (euint256) {
|
|
137
|
+
return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function or(euint256 a, uint256 b) internal returns (euint256) {
|
|
141
|
+
return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function or(uint256 a, euint256 b) internal returns (euint256) {
|
|
145
|
+
return euint256.wrap(inco.eBitOr(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function or(ebool a, ebool b) internal returns (ebool) {
|
|
149
|
+
return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function or(ebool a, bool b) internal returns (ebool) {
|
|
153
|
+
return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function or(bool a, ebool b) internal returns (ebool) {
|
|
157
|
+
return ebool.wrap(inco.eBitOr(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function xor(euint256 a, euint256 b) internal returns (euint256) {
|
|
161
|
+
return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function xor(euint256 a, uint256 b) internal returns (euint256) {
|
|
165
|
+
return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function xor(uint256 a, euint256 b) internal returns (euint256) {
|
|
169
|
+
return euint256.wrap(inco.eBitXor(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function xor(ebool a, ebool b) internal returns (ebool) {
|
|
173
|
+
return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function xor(ebool a, bool b) internal returns (ebool) {
|
|
177
|
+
return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function xor(bool a, ebool b) internal returns (ebool) {
|
|
181
|
+
return ebool.wrap(inco.eBitXor(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function shl(euint256 a, euint256 b) internal returns (euint256) {
|
|
185
|
+
return inco.eShl(s(a), s(b));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function shl(euint256 a, uint256 b) internal returns (euint256) {
|
|
189
|
+
return inco.eShl(s(a), asEuint256(b));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function shl(uint256 a, euint256 b) internal returns (euint256) {
|
|
193
|
+
return inco.eShl(asEuint256(a), s(b));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function shr(euint256 a, euint256 b) internal returns (euint256) {
|
|
197
|
+
return inco.eShr(s(a), s(b));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function shr(euint256 a, uint256 b) internal returns (euint256) {
|
|
201
|
+
return inco.eShr(s(a), asEuint256(b));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function shr(uint256 a, euint256 b) internal returns (euint256) {
|
|
205
|
+
return inco.eShr(asEuint256(a), s(b));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function rotl(euint256 a, euint256 b) internal returns (euint256) {
|
|
209
|
+
return inco.eRotl(s(a), s(b));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function rotl(euint256 a, uint256 b) internal returns (euint256) {
|
|
213
|
+
return inco.eRotl(s(a), asEuint256(b));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function rotl(uint256 a, euint256 b) internal returns (euint256) {
|
|
217
|
+
return inco.eRotl(asEuint256(a), s(b));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function rotr(euint256 a, euint256 b) internal returns (euint256) {
|
|
221
|
+
return inco.eRotr(s(a), s(b));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function rotr(euint256 a, uint256 b) internal returns (euint256) {
|
|
225
|
+
return inco.eRotr(s(a), asEuint256(b));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function rotr(uint256 a, euint256 b) internal returns (euint256) {
|
|
229
|
+
return inco.eRotr(asEuint256(a), s(b));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function eq(euint256 a, euint256 b) internal returns (ebool) {
|
|
233
|
+
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function eq(euint256 a, uint256 b) internal returns (ebool) {
|
|
237
|
+
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function eq(uint256 a, euint256 b) internal returns (ebool) {
|
|
241
|
+
return inco.eEq(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function eq(eaddress a, address b) internal returns (ebool) {
|
|
245
|
+
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function eq(eaddress a, eaddress b) internal returns (ebool) {
|
|
249
|
+
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function eq(address a, eaddress b) internal returns (ebool) {
|
|
253
|
+
return inco.eEq(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function ne(euint256 a, euint256 b) internal returns (ebool) {
|
|
257
|
+
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function ne(euint256 a, uint256 b) internal returns (ebool) {
|
|
261
|
+
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function ne(uint256 a, euint256 b) internal returns (ebool) {
|
|
265
|
+
return inco.eNe(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function ne(eaddress a, eaddress b) internal returns (ebool) {
|
|
269
|
+
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function ne(eaddress a, address b) internal returns (ebool) {
|
|
273
|
+
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function ne(address a, eaddress b) internal returns (ebool) {
|
|
277
|
+
return inco.eNe(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function ge(euint256 a, euint256 b) internal returns (ebool) {
|
|
281
|
+
return inco.eGe(s(a), s(b));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function ge(euint256 a, uint256 b) internal returns (ebool) {
|
|
285
|
+
return inco.eGe(s(a), asEuint256(b));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function ge(uint256 a, euint256 b) internal returns (ebool) {
|
|
289
|
+
return inco.eGe(asEuint256(a), s(b));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function gt(euint256 a, euint256 b) internal returns (ebool) {
|
|
293
|
+
return inco.eGt(s(a), s(b));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function gt(euint256 a, uint256 b) internal returns (ebool) {
|
|
297
|
+
return inco.eGt(s(a), asEuint256(b));
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function gt(uint256 a, euint256 b) internal returns (ebool) {
|
|
301
|
+
return inco.eGt(asEuint256(a), s(b));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function le(euint256 a, euint256 b) internal returns (ebool) {
|
|
305
|
+
return inco.eLe(s(a), s(b));
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function le(euint256 a, uint256 b) internal returns (ebool) {
|
|
309
|
+
return inco.eLe(s(a), asEuint256(b));
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function le(uint256 a, euint256 b) internal returns (ebool) {
|
|
313
|
+
return inco.eLe(asEuint256(a), s(b));
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function lt(euint256 a, euint256 b) internal returns (ebool) {
|
|
317
|
+
return inco.eLt(s(a), s(b));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function lt(euint256 a, uint256 b) internal returns (ebool) {
|
|
321
|
+
return inco.eLt(s(a), asEuint256(b));
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function lt(uint256 a, euint256 b) internal returns (ebool) {
|
|
325
|
+
return inco.eLt(asEuint256(a), s(b));
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function min(euint256 a, euint256 b) internal returns (euint256) {
|
|
329
|
+
return inco.eMin(s(a), s(b));
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function min(euint256 a, uint256 b) internal returns (euint256) {
|
|
333
|
+
return inco.eMin(s(a), asEuint256(b));
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function min(uint256 a, euint256 b) internal returns (euint256) {
|
|
337
|
+
return inco.eMin(asEuint256(a), s(b));
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function max(euint256 a, euint256 b) internal returns (euint256) {
|
|
341
|
+
return inco.eMax(s(a), s(b));
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function max(euint256 a, uint256 b) internal returns (euint256) {
|
|
345
|
+
return inco.eMax(s(a), asEuint256(b));
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function max(uint256 a, euint256 b) internal returns (euint256) {
|
|
349
|
+
return inco.eMax(asEuint256(a), s(b));
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function not(ebool a) internal returns (ebool) {
|
|
353
|
+
return inco.eNot(s(a));
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/// @dev costs the inco fee
|
|
357
|
+
function rand() internal returns (euint256) {
|
|
358
|
+
return euint256.wrap(inco.eRand{value: inco.getFee()}(ETypes.Uint256));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/// @dev costs the inco fee
|
|
362
|
+
function randBounded(uint256 upperBound) internal returns (euint256) {
|
|
363
|
+
return euint256.wrap(inco.eRandBounded{value: inco.getFee()}(euint256.unwrap(asEuint256(upperBound)), ETypes.Uint256));
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/// @dev costs the inco fee
|
|
367
|
+
function randBounded(euint256 upperBound) internal returns (euint256) {
|
|
368
|
+
return euint256.wrap(inco.eRandBounded{value: inco.getFee()}(euint256.unwrap(s(upperBound)), ETypes.Uint256));
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function asEuint256(uint256 a) internal returns (euint256) {
|
|
372
|
+
return inco.asEuint256(a);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function asEbool(bool a) internal returns (ebool) {
|
|
376
|
+
return inco.asEbool(a);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function asEaddress(address a) internal returns (eaddress) {
|
|
380
|
+
return inco.asEaddress(a);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function asEbool(euint256 a) internal returns (ebool) {
|
|
384
|
+
return ebool.wrap(inco.eCast(euint256.unwrap(a), ETypes.Bool));
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function asEuint256(ebool a) internal returns (euint256) {
|
|
388
|
+
return euint256.wrap(inco.eCast(ebool.unwrap(a), ETypes.Uint256));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/// @dev costs the inco fee
|
|
392
|
+
function newEuint256(bytes memory ciphertext, address user) internal returns (euint256) {
|
|
393
|
+
return inco.newEuint256{value: inco.getFee()}(ciphertext, user);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/// @dev costs the inco fee
|
|
397
|
+
function newEbool(bytes memory ciphertext, address user) internal returns (ebool) {
|
|
398
|
+
return inco.newEbool{value: inco.getFee()}(ciphertext, user);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/// @dev costs the inco fee
|
|
402
|
+
function newEaddress(bytes memory ciphertext, address user) internal returns (eaddress) {
|
|
403
|
+
return inco.newEaddress{value: inco.getFee()}(ciphertext, user);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function allow(euint256 a, address to) internal {
|
|
407
|
+
inco.allow(euint256.unwrap(a), to);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function allow(ebool a, address to) internal {
|
|
411
|
+
inco.allow(ebool.unwrap(a), to);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function allow(eaddress a, address to) internal {
|
|
415
|
+
inco.allow(eaddress.unwrap(a), to);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function reveal(euint256 a) internal {
|
|
419
|
+
inco.reveal(euint256.unwrap(a));
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function reveal(ebool a) internal {
|
|
423
|
+
inco.reveal(ebool.unwrap(a));
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function reveal(eaddress a) internal {
|
|
427
|
+
inco.reveal(eaddress.unwrap(a));
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function allowThis(euint256 a) internal {
|
|
431
|
+
allow(a, address(this));
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function allowThis(ebool a) internal {
|
|
435
|
+
allow(a, address(this));
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function allowThis(eaddress a) internal {
|
|
439
|
+
allow(a, address(this));
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function isAllowed(address user, euint256 a) internal view returns (bool) {
|
|
443
|
+
return inco.isAllowed(euint256.unwrap(a), user);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function select(ebool control, euint256 ifTrue, euint256 ifFalse) internal returns (euint256) {
|
|
447
|
+
return euint256.wrap(inco.eIfThenElse(s(control), euint256.unwrap(s(ifTrue)), euint256.unwrap(s(ifFalse))));
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function select(ebool control, ebool ifTrue, ebool ifFalse) internal returns (ebool) {
|
|
451
|
+
return ebool.wrap(inco.eIfThenElse(s(control), ebool.unwrap(s(ifTrue)), ebool.unwrap(s(ifFalse))));
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function select(ebool control, eaddress ifTrue, eaddress ifFalse) internal returns (eaddress) {
|
|
455
|
+
return eaddress.wrap(inco.eIfThenElse(s(control), eaddress.unwrap(s(ifTrue)), eaddress.unwrap(s(ifFalse))));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
@@ -353,16 +353,19 @@ library e {
|
|
|
353
353
|
return inco.eNot(s(a));
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
+
/// @dev costs the inco fee
|
|
356
357
|
function rand() internal returns (euint256) {
|
|
357
|
-
return euint256.wrap(inco.eRand(ETypes.Uint256));
|
|
358
|
+
return euint256.wrap(inco.eRand{value: inco.getFee()}(ETypes.Uint256));
|
|
358
359
|
}
|
|
359
360
|
|
|
361
|
+
/// @dev costs the inco fee
|
|
360
362
|
function randBounded(uint256 upperBound) internal returns (euint256) {
|
|
361
|
-
return euint256.wrap(inco.eRandBounded(euint256.unwrap(asEuint256(upperBound)), ETypes.Uint256));
|
|
363
|
+
return euint256.wrap(inco.eRandBounded{value: inco.getFee()}(euint256.unwrap(asEuint256(upperBound)), ETypes.Uint256));
|
|
362
364
|
}
|
|
363
365
|
|
|
366
|
+
/// @dev costs the inco fee
|
|
364
367
|
function randBounded(euint256 upperBound) internal returns (euint256) {
|
|
365
|
-
return euint256.wrap(inco.eRandBounded(euint256.unwrap(s(upperBound)), ETypes.Uint256));
|
|
368
|
+
return euint256.wrap(inco.eRandBounded{value: inco.getFee()}(euint256.unwrap(s(upperBound)), ETypes.Uint256));
|
|
366
369
|
}
|
|
367
370
|
|
|
368
371
|
function asEuint256(uint256 a) internal returns (euint256) {
|
|
@@ -385,16 +388,19 @@ library e {
|
|
|
385
388
|
return euint256.wrap(inco.eCast(ebool.unwrap(a), ETypes.Uint256));
|
|
386
389
|
}
|
|
387
390
|
|
|
391
|
+
/// @dev costs the inco fee
|
|
388
392
|
function newEuint256(bytes memory ciphertext, address user) internal returns (euint256) {
|
|
389
|
-
return inco.newEuint256(ciphertext, user);
|
|
393
|
+
return inco.newEuint256{value: inco.getFee()}(ciphertext, user);
|
|
390
394
|
}
|
|
391
395
|
|
|
396
|
+
/// @dev costs the inco fee
|
|
392
397
|
function newEbool(bytes memory ciphertext, address user) internal returns (ebool) {
|
|
393
|
-
return inco.newEbool(ciphertext, user);
|
|
398
|
+
return inco.newEbool{value: inco.getFee()}(ciphertext, user);
|
|
394
399
|
}
|
|
395
400
|
|
|
401
|
+
/// @dev costs the inco fee
|
|
396
402
|
function newEaddress(bytes memory ciphertext, address user) internal returns (eaddress) {
|
|
397
|
-
return inco.newEaddress(ciphertext, user);
|
|
403
|
+
return inco.newEaddress{value: inco.getFee()}(ciphertext, user);
|
|
398
404
|
}
|
|
399
405
|
|
|
400
406
|
function allow(euint256 a, address to) internal {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// SPDX-License-Identifier: No License
|
|
2
2
|
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
|
-
import {SenderNotAllowedForHandle} from "../../Types.sol";
|
|
4
|
+
import {EOps, SenderNotAllowedForHandle} from "../../Types.sol";
|
|
5
5
|
import {IBaseAccessControlList} from "./interfaces/IBaseAccessControlList.sol";
|
|
6
|
+
import {EventCounter} from "../primitives/EventCounter.sol";
|
|
6
7
|
import {VerifierAddressGetter} from "../primitives/VerifierAddressGetter.sol";
|
|
7
8
|
import {AllowanceProof} from "../AccessControl/AdvancedAccessControl.types.sol";
|
|
8
9
|
|
|
@@ -22,14 +23,24 @@ contract AccessControlListStorage {
|
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
abstract contract BaseAccessControlList is IBaseAccessControlList, AccessControlListStorage, VerifierAddressGetter {
|
|
26
|
+
abstract contract BaseAccessControlList is IBaseAccessControlList, AccessControlListStorage, VerifierAddressGetter, EventCounter {
|
|
27
27
|
error ProofVerificationFailed(
|
|
28
28
|
address verifyingContract,
|
|
29
29
|
bytes4 callFunction,
|
|
30
30
|
bytes argData
|
|
31
31
|
);
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
event Allow(
|
|
34
|
+
bytes32 handle,
|
|
35
|
+
address account,
|
|
36
|
+
uint256 eventId
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
event Reveal(
|
|
40
|
+
bytes32 handle,
|
|
41
|
+
uint256 eventId
|
|
42
|
+
);
|
|
43
|
+
|
|
33
44
|
/// @dev persistent
|
|
34
45
|
function allow(bytes32 handle, address account) public {
|
|
35
46
|
require(
|
|
@@ -47,13 +58,18 @@ abstract contract BaseAccessControlList is IBaseAccessControlList, AccessControl
|
|
|
47
58
|
);
|
|
48
59
|
ACLStorage storage $ = getACLStorage();
|
|
49
60
|
$.persistedAllowedForDecryption[handle] = true;
|
|
61
|
+
uint256 id = getNextEventId();
|
|
62
|
+
emit Reveal(handle, id);
|
|
63
|
+
setDigest(abi.encodePacked(EOps.Reveal, handle, id));
|
|
50
64
|
}
|
|
51
65
|
|
|
52
66
|
/// @dev persistent
|
|
53
67
|
function allowInternal(bytes32 handle, address account) internal {
|
|
54
68
|
ACLStorage storage $ = getACLStorage();
|
|
55
69
|
$.persistedAllowedPairs[handle][account] = true;
|
|
56
|
-
|
|
70
|
+
uint256 id = getNextEventId();
|
|
71
|
+
emit Allow(handle, account, id);
|
|
72
|
+
setDigest(abi.encodePacked(EOps.Allow, handle, account, id));
|
|
57
73
|
}
|
|
58
74
|
|
|
59
75
|
// todo current transient allowance is unsafe, make storage account bound + how to clean between UserOps
|
|
@@ -73,6 +73,7 @@ contract TestAdvancedAccessControl is IncoTest {
|
|
|
73
73
|
function setUp() public override {
|
|
74
74
|
super.setUp();
|
|
75
75
|
someContract = new SomeContractWithConfidentialData();
|
|
76
|
+
vm.deal(address(someContract), 100 ether);
|
|
76
77
|
bytes memory secretCt = fakePrepareEuint256Ciphertext(42);
|
|
77
78
|
vm.prank(alice);
|
|
78
79
|
someContract.saveAPersonalSecret(secretCt);
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
4
|
import {BaseAccessControlList} from "./AccessControl/BaseAccessControlList.sol";
|
|
5
|
-
import {EventCounter} from "./primitives/EventCounter.sol";
|
|
6
5
|
import {HandleGeneration} from "./primitives/HandleGeneration.sol";
|
|
7
6
|
import {euint256, ebool, eaddress, ETypes} from "../Types.sol";
|
|
8
7
|
import {IEncryptedInput} from "./interfaces/IEncryptedInput.sol";
|
|
9
8
|
import {HandleAlreadyExists} from "../Errors.sol";
|
|
9
|
+
import {Fee} from "./Fee.sol";
|
|
10
10
|
|
|
11
11
|
abstract contract EncryptedInput is
|
|
12
12
|
IEncryptedInput,
|
|
13
13
|
BaseAccessControlList,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
HandleGeneration,
|
|
15
|
+
Fee
|
|
16
16
|
{
|
|
17
17
|
event NewInput(
|
|
18
18
|
bytes32 indexed result,
|
|
@@ -26,21 +26,21 @@ abstract contract EncryptedInput is
|
|
|
26
26
|
function newEuint256(
|
|
27
27
|
bytes memory ciphertext,
|
|
28
28
|
address user
|
|
29
|
-
) external returns (euint256 newValue) {
|
|
29
|
+
) external payable returns (euint256 newValue) {
|
|
30
30
|
return euint256.wrap(newInput(ciphertext, user, ETypes.Uint256));
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function newEbool(
|
|
34
34
|
bytes memory ciphertext,
|
|
35
35
|
address user
|
|
36
|
-
) external returns (ebool newValue) {
|
|
36
|
+
) external payable returns (ebool newValue) {
|
|
37
37
|
return ebool.wrap(newInput(ciphertext, user, ETypes.Bool));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function newEaddress(
|
|
41
41
|
bytes memory ciphertext,
|
|
42
42
|
address user
|
|
43
|
-
) external returns (eaddress newValue) {
|
|
43
|
+
) external payable returns (eaddress newValue) {
|
|
44
44
|
return
|
|
45
45
|
eaddress.wrap(
|
|
46
46
|
newInput(ciphertext, user, ETypes.AddressOrUint160OrBytes20)
|
|
@@ -51,7 +51,23 @@ abstract contract EncryptedInput is
|
|
|
51
51
|
bytes memory ciphertext,
|
|
52
52
|
address user,
|
|
53
53
|
ETypes inputType
|
|
54
|
+
) internal paying returns (bytes32 newHandle) {
|
|
55
|
+
newHandle = _newInput(ciphertext, user, inputType);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function newInputNotPaying(
|
|
59
|
+
bytes memory ciphertext,
|
|
60
|
+
address user,
|
|
61
|
+
ETypes inputType
|
|
54
62
|
) internal returns (bytes32 newHandle) {
|
|
63
|
+
newHandle = _newInput(ciphertext, user, inputType);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function _newInput(
|
|
67
|
+
bytes memory ciphertext,
|
|
68
|
+
address user,
|
|
69
|
+
ETypes inputType
|
|
70
|
+
) private returns (bytes32 newHandle) {
|
|
55
71
|
newHandle = getInputHandle(ciphertext, user, msg.sender, inputType);
|
|
56
72
|
// We assume that providing the same handle (which via HADU implies same plaintext, same context, and same
|
|
57
73
|
// instance of encryption)
|
|
@@ -3,15 +3,15 @@ pragma solidity ^0.8;
|
|
|
3
3
|
|
|
4
4
|
import {euint256, ebool, EOps, SenderNotAllowedForHandle, ETypes, isTypeSupported, typeToBitMask} from "../Types.sol";
|
|
5
5
|
import {BaseAccessControlList} from "./AccessControl/BaseAccessControlList.sol";
|
|
6
|
-
import {EventCounter} from "./primitives/EventCounter.sol";
|
|
7
6
|
import {HandleGeneration} from "./primitives/HandleGeneration.sol";
|
|
8
7
|
import {IEncryptedOperations} from "./interfaces/IEncryptedOperations.sol";
|
|
8
|
+
import {Fee} from "./Fee.sol";
|
|
9
9
|
|
|
10
10
|
abstract contract EncryptedOperations is
|
|
11
11
|
IEncryptedOperations,
|
|
12
12
|
BaseAccessControlList,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
HandleGeneration,
|
|
14
|
+
Fee
|
|
15
15
|
{
|
|
16
16
|
error UnexpectedType(ETypes actual, bytes32 expectedTypes);
|
|
17
17
|
error UnsupportedType(ETypes actual);
|
|
@@ -600,12 +600,12 @@ abstract contract EncryptedOperations is
|
|
|
600
600
|
|
|
601
601
|
function eRand(
|
|
602
602
|
ETypes randType
|
|
603
|
-
) external returns (bytes32 result) {
|
|
603
|
+
) external paying payable returns (bytes32 result) {
|
|
604
604
|
require(isTypeSupported(randType), UnsupportedType(randType));
|
|
605
605
|
|
|
606
606
|
result = createResultHandle(
|
|
607
607
|
EOps.Rand,
|
|
608
|
-
randType,
|
|
608
|
+
randType,
|
|
609
609
|
bytes32(randCounter++),
|
|
610
610
|
bytes32(uint256(randType))
|
|
611
611
|
);
|
|
@@ -620,7 +620,7 @@ abstract contract EncryptedOperations is
|
|
|
620
620
|
function eRandBounded(
|
|
621
621
|
bytes32 upperBound,
|
|
622
622
|
ETypes randType
|
|
623
|
-
) external returns (bytes32 result) {
|
|
623
|
+
) external paying payable returns (bytes32 result) {
|
|
624
624
|
require(isTypeSupported(randType), UnsupportedType(randType));
|
|
625
625
|
checkInput(upperBound, typeToBitMask(ETypes.Uint256));
|
|
626
626
|
|