@inco/lightning 0.8.0-devnet-9 → 0.8.0-devnet-11

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.
Files changed (43) hide show
  1. package/manifest.yaml +22 -0
  2. package/package.json +1 -1
  3. package/src/IncoLightning.sol +2 -11
  4. package/src/Lib.alphanet.sol +261 -2
  5. package/src/Lib.demonet.sol +261 -2
  6. package/src/Lib.devnet.sol +262 -3
  7. package/src/Lib.sol +262 -3
  8. package/src/Lib.template.sol +283 -2
  9. package/src/Lib.testnet.sol +261 -2
  10. package/src/Types.sol +13 -0
  11. package/src/interfaces/IIncoLightning.sol +2 -12
  12. package/src/libs/incoLightning_alphanet_v0_297966649.sol +261 -2
  13. package/src/libs/incoLightning_alphanet_v1_725458969.sol +261 -2
  14. package/src/libs/incoLightning_alphanet_v2_976644394.sol +261 -2
  15. package/src/libs/incoLightning_demonet_v0_863421733.sol +261 -2
  16. package/src/libs/incoLightning_demonet_v2_467437523.sol +261 -2
  17. package/src/libs/incoLightning_devnet_v0_340846814.sol +261 -2
  18. package/src/libs/incoLightning_devnet_v1_904635675.sol +261 -2
  19. package/src/libs/incoLightning_devnet_v2_295237520.sol +261 -2
  20. package/src/libs/incoLightning_devnet_v3_976859633.sol +261 -2
  21. package/src/libs/incoLightning_devnet_v4_409204766.sol +261 -2
  22. package/src/libs/incoLightning_devnet_v5_203964628.sol +261 -2
  23. package/src/libs/incoLightning_devnet_v6_281949651.sol +1201 -0
  24. package/src/libs/incoLightning_testnet_v0_183408998.sol +261 -2
  25. package/src/libs/incoLightning_testnet_v2_889158349.sol +261 -2
  26. package/src/lightning-parts/AccessControl/interfaces/IBaseAccessControlList.sol +2 -1
  27. package/src/lightning-parts/DecryptionAttester.sol +38 -2
  28. package/src/lightning-parts/DecryptionAttester.types.sol +14 -0
  29. package/src/lightning-parts/EList.sol +323 -0
  30. package/src/lightning-parts/TrivialEncryption.sol +1 -2
  31. package/src/lightning-parts/interfaces/IDecryptionAttester.sol +7 -1
  32. package/src/lightning-parts/interfaces/IEList.sol +35 -0
  33. package/src/lightning-parts/interfaces/IEncryptedInput.sol +3 -1
  34. package/src/lightning-parts/interfaces/IEncryptedOperations.sol +3 -1
  35. package/src/lightning-parts/interfaces/ITrivialEncryption.sol +3 -1
  36. package/src/lightning-parts/primitives/EListHandleGeneration.sol +63 -0
  37. package/src/lightning-parts/primitives/EListHandleMetadata.sol +60 -0
  38. package/src/lightning-parts/primitives/interfaces/IEListHandleMetadata.sol +8 -0
  39. package/src/lightning-parts/test/Elist.t.sol +67 -0
  40. package/src/misc/ABIHelper.sol +15 -0
  41. package/src/shared/TestUtils.sol +8 -1
  42. package/src/test/EListTester.sol +148 -0
  43. package/src/version/IncoLightningConfig.sol +1 -1
@@ -3,8 +3,13 @@ pragma solidity ^0.8;
3
3
 
4
4
  import {Test} from "forge-std/Test.sol";
5
5
 
6
+ /// @title TestUtils
7
+ /// @notice WARNING: This contract contains TEST KEYS for LOCAL DEVELOPMENT ONLY.
8
+ /// @dev These keys are publicly known Anvil accounts and have NO security value.
9
+ /// NEVER use these keys on production networks - anyone can derive the private keys.
6
10
  contract TestUtils is Test {
7
11
 
12
+ // WARNING: Well-known Anvil account #0 - publicly known private key, DO NOT use in production
8
13
  address private constant ANVIL_ZEROTH_ADDRESS = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266;
9
14
  uint256 private constant ANVIL_ZEROTH_PRIVATE_KEY =
10
15
  0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80;
@@ -20,7 +25,9 @@ contract TestUtils is Test {
20
25
  uint256 internal evePrivKey;
21
26
  address internal immutable eve;
22
27
 
23
- // it is convenient for e2e tests to use these well-known addresses for the TEE
28
+ // WARNING: These are well-known Anvil test keys with publicly known private keys.
29
+ // They are convenient for e2e tests but have NO security value.
30
+ // Deploy.s.sol has safeguards to prevent using these on non-test chains.
24
31
  address internal teeEOA = ANVIL_ZEROTH_ADDRESS;
25
32
  uint256 internal teePrivKey = ANVIL_ZEROTH_PRIVATE_KEY;
26
33
 
@@ -0,0 +1,148 @@
1
+ // SPDX-License-Identifier: No License
2
+ pragma solidity ^0.8;
3
+
4
+ import {IIncoLightning} from "../interfaces/IIncoLightning.sol";
5
+ /// forge-lint: disable-next-line(unused-import)
6
+ import {ETypes, elist} from "../Types.sol";
7
+ import {euint256} from "../Types.sol";
8
+ import {IncoUtils, FEE} from "../periphery/IncoUtils.sol";
9
+
10
+ contract ElistTester is IncoUtils {
11
+
12
+ /// forge-lint: disable-next-line(screaming-snake-case-immutable)
13
+ IIncoLightning immutable inco;
14
+
15
+ constructor(IIncoLightning _inco) {
16
+ inco = _inco;
17
+ }
18
+
19
+ elist public list;
20
+ elist public newRangeList;
21
+
22
+ function newEList(bytes[] memory inputs, ETypes listType, address user)
23
+ public
24
+ payable
25
+ refundUnspent
26
+ returns (elist)
27
+ {
28
+ list = inco.newEList{value: FEE * inputs.length}(inputs, listType, user);
29
+ inco.allow(elist.unwrap(list), address(this));
30
+ inco.allow(elist.unwrap(list), address(msg.sender));
31
+ return list;
32
+ }
33
+
34
+ function listAppend(bytes memory ctValue) public payable refundUnspent returns (elist) {
35
+ euint256 handle = inco.newEuint256{value: FEE}(ctValue, msg.sender);
36
+ inco.allow(euint256.unwrap(handle), address(this));
37
+ inco.allow(euint256.unwrap(handle), address(msg.sender));
38
+ list = inco.listAppend(list, euint256.unwrap(handle));
39
+ inco.allow(elist.unwrap(list), address(this));
40
+ inco.allow(elist.unwrap(list), address(msg.sender));
41
+ return list;
42
+ }
43
+
44
+ function listGet(uint16 index) public returns (bytes32) {
45
+ bytes32 res = inco.listGet(list, index);
46
+ inco.allow(res, msg.sender);
47
+ return res;
48
+ }
49
+
50
+ function newEList(bytes32[] memory handles, ETypes listType) public payable refundUnspent returns (elist) {
51
+ list = inco.newEList(handles, listType);
52
+ inco.allow(elist.unwrap(list), address(this));
53
+ inco.allow(elist.unwrap(list), address(msg.sender));
54
+ return list;
55
+ }
56
+
57
+ function listGetOr(bytes memory ctIndex, bytes memory ctDefaultValue)
58
+ public
59
+ payable
60
+ refundUnspent
61
+ returns (bytes32)
62
+ {
63
+ euint256 index = inco.newEuint256{value: FEE}(ctIndex, msg.sender);
64
+ euint256 defaultValue = inco.newEuint256{value: FEE}(ctDefaultValue, msg.sender);
65
+ bytes32 res = inco.listGetOr(list, euint256.unwrap(index), euint256.unwrap(defaultValue));
66
+ inco.allow(res, msg.sender);
67
+ return res;
68
+ }
69
+
70
+ function listSet(bytes memory ctIndex, bytes memory ctValue) public payable refundUnspent returns (elist) {
71
+ euint256 index = inco.newEuint256{value: FEE}(ctIndex, msg.sender);
72
+ euint256 value = inco.newEuint256{value: FEE}(ctValue, msg.sender);
73
+ list = inco.listSet(list, euint256.unwrap(index), euint256.unwrap(value));
74
+ inco.allow(elist.unwrap(list), address(this));
75
+ inco.allow(elist.unwrap(list), address(msg.sender));
76
+ return list;
77
+ }
78
+
79
+ function listInsert(bytes memory ctIndex, bytes memory ctValue) public payable refundUnspent returns (elist) {
80
+ euint256 index = inco.newEuint256{value: FEE}(ctIndex, msg.sender);
81
+ euint256 value = inco.newEuint256{value: FEE}(ctValue, msg.sender);
82
+ list = inco.listInsert(list, euint256.unwrap(index), euint256.unwrap(value));
83
+ inco.allow(elist.unwrap(list), address(this));
84
+ inco.allow(elist.unwrap(list), address(msg.sender));
85
+ return list;
86
+ }
87
+
88
+ function listConcat(bytes[] memory cts, ETypes listType, address user)
89
+ public
90
+ payable
91
+ refundUnspent
92
+ returns (elist)
93
+ {
94
+ elist rhs = inco.newEList{value: FEE * cts.length}(cts, listType, user);
95
+ inco.allow(elist.unwrap(rhs), address(this));
96
+ inco.allow(elist.unwrap(rhs), address(msg.sender));
97
+ list = inco.listConcat(list, rhs);
98
+ inco.allow(elist.unwrap(list), address(this));
99
+ inco.allow(elist.unwrap(list), address(msg.sender));
100
+ return list;
101
+ }
102
+
103
+ function listSlice(bytes memory ctStart, uint16 len, bytes memory ctDefaultValue)
104
+ public
105
+ payable
106
+ refundUnspent
107
+ returns (elist)
108
+ {
109
+ euint256 start = inco.newEuint256{value: FEE}(ctStart, msg.sender);
110
+ euint256 defaultValue = inco.newEuint256{value: FEE}(ctDefaultValue, msg.sender);
111
+ list = inco.listSlice(list, euint256.unwrap(start), len, euint256.unwrap(defaultValue));
112
+ inco.allow(elist.unwrap(list), address(this));
113
+ inco.allow(elist.unwrap(list), address(msg.sender));
114
+ return list;
115
+ }
116
+
117
+ function listRange(uint16 start, uint16 end) public returns (elist) {
118
+ newRangeList = inco.listRange(start, end);
119
+ inco.allow(elist.unwrap(newRangeList), address(this));
120
+ inco.allow(elist.unwrap(newRangeList), address(msg.sender));
121
+ return newRangeList;
122
+ }
123
+
124
+ function listGetRange(uint16 index) public returns (bytes32) {
125
+ bytes32 res = inco.listGet(newRangeList, index);
126
+ inco.allow(res, msg.sender);
127
+ return res;
128
+ }
129
+
130
+ function listShuffle() public payable refundUnspent returns (elist) {
131
+ list = inco.listShuffle{value: FEE}(list);
132
+ inco.allow(elist.unwrap(list), address(this));
133
+ inco.allow(elist.unwrap(list), address(msg.sender));
134
+ return list;
135
+ }
136
+
137
+ function listReverse() public returns (elist) {
138
+ list = inco.listReverse(list);
139
+ inco.allow(elist.unwrap(list), address(this));
140
+ inco.allow(elist.unwrap(list), address(msg.sender));
141
+ return list;
142
+ }
143
+
144
+ receive() external payable {
145
+ // Allow contract to receive ETH
146
+ }
147
+
148
+ }
@@ -7,7 +7,7 @@ pragma solidity ^0.8;
7
7
  // UPDATE the CHANGELOG on new versions
8
8
 
9
9
  string constant CONTRACT_NAME = "incoLightning";
10
- uint8 constant MAJOR_VERSION = 5;
10
+ uint8 constant MAJOR_VERSION = 6;
11
11
  uint8 constant MINOR_VERSION = 0;
12
12
  // whenever a new version is deployed, we need to pump this up
13
13
  // otherwise make test_upgrade will fail