@inco/lightning 0.1.30 → 0.1.31
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 +4 -0
- package/manifest.yaml +23 -0
- package/package.json +5 -1
- package/src/CreateXHelper.sol +14 -0
- package/src/DeployUtils.sol +95 -19
- package/src/Lib.demonet.sol +389 -0
- package/src/Lib.devnet.sol +389 -0
- package/src/Lib.sol +37 -160
- package/src/Lib.testnet.sol +389 -0
- package/src/Types.sol +54 -52
- package/src/libs/incoLightning_0_1_29__863421733.sol +389 -0
- package/src/lightning-parts/DecryptionHandler.sol +208 -37
- package/src/lightning-parts/primitives/SignatureVerifier.sol +24 -9
- package/src/test/AddTwo.sol +15 -11
- package/src/test/FakeIncoInfra/FakeIncoInfraBase.sol +2 -1
- package/src/test/FibonacciDecrypt.sol +48 -0
- package/src/test/IncoTest.sol +6 -4
- package/src/test/TestAddTwo.t.sol +8 -10
- package/src/version/IncoLightningConfig.sol +2 -2
- package/dumps/incoLightning_0_1_23__547622051.dump.json +0 -1
- package/dumps/incoLightning_0_1_23__547622051.env +0 -15
- package/dumps/incoLightning_0_1_23__830342853.dump.json +0 -1
- package/dumps/incoLightning_0_1_23__830342853.env +0 -15
- package/dumps/incoLightning_0_1_24__266705097.dump.json +0 -1
- package/dumps/incoLightning_0_1_24__266705097.env +0 -15
- package/dumps/incoLightning_0_1_25__861473222.dump.json +0 -1
- package/dumps/incoLightning_0_1_25__861473222.env +0 -15
- package/dumps/incoLightning_0_1_25__986372984.dump.json +0 -1
- package/dumps/incoLightning_0_1_25__986372984.env +0 -15
- package/dumps/incoLightning_0_1_26__18043964.dump.json +0 -1
- package/dumps/incoLightning_0_1_26__18043964.env +0 -15
- package/dumps/incoLightning_0_1_26__444235330.dump.json +0 -1
- package/dumps/incoLightning_0_1_26__444235330.env +0 -15
- package/dumps/incoLightning_0_1_27__125335042.dump.json +0 -1
- package/dumps/incoLightning_0_1_27__125335042.env +0 -14
- package/dumps/incoLightning_0_1_27__558243565.dump.json +0 -1
- package/dumps/incoLightning_0_1_27__558243565.env +0 -14
- package/dumps/incoLightning_0_1_29__183408998.dump.json +0 -1
- package/dumps/incoLightning_0_1_29__183408998.env +0 -14
- package/dumps/incoLightning_0_1_29__340846814.dump.json +0 -1
- package/dumps/incoLightning_0_1_29__340846814.env +0 -14
|
@@ -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(0x3B22be60Ae699933959CA3cE147C96caa88Ccd3D);
|
|
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
|
+
}
|
package/src/Lib.sol
CHANGED
|
@@ -6,11 +6,9 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import "./IncoLightning.sol";
|
|
9
|
-
import {ebool, euint256, ETypes} from "./Types.sol";
|
|
9
|
+
import { ebool, euint256, ETypes } from "./Types.sol";
|
|
10
10
|
|
|
11
|
-
IncoLightning constant inco = IncoLightning(
|
|
12
|
-
0x63D8135aF4D393B1dB43B649010c8D3EE19FC9fd
|
|
13
|
-
);
|
|
11
|
+
IncoLightning constant inco = IncoLightning(0x63D8135aF4D393B1dB43B649010c8D3EE19FC9fd);
|
|
14
12
|
address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
|
|
15
13
|
uint256 constant defaultDecryptionDelayLimit = 2 hours;
|
|
16
14
|
|
|
@@ -98,30 +96,15 @@ library e {
|
|
|
98
96
|
}
|
|
99
97
|
|
|
100
98
|
function and(euint256 a, euint256 b) internal returns (euint256) {
|
|
101
|
-
return
|
|
102
|
-
euint256.wrap(
|
|
103
|
-
inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(s(b)))
|
|
104
|
-
);
|
|
99
|
+
return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
|
|
105
100
|
}
|
|
106
101
|
|
|
107
102
|
function and(euint256 a, uint256 b) internal returns (euint256) {
|
|
108
|
-
return
|
|
109
|
-
euint256.wrap(
|
|
110
|
-
inco.eBitAnd(
|
|
111
|
-
euint256.unwrap(s(a)),
|
|
112
|
-
euint256.unwrap(asEuint256(b))
|
|
113
|
-
)
|
|
114
|
-
);
|
|
103
|
+
return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
|
|
115
104
|
}
|
|
116
105
|
|
|
117
106
|
function and(uint256 a, euint256 b) internal returns (euint256) {
|
|
118
|
-
return
|
|
119
|
-
euint256.wrap(
|
|
120
|
-
inco.eBitAnd(
|
|
121
|
-
euint256.unwrap(asEuint256(a)),
|
|
122
|
-
euint256.unwrap(s(b))
|
|
123
|
-
)
|
|
124
|
-
);
|
|
107
|
+
return euint256.wrap(inco.eBitAnd(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
|
|
125
108
|
}
|
|
126
109
|
|
|
127
110
|
function and(ebool a, ebool b) internal returns (ebool) {
|
|
@@ -129,44 +112,23 @@ library e {
|
|
|
129
112
|
}
|
|
130
113
|
|
|
131
114
|
function and(ebool a, bool b) internal returns (ebool) {
|
|
132
|
-
return
|
|
133
|
-
ebool.wrap(
|
|
134
|
-
inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b)))
|
|
135
|
-
);
|
|
115
|
+
return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
|
|
136
116
|
}
|
|
137
117
|
|
|
138
118
|
function and(bool a, ebool b) internal returns (ebool) {
|
|
139
|
-
return
|
|
140
|
-
ebool.wrap(
|
|
141
|
-
inco.eBitAnd(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b)))
|
|
142
|
-
);
|
|
119
|
+
return ebool.wrap(inco.eBitAnd(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
|
|
143
120
|
}
|
|
144
121
|
|
|
145
122
|
function or(euint256 a, euint256 b) internal returns (euint256) {
|
|
146
|
-
return
|
|
147
|
-
euint256.wrap(
|
|
148
|
-
inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(s(b)))
|
|
149
|
-
);
|
|
123
|
+
return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
|
|
150
124
|
}
|
|
151
125
|
|
|
152
126
|
function or(euint256 a, uint256 b) internal returns (euint256) {
|
|
153
|
-
return
|
|
154
|
-
euint256.wrap(
|
|
155
|
-
inco.eBitOr(
|
|
156
|
-
euint256.unwrap(s(a)),
|
|
157
|
-
euint256.unwrap(asEuint256(b))
|
|
158
|
-
)
|
|
159
|
-
);
|
|
127
|
+
return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
|
|
160
128
|
}
|
|
161
129
|
|
|
162
130
|
function or(uint256 a, euint256 b) internal returns (euint256) {
|
|
163
|
-
return
|
|
164
|
-
euint256.wrap(
|
|
165
|
-
inco.eBitOr(
|
|
166
|
-
euint256.unwrap(asEuint256(a)),
|
|
167
|
-
euint256.unwrap(s(b))
|
|
168
|
-
)
|
|
169
|
-
);
|
|
131
|
+
return euint256.wrap(inco.eBitOr(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
|
|
170
132
|
}
|
|
171
133
|
|
|
172
134
|
function or(ebool a, ebool b) internal returns (ebool) {
|
|
@@ -174,44 +136,23 @@ library e {
|
|
|
174
136
|
}
|
|
175
137
|
|
|
176
138
|
function or(ebool a, bool b) internal returns (ebool) {
|
|
177
|
-
return
|
|
178
|
-
ebool.wrap(
|
|
179
|
-
inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b)))
|
|
180
|
-
);
|
|
139
|
+
return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
|
|
181
140
|
}
|
|
182
141
|
|
|
183
142
|
function or(bool a, ebool b) internal returns (ebool) {
|
|
184
|
-
return
|
|
185
|
-
ebool.wrap(
|
|
186
|
-
inco.eBitOr(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b)))
|
|
187
|
-
);
|
|
143
|
+
return ebool.wrap(inco.eBitOr(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
|
|
188
144
|
}
|
|
189
145
|
|
|
190
146
|
function xor(euint256 a, euint256 b) internal returns (euint256) {
|
|
191
|
-
return
|
|
192
|
-
euint256.wrap(
|
|
193
|
-
inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(s(b)))
|
|
194
|
-
);
|
|
147
|
+
return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
|
|
195
148
|
}
|
|
196
149
|
|
|
197
150
|
function xor(euint256 a, uint256 b) internal returns (euint256) {
|
|
198
|
-
return
|
|
199
|
-
euint256.wrap(
|
|
200
|
-
inco.eBitXor(
|
|
201
|
-
euint256.unwrap(s(a)),
|
|
202
|
-
euint256.unwrap(asEuint256(b))
|
|
203
|
-
)
|
|
204
|
-
);
|
|
151
|
+
return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
|
|
205
152
|
}
|
|
206
153
|
|
|
207
154
|
function xor(uint256 a, euint256 b) internal returns (euint256) {
|
|
208
|
-
return
|
|
209
|
-
euint256.wrap(
|
|
210
|
-
inco.eBitXor(
|
|
211
|
-
euint256.unwrap(asEuint256(a)),
|
|
212
|
-
euint256.unwrap(s(b))
|
|
213
|
-
)
|
|
214
|
-
);
|
|
155
|
+
return euint256.wrap(inco.eBitXor(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
|
|
215
156
|
}
|
|
216
157
|
|
|
217
158
|
function xor(ebool a, ebool b) internal returns (ebool) {
|
|
@@ -219,17 +160,11 @@ library e {
|
|
|
219
160
|
}
|
|
220
161
|
|
|
221
162
|
function xor(ebool a, bool b) internal returns (ebool) {
|
|
222
|
-
return
|
|
223
|
-
ebool.wrap(
|
|
224
|
-
inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b)))
|
|
225
|
-
);
|
|
163
|
+
return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
|
|
226
164
|
}
|
|
227
165
|
|
|
228
166
|
function xor(bool a, ebool b) internal returns (ebool) {
|
|
229
|
-
return
|
|
230
|
-
ebool.wrap(
|
|
231
|
-
inco.eBitXor(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b)))
|
|
232
|
-
);
|
|
167
|
+
return ebool.wrap(inco.eBitXor(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
|
|
233
168
|
}
|
|
234
169
|
|
|
235
170
|
function shl(euint256 a, euint256 b) internal returns (euint256) {
|
|
@@ -385,23 +320,11 @@ library e {
|
|
|
385
320
|
}
|
|
386
321
|
|
|
387
322
|
function randBounded(uint256 upperBound) internal returns (euint256) {
|
|
388
|
-
return
|
|
389
|
-
euint256.wrap(
|
|
390
|
-
inco.eRandBounded(
|
|
391
|
-
euint256.unwrap(asEuint256(upperBound)),
|
|
392
|
-
ETypes.Uint256
|
|
393
|
-
)
|
|
394
|
-
);
|
|
323
|
+
return euint256.wrap(inco.eRandBounded(euint256.unwrap(asEuint256(upperBound)), ETypes.Uint256));
|
|
395
324
|
}
|
|
396
325
|
|
|
397
326
|
function randBounded(euint256 upperBound) internal returns (euint256) {
|
|
398
|
-
return
|
|
399
|
-
euint256.wrap(
|
|
400
|
-
inco.eRandBounded(
|
|
401
|
-
euint256.unwrap(s(upperBound)),
|
|
402
|
-
ETypes.Uint256
|
|
403
|
-
)
|
|
404
|
-
);
|
|
327
|
+
return euint256.wrap(inco.eRandBounded(euint256.unwrap(s(upperBound)), ETypes.Uint256));
|
|
405
328
|
}
|
|
406
329
|
|
|
407
330
|
function asEuint256(uint256 a) internal returns (euint256) {
|
|
@@ -420,17 +343,11 @@ library e {
|
|
|
420
343
|
return euint256.wrap(inco.eCast(ebool.unwrap(a), ETypes.Uint256));
|
|
421
344
|
}
|
|
422
345
|
|
|
423
|
-
function newEuint256(
|
|
424
|
-
bytes memory ciphertext,
|
|
425
|
-
address user
|
|
426
|
-
) internal returns (euint256) {
|
|
346
|
+
function newEuint256(bytes memory ciphertext, address user) internal returns (euint256) {
|
|
427
347
|
return inco.newEuint256(ciphertext, user);
|
|
428
348
|
}
|
|
429
349
|
|
|
430
|
-
function newEbool(
|
|
431
|
-
bytes memory ciphertext,
|
|
432
|
-
address user
|
|
433
|
-
) internal returns (ebool) {
|
|
350
|
+
function newEbool(bytes memory ciphertext, address user) internal returns (ebool) {
|
|
434
351
|
return inco.newEbool(ciphertext, user);
|
|
435
352
|
}
|
|
436
353
|
|
|
@@ -454,59 +371,19 @@ library e {
|
|
|
454
371
|
return inco.isAllowed(euint256.unwrap(a), user);
|
|
455
372
|
}
|
|
456
373
|
|
|
457
|
-
function select(
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
) internal returns (
|
|
462
|
-
return
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
ebool control,
|
|
474
|
-
ebool ifTrue,
|
|
475
|
-
ebool ifFalse
|
|
476
|
-
) internal returns (ebool) {
|
|
477
|
-
return
|
|
478
|
-
ebool.wrap(
|
|
479
|
-
inco.eIfThenElse(
|
|
480
|
-
s(control),
|
|
481
|
-
ebool.unwrap(s(ifTrue)),
|
|
482
|
-
ebool.unwrap(s(ifFalse))
|
|
483
|
-
)
|
|
484
|
-
);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
function requestDecryption(
|
|
488
|
-
euint256 a,
|
|
489
|
-
bytes4 callbackSelector,
|
|
490
|
-
bytes memory callbackData
|
|
491
|
-
) internal returns (uint256 requestId) {
|
|
492
|
-
requestId = inco.requestDecryption(
|
|
493
|
-
callbackSelector,
|
|
494
|
-
block.timestamp + defaultDecryptionDelayLimit,
|
|
495
|
-
euint256.unwrap(s(a)),
|
|
496
|
-
callbackData
|
|
497
|
-
);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
function requestDecryption(
|
|
501
|
-
ebool a,
|
|
502
|
-
bytes4 callbackSelector,
|
|
503
|
-
bytes memory callbackData
|
|
504
|
-
) internal returns (uint256 requestId) {
|
|
505
|
-
requestId = inco.requestDecryption(
|
|
506
|
-
callbackSelector,
|
|
507
|
-
block.timestamp + defaultDecryptionDelayLimit,
|
|
508
|
-
ebool.unwrap(s(a)),
|
|
509
|
-
callbackData
|
|
510
|
-
);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
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
|
+
}
|