@inco/lightning 0.8.0-devnet-23 → 0.8.0-devnet-25
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 +5 -5
- package/src/Lib.demonet.sol +5 -5
- package/src/Lib.devnet.sol +5 -5
- package/src/Lib.sol +5 -5
- package/src/Lib.template.sol +5 -5
- package/src/Lib.testnet.sol +5 -5
- package/src/libs/incoLightning_alphanet_v0_297966649.sol +5 -5
- package/src/libs/incoLightning_alphanet_v1_725458969.sol +5 -5
- package/src/libs/incoLightning_alphanet_v2_976644394.sol +5 -5
- package/src/libs/incoLightning_demonet_v0_863421733.sol +5 -5
- package/src/libs/incoLightning_demonet_v2_467437523.sol +5 -5
- package/src/libs/incoLightning_devnet_v0_340846814.sol +5 -5
- package/src/libs/incoLightning_devnet_v1_904635675.sol +5 -5
- package/src/libs/incoLightning_devnet_v2_295237520.sol +5 -5
- package/src/libs/incoLightning_devnet_v3_976859633.sol +5 -5
- package/src/libs/incoLightning_devnet_v4_409204766.sol +5 -5
- package/src/libs/incoLightning_devnet_v5_203964628.sol +5 -5
- package/src/libs/incoLightning_devnet_v6_281949651.sol +5 -5
- package/src/libs/incoLightning_devnet_v7_24560427.sol +5 -5
- package/src/libs/incoLightning_devnet_v8_985328058.sol +5 -5
- package/src/libs/incoLightning_devnet_v9_269218568.sol +5 -5
- package/src/libs/incoLightning_testnet_v0_183408998.sol +5 -5
- package/src/libs/incoLightning_testnet_v2_889158349.sol +5 -5
- package/src/lightning-parts/EList.sol +9 -15
- package/src/lightning-parts/EncryptedOperations.sol +22 -12
- package/src/lightning-parts/TEELifecycle.sol +1 -1
- package/src/lightning-parts/interfaces/IEList.sol +1 -1
- package/src/lightning-parts/primitives/EListHandleMetadata.sol +9 -2
- package/src/lightning-parts/primitives/HandleMetadata.sol +10 -3
- package/src/lightning-parts/test/Elist.t.sol +12 -12
- package/src/lightning-parts/test/HandleMetadata.t.sol +7 -7
- package/src/test/EListTester.sol +3 -2
- package/src/test/TEELifecycle/TEELifecycleMockTest.t.sol +3 -0
- package/src/test/TestLib.t.sol +49 -44
|
@@ -46,7 +46,9 @@ abstract contract EList is IEList, EncryptedOperations, EncryptedInput, EListHan
|
|
|
46
46
|
elist indexed result,
|
|
47
47
|
uint256 eventId
|
|
48
48
|
);
|
|
49
|
-
event EListRange(
|
|
49
|
+
event EListRange(
|
|
50
|
+
uint256 indexed start, uint256 indexed end, ETypes listType, elist indexed result, uint256 eventId
|
|
51
|
+
);
|
|
50
52
|
event EListShuffle(elist indexed list, uint256 indexed counter, elist indexed result, uint256 eventId);
|
|
51
53
|
event EListReverse(elist indexed list, elist indexed result, uint256 eventId);
|
|
52
54
|
|
|
@@ -128,14 +130,6 @@ abstract contract EList is IEList, EncryptedOperations, EncryptedInput, EListHan
|
|
|
128
130
|
return newEListFromInputs(inputs, listType, user);
|
|
129
131
|
}
|
|
130
132
|
|
|
131
|
-
/// @notice Returns the element type of an encrypted list handle.
|
|
132
|
-
/// @dev Extracts the type from the handle's metadata bytes.
|
|
133
|
-
/// @param handle The list handle to inspect.
|
|
134
|
-
/// @return The ETypes enum value representing the element type.
|
|
135
|
-
function elementTypeOf(bytes32 handle) internal pure returns (ETypes) {
|
|
136
|
-
return ETypes(uint8(uint256(handle) >> 16));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
133
|
/// @notice Appends an encrypted value to the end of an encrypted list.
|
|
140
134
|
/// @dev Returns a new list with the value appended; original list is unchanged.
|
|
141
135
|
/// @param list The encrypted list to append to.
|
|
@@ -329,22 +323,22 @@ abstract contract EList is IEList, EncryptedOperations, EncryptedInput, EListHan
|
|
|
329
323
|
/// @dev Creates a list of euint256 values from start (inclusive) to end (exclusive).
|
|
330
324
|
/// @param start The starting value (inclusive).
|
|
331
325
|
/// @param end The ending value (exclusive). Must be >= start.
|
|
326
|
+
/// @param listType The type of elements in the list.
|
|
332
327
|
/// @return result A new encrypted list containing the range [start, end).
|
|
333
|
-
function listRange(uint16 start, uint16 end)
|
|
328
|
+
function listRange(uint16 start, uint16 end, ETypes listType)
|
|
334
329
|
external
|
|
335
330
|
payable
|
|
336
|
-
payingElistFee(uint256(end - start) * typeBitSize(
|
|
331
|
+
payingElistFee(uint256(end - start) * typeBitSize(listType))
|
|
337
332
|
returns (elist result)
|
|
338
333
|
{
|
|
339
334
|
require(start <= end, InvalidRange(start, end));
|
|
340
335
|
|
|
341
|
-
result =
|
|
342
|
-
createListResultHandle(EOps.EListRange,
|
|
343
|
-
);
|
|
336
|
+
result =
|
|
337
|
+
elist.wrap(createListResultHandle(EOps.EListRange, listType, end - start, abi.encodePacked(start, end)));
|
|
344
338
|
allowTransientInternal(elist.unwrap(result), msg.sender);
|
|
345
339
|
uint256 id = getNextEventId();
|
|
346
340
|
setDigest(abi.encodePacked(elist.unwrap(result), id));
|
|
347
|
-
emit EListRange(start, end, result, id);
|
|
341
|
+
emit EListRange(start, end, listType, result, id);
|
|
348
342
|
}
|
|
349
343
|
|
|
350
344
|
/// @notice Randomly shuffles the elements of an encrypted list.
|
|
@@ -33,6 +33,10 @@ abstract contract EncryptedOperations is IEncryptedOperations, BaseAccessControl
|
|
|
33
33
|
/// @param actual The unsupported type.
|
|
34
34
|
error UnsupportedType(ETypes actual);
|
|
35
35
|
|
|
36
|
+
/// @notice Thrown when a cast is attempted to the same type.
|
|
37
|
+
/// @param t The type that was both source and target.
|
|
38
|
+
error SameTypeCast(ETypes t);
|
|
39
|
+
|
|
36
40
|
uint256 internal randCounter;
|
|
37
41
|
uint256 internal constant ONE = 1;
|
|
38
42
|
|
|
@@ -176,11 +180,11 @@ abstract contract EncryptedOperations is IEncryptedOperations, BaseAccessControl
|
|
|
176
180
|
/// @param rhs The right-hand side encrypted operand (must be same type as lhs).
|
|
177
181
|
/// @return result The encrypted bitwise AND result.
|
|
178
182
|
function eBitAnd(bytes32 lhs, bytes32 rhs) external returns (bytes32 result) {
|
|
183
|
+
checkInput(lhs, SUPPORTED_TYPES_MASK);
|
|
184
|
+
checkInput(rhs, SUPPORTED_TYPES_MASK);
|
|
179
185
|
ETypes lhsType = typeOf(lhs);
|
|
180
186
|
ETypes rhsType = typeOf(rhs);
|
|
181
|
-
|
|
182
|
-
checkInput(rhs, typeToBitMask(rhsType));
|
|
183
|
-
require(lhsType == rhsType, UnexpectedType(lhsType, typeToBitMask(rhsType)));
|
|
187
|
+
require(lhsType == rhsType, UnexpectedType(rhsType, typeToBitMask(lhsType)));
|
|
184
188
|
uint256 id = getNextEventId();
|
|
185
189
|
result = createResultHandle(EOps.BitAnd, lhsType, abi.encodePacked(lhs, rhs));
|
|
186
190
|
emit EBitAnd(lhs, rhs, result, id);
|
|
@@ -192,11 +196,11 @@ abstract contract EncryptedOperations is IEncryptedOperations, BaseAccessControl
|
|
|
192
196
|
/// @param rhs The right-hand side encrypted operand (must be same type as lhs).
|
|
193
197
|
/// @return result The encrypted bitwise OR result.
|
|
194
198
|
function eBitOr(bytes32 lhs, bytes32 rhs) external returns (bytes32 result) {
|
|
199
|
+
checkInput(lhs, SUPPORTED_TYPES_MASK);
|
|
200
|
+
checkInput(rhs, SUPPORTED_TYPES_MASK);
|
|
195
201
|
ETypes lhsType = typeOf(lhs);
|
|
196
202
|
ETypes rhsType = typeOf(rhs);
|
|
197
|
-
|
|
198
|
-
checkInput(rhs, typeToBitMask(rhsType));
|
|
199
|
-
require(lhsType == rhsType, UnexpectedType(lhsType, typeToBitMask(rhsType)));
|
|
203
|
+
require(lhsType == rhsType, UnexpectedType(rhsType, typeToBitMask(lhsType)));
|
|
200
204
|
uint256 id = getNextEventId();
|
|
201
205
|
result = createResultHandle(EOps.BitOr, lhsType, abi.encodePacked(lhs, rhs));
|
|
202
206
|
emit EBitOr(lhs, rhs, result, id);
|
|
@@ -208,11 +212,11 @@ abstract contract EncryptedOperations is IEncryptedOperations, BaseAccessControl
|
|
|
208
212
|
/// @param rhs The right-hand side encrypted operand (must be same type as lhs).
|
|
209
213
|
/// @return result The encrypted bitwise XOR result.
|
|
210
214
|
function eBitXor(bytes32 lhs, bytes32 rhs) external returns (bytes32 result) {
|
|
215
|
+
checkInput(lhs, SUPPORTED_TYPES_MASK);
|
|
216
|
+
checkInput(rhs, SUPPORTED_TYPES_MASK);
|
|
211
217
|
ETypes lhsType = typeOf(lhs);
|
|
212
218
|
ETypes rhsType = typeOf(rhs);
|
|
213
|
-
|
|
214
|
-
checkInput(rhs, typeToBitMask(rhsType));
|
|
215
|
-
require(lhsType == rhsType, UnexpectedType(lhsType, typeToBitMask(rhsType)));
|
|
219
|
+
require(lhsType == rhsType, UnexpectedType(rhsType, typeToBitMask(lhsType)));
|
|
216
220
|
uint256 id = getNextEventId();
|
|
217
221
|
result = createResultHandle(EOps.BitXor, lhsType, abi.encodePacked(lhs, rhs));
|
|
218
222
|
emit EBitXor(lhs, rhs, result, id);
|
|
@@ -279,6 +283,9 @@ abstract contract EncryptedOperations is IEncryptedOperations, BaseAccessControl
|
|
|
279
283
|
function eEq(bytes32 lhs, bytes32 rhs) external returns (ebool result) {
|
|
280
284
|
checkInput(lhs, SUPPORTED_TYPES_MASK);
|
|
281
285
|
checkInput(rhs, SUPPORTED_TYPES_MASK);
|
|
286
|
+
ETypes lhsType = typeOf(lhs);
|
|
287
|
+
ETypes rhsType = typeOf(rhs);
|
|
288
|
+
require(lhsType == rhsType, UnexpectedType(rhsType, typeToBitMask(lhsType)));
|
|
282
289
|
|
|
283
290
|
result = ebool.wrap(createResultHandle(EOps.Eq, ETypes.Bool, abi.encodePacked(lhs, rhs)));
|
|
284
291
|
uint256 id = getNextEventId();
|
|
@@ -294,6 +301,9 @@ abstract contract EncryptedOperations is IEncryptedOperations, BaseAccessControl
|
|
|
294
301
|
function eNe(bytes32 lhs, bytes32 rhs) external returns (ebool result) {
|
|
295
302
|
checkInput(lhs, SUPPORTED_TYPES_MASK);
|
|
296
303
|
checkInput(rhs, SUPPORTED_TYPES_MASK);
|
|
304
|
+
ETypes lhsType = typeOf(lhs);
|
|
305
|
+
ETypes rhsType = typeOf(rhs);
|
|
306
|
+
require(lhsType == rhsType, UnexpectedType(rhsType, typeToBitMask(lhsType)));
|
|
297
307
|
|
|
298
308
|
result = ebool.wrap(createResultHandle(EOps.Ne, ETypes.Bool, abi.encodePacked(lhs, rhs)));
|
|
299
309
|
uint256 id = getNextEventId();
|
|
@@ -390,16 +400,17 @@ abstract contract EncryptedOperations is IEncryptedOperations, BaseAccessControl
|
|
|
390
400
|
setDigest(abi.encodePacked(result, id));
|
|
391
401
|
}
|
|
392
402
|
|
|
393
|
-
/// @notice Casts an encrypted value to a different encrypted type.
|
|
403
|
+
/// @notice Casts an encrypted value to a different encrypted type. Same-type casting is not allowed.
|
|
394
404
|
/// @dev Supports casting to euint256 and eaddress. Casting to ebool is not supported, only from ebool to a larger type.
|
|
405
|
+
/// Reverts with SameTypeCast if the source type matches the target type.
|
|
395
406
|
/// @param ct The encrypted value to cast.
|
|
396
407
|
/// @param toType The target type to cast to.
|
|
397
408
|
/// @return result The casted encrypted value.
|
|
398
409
|
function eCast(bytes32 ct, ETypes toType) external returns (bytes32 result) {
|
|
399
410
|
checkInput(ct, SUPPORTED_TYPES_MASK);
|
|
400
411
|
require(canCastTo(toType), UnsupportedType(toType));
|
|
412
|
+
require(typeOf(ct) != toType, SameTypeCast(toType));
|
|
401
413
|
result = createResultHandle(EOps.Cast, toType, abi.encodePacked(ct));
|
|
402
|
-
allowTransientInternal(result, msg.sender);
|
|
403
414
|
uint256 id = getNextEventId();
|
|
404
415
|
emit ECast(ct, uint8(toType), result, id);
|
|
405
416
|
setDigest(abi.encodePacked(result, id));
|
|
@@ -445,7 +456,6 @@ abstract contract EncryptedOperations is IEncryptedOperations, BaseAccessControl
|
|
|
445
456
|
ETypes returnType = checkEIfThenElseInputs(control, ifTrue, ifFalse);
|
|
446
457
|
result =
|
|
447
458
|
createResultHandle(EOps.IfThenElse, returnType, abi.encodePacked(ebool.unwrap(control), ifTrue, ifFalse));
|
|
448
|
-
allowTransientInternal(result, msg.sender);
|
|
449
459
|
uint256 id = getNextEventId();
|
|
450
460
|
emit EIfThenElse(control, ifTrue, ifFalse, result, id);
|
|
451
461
|
setDigest(abi.encodePacked(result, id));
|
|
@@ -155,7 +155,7 @@ abstract contract TEELifecycle is
|
|
|
155
155
|
UpgradeResult calldata upgradeResult,
|
|
156
156
|
bytes calldata quote,
|
|
157
157
|
bytes calldata signature
|
|
158
|
-
) public {
|
|
158
|
+
) public onlyOwner {
|
|
159
159
|
StorageForTeeLifecycle storage $ = getTeeLifecycleStorage();
|
|
160
160
|
|
|
161
161
|
require(isBootstrapComplete(), BootstrapNotComplete());
|
|
@@ -29,7 +29,7 @@ interface IEList is IEncryptedOperations, IEncryptedInput, IEListHandleMetadata
|
|
|
29
29
|
payable
|
|
30
30
|
returns (elist result);
|
|
31
31
|
|
|
32
|
-
function listRange(uint16 start, uint16 end) external payable returns (elist result);
|
|
32
|
+
function listRange(uint16 start, uint16 end, ETypes listType) external payable returns (elist result);
|
|
33
33
|
|
|
34
34
|
function listShuffle(elist list) external payable returns (elist result);
|
|
35
35
|
|
|
@@ -17,6 +17,10 @@ import {IEListHandleMetadata} from "./interfaces/IEListHandleMetadata.sol";
|
|
|
17
17
|
/// This allows efficient extraction of list metadata without external calls.
|
|
18
18
|
contract EListHandleMetadata is IEListHandleMetadata {
|
|
19
19
|
|
|
20
|
+
/// @notice Thrown when a handle contains an element type value outside the valid ETypes enum range.
|
|
21
|
+
/// @param raw The raw uint8 value extracted from the handle.
|
|
22
|
+
error InvalidListTypeValue(uint8 raw);
|
|
23
|
+
|
|
20
24
|
/// @notice Embeds the list length into a list handle
|
|
21
25
|
/// @dev Sets bytes 27-28 of the handle to the list length.
|
|
22
26
|
/// Clears existing length bits before setting new value.
|
|
@@ -51,10 +55,13 @@ contract EListHandleMetadata is IEListHandleMetadata {
|
|
|
51
55
|
/// @notice Extracts the element type from a list handle
|
|
52
56
|
/// @dev Reads byte 29 of the handle and casts to ETypes enum.
|
|
53
57
|
/// This is the type of individual elements, not the list container type.
|
|
58
|
+
/// Reverts with InvalidListTypeValue if the raw byte exceeds the valid ETypes range.
|
|
54
59
|
/// @param handle The encrypted list handle to inspect
|
|
55
|
-
/// @return The encrypted type of list elements (
|
|
60
|
+
/// @return The encrypted type of list elements (ebool, euint160, euint256, etc.)
|
|
56
61
|
function listTypeOf(bytes32 handle) internal pure returns (ETypes) {
|
|
57
|
-
|
|
62
|
+
uint8 raw = uint8(uint256(handle) >> 16);
|
|
63
|
+
require(raw <= uint8(type(ETypes).max), InvalidListTypeValue(raw));
|
|
64
|
+
return ETypes(raw);
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
}
|
|
@@ -12,6 +12,10 @@ import {HANDLE_VERSION, HANDLE_INDEX, ETypes} from "../../Types.sol";
|
|
|
12
12
|
/// - Byte 31: Handle version
|
|
13
13
|
contract HandleMetadata {
|
|
14
14
|
|
|
15
|
+
/// @notice Thrown when a handle contains a type value outside the valid ETypes enum range.
|
|
16
|
+
/// @param raw The raw uint8 value extracted from the handle.
|
|
17
|
+
error InvalidTypeValue(uint8 raw);
|
|
18
|
+
|
|
15
19
|
/// @notice Embeds the handle index, encrypted type, and protocol version into a prehandle
|
|
16
20
|
/// @dev Used for input handles where the index distinguishes the source.
|
|
17
21
|
/// Clears bytes 29-31 of the prehandle, then sets:
|
|
@@ -46,11 +50,14 @@ contract HandleMetadata {
|
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
/// @notice Extracts the encrypted type from a handle
|
|
49
|
-
/// @dev Reads byte 30 of the handle and casts to ETypes enum
|
|
53
|
+
/// @dev Reads byte 30 of the handle and casts to ETypes enum.
|
|
54
|
+
/// Reverts with InvalidTypeValue if the raw byte exceeds the valid ETypes range.
|
|
50
55
|
/// @param handle The encrypted value handle to inspect
|
|
51
|
-
/// @return The encrypted type (ebool,
|
|
56
|
+
/// @return The encrypted type (ebool, euint160, euint256, etc.)
|
|
52
57
|
function typeOf(bytes32 handle) internal pure returns (ETypes) {
|
|
53
|
-
|
|
58
|
+
uint8 raw = uint8(uint256(handle) >> 8);
|
|
59
|
+
require(raw <= uint8(type(ETypes).max), InvalidTypeValue(raw));
|
|
60
|
+
return ETypes(raw);
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
}
|
|
@@ -30,8 +30,8 @@ contract TestEList is IncoTest {
|
|
|
30
30
|
vm.deal(address(feeTester), 100 ether);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function _listRange(uint16 start, uint16 end) internal returns (elist) {
|
|
34
|
-
return inco.listRange{value: uint256(end - start) * typeBitSize(
|
|
33
|
+
function _listRange(uint16 start, uint16 end, ETypes listType) internal returns (elist) {
|
|
34
|
+
return inco.listRange{value: uint256(end - start) * typeBitSize(listType) * BIT_FEE}(start, end, listType);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function _listAppend(elist list, bytes32 value) internal returns (elist) {
|
|
@@ -101,7 +101,7 @@ contract TestEList is IncoTest {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
function testListAppend_SucceedsAtMaxLength() public {
|
|
104
|
-
elist almostMaxList = _listRange(0, MAX_LIST_LENGTH - 1);
|
|
104
|
+
elist almostMaxList = _listRange(0, MAX_LIST_LENGTH - 1, ETypes.Uint256);
|
|
105
105
|
|
|
106
106
|
bytes32 validHandle = inco.listGet(almostMaxList, 0);
|
|
107
107
|
|
|
@@ -110,7 +110,7 @@ contract TestEList is IncoTest {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
function testListInsert_SucceedsAtMaxLength() public {
|
|
113
|
-
elist almostMaxList = _listRange(0, MAX_LIST_LENGTH - 1);
|
|
113
|
+
elist almostMaxList = _listRange(0, MAX_LIST_LENGTH - 1, ETypes.Uint256);
|
|
114
114
|
|
|
115
115
|
// Get valid handles from the list (listGet returns handles with transient permissions)
|
|
116
116
|
bytes32 validIndex = inco.listGet(almostMaxList, 0);
|
|
@@ -123,8 +123,8 @@ contract TestEList is IncoTest {
|
|
|
123
123
|
function testListConcat_SucceedsAtMaxLength() public {
|
|
124
124
|
uint16 half = MAX_LIST_LENGTH / 2;
|
|
125
125
|
uint16 otherHalf = MAX_LIST_LENGTH - half;
|
|
126
|
-
elist list1 = _listRange(0, half);
|
|
127
|
-
elist list2 = _listRange(0, otherHalf);
|
|
126
|
+
elist list1 = _listRange(0, half, ETypes.Uint256);
|
|
127
|
+
elist list2 = _listRange(0, otherHalf, ETypes.Uint256);
|
|
128
128
|
|
|
129
129
|
// Should succeed
|
|
130
130
|
elist combined = _listConcat(list1, list2);
|
|
@@ -132,7 +132,7 @@ contract TestEList is IncoTest {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
function testListRange_SucceedsAtMaxLength() public {
|
|
135
|
-
elist maxList = _listRange(0, MAX_LIST_LENGTH);
|
|
135
|
+
elist maxList = _listRange(0, MAX_LIST_LENGTH, ETypes.Uint256);
|
|
136
136
|
assert(elist.unwrap(maxList) != bytes32(0));
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -141,7 +141,7 @@ contract TestEList is IncoTest {
|
|
|
141
141
|
// Operations use uint16 arithmetic which auto-reverts on overflow in Solidity 0.8+.
|
|
142
142
|
|
|
143
143
|
function testListAppend_RevertsOnOverflow() public {
|
|
144
|
-
elist maxList = _listRange(0, MAX_LIST_LENGTH);
|
|
144
|
+
elist maxList = _listRange(0, MAX_LIST_LENGTH, ETypes.Uint256);
|
|
145
145
|
|
|
146
146
|
bytes32 validHandle = inco.listGet(maxList, 0);
|
|
147
147
|
|
|
@@ -153,7 +153,7 @@ contract TestEList is IncoTest {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
function testListInsert_RevertsOnOverflow() public {
|
|
156
|
-
elist maxList = _listRange(0, MAX_LIST_LENGTH);
|
|
156
|
+
elist maxList = _listRange(0, MAX_LIST_LENGTH, ETypes.Uint256);
|
|
157
157
|
|
|
158
158
|
bytes32 validIndex = inco.listGet(maxList, 0);
|
|
159
159
|
bytes32 validValue = inco.listGet(maxList, 1);
|
|
@@ -168,8 +168,8 @@ contract TestEList is IncoTest {
|
|
|
168
168
|
|
|
169
169
|
function testListConcat_RevertsOnOverflow() public {
|
|
170
170
|
uint16 half = MAX_LIST_LENGTH / 2 + 1;
|
|
171
|
-
elist list1 = _listRange(0, half);
|
|
172
|
-
elist list2 = _listRange(0, half);
|
|
171
|
+
elist list1 = _listRange(0, half, ETypes.Uint256);
|
|
172
|
+
elist list2 = _listRange(0, half, ETypes.Uint256);
|
|
173
173
|
|
|
174
174
|
// Concatenating should revert with arithmetic overflow
|
|
175
175
|
uint256 bitsPerList = uint256(half) * typeBitSize(ETypes.Uint256);
|
|
@@ -202,7 +202,7 @@ contract TestEList is IncoTest {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
function testNewEListFromHandles() public {
|
|
205
|
-
elist sourceList = _listRange(0, 3);
|
|
205
|
+
elist sourceList = _listRange(0, 3, ETypes.Uint256);
|
|
206
206
|
|
|
207
207
|
// Extract handles from the source list
|
|
208
208
|
bytes32[] memory handles = new bytes32[](3);
|
|
@@ -284,35 +284,35 @@ contract TestHandleMetadata is
|
|
|
284
284
|
function testEBitAndTypeMismatch() public {
|
|
285
285
|
euint256 a = this.asEuint256(42);
|
|
286
286
|
ebool b = this.asEbool(true);
|
|
287
|
-
// Error: UnexpectedType(
|
|
288
|
-
// With lhs=Uint256, rhs=Bool: UnexpectedType(
|
|
287
|
+
// Error: UnexpectedType(typeOf(rhs), typeToBitMask(lhsType))
|
|
288
|
+
// With lhs=Uint256, rhs=Bool: UnexpectedType(Bool, typeToBitMask(Uint256))
|
|
289
289
|
vm.expectRevert(
|
|
290
290
|
abi.encodeWithSelector(
|
|
291
|
-
EncryptedOperations.UnexpectedType.selector, ETypes.
|
|
291
|
+
EncryptedOperations.UnexpectedType.selector, ETypes.Bool, typeToBitMask(ETypes.Uint256)
|
|
292
292
|
)
|
|
293
293
|
);
|
|
294
294
|
this.eBitAnd(euint256.unwrap(a), ebool.unwrap(b));
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
/// @notice Test eBitOr with mismatched types
|
|
297
|
+
/// @notice Test eBitOr with mismatched types
|
|
298
298
|
function testEBitOrTypeMismatch() public {
|
|
299
299
|
euint256 a = this.asEuint256(42);
|
|
300
300
|
ebool b = this.asEbool(true);
|
|
301
301
|
vm.expectRevert(
|
|
302
302
|
abi.encodeWithSelector(
|
|
303
|
-
EncryptedOperations.UnexpectedType.selector, ETypes.
|
|
303
|
+
EncryptedOperations.UnexpectedType.selector, ETypes.Bool, typeToBitMask(ETypes.Uint256)
|
|
304
304
|
)
|
|
305
305
|
);
|
|
306
306
|
this.eBitOr(euint256.unwrap(a), ebool.unwrap(b));
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
/// @notice Test eBitXor with mismatched types
|
|
309
|
+
/// @notice Test eBitXor with mismatched types
|
|
310
310
|
function testEBitXorTypeMismatch() public {
|
|
311
311
|
euint256 a = this.asEuint256(42);
|
|
312
312
|
ebool b = this.asEbool(true);
|
|
313
313
|
vm.expectRevert(
|
|
314
314
|
abi.encodeWithSelector(
|
|
315
|
-
EncryptedOperations.UnexpectedType.selector, ETypes.
|
|
315
|
+
EncryptedOperations.UnexpectedType.selector, ETypes.Bool, typeToBitMask(ETypes.Uint256)
|
|
316
316
|
)
|
|
317
317
|
);
|
|
318
318
|
this.eBitXor(euint256.unwrap(a), ebool.unwrap(b));
|
package/src/test/EListTester.sol
CHANGED
|
@@ -130,8 +130,9 @@ contract ElistTester is IncoUtils {
|
|
|
130
130
|
return list;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
function listRange(uint16 start, uint16 end) public payable returns (elist) {
|
|
134
|
-
newRangeList =
|
|
133
|
+
function listRange(uint16 start, uint16 end, ETypes listType) public payable returns (elist) {
|
|
134
|
+
newRangeList =
|
|
135
|
+
inco.listRange{value: uint256(end - start) * typeBitSize(listType) * BIT_FEE}(start, end, listType);
|
|
135
136
|
inco.allow(elist.unwrap(newRangeList), address(this));
|
|
136
137
|
inco.allow(elist.unwrap(newRangeList), address(msg.sender));
|
|
137
138
|
return newRangeList;
|
|
@@ -256,6 +256,7 @@ contract TEELifecycleMockTest is MockRemoteAttestation, TEELifecycle {
|
|
|
256
256
|
|
|
257
257
|
function testVerifyUpgradeResult_BootstrapNotComplete() public {
|
|
258
258
|
UpgradeResult memory upgradeResult = UpgradeResult({networkPubkey: testNetworkPubkey});
|
|
259
|
+
vm.prank(this.owner());
|
|
259
260
|
vm.expectRevert(TEELifecycle.BootstrapNotComplete.selector);
|
|
260
261
|
this.verifyUpgradeResult(testMrAggregated, upgradeResult, hex"", hex"");
|
|
261
262
|
}
|
|
@@ -271,6 +272,7 @@ contract TEELifecycleMockTest is MockRemoteAttestation, TEELifecycle {
|
|
|
271
272
|
|
|
272
273
|
// Try upgrade with wrong network pubkey
|
|
273
274
|
UpgradeResult memory upgradeResult = UpgradeResult({networkPubkey: hex"deadbeef"});
|
|
275
|
+
vm.prank(this.owner());
|
|
274
276
|
vm.expectRevert(TEELifecycle.InvalidNetworkPubkey.selector);
|
|
275
277
|
this.verifyUpgradeResult(mrAggregated, upgradeResult, quote, signature);
|
|
276
278
|
}
|
|
@@ -287,6 +289,7 @@ contract TEELifecycleMockTest is MockRemoteAttestation, TEELifecycle {
|
|
|
287
289
|
// Try upgrade with unapproved MR_AGGREGATED
|
|
288
290
|
bytes32 unapprovedMr = bytes32(uint256(1234));
|
|
289
291
|
UpgradeResult memory upgradeResult = UpgradeResult({networkPubkey: testNetworkPubkey});
|
|
292
|
+
vm.prank(this.owner());
|
|
290
293
|
vm.expectRevert(TEELifecycle.TEEVersionNotFound.selector);
|
|
291
294
|
this.verifyUpgradeResult(unapprovedMr, upgradeResult, quote, signature);
|
|
292
295
|
}
|