@inco/lightning 0.8.0-devnet-8 → 0.8.0-devnet-10
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 +44 -0
- package/package.json +1 -1
- package/src/CreateXHelper.sol +1 -1
- package/src/IncoLightning.sol +9 -18
- package/src/IncoVerifier.sol +1 -1
- package/src/Lib.alphanet.sol +261 -2
- package/src/Lib.demonet.sol +261 -2
- package/src/Lib.devnet.sol +262 -3
- package/src/Lib.sol +262 -3
- package/src/Lib.template.sol +283 -2
- package/src/Lib.testnet.sol +261 -2
- package/src/Types.sol +13 -0
- package/src/interfaces/IIncoLightning.sol +2 -12
- package/src/interfaces/automata-interfaces/BELE.sol +1 -1
- package/src/interfaces/automata-interfaces/IPCCSRouter.sol +1 -1
- package/src/interfaces/automata-interfaces/IPcsDao.sol +1 -1
- package/src/interfaces/automata-interfaces/IQuoteVerifier.sol +1 -1
- package/src/interfaces/automata-interfaces/Types.sol +1 -1
- package/src/libs/incoLightning_alphanet_v0_297966649.sol +261 -2
- package/src/libs/incoLightning_alphanet_v1_725458969.sol +261 -2
- package/src/libs/incoLightning_alphanet_v2_976644394.sol +261 -2
- package/src/libs/incoLightning_demonet_v0_863421733.sol +261 -2
- package/src/libs/incoLightning_demonet_v2_467437523.sol +261 -2
- package/src/libs/incoLightning_devnet_v0_340846814.sol +261 -2
- package/src/libs/incoLightning_devnet_v1_904635675.sol +261 -2
- package/src/libs/incoLightning_devnet_v2_295237520.sol +261 -2
- package/src/libs/incoLightning_devnet_v3_976859633.sol +261 -2
- package/src/libs/incoLightning_devnet_v4_409204766.sol +261 -2
- package/src/libs/incoLightning_devnet_v5_203964628.sol +1201 -0
- package/src/libs/incoLightning_devnet_v6_281949651.sol +1201 -0
- package/src/libs/incoLightning_testnet_v0_183408998.sol +261 -2
- package/src/libs/incoLightning_testnet_v2_889158349.sol +261 -2
- package/src/lightning-parts/AccessControl/AdvancedAccessControl.sol +4 -0
- package/src/lightning-parts/AccessControl/interfaces/IBaseAccessControlList.sol +2 -1
- package/src/lightning-parts/AccessControl/test/TestAdvancedAccessControl.t.sol +15 -0
- package/src/lightning-parts/DecryptionAttester.sol +38 -2
- package/src/lightning-parts/DecryptionAttester.types.sol +14 -0
- package/src/lightning-parts/EList.sol +323 -0
- package/src/lightning-parts/TEELifecycle.sol +1 -1
- package/src/lightning-parts/TEELifecycle.types.sol +1 -1
- package/src/lightning-parts/TrivialEncryption.sol +1 -2
- package/src/lightning-parts/interfaces/IDecryptionAttester.sol +7 -1
- package/src/lightning-parts/interfaces/IEList.sol +35 -0
- package/src/lightning-parts/interfaces/IEncryptedInput.sol +3 -1
- package/src/lightning-parts/interfaces/IEncryptedOperations.sol +3 -1
- package/src/lightning-parts/interfaces/ITEELifecycle.sol +1 -1
- package/src/lightning-parts/interfaces/ITrivialEncryption.sol +3 -1
- package/src/lightning-parts/primitives/EListHandleGeneration.sol +63 -0
- package/src/lightning-parts/primitives/EListHandleMetadata.sol +60 -0
- package/src/lightning-parts/primitives/interfaces/IEListHandleMetadata.sol +8 -0
- package/src/lightning-parts/test/Elist.t.sol +67 -0
- package/src/misc/ABIHelper.sol +15 -0
- package/src/pasted-dependencies/ICreateX.sol +1 -1
- package/src/periphery/SessionVerifier.sol +4 -4
- package/src/shared/IOwnable.sol +1 -1
- package/src/shared/IUUPSUpgradable.sol +1 -1
- package/src/shared/TestUtils.sol +8 -1
- package/src/test/EListTester.sol +148 -0
- package/src/test/TEELifecycle/TEELifecycleMockTest.t.sol +1 -1
- package/src/test/TestUpgrade.t.sol +1 -1
- package/src/version/IncoLightningConfig.sol +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import {IncoTest} from "../../test/IncoTest.sol";
|
|
5
|
+
import {ElistTester} from "../../test/EListTester.sol";
|
|
6
|
+
import {inco, e} from "../../Lib.sol";
|
|
7
|
+
import {ETypes, elist} from "../../Types.sol";
|
|
8
|
+
import {FEE, Fee} from "../Fee.sol";
|
|
9
|
+
import {EList} from "../EList.sol";
|
|
10
|
+
import {VerifierAddressGetter} from "../primitives/VerifierAddressGetter.sol";
|
|
11
|
+
|
|
12
|
+
contract ElistFeeTester is EList {
|
|
13
|
+
|
|
14
|
+
constructor() VerifierAddressGetter(address(0)) {}
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
contract TestEList is IncoTest {
|
|
19
|
+
|
|
20
|
+
ElistTester tester;
|
|
21
|
+
ElistFeeTester feeTester;
|
|
22
|
+
|
|
23
|
+
function setUp() public virtual override {
|
|
24
|
+
super.setUp();
|
|
25
|
+
tester = new ElistTester(inco);
|
|
26
|
+
vm.deal(address(tester), 1 ether);
|
|
27
|
+
feeTester = new ElistFeeTester();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function testNewElistFromInputs() public {
|
|
31
|
+
createList();
|
|
32
|
+
// todo test read the created list
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function testListAppend() public {
|
|
36
|
+
createList();
|
|
37
|
+
bytes memory ctValue = fakePrepareEuint256Ciphertext(40, address(this), address(tester));
|
|
38
|
+
tester.listAppend(ctValue);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function createList() internal returns (elist list) {
|
|
42
|
+
bytes[] memory inputs = new bytes[](3);
|
|
43
|
+
inputs[0] = fakePrepareEuint256Ciphertext(10, address(this), address(tester));
|
|
44
|
+
inputs[1] = fakePrepareEuint256Ciphertext(20, address(this), address(tester));
|
|
45
|
+
inputs[2] = fakePrepareEuint256Ciphertext(30, address(this), address(tester));
|
|
46
|
+
list = tester.newEList(inputs, ETypes.Uint256, address(this));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function testRevertsOnBadFeeAmount() public {
|
|
50
|
+
// should fail if no fee
|
|
51
|
+
vm.expectRevert(Fee.FeeNotPaid.selector);
|
|
52
|
+
feeTester.listShuffle(elist.wrap(bytes32(0)));
|
|
53
|
+
|
|
54
|
+
// should fail if not enough fee
|
|
55
|
+
vm.expectRevert(Fee.FeeNotPaid.selector);
|
|
56
|
+
feeTester.listShuffle{value: FEE - 1}(elist.wrap(bytes32(0)));
|
|
57
|
+
|
|
58
|
+
// should fail if too much fee
|
|
59
|
+
vm.expectRevert(Fee.FeeNotPaid.selector);
|
|
60
|
+
feeTester.listShuffle{value: FEE + 1}(elist.wrap(bytes32(0)));
|
|
61
|
+
|
|
62
|
+
vm.expectRevert(Fee.FeeNotPaid.selector);
|
|
63
|
+
bytes[] memory inputs = new bytes[](3);
|
|
64
|
+
feeTester.newEList{value: FEE * 2}(inputs, ETypes.Uint256, address(this));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import {Session} from "@inco/lightning/src/periphery/SessionVerifier.sol";
|
|
5
|
+
|
|
6
|
+
// @dev this contract is not used on-chain, it is only used to generate the
|
|
7
|
+
// ABI of some symbols that are not exposed directly by the IncoLightning or
|
|
8
|
+
// periphery contracts, but are needed for the JS SDK.
|
|
9
|
+
contract ABIHelper {
|
|
10
|
+
|
|
11
|
+
function getSession() public pure returns (Session memory) {
|
|
12
|
+
revert("This function exists only to include Session struct in ABI");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: No License
|
|
2
|
-
pragma solidity ^0.8;
|
|
2
|
+
pragma solidity ^0.8.29;
|
|
3
3
|
|
|
4
4
|
import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
5
5
|
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
@@ -38,13 +38,13 @@ struct Session {
|
|
|
38
38
|
contract SessionVerifier is UUPSUpgradeable, OwnableUpgradeable, Version {
|
|
39
39
|
|
|
40
40
|
/// @notice Initializes the SessionVerifier with version information
|
|
41
|
-
/// @param
|
|
42
|
-
constructor(bytes32
|
|
41
|
+
/// @param _salt Unique salt used for deterministic deployment via CreateX
|
|
42
|
+
constructor(bytes32 _salt)
|
|
43
43
|
Version(
|
|
44
44
|
SESSION_VERIFIER_MAJOR_VERSION,
|
|
45
45
|
SESSION_VERIFIER_MINOR_VERSION,
|
|
46
46
|
SESSION_VERIFIER_PATCH_VERSION,
|
|
47
|
-
|
|
47
|
+
_salt,
|
|
48
48
|
SESSION_VERIFIER_NAME
|
|
49
49
|
)
|
|
50
50
|
{}
|
package/src/shared/IOwnable.sol
CHANGED
package/src/shared/TestUtils.sol
CHANGED
|
@@ -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
|
-
//
|
|
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
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
4
|
import {TEELifecycle} from "../../lightning-parts/TEELifecycle.sol";
|
|
5
5
|
import {BootstrapResult, AddNodeResult, UpgradeResult} from "../../lightning-parts/TEELifecycle.types.sol";
|
|
@@ -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 =
|
|
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
|