@inco/lightning 0.2.13 → 0.2.15
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/package.json +1 -1
- package/src/Lib.alphanet.sol +70 -7
- package/src/Lib.demonet.sol +70 -7
- package/src/Lib.devnet.sol +70 -7
- package/src/Lib.sol +70 -7
- package/src/Lib.template.sol +89 -7
- package/src/Lib.testnet.sol +70 -7
- package/src/Types.sol +3 -2
- package/src/libs/incoLightning_alphanet_v0_297966649.sol +70 -7
- package/src/libs/incoLightning_demonet_v0_863421733.sol +70 -7
- package/src/libs/incoLightning_devnet_v0_340846814.sol +70 -7
- package/src/libs/incoLightning_testnet_v0_183408998.sol +70 -7
- package/src/lightning-parts/EncryptedInput.gen.sol +3 -1
- package/src/lightning-parts/EncryptedInput.sol +8 -1
- package/src/lightning-parts/EncryptedOperations.gen.sol +2 -2
- package/src/lightning-parts/EncryptedOperations.sol +54 -37
- package/src/lightning-parts/TrivialEncryption.gen.sol +3 -1
- package/src/lightning-parts/TrivialEncryption.sol +6 -1
- package/src/lightning-parts/test/HandleMetadata.t.sol +13 -2
- package/src/test/FakeIncoInfra/FakeIncoInfraBase.sol +12 -0
- package/src/test/FakeIncoInfra/KVStore.sol +7 -1
- package/src/test/FakeIncoInfra/MockOpHandler.sol +3 -1
- package/src/test/TestFakeInfra.t.sol +6 -1
- package/src/libs/incoLightning_junknet3_v0_495844717.sol +0 -389
package/package.json
CHANGED
package/src/Lib.alphanet.sol
CHANGED
|
@@ -6,12 +6,16 @@
|
|
|
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, eaddress, ETypes, isTypeSupported } from "./Types.sol";
|
|
10
10
|
|
|
11
11
|
IncoLightning constant inco = IncoLightning(0x4651DfD7729aE5568092E7351fAaD872266d4CBd);
|
|
12
12
|
address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
|
|
13
13
|
uint256 constant defaultDecryptionDelayLimit = 2 hours;
|
|
14
14
|
|
|
15
|
+
function typeOf(bytes32 handle) pure returns (ETypes) {
|
|
16
|
+
return ETypes(uint8(uint256(handle) >> 8));
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
library e {
|
|
16
20
|
function sanitize(euint256 a) internal returns (euint256) {
|
|
17
21
|
if (euint256.unwrap(a) == bytes32(0)) {
|
|
@@ -27,6 +31,13 @@ library e {
|
|
|
27
31
|
return a;
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
function sanitize(eaddress a) internal returns (eaddress) {
|
|
35
|
+
if (eaddress.unwrap(a) == bytes32(0)) {
|
|
36
|
+
return asEaddress(address(0));
|
|
37
|
+
}
|
|
38
|
+
return a;
|
|
39
|
+
}
|
|
40
|
+
|
|
30
41
|
function s(euint256 a) internal returns (euint256) {
|
|
31
42
|
return sanitize(a);
|
|
32
43
|
}
|
|
@@ -35,6 +46,10 @@ library e {
|
|
|
35
46
|
return sanitize(a);
|
|
36
47
|
}
|
|
37
48
|
|
|
49
|
+
function s(eaddress a) internal returns (eaddress) {
|
|
50
|
+
return sanitize(a);
|
|
51
|
+
}
|
|
52
|
+
|
|
38
53
|
function add(euint256 a, euint256 b) internal returns (euint256) {
|
|
39
54
|
return inco.eAdd(s(a), s(b));
|
|
40
55
|
}
|
|
@@ -216,27 +231,51 @@ library e {
|
|
|
216
231
|
}
|
|
217
232
|
|
|
218
233
|
function eq(euint256 a, euint256 b) internal returns (ebool) {
|
|
219
|
-
return inco.eEq(s(a), s(b));
|
|
234
|
+
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
220
235
|
}
|
|
221
236
|
|
|
222
237
|
function eq(euint256 a, uint256 b) internal returns (ebool) {
|
|
223
|
-
return inco.eEq(s(a), asEuint256(b));
|
|
238
|
+
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
224
239
|
}
|
|
225
240
|
|
|
226
241
|
function eq(uint256 a, euint256 b) internal returns (ebool) {
|
|
227
|
-
return inco.eEq(asEuint256(a), s(b));
|
|
242
|
+
return inco.eEq(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function eq(eaddress a, address b) internal returns (ebool) {
|
|
246
|
+
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function eq(eaddress a, eaddress b) internal returns (ebool) {
|
|
250
|
+
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function eq(address a, eaddress b) internal returns (ebool) {
|
|
254
|
+
return inco.eEq(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
228
255
|
}
|
|
229
256
|
|
|
230
257
|
function ne(euint256 a, euint256 b) internal returns (ebool) {
|
|
231
|
-
return inco.eNe(s(a), s(b));
|
|
258
|
+
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
232
259
|
}
|
|
233
260
|
|
|
234
261
|
function ne(euint256 a, uint256 b) internal returns (ebool) {
|
|
235
|
-
return inco.eNe(s(a), asEuint256(b));
|
|
262
|
+
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
236
263
|
}
|
|
237
264
|
|
|
238
265
|
function ne(uint256 a, euint256 b) internal returns (ebool) {
|
|
239
|
-
return inco.eNe(asEuint256(a), s(b));
|
|
266
|
+
return inco.eNe(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function ne(eaddress a, eaddress b) internal returns (ebool) {
|
|
270
|
+
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function ne(eaddress a, address b) internal returns (ebool) {
|
|
274
|
+
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function ne(address a, eaddress b) internal returns (ebool) {
|
|
278
|
+
return inco.eNe(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
240
279
|
}
|
|
241
280
|
|
|
242
281
|
function ge(euint256 a, euint256 b) internal returns (ebool) {
|
|
@@ -335,6 +374,10 @@ library e {
|
|
|
335
374
|
return inco.asEbool(a);
|
|
336
375
|
}
|
|
337
376
|
|
|
377
|
+
function asEaddress(address a) internal returns (eaddress) {
|
|
378
|
+
return inco.asEaddress(a);
|
|
379
|
+
}
|
|
380
|
+
|
|
338
381
|
function asEbool(euint256 a) internal returns (ebool) {
|
|
339
382
|
return ebool.wrap(inco.eCast(euint256.unwrap(a), ETypes.Bool));
|
|
340
383
|
}
|
|
@@ -351,6 +394,10 @@ library e {
|
|
|
351
394
|
return inco.newEbool(ciphertext, user);
|
|
352
395
|
}
|
|
353
396
|
|
|
397
|
+
function newEaddress(bytes memory ciphertext, address user) internal returns (eaddress) {
|
|
398
|
+
return inco.newEaddress(ciphertext, user);
|
|
399
|
+
}
|
|
400
|
+
|
|
354
401
|
function allow(euint256 a, address to) internal {
|
|
355
402
|
inco.allow(euint256.unwrap(a), to);
|
|
356
403
|
}
|
|
@@ -359,6 +406,10 @@ library e {
|
|
|
359
406
|
inco.allow(ebool.unwrap(a), to);
|
|
360
407
|
}
|
|
361
408
|
|
|
409
|
+
function allow(eaddress a, address to) internal {
|
|
410
|
+
inco.allow(eaddress.unwrap(a), to);
|
|
411
|
+
}
|
|
412
|
+
|
|
362
413
|
function allowThis(euint256 a) internal {
|
|
363
414
|
allow(a, address(this));
|
|
364
415
|
}
|
|
@@ -367,6 +418,10 @@ library e {
|
|
|
367
418
|
allow(a, address(this));
|
|
368
419
|
}
|
|
369
420
|
|
|
421
|
+
function allowThis(eaddress a) internal {
|
|
422
|
+
allow(a, address(this));
|
|
423
|
+
}
|
|
424
|
+
|
|
370
425
|
function isAllowed(address user, euint256 a) internal view returns (bool) {
|
|
371
426
|
return inco.isAllowed(euint256.unwrap(a), user);
|
|
372
427
|
}
|
|
@@ -379,6 +434,10 @@ library e {
|
|
|
379
434
|
return ebool.wrap(inco.eIfThenElse(s(control), ebool.unwrap(s(ifTrue)), ebool.unwrap(s(ifFalse))));
|
|
380
435
|
}
|
|
381
436
|
|
|
437
|
+
function select(ebool control, eaddress ifTrue, eaddress ifFalse) internal returns (eaddress) {
|
|
438
|
+
return eaddress.wrap(inco.eIfThenElse(s(control), eaddress.unwrap(s(ifTrue)), eaddress.unwrap(s(ifFalse))));
|
|
439
|
+
}
|
|
440
|
+
|
|
382
441
|
function requestDecryption(euint256 a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
|
|
383
442
|
requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, euint256.unwrap(s(a)), callbackData);
|
|
384
443
|
}
|
|
@@ -386,4 +445,8 @@ library e {
|
|
|
386
445
|
function requestDecryption(ebool a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
|
|
387
446
|
requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, ebool.unwrap(s(a)), callbackData);
|
|
388
447
|
}
|
|
448
|
+
|
|
449
|
+
function requestDecryption(eaddress a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
|
|
450
|
+
requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, eaddress.unwrap(s(a)), callbackData);
|
|
451
|
+
}
|
|
389
452
|
}
|
package/src/Lib.demonet.sol
CHANGED
|
@@ -6,12 +6,16 @@
|
|
|
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, eaddress, ETypes, isTypeSupported } from "./Types.sol";
|
|
10
10
|
|
|
11
11
|
IncoLightning constant inco = IncoLightning(0xeBAFF6D578733E4603b99CBdbb221482F29a78E1);
|
|
12
12
|
address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
|
|
13
13
|
uint256 constant defaultDecryptionDelayLimit = 2 hours;
|
|
14
14
|
|
|
15
|
+
function typeOf(bytes32 handle) pure returns (ETypes) {
|
|
16
|
+
return ETypes(uint8(uint256(handle) >> 8));
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
library e {
|
|
16
20
|
function sanitize(euint256 a) internal returns (euint256) {
|
|
17
21
|
if (euint256.unwrap(a) == bytes32(0)) {
|
|
@@ -27,6 +31,13 @@ library e {
|
|
|
27
31
|
return a;
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
function sanitize(eaddress a) internal returns (eaddress) {
|
|
35
|
+
if (eaddress.unwrap(a) == bytes32(0)) {
|
|
36
|
+
return asEaddress(address(0));
|
|
37
|
+
}
|
|
38
|
+
return a;
|
|
39
|
+
}
|
|
40
|
+
|
|
30
41
|
function s(euint256 a) internal returns (euint256) {
|
|
31
42
|
return sanitize(a);
|
|
32
43
|
}
|
|
@@ -35,6 +46,10 @@ library e {
|
|
|
35
46
|
return sanitize(a);
|
|
36
47
|
}
|
|
37
48
|
|
|
49
|
+
function s(eaddress a) internal returns (eaddress) {
|
|
50
|
+
return sanitize(a);
|
|
51
|
+
}
|
|
52
|
+
|
|
38
53
|
function add(euint256 a, euint256 b) internal returns (euint256) {
|
|
39
54
|
return inco.eAdd(s(a), s(b));
|
|
40
55
|
}
|
|
@@ -216,27 +231,51 @@ library e {
|
|
|
216
231
|
}
|
|
217
232
|
|
|
218
233
|
function eq(euint256 a, euint256 b) internal returns (ebool) {
|
|
219
|
-
return inco.eEq(s(a), s(b));
|
|
234
|
+
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
220
235
|
}
|
|
221
236
|
|
|
222
237
|
function eq(euint256 a, uint256 b) internal returns (ebool) {
|
|
223
|
-
return inco.eEq(s(a), asEuint256(b));
|
|
238
|
+
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
224
239
|
}
|
|
225
240
|
|
|
226
241
|
function eq(uint256 a, euint256 b) internal returns (ebool) {
|
|
227
|
-
return inco.eEq(asEuint256(a), s(b));
|
|
242
|
+
return inco.eEq(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function eq(eaddress a, address b) internal returns (ebool) {
|
|
246
|
+
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function eq(eaddress a, eaddress b) internal returns (ebool) {
|
|
250
|
+
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function eq(address a, eaddress b) internal returns (ebool) {
|
|
254
|
+
return inco.eEq(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
228
255
|
}
|
|
229
256
|
|
|
230
257
|
function ne(euint256 a, euint256 b) internal returns (ebool) {
|
|
231
|
-
return inco.eNe(s(a), s(b));
|
|
258
|
+
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
232
259
|
}
|
|
233
260
|
|
|
234
261
|
function ne(euint256 a, uint256 b) internal returns (ebool) {
|
|
235
|
-
return inco.eNe(s(a), asEuint256(b));
|
|
262
|
+
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
236
263
|
}
|
|
237
264
|
|
|
238
265
|
function ne(uint256 a, euint256 b) internal returns (ebool) {
|
|
239
|
-
return inco.eNe(asEuint256(a), s(b));
|
|
266
|
+
return inco.eNe(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function ne(eaddress a, eaddress b) internal returns (ebool) {
|
|
270
|
+
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function ne(eaddress a, address b) internal returns (ebool) {
|
|
274
|
+
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function ne(address a, eaddress b) internal returns (ebool) {
|
|
278
|
+
return inco.eNe(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
240
279
|
}
|
|
241
280
|
|
|
242
281
|
function ge(euint256 a, euint256 b) internal returns (ebool) {
|
|
@@ -335,6 +374,10 @@ library e {
|
|
|
335
374
|
return inco.asEbool(a);
|
|
336
375
|
}
|
|
337
376
|
|
|
377
|
+
function asEaddress(address a) internal returns (eaddress) {
|
|
378
|
+
return inco.asEaddress(a);
|
|
379
|
+
}
|
|
380
|
+
|
|
338
381
|
function asEbool(euint256 a) internal returns (ebool) {
|
|
339
382
|
return ebool.wrap(inco.eCast(euint256.unwrap(a), ETypes.Bool));
|
|
340
383
|
}
|
|
@@ -351,6 +394,10 @@ library e {
|
|
|
351
394
|
return inco.newEbool(ciphertext, user);
|
|
352
395
|
}
|
|
353
396
|
|
|
397
|
+
function newEaddress(bytes memory ciphertext, address user) internal returns (eaddress) {
|
|
398
|
+
return inco.newEaddress(ciphertext, user);
|
|
399
|
+
}
|
|
400
|
+
|
|
354
401
|
function allow(euint256 a, address to) internal {
|
|
355
402
|
inco.allow(euint256.unwrap(a), to);
|
|
356
403
|
}
|
|
@@ -359,6 +406,10 @@ library e {
|
|
|
359
406
|
inco.allow(ebool.unwrap(a), to);
|
|
360
407
|
}
|
|
361
408
|
|
|
409
|
+
function allow(eaddress a, address to) internal {
|
|
410
|
+
inco.allow(eaddress.unwrap(a), to);
|
|
411
|
+
}
|
|
412
|
+
|
|
362
413
|
function allowThis(euint256 a) internal {
|
|
363
414
|
allow(a, address(this));
|
|
364
415
|
}
|
|
@@ -367,6 +418,10 @@ library e {
|
|
|
367
418
|
allow(a, address(this));
|
|
368
419
|
}
|
|
369
420
|
|
|
421
|
+
function allowThis(eaddress a) internal {
|
|
422
|
+
allow(a, address(this));
|
|
423
|
+
}
|
|
424
|
+
|
|
370
425
|
function isAllowed(address user, euint256 a) internal view returns (bool) {
|
|
371
426
|
return inco.isAllowed(euint256.unwrap(a), user);
|
|
372
427
|
}
|
|
@@ -379,6 +434,10 @@ library e {
|
|
|
379
434
|
return ebool.wrap(inco.eIfThenElse(s(control), ebool.unwrap(s(ifTrue)), ebool.unwrap(s(ifFalse))));
|
|
380
435
|
}
|
|
381
436
|
|
|
437
|
+
function select(ebool control, eaddress ifTrue, eaddress ifFalse) internal returns (eaddress) {
|
|
438
|
+
return eaddress.wrap(inco.eIfThenElse(s(control), eaddress.unwrap(s(ifTrue)), eaddress.unwrap(s(ifFalse))));
|
|
439
|
+
}
|
|
440
|
+
|
|
382
441
|
function requestDecryption(euint256 a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
|
|
383
442
|
requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, euint256.unwrap(s(a)), callbackData);
|
|
384
443
|
}
|
|
@@ -386,4 +445,8 @@ library e {
|
|
|
386
445
|
function requestDecryption(ebool a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
|
|
387
446
|
requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, ebool.unwrap(s(a)), callbackData);
|
|
388
447
|
}
|
|
448
|
+
|
|
449
|
+
function requestDecryption(eaddress a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
|
|
450
|
+
requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, eaddress.unwrap(s(a)), callbackData);
|
|
451
|
+
}
|
|
389
452
|
}
|
package/src/Lib.devnet.sol
CHANGED
|
@@ -6,12 +6,16 @@
|
|
|
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, eaddress, ETypes, isTypeSupported } from "./Types.sol";
|
|
10
10
|
|
|
11
11
|
IncoLightning constant inco = IncoLightning(0x3B22be60Ae699933959CA3cE147C96caa88Ccd3D);
|
|
12
12
|
address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
|
|
13
13
|
uint256 constant defaultDecryptionDelayLimit = 2 hours;
|
|
14
14
|
|
|
15
|
+
function typeOf(bytes32 handle) pure returns (ETypes) {
|
|
16
|
+
return ETypes(uint8(uint256(handle) >> 8));
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
library e {
|
|
16
20
|
function sanitize(euint256 a) internal returns (euint256) {
|
|
17
21
|
if (euint256.unwrap(a) == bytes32(0)) {
|
|
@@ -27,6 +31,13 @@ library e {
|
|
|
27
31
|
return a;
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
function sanitize(eaddress a) internal returns (eaddress) {
|
|
35
|
+
if (eaddress.unwrap(a) == bytes32(0)) {
|
|
36
|
+
return asEaddress(address(0));
|
|
37
|
+
}
|
|
38
|
+
return a;
|
|
39
|
+
}
|
|
40
|
+
|
|
30
41
|
function s(euint256 a) internal returns (euint256) {
|
|
31
42
|
return sanitize(a);
|
|
32
43
|
}
|
|
@@ -35,6 +46,10 @@ library e {
|
|
|
35
46
|
return sanitize(a);
|
|
36
47
|
}
|
|
37
48
|
|
|
49
|
+
function s(eaddress a) internal returns (eaddress) {
|
|
50
|
+
return sanitize(a);
|
|
51
|
+
}
|
|
52
|
+
|
|
38
53
|
function add(euint256 a, euint256 b) internal returns (euint256) {
|
|
39
54
|
return inco.eAdd(s(a), s(b));
|
|
40
55
|
}
|
|
@@ -216,27 +231,51 @@ library e {
|
|
|
216
231
|
}
|
|
217
232
|
|
|
218
233
|
function eq(euint256 a, euint256 b) internal returns (ebool) {
|
|
219
|
-
return inco.eEq(s(a), s(b));
|
|
234
|
+
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
220
235
|
}
|
|
221
236
|
|
|
222
237
|
function eq(euint256 a, uint256 b) internal returns (ebool) {
|
|
223
|
-
return inco.eEq(s(a), asEuint256(b));
|
|
238
|
+
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
224
239
|
}
|
|
225
240
|
|
|
226
241
|
function eq(uint256 a, euint256 b) internal returns (ebool) {
|
|
227
|
-
return inco.eEq(asEuint256(a), s(b));
|
|
242
|
+
return inco.eEq(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function eq(eaddress a, address b) internal returns (ebool) {
|
|
246
|
+
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function eq(eaddress a, eaddress b) internal returns (ebool) {
|
|
250
|
+
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function eq(address a, eaddress b) internal returns (ebool) {
|
|
254
|
+
return inco.eEq(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
228
255
|
}
|
|
229
256
|
|
|
230
257
|
function ne(euint256 a, euint256 b) internal returns (ebool) {
|
|
231
|
-
return inco.eNe(s(a), s(b));
|
|
258
|
+
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
232
259
|
}
|
|
233
260
|
|
|
234
261
|
function ne(euint256 a, uint256 b) internal returns (ebool) {
|
|
235
|
-
return inco.eNe(s(a), asEuint256(b));
|
|
262
|
+
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
236
263
|
}
|
|
237
264
|
|
|
238
265
|
function ne(uint256 a, euint256 b) internal returns (ebool) {
|
|
239
|
-
return inco.eNe(asEuint256(a), s(b));
|
|
266
|
+
return inco.eNe(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function ne(eaddress a, eaddress b) internal returns (ebool) {
|
|
270
|
+
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function ne(eaddress a, address b) internal returns (ebool) {
|
|
274
|
+
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function ne(address a, eaddress b) internal returns (ebool) {
|
|
278
|
+
return inco.eNe(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
240
279
|
}
|
|
241
280
|
|
|
242
281
|
function ge(euint256 a, euint256 b) internal returns (ebool) {
|
|
@@ -335,6 +374,10 @@ library e {
|
|
|
335
374
|
return inco.asEbool(a);
|
|
336
375
|
}
|
|
337
376
|
|
|
377
|
+
function asEaddress(address a) internal returns (eaddress) {
|
|
378
|
+
return inco.asEaddress(a);
|
|
379
|
+
}
|
|
380
|
+
|
|
338
381
|
function asEbool(euint256 a) internal returns (ebool) {
|
|
339
382
|
return ebool.wrap(inco.eCast(euint256.unwrap(a), ETypes.Bool));
|
|
340
383
|
}
|
|
@@ -351,6 +394,10 @@ library e {
|
|
|
351
394
|
return inco.newEbool(ciphertext, user);
|
|
352
395
|
}
|
|
353
396
|
|
|
397
|
+
function newEaddress(bytes memory ciphertext, address user) internal returns (eaddress) {
|
|
398
|
+
return inco.newEaddress(ciphertext, user);
|
|
399
|
+
}
|
|
400
|
+
|
|
354
401
|
function allow(euint256 a, address to) internal {
|
|
355
402
|
inco.allow(euint256.unwrap(a), to);
|
|
356
403
|
}
|
|
@@ -359,6 +406,10 @@ library e {
|
|
|
359
406
|
inco.allow(ebool.unwrap(a), to);
|
|
360
407
|
}
|
|
361
408
|
|
|
409
|
+
function allow(eaddress a, address to) internal {
|
|
410
|
+
inco.allow(eaddress.unwrap(a), to);
|
|
411
|
+
}
|
|
412
|
+
|
|
362
413
|
function allowThis(euint256 a) internal {
|
|
363
414
|
allow(a, address(this));
|
|
364
415
|
}
|
|
@@ -367,6 +418,10 @@ library e {
|
|
|
367
418
|
allow(a, address(this));
|
|
368
419
|
}
|
|
369
420
|
|
|
421
|
+
function allowThis(eaddress a) internal {
|
|
422
|
+
allow(a, address(this));
|
|
423
|
+
}
|
|
424
|
+
|
|
370
425
|
function isAllowed(address user, euint256 a) internal view returns (bool) {
|
|
371
426
|
return inco.isAllowed(euint256.unwrap(a), user);
|
|
372
427
|
}
|
|
@@ -379,6 +434,10 @@ library e {
|
|
|
379
434
|
return ebool.wrap(inco.eIfThenElse(s(control), ebool.unwrap(s(ifTrue)), ebool.unwrap(s(ifFalse))));
|
|
380
435
|
}
|
|
381
436
|
|
|
437
|
+
function select(ebool control, eaddress ifTrue, eaddress ifFalse) internal returns (eaddress) {
|
|
438
|
+
return eaddress.wrap(inco.eIfThenElse(s(control), eaddress.unwrap(s(ifTrue)), eaddress.unwrap(s(ifFalse))));
|
|
439
|
+
}
|
|
440
|
+
|
|
382
441
|
function requestDecryption(euint256 a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
|
|
383
442
|
requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, euint256.unwrap(s(a)), callbackData);
|
|
384
443
|
}
|
|
@@ -386,4 +445,8 @@ library e {
|
|
|
386
445
|
function requestDecryption(ebool a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
|
|
387
446
|
requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, ebool.unwrap(s(a)), callbackData);
|
|
388
447
|
}
|
|
448
|
+
|
|
449
|
+
function requestDecryption(eaddress a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
|
|
450
|
+
requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, eaddress.unwrap(s(a)), callbackData);
|
|
451
|
+
}
|
|
389
452
|
}
|
package/src/Lib.sol
CHANGED
|
@@ -6,12 +6,16 @@
|
|
|
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, eaddress, ETypes, isTypeSupported } from "./Types.sol";
|
|
10
10
|
|
|
11
11
|
IncoLightning constant inco = IncoLightning(0x63D8135aF4D393B1dB43B649010c8D3EE19FC9fd);
|
|
12
12
|
address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
|
|
13
13
|
uint256 constant defaultDecryptionDelayLimit = 2 hours;
|
|
14
14
|
|
|
15
|
+
function typeOf(bytes32 handle) pure returns (ETypes) {
|
|
16
|
+
return ETypes(uint8(uint256(handle) >> 8));
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
library e {
|
|
16
20
|
function sanitize(euint256 a) internal returns (euint256) {
|
|
17
21
|
if (euint256.unwrap(a) == bytes32(0)) {
|
|
@@ -27,6 +31,13 @@ library e {
|
|
|
27
31
|
return a;
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
function sanitize(eaddress a) internal returns (eaddress) {
|
|
35
|
+
if (eaddress.unwrap(a) == bytes32(0)) {
|
|
36
|
+
return asEaddress(address(0));
|
|
37
|
+
}
|
|
38
|
+
return a;
|
|
39
|
+
}
|
|
40
|
+
|
|
30
41
|
function s(euint256 a) internal returns (euint256) {
|
|
31
42
|
return sanitize(a);
|
|
32
43
|
}
|
|
@@ -35,6 +46,10 @@ library e {
|
|
|
35
46
|
return sanitize(a);
|
|
36
47
|
}
|
|
37
48
|
|
|
49
|
+
function s(eaddress a) internal returns (eaddress) {
|
|
50
|
+
return sanitize(a);
|
|
51
|
+
}
|
|
52
|
+
|
|
38
53
|
function add(euint256 a, euint256 b) internal returns (euint256) {
|
|
39
54
|
return inco.eAdd(s(a), s(b));
|
|
40
55
|
}
|
|
@@ -216,27 +231,51 @@ library e {
|
|
|
216
231
|
}
|
|
217
232
|
|
|
218
233
|
function eq(euint256 a, euint256 b) internal returns (ebool) {
|
|
219
|
-
return inco.eEq(s(a), s(b));
|
|
234
|
+
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
220
235
|
}
|
|
221
236
|
|
|
222
237
|
function eq(euint256 a, uint256 b) internal returns (ebool) {
|
|
223
|
-
return inco.eEq(s(a), asEuint256(b));
|
|
238
|
+
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
224
239
|
}
|
|
225
240
|
|
|
226
241
|
function eq(uint256 a, euint256 b) internal returns (ebool) {
|
|
227
|
-
return inco.eEq(asEuint256(a), s(b));
|
|
242
|
+
return inco.eEq(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function eq(eaddress a, address b) internal returns (ebool) {
|
|
246
|
+
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function eq(eaddress a, eaddress b) internal returns (ebool) {
|
|
250
|
+
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function eq(address a, eaddress b) internal returns (ebool) {
|
|
254
|
+
return inco.eEq(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
228
255
|
}
|
|
229
256
|
|
|
230
257
|
function ne(euint256 a, euint256 b) internal returns (ebool) {
|
|
231
|
-
return inco.eNe(s(a), s(b));
|
|
258
|
+
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
232
259
|
}
|
|
233
260
|
|
|
234
261
|
function ne(euint256 a, uint256 b) internal returns (ebool) {
|
|
235
|
-
return inco.eNe(s(a), asEuint256(b));
|
|
262
|
+
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
236
263
|
}
|
|
237
264
|
|
|
238
265
|
function ne(uint256 a, euint256 b) internal returns (ebool) {
|
|
239
|
-
return inco.eNe(asEuint256(a), s(b));
|
|
266
|
+
return inco.eNe(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function ne(eaddress a, eaddress b) internal returns (ebool) {
|
|
270
|
+
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function ne(eaddress a, address b) internal returns (ebool) {
|
|
274
|
+
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function ne(address a, eaddress b) internal returns (ebool) {
|
|
278
|
+
return inco.eNe(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
240
279
|
}
|
|
241
280
|
|
|
242
281
|
function ge(euint256 a, euint256 b) internal returns (ebool) {
|
|
@@ -335,6 +374,10 @@ library e {
|
|
|
335
374
|
return inco.asEbool(a);
|
|
336
375
|
}
|
|
337
376
|
|
|
377
|
+
function asEaddress(address a) internal returns (eaddress) {
|
|
378
|
+
return inco.asEaddress(a);
|
|
379
|
+
}
|
|
380
|
+
|
|
338
381
|
function asEbool(euint256 a) internal returns (ebool) {
|
|
339
382
|
return ebool.wrap(inco.eCast(euint256.unwrap(a), ETypes.Bool));
|
|
340
383
|
}
|
|
@@ -351,6 +394,10 @@ library e {
|
|
|
351
394
|
return inco.newEbool(ciphertext, user);
|
|
352
395
|
}
|
|
353
396
|
|
|
397
|
+
function newEaddress(bytes memory ciphertext, address user) internal returns (eaddress) {
|
|
398
|
+
return inco.newEaddress(ciphertext, user);
|
|
399
|
+
}
|
|
400
|
+
|
|
354
401
|
function allow(euint256 a, address to) internal {
|
|
355
402
|
inco.allow(euint256.unwrap(a), to);
|
|
356
403
|
}
|
|
@@ -359,6 +406,10 @@ library e {
|
|
|
359
406
|
inco.allow(ebool.unwrap(a), to);
|
|
360
407
|
}
|
|
361
408
|
|
|
409
|
+
function allow(eaddress a, address to) internal {
|
|
410
|
+
inco.allow(eaddress.unwrap(a), to);
|
|
411
|
+
}
|
|
412
|
+
|
|
362
413
|
function allowThis(euint256 a) internal {
|
|
363
414
|
allow(a, address(this));
|
|
364
415
|
}
|
|
@@ -367,6 +418,10 @@ library e {
|
|
|
367
418
|
allow(a, address(this));
|
|
368
419
|
}
|
|
369
420
|
|
|
421
|
+
function allowThis(eaddress a) internal {
|
|
422
|
+
allow(a, address(this));
|
|
423
|
+
}
|
|
424
|
+
|
|
370
425
|
function isAllowed(address user, euint256 a) internal view returns (bool) {
|
|
371
426
|
return inco.isAllowed(euint256.unwrap(a), user);
|
|
372
427
|
}
|
|
@@ -379,6 +434,10 @@ library e {
|
|
|
379
434
|
return ebool.wrap(inco.eIfThenElse(s(control), ebool.unwrap(s(ifTrue)), ebool.unwrap(s(ifFalse))));
|
|
380
435
|
}
|
|
381
436
|
|
|
437
|
+
function select(ebool control, eaddress ifTrue, eaddress ifFalse) internal returns (eaddress) {
|
|
438
|
+
return eaddress.wrap(inco.eIfThenElse(s(control), eaddress.unwrap(s(ifTrue)), eaddress.unwrap(s(ifFalse))));
|
|
439
|
+
}
|
|
440
|
+
|
|
382
441
|
function requestDecryption(euint256 a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
|
|
383
442
|
requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, euint256.unwrap(s(a)), callbackData);
|
|
384
443
|
}
|
|
@@ -386,4 +445,8 @@ library e {
|
|
|
386
445
|
function requestDecryption(ebool a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
|
|
387
446
|
requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, ebool.unwrap(s(a)), callbackData);
|
|
388
447
|
}
|
|
448
|
+
|
|
449
|
+
function requestDecryption(eaddress a, bytes4 callbackSelector, bytes memory callbackData) internal returns (uint256 requestId) {
|
|
450
|
+
requestId = inco.requestDecryption(callbackSelector, block.timestamp + defaultDecryptionDelayLimit, eaddress.unwrap(s(a)), callbackData);
|
|
451
|
+
}
|
|
389
452
|
}
|