@inco/lightning 0.8.0-devnet-13 → 0.8.0-devnet-22
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 +66 -0
- package/package.json +8 -8
- package/src/IncoLightning.sol +5 -0
- package/src/Lib.alphanet.sol +31 -35
- package/src/Lib.demonet.sol +31 -35
- package/src/Lib.devnet.sol +31 -35
- package/src/Lib.sol +31 -35
- package/src/Lib.template.sol +54 -35
- package/src/Lib.testnet.sol +31 -35
- package/src/Types.sol +18 -0
- package/src/interfaces/IIncoLightning.sol +2 -0
- package/src/libs/incoLightning_alphanet_v0_297966649.sol +31 -35
- package/src/libs/incoLightning_alphanet_v1_725458969.sol +31 -35
- package/src/libs/incoLightning_alphanet_v2_976644394.sol +31 -35
- package/src/libs/incoLightning_demonet_v0_863421733.sol +31 -35
- package/src/libs/incoLightning_demonet_v2_467437523.sol +31 -35
- package/src/libs/incoLightning_devnet_v0_340846814.sol +31 -35
- package/src/libs/incoLightning_devnet_v1_904635675.sol +31 -35
- package/src/libs/incoLightning_devnet_v2_295237520.sol +31 -35
- package/src/libs/incoLightning_devnet_v3_976859633.sol +31 -35
- package/src/libs/incoLightning_devnet_v4_409204766.sol +31 -35
- package/src/libs/incoLightning_devnet_v5_203964628.sol +31 -35
- package/src/libs/incoLightning_devnet_v6_281949651.sol +31 -35
- package/src/libs/incoLightning_devnet_v7_24560427.sol +1197 -0
- package/src/libs/incoLightning_devnet_v8_985328058.sol +1197 -0
- package/src/libs/incoLightning_devnet_v9_269218568.sol +1197 -0
- package/src/libs/incoLightning_testnet_v0_183408998.sol +31 -35
- package/src/libs/incoLightning_testnet_v2_889158349.sol +31 -35
- package/src/lightning-parts/AccessControl/AdvancedAccessControl.sol +4 -3
- package/src/lightning-parts/AccessControl/BaseAccessControlList.sol +0 -16
- package/src/lightning-parts/AccessControl/interfaces/IAdvancedAccessControl.sol +1 -1
- package/src/lightning-parts/AccessControl/interfaces/IBaseAccessControlList.sol +0 -1
- package/src/lightning-parts/AccessControl/test/TestAdvancedAccessControl.t.sol +3 -1
- package/src/lightning-parts/AccessControl/test/TestBaseAccessControl.t.sol +0 -43
- package/src/lightning-parts/DecryptionAttester.sol +88 -2
- package/src/lightning-parts/DecryptionAttester.types.sol +9 -3
- package/src/lightning-parts/EList.sol +105 -25
- package/src/lightning-parts/EncryptedOperations.sol +18 -8
- package/src/lightning-parts/Fee.sol +29 -0
- package/src/lightning-parts/interfaces/IDecryptionAttester.sol +11 -2
- package/src/lightning-parts/interfaces/IEList.sol +11 -8
- package/src/lightning-parts/interfaces/IEncryptedInput.sol +2 -2
- package/src/lightning-parts/test/Elist.t.sol +160 -9
- package/src/lightning-parts/test/TestDecryptionAttestationInSynchronousFlow.t.sol +41 -13
- package/src/periphery/IncoUtils.sol +1 -1
- package/src/test/EListTester.sol +31 -13
- package/src/test/FakeIncoInfra/FakeComputeServer.sol +2 -2
- package/src/test/TestDeploy.t.sol +45 -1
- package/src/test/TestFakeInfra.t.sol +32 -6
- package/src/test/TestLib.t.sol +840 -19
- package/src/test/TestReceive.t.sol +42 -0
- package/src/version/IncoLightningConfig.sol +1 -1
package/src/test/TestLib.t.sol
CHANGED
|
@@ -3,7 +3,18 @@ pragma solidity ^0.8;
|
|
|
3
3
|
|
|
4
4
|
import {IncoTest} from "./IncoTest.sol";
|
|
5
5
|
import {e, euint256, ebool, eaddress, inco} from "../Lib.sol";
|
|
6
|
-
import {
|
|
6
|
+
import {FEE} from "../lightning-parts/Fee.sol";
|
|
7
|
+
import {
|
|
8
|
+
ETypes,
|
|
9
|
+
elist,
|
|
10
|
+
IndexOutOfRange,
|
|
11
|
+
InvalidRange,
|
|
12
|
+
SliceOutOfRange,
|
|
13
|
+
UnsupportedListType,
|
|
14
|
+
UnsupportedType
|
|
15
|
+
} from "../Types.sol";
|
|
16
|
+
import {DecryptionAttestation, ElementAttestationWithProof} from "../lightning-parts/DecryptionAttester.types.sol";
|
|
17
|
+
import {AllowanceProof, AllowanceVoucher} from "../lightning-parts/AccessControl/AdvancedAccessControl.sol";
|
|
7
18
|
|
|
8
19
|
/// @notice Tests for Lib.sol library functions to achieve 100% coverage
|
|
9
20
|
/// @dev This file tests all the scalar variants and uncovered branches in the library
|
|
@@ -16,6 +27,34 @@ contract TestLib is IncoTest {
|
|
|
16
27
|
using e for address;
|
|
17
28
|
using e for eaddress;
|
|
18
29
|
using e for bytes;
|
|
30
|
+
using e for elist;
|
|
31
|
+
|
|
32
|
+
function setUp() public virtual override {
|
|
33
|
+
super.setUp();
|
|
34
|
+
vm.deal(address(this), 100 ether);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ============ ELIST FEE HELPERS ============
|
|
38
|
+
|
|
39
|
+
function _listRange(uint16 start, uint16 end) internal returns (elist) {
|
|
40
|
+
return inco.listRange{value: inco.getEListFee(end - start, ETypes.Uint256)}(start, end);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function _newEList(bytes32[] memory handles, ETypes listType) internal returns (elist) {
|
|
44
|
+
return inco.newEList{value: inco.getEListFee(uint16(handles.length), listType)}(handles, listType);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function _listAppend(elist list, bytes32 value) internal returns (elist) {
|
|
48
|
+
return inco.listAppend{value: inco.getEListFee(e.length(list) + 1, e.listTypeOf(list))}(list, value);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function _listConcat(elist a, elist b) internal returns (elist) {
|
|
52
|
+
return inco.listConcat{value: inco.getEListFee(e.length(a) + e.length(b), e.listTypeOf(a))}(a, b);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _listReverse(elist list) internal returns (elist) {
|
|
56
|
+
return inco.listReverse{value: inco.getEListFee(e.length(list), e.listTypeOf(list))}(list);
|
|
57
|
+
}
|
|
19
58
|
|
|
20
59
|
// ============ SANITIZE BRANCH TESTS ============
|
|
21
60
|
|
|
@@ -632,18 +671,10 @@ contract TestLib is IncoTest {
|
|
|
632
671
|
|
|
633
672
|
// ============ CAST OPERATIONS ============
|
|
634
673
|
|
|
635
|
-
function
|
|
674
|
+
function testCastEuint256ToEboolRevert() public {
|
|
636
675
|
euint256 a = e.asEuint256(1);
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
assertEq(getBoolValue(b), true);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
function testCastEuint256ToEboolFalse() public {
|
|
643
|
-
euint256 a = e.asEuint256(0);
|
|
644
|
-
ebool b = e.asEbool(a);
|
|
645
|
-
processAllOperations();
|
|
646
|
-
assertEq(getBoolValue(b), false);
|
|
676
|
+
vm.expectRevert(abi.encodeWithSelector(UnsupportedType.selector, ETypes.Bool));
|
|
677
|
+
inco.eCast(euint256.unwrap(a), ETypes.Bool);
|
|
647
678
|
}
|
|
648
679
|
|
|
649
680
|
function testCastEboolToEuint256True() public {
|
|
@@ -707,20 +738,37 @@ contract TestLib is IncoTest {
|
|
|
707
738
|
assertEq(getUint256Value(b), 0);
|
|
708
739
|
}
|
|
709
740
|
|
|
710
|
-
function
|
|
741
|
+
function testCastEaddressToEboolNonZeroRevert() public {
|
|
711
742
|
eaddress a = e.asEaddress(alice);
|
|
712
743
|
processAllOperations();
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
assertEq(getBoolValue(b), true);
|
|
744
|
+
vm.expectRevert(abi.encodeWithSelector(UnsupportedType.selector, ETypes.Bool));
|
|
745
|
+
ebool.wrap(inco.eCast(eaddress.unwrap(a), ETypes.Bool));
|
|
716
746
|
}
|
|
717
747
|
|
|
718
|
-
function
|
|
748
|
+
function testCastEaddressToEboolZeroRevert() public {
|
|
719
749
|
eaddress a = e.asEaddress(address(0));
|
|
720
750
|
processAllOperations();
|
|
721
|
-
|
|
751
|
+
vm.expectRevert(abi.encodeWithSelector(UnsupportedType.selector, ETypes.Bool));
|
|
752
|
+
ebool.wrap(inco.eCast(eaddress.unwrap(a), ETypes.Bool));
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
function testCastEboolToEboolZeroRevert() public {
|
|
756
|
+
ebool a = e.asEbool(true);
|
|
722
757
|
processAllOperations();
|
|
723
|
-
|
|
758
|
+
vm.expectRevert(abi.encodeWithSelector(UnsupportedType.selector, ETypes.Bool));
|
|
759
|
+
ebool.wrap(inco.eCast(ebool.unwrap(a), ETypes.Bool));
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
function testCastEuint256ToEuint256() public {
|
|
763
|
+
euint256 a = e.asEuint256(10);
|
|
764
|
+
processAllOperations();
|
|
765
|
+
euint256.wrap(inco.eCast(euint256.unwrap(a), ETypes.Uint256));
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
function testCastEaddressToEaddress() public {
|
|
769
|
+
eaddress a = e.asEaddress(alice);
|
|
770
|
+
processAllOperations();
|
|
771
|
+
eaddress.wrap(inco.eCast(eaddress.unwrap(a), ETypes.AddressOrUint160OrBytes20));
|
|
724
772
|
}
|
|
725
773
|
|
|
726
774
|
// ============ NOT OPERATION ============
|
|
@@ -768,6 +816,602 @@ contract TestLib is IncoTest {
|
|
|
768
816
|
assertTrue(value < 50);
|
|
769
817
|
}
|
|
770
818
|
|
|
819
|
+
// ============ VERIFY DECRYPTION TESTS ============
|
|
820
|
+
|
|
821
|
+
function testVerifyDecryption_Euint256_ValidAttestation() public {
|
|
822
|
+
// Create an encrypted value
|
|
823
|
+
euint256 encrypted = e.asEuint256(12345);
|
|
824
|
+
processAllOperations();
|
|
825
|
+
|
|
826
|
+
// Get a valid decryption attestation
|
|
827
|
+
(DecryptionAttestation memory attestation, bytes[] memory signatures) = getDecryptionAttestation(
|
|
828
|
+
address(this), HandleWithProof({handle: euint256.unwrap(encrypted), proof: _emptyAllowanceProof()})
|
|
829
|
+
);
|
|
830
|
+
|
|
831
|
+
// Verify the decryption
|
|
832
|
+
bool isValid = e.verifyDecryption(encrypted, uint256(attestation.value), signatures);
|
|
833
|
+
assertTrue(isValid, "Valid attestation should return true");
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
function testVerifyDecryption_Euint256_InvalidValue() public {
|
|
837
|
+
// Create an encrypted value
|
|
838
|
+
euint256 encrypted = e.asEuint256(12345);
|
|
839
|
+
processAllOperations();
|
|
840
|
+
|
|
841
|
+
// Get a valid decryption attestation
|
|
842
|
+
(, bytes[] memory signatures) = getDecryptionAttestation(
|
|
843
|
+
address(this), HandleWithProof({handle: euint256.unwrap(encrypted), proof: _emptyAllowanceProof()})
|
|
844
|
+
);
|
|
845
|
+
|
|
846
|
+
// Try to verify with wrong value
|
|
847
|
+
bool isValid = e.verifyDecryption(encrypted, 99999, signatures);
|
|
848
|
+
assertFalse(isValid, "Invalid value should return false");
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
function testVerifyDecryption_Euint256_InvalidSignatures() public {
|
|
852
|
+
// Create an encrypted value
|
|
853
|
+
euint256 encrypted = e.asEuint256(12345);
|
|
854
|
+
processAllOperations();
|
|
855
|
+
|
|
856
|
+
// Create empty/invalid signatures
|
|
857
|
+
bytes[] memory invalidSignatures = new bytes[](0);
|
|
858
|
+
|
|
859
|
+
// Verify with invalid signatures should return false
|
|
860
|
+
bool isValid = e.verifyDecryption(encrypted, 12345, invalidSignatures);
|
|
861
|
+
assertFalse(isValid, "Invalid signatures should return false");
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
function testVerifyDecryption_Ebool_ValidAttestation_True() public {
|
|
865
|
+
// Create an encrypted bool (true)
|
|
866
|
+
ebool encrypted = e.asEbool(true);
|
|
867
|
+
processAllOperations();
|
|
868
|
+
|
|
869
|
+
// Get a valid decryption attestation
|
|
870
|
+
(DecryptionAttestation memory attestation, bytes[] memory signatures) = getDecryptionAttestation(
|
|
871
|
+
address(this), HandleWithProof({handle: ebool.unwrap(encrypted), proof: _emptyAllowanceProof()})
|
|
872
|
+
);
|
|
873
|
+
|
|
874
|
+
// Verify the decryption
|
|
875
|
+
bool decryptedValue = uint256(attestation.value) != 0;
|
|
876
|
+
bool isValid = e.verifyDecryption(encrypted, decryptedValue, signatures);
|
|
877
|
+
assertTrue(isValid, "Valid attestation for true should return true");
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
function testVerifyDecryption_Ebool_ValidAttestation_False() public {
|
|
881
|
+
// Create an encrypted bool (false)
|
|
882
|
+
ebool encrypted = e.asEbool(false);
|
|
883
|
+
processAllOperations();
|
|
884
|
+
|
|
885
|
+
// Get a valid decryption attestation
|
|
886
|
+
(DecryptionAttestation memory attestation, bytes[] memory signatures) = getDecryptionAttestation(
|
|
887
|
+
address(this), HandleWithProof({handle: ebool.unwrap(encrypted), proof: _emptyAllowanceProof()})
|
|
888
|
+
);
|
|
889
|
+
|
|
890
|
+
// Verify the decryption
|
|
891
|
+
bool decryptedValue = uint256(attestation.value) != 0;
|
|
892
|
+
bool isValid = e.verifyDecryption(encrypted, decryptedValue, signatures);
|
|
893
|
+
assertTrue(isValid, "Valid attestation for false should return true");
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
function testVerifyDecryption_Ebool_InvalidValue() public {
|
|
897
|
+
// Create an encrypted bool (true)
|
|
898
|
+
ebool encrypted = e.asEbool(true);
|
|
899
|
+
processAllOperations();
|
|
900
|
+
|
|
901
|
+
// Get a valid decryption attestation for true
|
|
902
|
+
(, bytes[] memory signatures) = getDecryptionAttestation(
|
|
903
|
+
address(this), HandleWithProof({handle: ebool.unwrap(encrypted), proof: _emptyAllowanceProof()})
|
|
904
|
+
);
|
|
905
|
+
|
|
906
|
+
// Try to verify with wrong value (false instead of true)
|
|
907
|
+
bool isValid = e.verifyDecryption(encrypted, false, signatures);
|
|
908
|
+
assertFalse(isValid, "Invalid bool value should return false");
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/// @dev Creates an empty AllowanceProof (no proof required when sharer is address(0))
|
|
912
|
+
function _emptyAllowanceProof() internal pure returns (AllowanceProof memory) {
|
|
913
|
+
return AllowanceProof({
|
|
914
|
+
sharer: address(0),
|
|
915
|
+
voucher: AllowanceVoucher({
|
|
916
|
+
sessionNonce: bytes32(0), verifyingContract: address(0), callFunction: bytes4(0), sharerArgData: ""
|
|
917
|
+
}),
|
|
918
|
+
voucherSignature: "",
|
|
919
|
+
requesterArgData: ""
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
// ============ ELIST PURE FUNCTION TESTS ============
|
|
924
|
+
// Note: Most EList functions in Lib.sol are thin wrappers around inco.* calls.
|
|
925
|
+
|
|
926
|
+
function testEList_ListTypeOf_Uint256() public {
|
|
927
|
+
elist list = _listRange(0, 5);
|
|
928
|
+
|
|
929
|
+
// Test listTypeOf - this is a pure function that extracts type from handle
|
|
930
|
+
ETypes listType = e.listTypeOf(list);
|
|
931
|
+
assertEq(uint8(listType), uint8(ETypes.Uint256), "Range creates Uint256 list");
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
function testEList_Length_Empty() public {
|
|
935
|
+
elist list = inco.newEList(new bytes32[](0), ETypes.Uint256); // empty list, fee = 0
|
|
936
|
+
|
|
937
|
+
// Test length function
|
|
938
|
+
uint16 len = e.length(list);
|
|
939
|
+
assertEq(len, 0, "Empty list should have length 0");
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
function testEList_Length_NonEmpty() public {
|
|
943
|
+
elist list = _listRange(0, 5);
|
|
944
|
+
|
|
945
|
+
// Test length function
|
|
946
|
+
uint16 len = e.length(list);
|
|
947
|
+
assertEq(len, 5, "Range(0,5) should have length 5");
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
function testEList_Length_AfterAppend() public {
|
|
951
|
+
elist list = _listRange(0, 3);
|
|
952
|
+
|
|
953
|
+
// Get a handle to append
|
|
954
|
+
bytes32 valueHandle = inco.listGet(list, 0);
|
|
955
|
+
|
|
956
|
+
elist newList = _listAppend(list, valueHandle);
|
|
957
|
+
|
|
958
|
+
assertEq(e.length(newList), 4, "After append, length should be 4");
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
function testEList_Length_AfterConcat() public {
|
|
962
|
+
elist list1 = _listRange(0, 3);
|
|
963
|
+
elist list2 = _listRange(10, 15);
|
|
964
|
+
|
|
965
|
+
elist combined = _listConcat(list1, list2);
|
|
966
|
+
|
|
967
|
+
assertEq(e.length(combined), 8, "Combined list should have length 8");
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
function testEList_Length_AfterReverse() public {
|
|
971
|
+
// Create a list
|
|
972
|
+
elist list = _listRange(0, 7);
|
|
973
|
+
|
|
974
|
+
// Reverse using inco directly
|
|
975
|
+
elist reversed = _listReverse(list);
|
|
976
|
+
|
|
977
|
+
// Verify length unchanged
|
|
978
|
+
assertEq(e.length(reversed), 7, "Reversed list should have same length");
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
LibEListHelper elistHelper;
|
|
982
|
+
|
|
983
|
+
function _setupEListHelper() internal {
|
|
984
|
+
if (address(elistHelper) == address(0)) {
|
|
985
|
+
elistHelper = new LibEListHelper();
|
|
986
|
+
vm.deal(address(elistHelper), 10 ether);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
function _allowHelperForList(elist list) internal {
|
|
991
|
+
inco.allow(elist.unwrap(list), address(elistHelper));
|
|
992
|
+
// Also allow individual elements
|
|
993
|
+
uint16 len = e.length(list);
|
|
994
|
+
for (uint16 i = 0; i < len; i++) {
|
|
995
|
+
bytes32 handle = inco.listGet(list, i);
|
|
996
|
+
inco.allow(handle, address(elistHelper));
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
function testEListWrapper_NewEListEmpty() public {
|
|
1001
|
+
_setupEListHelper();
|
|
1002
|
+
elist list = elistHelper.callNewEListEmpty(ETypes.Uint256);
|
|
1003
|
+
assertEq(e.length(list), 0);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
function testEListWrapper_NewEListFromHandles() public {
|
|
1007
|
+
_setupEListHelper();
|
|
1008
|
+
|
|
1009
|
+
elist rangeList = _listRange(0, 3);
|
|
1010
|
+
bytes32[] memory handles = new bytes32[](3);
|
|
1011
|
+
handles[0] = inco.listGet(rangeList, 0);
|
|
1012
|
+
handles[1] = inco.listGet(rangeList, 1);
|
|
1013
|
+
handles[2] = inco.listGet(rangeList, 2);
|
|
1014
|
+
// Grant permissions
|
|
1015
|
+
inco.allow(handles[0], address(elistHelper));
|
|
1016
|
+
inco.allow(handles[1], address(elistHelper));
|
|
1017
|
+
inco.allow(handles[2], address(elistHelper));
|
|
1018
|
+
|
|
1019
|
+
elist list = elistHelper.callNewEListFromHandles(handles, ETypes.Uint256);
|
|
1020
|
+
assertEq(e.length(list), 3);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
function testEListWrapper_NewEListFromCiphertexts() public {
|
|
1024
|
+
_setupEListHelper();
|
|
1025
|
+
|
|
1026
|
+
// Create ciphertexts for the list
|
|
1027
|
+
bytes[] memory ciphertexts = new bytes[](3);
|
|
1028
|
+
ciphertexts[0] = fakePrepareEuint256Ciphertext(10, address(elistHelper), address(elistHelper));
|
|
1029
|
+
ciphertexts[1] = fakePrepareEuint256Ciphertext(20, address(elistHelper), address(elistHelper));
|
|
1030
|
+
ciphertexts[2] = fakePrepareEuint256Ciphertext(30, address(elistHelper), address(elistHelper));
|
|
1031
|
+
|
|
1032
|
+
// Calculate fee: uses elist bit fee
|
|
1033
|
+
uint256 fee = inco.getEListFee(uint16(ciphertexts.length), ETypes.Uint256);
|
|
1034
|
+
|
|
1035
|
+
// Create the list from ciphertexts
|
|
1036
|
+
elist list =
|
|
1037
|
+
elistHelper.callNewEListFromCiphertexts{value: fee}(ciphertexts, ETypes.Uint256, address(elistHelper));
|
|
1038
|
+
|
|
1039
|
+
// Verify the list was created with correct length
|
|
1040
|
+
assertEq(e.length(list), 3);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
function testEListWrapper_AppendEuint256() public {
|
|
1044
|
+
_setupEListHelper();
|
|
1045
|
+
// Create a list and get a handle
|
|
1046
|
+
elist list = _listRange(0, 3);
|
|
1047
|
+
bytes32 valueHandle = inco.listGet(list, 0);
|
|
1048
|
+
euint256 value = euint256.wrap(valueHandle);
|
|
1049
|
+
// Grant permissions
|
|
1050
|
+
_allowHelperForList(list);
|
|
1051
|
+
|
|
1052
|
+
elist newList = elistHelper.callAppendEuint256(list, value);
|
|
1053
|
+
assertEq(e.length(newList), 4);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
function testEListWrapper_AppendEbool() public {
|
|
1057
|
+
_setupEListHelper();
|
|
1058
|
+
// Create a list and get a handle
|
|
1059
|
+
elist list = _listRange(0, 3);
|
|
1060
|
+
bytes32 valueHandle = inco.listGet(list, 0);
|
|
1061
|
+
ebool value = ebool.wrap(valueHandle);
|
|
1062
|
+
// Grant permissions
|
|
1063
|
+
_allowHelperForList(list);
|
|
1064
|
+
|
|
1065
|
+
elist newList = elistHelper.callAppendEbool(list, value);
|
|
1066
|
+
assertEq(e.length(newList), 4);
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
function testEListWrapper_SetHiddenIndexEuint256() public {
|
|
1070
|
+
_setupEListHelper();
|
|
1071
|
+
elist list = _listRange(0, 3);
|
|
1072
|
+
_allowHelperForList(list);
|
|
1073
|
+
euint256 idx = euint256.wrap(inco.listGet(list, 0)); // Use element as index
|
|
1074
|
+
euint256 value = euint256.wrap(inco.listGet(list, 1));
|
|
1075
|
+
|
|
1076
|
+
elist newList = elistHelper.callSetHiddenIndexEuint256(list, idx, value);
|
|
1077
|
+
assertEq(e.length(newList), 3);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
function testEListWrapper_SetHiddenIndexEbool() public {
|
|
1081
|
+
_setupEListHelper();
|
|
1082
|
+
elist list = _listRange(0, 3);
|
|
1083
|
+
_allowHelperForList(list);
|
|
1084
|
+
euint256 idx = euint256.wrap(inco.listGet(list, 0));
|
|
1085
|
+
ebool value = ebool.wrap(inco.listGet(list, 1));
|
|
1086
|
+
|
|
1087
|
+
elist newList = elistHelper.callSetHiddenIndexEbool(list, idx, value);
|
|
1088
|
+
assertEq(e.length(newList), 3);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
function testEListWrapper_SetPlaintextIndexEuint256() public {
|
|
1092
|
+
_setupEListHelper();
|
|
1093
|
+
elist list = _listRange(0, 3);
|
|
1094
|
+
_allowHelperForList(list);
|
|
1095
|
+
euint256 value = euint256.wrap(inco.listGet(list, 1));
|
|
1096
|
+
|
|
1097
|
+
elist newList = elistHelper.callSetPlaintextIndexEuint256(list, 0, value);
|
|
1098
|
+
assertEq(e.length(newList), 3);
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
function testEListWrapper_SetPlaintextIndexEbool() public {
|
|
1102
|
+
_setupEListHelper();
|
|
1103
|
+
elist list = _listRange(0, 3);
|
|
1104
|
+
_allowHelperForList(list);
|
|
1105
|
+
ebool value = ebool.wrap(inco.listGet(list, 1));
|
|
1106
|
+
|
|
1107
|
+
elist newList = elistHelper.callSetPlaintextIndexEbool(list, 0, value);
|
|
1108
|
+
assertEq(e.length(newList), 3);
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
function testEListWrapper_GetOrEuint256() public {
|
|
1112
|
+
_setupEListHelper();
|
|
1113
|
+
elist list = _listRange(0, 5);
|
|
1114
|
+
_allowHelperForList(list);
|
|
1115
|
+
euint256 idx = euint256.wrap(inco.listGet(list, 1));
|
|
1116
|
+
euint256 defaultValue = euint256.wrap(inco.listGet(list, 0));
|
|
1117
|
+
|
|
1118
|
+
euint256 result = elistHelper.callGetOrEuint256(list, idx, defaultValue);
|
|
1119
|
+
assertTrue(euint256.unwrap(result) != bytes32(0));
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
function testEListWrapper_GetOrEbool() public {
|
|
1123
|
+
_setupEListHelper();
|
|
1124
|
+
elist list = _listRange(0, 5);
|
|
1125
|
+
_allowHelperForList(list);
|
|
1126
|
+
euint256 idx = euint256.wrap(inco.listGet(list, 1));
|
|
1127
|
+
ebool defaultValue = ebool.wrap(inco.listGet(list, 0));
|
|
1128
|
+
|
|
1129
|
+
ebool result = elistHelper.callGetOrEbool(list, idx, defaultValue);
|
|
1130
|
+
assertTrue(ebool.unwrap(result) != bytes32(0));
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
function testEListWrapper_GetEuint256() public {
|
|
1134
|
+
_setupEListHelper();
|
|
1135
|
+
elist list = _listRange(0, 5);
|
|
1136
|
+
_allowHelperForList(list);
|
|
1137
|
+
|
|
1138
|
+
euint256 result = elistHelper.callGetEuint256(list, 2);
|
|
1139
|
+
assertTrue(euint256.unwrap(result) != bytes32(0));
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
function testEListWrapper_GetEbool() public {
|
|
1143
|
+
_setupEListHelper();
|
|
1144
|
+
elist list = _listRange(0, 5);
|
|
1145
|
+
_allowHelperForList(list);
|
|
1146
|
+
|
|
1147
|
+
ebool result = elistHelper.callGetEbool(list, 2);
|
|
1148
|
+
assertTrue(ebool.unwrap(result) != bytes32(0));
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
function testEListWrapper_InsertHiddenIndexEuint256() public {
|
|
1152
|
+
_setupEListHelper();
|
|
1153
|
+
elist list = _listRange(0, 3);
|
|
1154
|
+
_allowHelperForList(list);
|
|
1155
|
+
euint256 idx = euint256.wrap(inco.listGet(list, 0));
|
|
1156
|
+
euint256 value = euint256.wrap(inco.listGet(list, 1));
|
|
1157
|
+
|
|
1158
|
+
elist newList = elistHelper.callInsertHiddenIndexEuint256(list, idx, value);
|
|
1159
|
+
assertEq(e.length(newList), 4);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
function testEListWrapper_InsertHiddenIndexEbool() public {
|
|
1163
|
+
_setupEListHelper();
|
|
1164
|
+
elist list = _listRange(0, 3);
|
|
1165
|
+
_allowHelperForList(list);
|
|
1166
|
+
euint256 idx = euint256.wrap(inco.listGet(list, 0));
|
|
1167
|
+
ebool value = ebool.wrap(inco.listGet(list, 1));
|
|
1168
|
+
|
|
1169
|
+
elist newList = elistHelper.callInsertHiddenIndexEbool(list, idx, value);
|
|
1170
|
+
assertEq(e.length(newList), 4);
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
function testEListWrapper_InsertPlaintextIndexEuint256() public {
|
|
1174
|
+
_setupEListHelper();
|
|
1175
|
+
elist list = _listRange(0, 3);
|
|
1176
|
+
_allowHelperForList(list);
|
|
1177
|
+
euint256 value = euint256.wrap(inco.listGet(list, 1));
|
|
1178
|
+
|
|
1179
|
+
elist newList = elistHelper.callInsertPlaintextIndexEuint256(list, 1, value);
|
|
1180
|
+
assertEq(e.length(newList), 4);
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
function testEListWrapper_InsertPlaintextIndexEbool() public {
|
|
1184
|
+
_setupEListHelper();
|
|
1185
|
+
elist list = _listRange(0, 3);
|
|
1186
|
+
_allowHelperForList(list);
|
|
1187
|
+
ebool value = ebool.wrap(inco.listGet(list, 1));
|
|
1188
|
+
|
|
1189
|
+
elist newList = elistHelper.callInsertPlaintextIndexEbool(list, 1, value);
|
|
1190
|
+
assertEq(e.length(newList), 4);
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
function testEListWrapper_Concat() public {
|
|
1194
|
+
_setupEListHelper();
|
|
1195
|
+
elist list1 = _listRange(0, 3);
|
|
1196
|
+
elist list2 = _listRange(10, 13);
|
|
1197
|
+
_allowHelperForList(list1);
|
|
1198
|
+
_allowHelperForList(list2);
|
|
1199
|
+
|
|
1200
|
+
elist combined = elistHelper.callConcat(list1, list2);
|
|
1201
|
+
assertEq(e.length(combined), 6);
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
function testEListWrapper_Slice() public {
|
|
1205
|
+
_setupEListHelper();
|
|
1206
|
+
elist list = _listRange(0, 10);
|
|
1207
|
+
_allowHelperForList(list);
|
|
1208
|
+
|
|
1209
|
+
elist sliced = elistHelper.callSlice(list, 2, 7);
|
|
1210
|
+
assertEq(e.length(sliced), 5);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
function testEListWrapper_SliceLenEuint256() public {
|
|
1214
|
+
_setupEListHelper();
|
|
1215
|
+
elist list = _listRange(0, 10);
|
|
1216
|
+
_allowHelperForList(list);
|
|
1217
|
+
euint256 start = euint256.wrap(inco.listGet(list, 1));
|
|
1218
|
+
euint256 defaultValue = euint256.wrap(inco.listGet(list, 0));
|
|
1219
|
+
|
|
1220
|
+
elist sliced = elistHelper.callSliceLenEuint256(list, start, 3, defaultValue);
|
|
1221
|
+
assertEq(e.length(sliced), 3);
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
function testEListWrapper_SliceLenEbool() public {
|
|
1225
|
+
_setupEListHelper();
|
|
1226
|
+
elist list = _listRange(0, 10);
|
|
1227
|
+
_allowHelperForList(list);
|
|
1228
|
+
euint256 start = euint256.wrap(inco.listGet(list, 1));
|
|
1229
|
+
ebool defaultValue = ebool.wrap(inco.listGet(list, 0));
|
|
1230
|
+
|
|
1231
|
+
elist sliced = elistHelper.callSliceLenEbool(list, start, 3, defaultValue);
|
|
1232
|
+
assertEq(e.length(sliced), 3);
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
function testEListWrapper_Range() public {
|
|
1236
|
+
_setupEListHelper();
|
|
1237
|
+
elist list = elistHelper.callRange(5, 15);
|
|
1238
|
+
assertEq(e.length(list), 10);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
function testEListWrapper_Reverse() public {
|
|
1242
|
+
_setupEListHelper();
|
|
1243
|
+
elist list = _listRange(0, 5);
|
|
1244
|
+
_allowHelperForList(list);
|
|
1245
|
+
|
|
1246
|
+
elist reversed = elistHelper.callReverse(list);
|
|
1247
|
+
assertEq(e.length(reversed), 5);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
function testEListWrapper_Shuffle() public {
|
|
1251
|
+
_setupEListHelper();
|
|
1252
|
+
elist list = _listRange(0, 5);
|
|
1253
|
+
_allowHelperForList(list);
|
|
1254
|
+
|
|
1255
|
+
elist shuffled = elistHelper.callShuffle(list);
|
|
1256
|
+
assertEq(e.length(shuffled), 5);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
function testEListWrapper_ShuffledRange() public {
|
|
1260
|
+
_setupEListHelper();
|
|
1261
|
+
elist list = elistHelper.callShuffledRange(0, 10);
|
|
1262
|
+
assertEq(e.length(list), 10);
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
function testEListWrapper_Length() public {
|
|
1266
|
+
_setupEListHelper();
|
|
1267
|
+
elist list = _listRange(0, 7);
|
|
1268
|
+
assertEq(elistHelper.callLength(list), 7);
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
function testEListWrapper_ListTypeOf() public {
|
|
1272
|
+
_setupEListHelper();
|
|
1273
|
+
elist list = _listRange(0, 5);
|
|
1274
|
+
assertEq(uint8(elistHelper.callListTypeOf(list)), uint8(ETypes.Uint256));
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
// ============ ELIST REQUIRE/REVERT TESTS ============
|
|
1278
|
+
|
|
1279
|
+
function testEListWrapper_SetPlaintextIndexEuint256_RevertsOnOutOfRange() public {
|
|
1280
|
+
_setupEListHelper();
|
|
1281
|
+
elist list = _listRange(0, 3); // length 3, valid indices 0-2
|
|
1282
|
+
_allowHelperForList(list);
|
|
1283
|
+
euint256 value = euint256.wrap(inco.listGet(list, 0));
|
|
1284
|
+
|
|
1285
|
+
// Index 3 is out of range for a list of length 3
|
|
1286
|
+
vm.expectRevert(abi.encodeWithSelector(IndexOutOfRange.selector, 3, 3));
|
|
1287
|
+
elistHelper.callSetPlaintextIndexEuint256(list, 3, value);
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
function testEListWrapper_SetPlaintextIndexEbool_RevertsOnOutOfRange() public {
|
|
1291
|
+
_setupEListHelper();
|
|
1292
|
+
elist list = _listRange(0, 3);
|
|
1293
|
+
_allowHelperForList(list);
|
|
1294
|
+
ebool value = ebool.wrap(inco.listGet(list, 0));
|
|
1295
|
+
|
|
1296
|
+
vm.expectRevert(abi.encodeWithSelector(IndexOutOfRange.selector, 5, 3));
|
|
1297
|
+
elistHelper.callSetPlaintextIndexEbool(list, 5, value);
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
function testEListWrapper_InsertPlaintextIndexEbool_RevertsOnOutOfRange() public {
|
|
1301
|
+
_setupEListHelper();
|
|
1302
|
+
elist list = _listRange(0, 3);
|
|
1303
|
+
_allowHelperForList(list);
|
|
1304
|
+
ebool value = ebool.wrap(inco.listGet(list, 0));
|
|
1305
|
+
|
|
1306
|
+
vm.expectRevert(abi.encodeWithSelector(IndexOutOfRange.selector, 10, 3));
|
|
1307
|
+
elistHelper.callInsertPlaintextIndexEbool(list, 10, value);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
function testEListWrapper_InsertPlaintextIndexEuint256_RevertsOnOutOfRange() public {
|
|
1311
|
+
_setupEListHelper();
|
|
1312
|
+
elist list = _listRange(0, 3);
|
|
1313
|
+
_allowHelperForList(list);
|
|
1314
|
+
euint256 value = euint256.wrap(inco.listGet(list, 0));
|
|
1315
|
+
|
|
1316
|
+
vm.expectRevert(abi.encodeWithSelector(IndexOutOfRange.selector, 3, 3));
|
|
1317
|
+
elistHelper.callInsertPlaintextIndexEuint256(list, 3, value);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
function testEListWrapper_Slice_RevertsOnInvalidRange() public {
|
|
1321
|
+
_setupEListHelper();
|
|
1322
|
+
elist list = _listRange(0, 10);
|
|
1323
|
+
_allowHelperForList(list);
|
|
1324
|
+
|
|
1325
|
+
// end < start is invalid
|
|
1326
|
+
vm.expectRevert(abi.encodeWithSelector(InvalidRange.selector, 5, 3));
|
|
1327
|
+
elistHelper.callSlice(list, 5, 3);
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
function testEListWrapper_Slice_RevertsOnEndOutOfRange() public {
|
|
1331
|
+
_setupEListHelper();
|
|
1332
|
+
elist list = _listRange(0, 5); // length 5
|
|
1333
|
+
_allowHelperForList(list);
|
|
1334
|
+
|
|
1335
|
+
// end > length is out of range
|
|
1336
|
+
vm.expectRevert(abi.encodeWithSelector(SliceOutOfRange.selector, 2, 10, 5));
|
|
1337
|
+
elistHelper.callSlice(list, 2, 10);
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
function testEListWrapper_Slice_RevertsOnStartOutOfRange() public {
|
|
1341
|
+
_setupEListHelper();
|
|
1342
|
+
elist list = _listRange(0, 5); // length 5
|
|
1343
|
+
_allowHelperForList(list);
|
|
1344
|
+
|
|
1345
|
+
// start >= length is out of range
|
|
1346
|
+
vm.expectRevert(abi.encodeWithSelector(SliceOutOfRange.selector, 5, 5, 5));
|
|
1347
|
+
elistHelper.callSlice(list, 5, 5);
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
function testEListWrapper_Slice_WorksWithEboolList() public {
|
|
1351
|
+
_setupEListHelper();
|
|
1352
|
+
|
|
1353
|
+
ebool val1 = e.asEbool(true);
|
|
1354
|
+
ebool val2 = e.asEbool(false);
|
|
1355
|
+
ebool val3 = e.asEbool(true);
|
|
1356
|
+
processAllOperations();
|
|
1357
|
+
|
|
1358
|
+
bytes32[] memory handles = new bytes32[](3);
|
|
1359
|
+
handles[0] = ebool.unwrap(val1);
|
|
1360
|
+
handles[1] = ebool.unwrap(val2);
|
|
1361
|
+
handles[2] = ebool.unwrap(val3);
|
|
1362
|
+
inco.allow(handles[0], address(elistHelper));
|
|
1363
|
+
inco.allow(handles[1], address(elistHelper));
|
|
1364
|
+
inco.allow(handles[2], address(elistHelper));
|
|
1365
|
+
|
|
1366
|
+
elist boolList = _newEList(handles, ETypes.Bool);
|
|
1367
|
+
_allowHelperForList(boolList);
|
|
1368
|
+
|
|
1369
|
+
// Slice should work and use ebool default value branch
|
|
1370
|
+
elist sliced = elistHelper.callSlice(boolList, 0, 2);
|
|
1371
|
+
assertEq(e.length(sliced), 2);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
function testEListWrapper_Slice_RevertsOnUnsupportedListType() public {
|
|
1375
|
+
_setupEListHelper();
|
|
1376
|
+
|
|
1377
|
+
eaddress addr1 = e.asEaddress(address(0x1));
|
|
1378
|
+
eaddress addr2 = e.asEaddress(address(0x2));
|
|
1379
|
+
eaddress addr3 = e.asEaddress(address(0x3));
|
|
1380
|
+
processAllOperations();
|
|
1381
|
+
|
|
1382
|
+
bytes32[] memory handles = new bytes32[](3);
|
|
1383
|
+
handles[0] = eaddress.unwrap(addr1);
|
|
1384
|
+
handles[1] = eaddress.unwrap(addr2);
|
|
1385
|
+
handles[2] = eaddress.unwrap(addr3);
|
|
1386
|
+
inco.allow(handles[0], address(elistHelper));
|
|
1387
|
+
inco.allow(handles[1], address(elistHelper));
|
|
1388
|
+
inco.allow(handles[2], address(elistHelper));
|
|
1389
|
+
|
|
1390
|
+
elist unsupportedList = _newEList(handles, ETypes.AddressOrUint160OrBytes20);
|
|
1391
|
+
_allowHelperForList(unsupportedList);
|
|
1392
|
+
|
|
1393
|
+
// Slice should revert with UnsupportedListType
|
|
1394
|
+
vm.expectRevert(abi.encodeWithSelector(UnsupportedListType.selector, ETypes.AddressOrUint160OrBytes20));
|
|
1395
|
+
elistHelper.callSlice(unsupportedList, 0, 2);
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
// ============ VERIFY ELIST DECRYPTION TEST ============
|
|
1399
|
+
|
|
1400
|
+
function testEListWrapper_VerifyEListDecryption() public {
|
|
1401
|
+
_setupEListHelper();
|
|
1402
|
+
|
|
1403
|
+
elist list = _listRange(0, 3);
|
|
1404
|
+
|
|
1405
|
+
// Create empty proof elements (for basic verification test)
|
|
1406
|
+
ElementAttestationWithProof[] memory proofElements = new ElementAttestationWithProof[](0);
|
|
1407
|
+
bytes32 proof = bytes32(0);
|
|
1408
|
+
bytes[] memory signatures = new bytes[](0);
|
|
1409
|
+
|
|
1410
|
+
// This should return false with empty/invalid data
|
|
1411
|
+
bool result = elistHelper.callVerifyEListDecryption(list, proofElements, proof, signatures);
|
|
1412
|
+
assertFalse(result, "Empty proof should fail verification");
|
|
1413
|
+
}
|
|
1414
|
+
|
|
771
1415
|
}
|
|
772
1416
|
|
|
773
1417
|
/// @notice Helper contract for testing msg.sender variants
|
|
@@ -792,3 +1436,180 @@ contract LibTestHelper {
|
|
|
792
1436
|
}
|
|
793
1437
|
|
|
794
1438
|
}
|
|
1439
|
+
|
|
1440
|
+
/// @notice Helper contract for testing e.* EList wrapper functions
|
|
1441
|
+
/// @dev Uses inco.* to create handles, then calls e.* wrappers with non-zero handles
|
|
1442
|
+
contract LibEListHelper {
|
|
1443
|
+
|
|
1444
|
+
using e for euint256;
|
|
1445
|
+
using e for ebool;
|
|
1446
|
+
using e for elist;
|
|
1447
|
+
|
|
1448
|
+
elist public storedList;
|
|
1449
|
+
euint256 public storedEuint256;
|
|
1450
|
+
ebool public storedEbool;
|
|
1451
|
+
|
|
1452
|
+
// ============ newEList wrappers ============
|
|
1453
|
+
|
|
1454
|
+
function callNewEListEmpty(ETypes listType) external returns (elist) {
|
|
1455
|
+
storedList = e.newEList(listType);
|
|
1456
|
+
return storedList;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
function callNewEListFromHandles(bytes32[] memory handles, ETypes listType) external returns (elist) {
|
|
1460
|
+
storedList = e.newEList(handles, listType);
|
|
1461
|
+
return storedList;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
function callNewEListFromCiphertexts(bytes[] memory ciphertexts, ETypes listType, address user)
|
|
1465
|
+
external
|
|
1466
|
+
payable
|
|
1467
|
+
returns (elist)
|
|
1468
|
+
{
|
|
1469
|
+
storedList = e.newEList(ciphertexts, listType, user);
|
|
1470
|
+
return storedList;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
// ============ append wrappers ============
|
|
1474
|
+
|
|
1475
|
+
function callAppendEuint256(elist list, euint256 value) external returns (elist) {
|
|
1476
|
+
storedList = e.append(list, value);
|
|
1477
|
+
return storedList;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
function callAppendEbool(elist list, ebool value) external returns (elist) {
|
|
1481
|
+
storedList = e.append(list, value);
|
|
1482
|
+
return storedList;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
// ============ set wrappers ============
|
|
1486
|
+
|
|
1487
|
+
function callSetHiddenIndexEuint256(elist list, euint256 idx, euint256 value) external returns (elist) {
|
|
1488
|
+
storedList = e.set(list, idx, value);
|
|
1489
|
+
return storedList;
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
function callSetHiddenIndexEbool(elist list, euint256 idx, ebool value) external returns (elist) {
|
|
1493
|
+
storedList = e.set(list, idx, value);
|
|
1494
|
+
return storedList;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
function callSetPlaintextIndexEuint256(elist list, uint16 idx, euint256 value) external returns (elist) {
|
|
1498
|
+
storedList = e.set(list, idx, value);
|
|
1499
|
+
return storedList;
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
function callSetPlaintextIndexEbool(elist list, uint16 idx, ebool value) external returns (elist) {
|
|
1503
|
+
storedList = e.set(list, idx, value);
|
|
1504
|
+
return storedList;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
// ============ getOr wrappers ============
|
|
1508
|
+
|
|
1509
|
+
function callGetOrEuint256(elist list, euint256 idx, euint256 defaultValue) external returns (euint256) {
|
|
1510
|
+
storedEuint256 = e.getOr(list, idx, defaultValue);
|
|
1511
|
+
return storedEuint256;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
function callGetOrEbool(elist list, euint256 idx, ebool defaultValue) external returns (ebool) {
|
|
1515
|
+
storedEbool = e.getOr(list, idx, defaultValue);
|
|
1516
|
+
return storedEbool;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
// ============ get wrappers ============
|
|
1520
|
+
|
|
1521
|
+
function callGetEuint256(elist list, uint16 idx) external returns (euint256) {
|
|
1522
|
+
storedEuint256 = e.getEuint256(list, idx);
|
|
1523
|
+
return storedEuint256;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
function callGetEbool(elist list, uint16 idx) external returns (ebool) {
|
|
1527
|
+
storedEbool = e.getEbool(list, idx);
|
|
1528
|
+
return storedEbool;
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
// ============ insert wrappers ============
|
|
1532
|
+
|
|
1533
|
+
function callInsertHiddenIndexEuint256(elist list, euint256 idx, euint256 value) external returns (elist) {
|
|
1534
|
+
storedList = e.insert(list, idx, value);
|
|
1535
|
+
return storedList;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
function callInsertHiddenIndexEbool(elist list, euint256 idx, ebool value) external returns (elist) {
|
|
1539
|
+
storedList = e.insert(list, idx, value);
|
|
1540
|
+
return storedList;
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
function callInsertPlaintextIndexEuint256(elist list, uint16 idx, euint256 value) external returns (elist) {
|
|
1544
|
+
storedList = e.insert(list, idx, value);
|
|
1545
|
+
return storedList;
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
function callInsertPlaintextIndexEbool(elist list, uint16 idx, ebool value) external returns (elist) {
|
|
1549
|
+
storedList = e.insert(list, idx, value);
|
|
1550
|
+
return storedList;
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
// ============ other list operations ============
|
|
1554
|
+
|
|
1555
|
+
function callConcat(elist list1, elist list2) external returns (elist) {
|
|
1556
|
+
storedList = e.concat(list1, list2);
|
|
1557
|
+
return storedList;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
function callSlice(elist list, uint16 start, uint16 end) external returns (elist) {
|
|
1561
|
+
storedList = e.slice(list, start, end);
|
|
1562
|
+
return storedList;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
function callSliceLenEuint256(elist list, euint256 start, uint16 len, euint256 defaultValue)
|
|
1566
|
+
external
|
|
1567
|
+
returns (elist)
|
|
1568
|
+
{
|
|
1569
|
+
storedList = e.sliceLen(list, start, len, defaultValue);
|
|
1570
|
+
return storedList;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
function callSliceLenEbool(elist list, euint256 start, uint16 len, ebool defaultValue) external returns (elist) {
|
|
1574
|
+
storedList = e.sliceLen(list, start, len, defaultValue);
|
|
1575
|
+
return storedList;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
function callRange(uint16 start, uint16 end) external returns (elist) {
|
|
1579
|
+
storedList = e.range(start, end);
|
|
1580
|
+
return storedList;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
function callShuffle(elist list) external returns (elist) {
|
|
1584
|
+
storedList = e.shuffle(list);
|
|
1585
|
+
return storedList;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
function callShuffledRange(uint16 start, uint16 end) external returns (elist) {
|
|
1589
|
+
storedList = e.shuffledRange(start, end);
|
|
1590
|
+
return storedList;
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
function callReverse(elist list) external returns (elist) {
|
|
1594
|
+
storedList = e.reverse(list);
|
|
1595
|
+
return storedList;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
function callLength(elist list) external pure returns (uint16) {
|
|
1599
|
+
return e.length(list);
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
function callListTypeOf(elist list) external pure returns (ETypes) {
|
|
1603
|
+
return e.listTypeOf(list);
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
function callVerifyEListDecryption(
|
|
1607
|
+
elist elistHandle,
|
|
1608
|
+
ElementAttestationWithProof[] memory proofElements,
|
|
1609
|
+
bytes32 proof,
|
|
1610
|
+
bytes[] memory signatures
|
|
1611
|
+
) external view returns (bool) {
|
|
1612
|
+
return e.verifyEListDecryption(elistHandle, proofElements, proof, signatures);
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
}
|