@inco/lightning 0.6.9 → 0.7.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+
5
+ - Add DecryptionAttester to IncoVerifier
6
+ - Merge EOA signers from SignatureVerifier and TEELifecycle
7
+ - IncoLightning to allow multiple signers + threshold
8
+
3
9
  ## 1.0.2
4
10
 
5
11
  - Inco Fees on:
package/manifest.yaml CHANGED
@@ -1,3 +1,25 @@
1
+ incoLightning_alphanet_v2_976644394:
2
+ executor:
3
+ name: incoLightning_alphanet_v2_976644394
4
+ majorVersion: 2
5
+ deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
6
+ pepper: alphanet
7
+ executorAddress: "0xc0d693DeEF0A91CE39208676b6da09B822abd199"
8
+ salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc000822f11f6e30f933e76d2a"
9
+ deployments:
10
+ - name: incoLightningPreview_2_0_0__976644394
11
+ chainId: "84532"
12
+ chainName: Base Sepolia
13
+ version:
14
+ major: 2
15
+ minor: 0
16
+ patch: 0
17
+ shortSalt: "976644394"
18
+ blockNumber: "34459258"
19
+ deployDate: 2025-12-02T14:46:46.026Z
20
+ commit: v0.6.9-17-g217794f3-dirty
21
+ active: true
22
+ includesPreviewFeatures: true
1
23
  incoLightning_alphanet_v1_725458969:
2
24
  executor:
3
25
  name: incoLightning_alphanet_v1_725458969
@@ -7,6 +29,19 @@ incoLightning_alphanet_v1_725458969:
7
29
  executorAddress: "0x28676Cd3b10b03b2FDF105Ba280425b45a674F2A"
8
30
  salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc004dfbe338c6966a22bcca19"
9
31
  deployments:
32
+ - name: incoLightningPreview_1_1_0__725458969
33
+ chainId: "84532"
34
+ chainName: Base Sepolia
35
+ version:
36
+ major: 1
37
+ minor: 1
38
+ patch: 0
39
+ shortSalt: "725458969"
40
+ blockNumber: "34456535"
41
+ deployDate: 2025-12-02T13:16:00.594Z
42
+ commit: v0.6.9-16-g428d1837-dirty
43
+ active: true
44
+ includesPreviewFeatures: true
10
45
  - name: incoLightningPreview_1_0_2__725458969
11
46
  chainId: "84532"
12
47
  chainName: Base Sepolia
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inco/lightning",
3
- "version": "0.6.9",
3
+ "version": "0.7.1",
4
4
  "repository": "https://github.com/Inco-fhevm/inco-monorepo",
5
5
  "files": [
6
6
  "src/",
@@ -8,7 +8,7 @@ pragma solidity ^0.8;
8
8
  import { IncoLightning } from "./IncoLightning.sol";
9
9
  import { ebool, euint256, eaddress, ETypes } from "./Types.sol";
10
10
 
11
- IncoLightning constant inco = IncoLightning(0x28676Cd3b10b03b2FDF105Ba280425b45a674F2A);
11
+ IncoLightning constant inco = IncoLightning(0xc0d693DeEF0A91CE39208676b6da09B822abd199);
12
12
  address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
13
13
 
14
14
  function typeOf(bytes32 handle) pure returns (ETypes) {
package/src/Lib.sol CHANGED
@@ -8,7 +8,7 @@ pragma solidity ^0.8;
8
8
  import { IncoLightning } from "./IncoLightning.sol";
9
9
  import { ebool, euint256, eaddress, ETypes } from "./Types.sol";
10
10
 
11
- IncoLightning constant inco = IncoLightning(0x28676Cd3b10b03b2FDF105Ba280425b45a674F2A);
11
+ IncoLightning constant inco = IncoLightning(0xc0d693DeEF0A91CE39208676b6da09B822abd199);
12
12
  address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
13
13
 
14
14
  function typeOf(bytes32 handle) pure returns (ETypes) {
@@ -360,9 +360,10 @@ library e {
360
360
 
361
361
  /// @dev costs the inco fee
362
362
  function randBounded(uint256 upperBound) internal returns (euint256) {
363
- return euint256.wrap(
364
- inco.eRandBounded{value: inco.getFee()}(euint256.unwrap(asEuint256(upperBound)), ETypes.Uint256)
365
- );
363
+ return
364
+ euint256.wrap(
365
+ inco.eRandBounded{value: inco.getFee()}(euint256.unwrap(asEuint256(upperBound)), ETypes.Uint256)
366
+ );
366
367
  }
367
368
 
368
369
  /// @dev costs the inco fee
package/src/Types.sol CHANGED
@@ -117,7 +117,6 @@ enum EOps {
117
117
  EListRange, // 108
118
118
  EListShuffle, // 109
119
119
  EListReverse // 110
120
-
121
120
  }
122
121
 
123
122
  type ebool is bytes32;
@@ -230,7 +229,6 @@ enum ETypes {
230
229
  EmptyType98,
231
230
  EmptyType99,
232
231
  List // 100
233
-
234
232
  }
235
233
 
236
234
  // check correctness of compute
@@ -9,8 +9,7 @@ import {ISignatureVerifier} from "../lightning-parts/primitives/interfaces/ISign
9
9
 
10
10
  interface IIncoVerifier is IAdvancedAccessControl, IDecryptionAttester, ITEELifecycle, ISignatureVerifier {
11
11
 
12
- function initialize(address owner, string memory name, string memory version, IQuoteVerifier quoteVerifier)
13
- external;
12
+ function initialize(address owner, string memory name, string memory version, IQuoteVerifier quoteVerifier) external;
14
13
  // forge-lint: disable-next-line(mixed-case-function)
15
14
  function getEIP712Name() external view returns (string memory);
16
15
  // forge-lint: disable-next-line(mixed-case-function)
@@ -0,0 +1,478 @@
1
+ // AUTOGENERATED FILE. DO NOT EDIT.
2
+ // This file was generated by the IncoLightning library generator.
3
+ // The original template is located at Lib.template.sol
4
+
5
+ /// SPDX-License-Identifier: No License
6
+ pragma solidity ^0.8;
7
+
8
+ import { IncoLightning } from "../IncoLightning.sol";
9
+ import { ebool, euint256, eaddress, ETypes } from "../Types.sol";
10
+
11
+ IncoLightning constant inco = IncoLightning(0xc0d693DeEF0A91CE39208676b6da09B822abd199);
12
+ address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
13
+
14
+ function typeOf(bytes32 handle) pure returns (ETypes) {
15
+ return ETypes(uint8(uint256(handle) >> 8));
16
+ }
17
+
18
+ library e {
19
+ function sanitize(euint256 a) internal returns (euint256) {
20
+ if (euint256.unwrap(a) == bytes32(0)) {
21
+ return asEuint256(0);
22
+ }
23
+ return a;
24
+ }
25
+
26
+ function sanitize(ebool a) internal returns (ebool) {
27
+ if (ebool.unwrap(a) == bytes32(0)) {
28
+ return asEbool(false);
29
+ }
30
+ return a;
31
+ }
32
+
33
+ function sanitize(eaddress a) internal returns (eaddress) {
34
+ if (eaddress.unwrap(a) == bytes32(0)) {
35
+ return asEaddress(address(0));
36
+ }
37
+ return a;
38
+ }
39
+
40
+ function s(euint256 a) internal returns (euint256) {
41
+ return sanitize(a);
42
+ }
43
+
44
+ function s(ebool a) internal returns (ebool) {
45
+ return sanitize(a);
46
+ }
47
+
48
+ function s(eaddress a) internal returns (eaddress) {
49
+ return sanitize(a);
50
+ }
51
+
52
+ function add(euint256 a, euint256 b) internal returns (euint256) {
53
+ return inco.eAdd(s(a), s(b));
54
+ }
55
+
56
+ function add(euint256 a, uint256 b) internal returns (euint256) {
57
+ return inco.eAdd(s(a), asEuint256(b));
58
+ }
59
+
60
+ function add(uint256 a, euint256 b) internal returns (euint256) {
61
+ return inco.eAdd(asEuint256(a), s(b));
62
+ }
63
+
64
+ function sub(euint256 a, euint256 b) internal returns (euint256) {
65
+ return inco.eSub(s(a), s(b));
66
+ }
67
+
68
+ function sub(euint256 a, uint256 b) internal returns (euint256) {
69
+ return inco.eSub(s(a), asEuint256(b));
70
+ }
71
+
72
+ function sub(uint256 a, euint256 b) internal returns (euint256) {
73
+ return inco.eSub(asEuint256(a), s(b));
74
+ }
75
+
76
+ function mul(euint256 a, euint256 b) internal returns (euint256) {
77
+ return inco.eMul(s(a), s(b));
78
+ }
79
+
80
+ function mul(euint256 a, uint256 b) internal returns (euint256) {
81
+ return inco.eMul(s(a), asEuint256(b));
82
+ }
83
+
84
+ function mul(uint256 a, euint256 b) internal returns (euint256) {
85
+ return inco.eMul(asEuint256(a), s(b));
86
+ }
87
+
88
+ function div(euint256 a, euint256 b) internal returns (euint256) {
89
+ return inco.eDiv(s(a), s(b));
90
+ }
91
+
92
+ function div(euint256 a, uint256 b) internal returns (euint256) {
93
+ return inco.eDiv(s(a), asEuint256(b));
94
+ }
95
+
96
+ function div(uint256 a, euint256 b) internal returns (euint256) {
97
+ return inco.eDiv(asEuint256(a), s(b));
98
+ }
99
+
100
+ function rem(euint256 a, euint256 b) internal returns (euint256) {
101
+ return inco.eRem(s(a), s(b));
102
+ }
103
+
104
+ function rem(euint256 a, uint256 b) internal returns (euint256) {
105
+ return inco.eRem(s(a), asEuint256(b));
106
+ }
107
+
108
+ function rem(uint256 a, euint256 b) internal returns (euint256) {
109
+ return inco.eRem(asEuint256(a), s(b));
110
+ }
111
+
112
+ function and(euint256 a, euint256 b) internal returns (euint256) {
113
+ return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
114
+ }
115
+
116
+ function and(euint256 a, uint256 b) internal returns (euint256) {
117
+ return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
118
+ }
119
+
120
+ function and(uint256 a, euint256 b) internal returns (euint256) {
121
+ return euint256.wrap(inco.eBitAnd(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
122
+ }
123
+
124
+ function and(ebool a, ebool b) internal returns (ebool) {
125
+ return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
126
+ }
127
+
128
+ function and(ebool a, bool b) internal returns (ebool) {
129
+ return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
130
+ }
131
+
132
+ function and(bool a, ebool b) internal returns (ebool) {
133
+ return ebool.wrap(inco.eBitAnd(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
134
+ }
135
+
136
+ function or(euint256 a, euint256 b) internal returns (euint256) {
137
+ return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
138
+ }
139
+
140
+ function or(euint256 a, uint256 b) internal returns (euint256) {
141
+ return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
142
+ }
143
+
144
+ function or(uint256 a, euint256 b) internal returns (euint256) {
145
+ return euint256.wrap(inco.eBitOr(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
146
+ }
147
+
148
+ function or(ebool a, ebool b) internal returns (ebool) {
149
+ return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
150
+ }
151
+
152
+ function or(ebool a, bool b) internal returns (ebool) {
153
+ return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
154
+ }
155
+
156
+ function or(bool a, ebool b) internal returns (ebool) {
157
+ return ebool.wrap(inco.eBitOr(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
158
+ }
159
+
160
+ function xor(euint256 a, euint256 b) internal returns (euint256) {
161
+ return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
162
+ }
163
+
164
+ function xor(euint256 a, uint256 b) internal returns (euint256) {
165
+ return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
166
+ }
167
+
168
+ function xor(uint256 a, euint256 b) internal returns (euint256) {
169
+ return euint256.wrap(inco.eBitXor(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
170
+ }
171
+
172
+ function xor(ebool a, ebool b) internal returns (ebool) {
173
+ return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
174
+ }
175
+
176
+ function xor(ebool a, bool b) internal returns (ebool) {
177
+ return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
178
+ }
179
+
180
+ function xor(bool a, ebool b) internal returns (ebool) {
181
+ return ebool.wrap(inco.eBitXor(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
182
+ }
183
+
184
+ function shl(euint256 a, euint256 b) internal returns (euint256) {
185
+ return inco.eShl(s(a), s(b));
186
+ }
187
+
188
+ function shl(euint256 a, uint256 b) internal returns (euint256) {
189
+ return inco.eShl(s(a), asEuint256(b));
190
+ }
191
+
192
+ function shl(uint256 a, euint256 b) internal returns (euint256) {
193
+ return inco.eShl(asEuint256(a), s(b));
194
+ }
195
+
196
+ function shr(euint256 a, euint256 b) internal returns (euint256) {
197
+ return inco.eShr(s(a), s(b));
198
+ }
199
+
200
+ function shr(euint256 a, uint256 b) internal returns (euint256) {
201
+ return inco.eShr(s(a), asEuint256(b));
202
+ }
203
+
204
+ function shr(uint256 a, euint256 b) internal returns (euint256) {
205
+ return inco.eShr(asEuint256(a), s(b));
206
+ }
207
+
208
+ function rotl(euint256 a, euint256 b) internal returns (euint256) {
209
+ return inco.eRotl(s(a), s(b));
210
+ }
211
+
212
+ function rotl(euint256 a, uint256 b) internal returns (euint256) {
213
+ return inco.eRotl(s(a), asEuint256(b));
214
+ }
215
+
216
+ function rotl(uint256 a, euint256 b) internal returns (euint256) {
217
+ return inco.eRotl(asEuint256(a), s(b));
218
+ }
219
+
220
+ function rotr(euint256 a, euint256 b) internal returns (euint256) {
221
+ return inco.eRotr(s(a), s(b));
222
+ }
223
+
224
+ function rotr(euint256 a, uint256 b) internal returns (euint256) {
225
+ return inco.eRotr(s(a), asEuint256(b));
226
+ }
227
+
228
+ function rotr(uint256 a, euint256 b) internal returns (euint256) {
229
+ return inco.eRotr(asEuint256(a), s(b));
230
+ }
231
+
232
+ function eq(euint256 a, euint256 b) internal returns (ebool) {
233
+ return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
234
+ }
235
+
236
+ function eq(euint256 a, uint256 b) internal returns (ebool) {
237
+ return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
238
+ }
239
+
240
+ function eq(uint256 a, euint256 b) internal returns (ebool) {
241
+ return inco.eEq(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
242
+ }
243
+
244
+ function eq(eaddress a, address b) internal returns (ebool) {
245
+ return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
246
+ }
247
+
248
+ function eq(eaddress a, eaddress b) internal returns (ebool) {
249
+ return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
250
+ }
251
+
252
+ function eq(address a, eaddress b) internal returns (ebool) {
253
+ return inco.eEq(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
254
+ }
255
+
256
+ function ne(euint256 a, euint256 b) internal returns (ebool) {
257
+ return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
258
+ }
259
+
260
+ function ne(euint256 a, uint256 b) internal returns (ebool) {
261
+ return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
262
+ }
263
+
264
+ function ne(uint256 a, euint256 b) internal returns (ebool) {
265
+ return inco.eNe(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
266
+ }
267
+
268
+ function ne(eaddress a, eaddress b) internal returns (ebool) {
269
+ return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
270
+ }
271
+
272
+ function ne(eaddress a, address b) internal returns (ebool) {
273
+ return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
274
+ }
275
+
276
+ function ne(address a, eaddress b) internal returns (ebool) {
277
+ return inco.eNe(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
278
+ }
279
+
280
+ function ge(euint256 a, euint256 b) internal returns (ebool) {
281
+ return inco.eGe(s(a), s(b));
282
+ }
283
+
284
+ function ge(euint256 a, uint256 b) internal returns (ebool) {
285
+ return inco.eGe(s(a), asEuint256(b));
286
+ }
287
+
288
+ function ge(uint256 a, euint256 b) internal returns (ebool) {
289
+ return inco.eGe(asEuint256(a), s(b));
290
+ }
291
+
292
+ function gt(euint256 a, euint256 b) internal returns (ebool) {
293
+ return inco.eGt(s(a), s(b));
294
+ }
295
+
296
+ function gt(euint256 a, uint256 b) internal returns (ebool) {
297
+ return inco.eGt(s(a), asEuint256(b));
298
+ }
299
+
300
+ function gt(uint256 a, euint256 b) internal returns (ebool) {
301
+ return inco.eGt(asEuint256(a), s(b));
302
+ }
303
+
304
+ function le(euint256 a, euint256 b) internal returns (ebool) {
305
+ return inco.eLe(s(a), s(b));
306
+ }
307
+
308
+ function le(euint256 a, uint256 b) internal returns (ebool) {
309
+ return inco.eLe(s(a), asEuint256(b));
310
+ }
311
+
312
+ function le(uint256 a, euint256 b) internal returns (ebool) {
313
+ return inco.eLe(asEuint256(a), s(b));
314
+ }
315
+
316
+ function lt(euint256 a, euint256 b) internal returns (ebool) {
317
+ return inco.eLt(s(a), s(b));
318
+ }
319
+
320
+ function lt(euint256 a, uint256 b) internal returns (ebool) {
321
+ return inco.eLt(s(a), asEuint256(b));
322
+ }
323
+
324
+ function lt(uint256 a, euint256 b) internal returns (ebool) {
325
+ return inco.eLt(asEuint256(a), s(b));
326
+ }
327
+
328
+ function min(euint256 a, euint256 b) internal returns (euint256) {
329
+ return inco.eMin(s(a), s(b));
330
+ }
331
+
332
+ function min(euint256 a, uint256 b) internal returns (euint256) {
333
+ return inco.eMin(s(a), asEuint256(b));
334
+ }
335
+
336
+ function min(uint256 a, euint256 b) internal returns (euint256) {
337
+ return inco.eMin(asEuint256(a), s(b));
338
+ }
339
+
340
+ function max(euint256 a, euint256 b) internal returns (euint256) {
341
+ return inco.eMax(s(a), s(b));
342
+ }
343
+
344
+ function max(euint256 a, uint256 b) internal returns (euint256) {
345
+ return inco.eMax(s(a), asEuint256(b));
346
+ }
347
+
348
+ function max(uint256 a, euint256 b) internal returns (euint256) {
349
+ return inco.eMax(asEuint256(a), s(b));
350
+ }
351
+
352
+ function not(ebool a) internal returns (ebool) {
353
+ return inco.eNot(s(a));
354
+ }
355
+
356
+ /// @dev costs the inco fee
357
+ function rand() internal returns (euint256) {
358
+ return euint256.wrap(inco.eRand{value: inco.getFee()}(ETypes.Uint256));
359
+ }
360
+
361
+ /// @dev costs the inco fee
362
+ function randBounded(uint256 upperBound) internal returns (euint256) {
363
+ return euint256.wrap(inco.eRandBounded{value: inco.getFee()}(euint256.unwrap(asEuint256(upperBound)), ETypes.Uint256));
364
+ }
365
+
366
+ /// @dev costs the inco fee
367
+ function randBounded(euint256 upperBound) internal returns (euint256) {
368
+ return euint256.wrap(inco.eRandBounded{value: inco.getFee()}(euint256.unwrap(s(upperBound)), ETypes.Uint256));
369
+ }
370
+
371
+ function asEuint256(uint256 a) internal returns (euint256) {
372
+ return inco.asEuint256(a);
373
+ }
374
+
375
+ function asEbool(bool a) internal returns (ebool) {
376
+ return inco.asEbool(a);
377
+ }
378
+
379
+ function asEaddress(address a) internal returns (eaddress) {
380
+ return inco.asEaddress(a);
381
+ }
382
+
383
+ function asEbool(euint256 a) internal returns (ebool) {
384
+ return ebool.wrap(inco.eCast(euint256.unwrap(a), ETypes.Bool));
385
+ }
386
+
387
+ function asEuint256(ebool a) internal returns (euint256) {
388
+ return euint256.wrap(inco.eCast(ebool.unwrap(a), ETypes.Uint256));
389
+ }
390
+
391
+ /// @notice Creates a new encrypted uint256 assuming msg.sender is the user
392
+ /// @dev costs the inco fee
393
+ function newEuint256(bytes memory ciphertext) internal returns (euint256) {
394
+ return newEuint256(ciphertext, msg.sender);
395
+ }
396
+
397
+ /// @notice Creates a new encrypted uint256 for the given user.
398
+ /// @dev costs the inco fee
399
+ function newEuint256(bytes memory ciphertext, address user) internal returns (euint256) {
400
+ return inco.newEuint256{value: inco.getFee()}(ciphertext, user);
401
+ }
402
+
403
+ /// @notice Creates a new encrypted bool assuming msg.sender is the user
404
+ /// @dev costs the inco fee
405
+ function newEbool(bytes memory ciphertext) internal returns (ebool) {
406
+ return newEbool(ciphertext, msg.sender);
407
+ }
408
+
409
+ /// @notice Creates a new encrypted bool for the given user.
410
+ /// @dev costs the inco fee
411
+ function newEbool(bytes memory ciphertext, address user) internal returns (ebool) {
412
+ return inco.newEbool{value: inco.getFee()}(ciphertext, user);
413
+ }
414
+
415
+ /// @notice Creates a new encrypted address assuming msg.sender is the user
416
+ /// @dev costs the inco fee
417
+ function newEaddress(bytes memory ciphertext) internal returns (eaddress) {
418
+ return newEaddress(ciphertext, msg.sender);
419
+ }
420
+
421
+ /// @notice Creates a new encrypted address for the given user.
422
+ /// @dev costs the inco fee
423
+ function newEaddress(bytes memory ciphertext, address user) internal returns (eaddress) {
424
+ return inco.newEaddress{value: inco.getFee()}(ciphertext, user);
425
+ }
426
+
427
+ function allow(euint256 a, address to) internal {
428
+ inco.allow(euint256.unwrap(a), to);
429
+ }
430
+
431
+ function allow(ebool a, address to) internal {
432
+ inco.allow(ebool.unwrap(a), to);
433
+ }
434
+
435
+ function allow(eaddress a, address to) internal {
436
+ inco.allow(eaddress.unwrap(a), to);
437
+ }
438
+
439
+ function reveal(euint256 a) internal {
440
+ inco.reveal(euint256.unwrap(a));
441
+ }
442
+
443
+ function reveal(ebool a) internal {
444
+ inco.reveal(ebool.unwrap(a));
445
+ }
446
+
447
+ function reveal(eaddress a) internal {
448
+ inco.reveal(eaddress.unwrap(a));
449
+ }
450
+
451
+ function allowThis(euint256 a) internal {
452
+ allow(a, address(this));
453
+ }
454
+
455
+ function allowThis(ebool a) internal {
456
+ allow(a, address(this));
457
+ }
458
+
459
+ function allowThis(eaddress a) internal {
460
+ allow(a, address(this));
461
+ }
462
+
463
+ function isAllowed(address user, euint256 a) internal view returns (bool) {
464
+ return inco.isAllowed(euint256.unwrap(a), user);
465
+ }
466
+
467
+ function select(ebool control, euint256 ifTrue, euint256 ifFalse) internal returns (euint256) {
468
+ return euint256.wrap(inco.eIfThenElse(s(control), euint256.unwrap(s(ifTrue)), euint256.unwrap(s(ifFalse))));
469
+ }
470
+
471
+ function select(ebool control, ebool ifTrue, ebool ifFalse) internal returns (ebool) {
472
+ return ebool.wrap(inco.eIfThenElse(s(control), ebool.unwrap(s(ifTrue)), ebool.unwrap(s(ifFalse))));
473
+ }
474
+
475
+ function select(ebool control, eaddress ifTrue, eaddress ifFalse) internal returns (eaddress) {
476
+ return eaddress.wrap(inco.eIfThenElse(s(control), eaddress.unwrap(s(ifTrue)), eaddress.unwrap(s(ifFalse))));
477
+ }
478
+ }
@@ -78,11 +78,12 @@ abstract contract AdvancedAccessControl is
78
78
  proof.voucher.sessionNonce == sharerActiveVouchersSessionNonce,
79
79
  InvalidVoucherSessionNonce(proof.voucher.sessionNonce, sharerActiveVouchersSessionNonce)
80
80
  );
81
- (bool success, bytes memory result) = proof.voucher.verifyingContract.call(
82
- abi.encodeWithSelector(
83
- proof.voucher.callFunction, handle, account, proof.voucher.sharerArgData, proof.requesterArgData
84
- )
85
- );
81
+ (bool success, bytes memory result) = proof.voucher.verifyingContract
82
+ .call(
83
+ abi.encodeWithSelector(
84
+ proof.voucher.callFunction, handle, account, proof.voucher.sharerArgData, proof.requesterArgData
85
+ )
86
+ );
86
87
  return (success && result.length >= 32 && abi.decode(result, (bytes32)) == ALLOWANCE_GRANTED_MAGIC_VALUE);
87
88
  }
88
89
 
@@ -60,7 +60,11 @@ contract DoesNotVerifyAnything {
60
60
  address, /* account */
61
61
  bytes memory, /* sharerArgData */
62
62
  bytes memory /* requesterArgData */
63
- ) public pure returns (bytes32) {
63
+ )
64
+ public
65
+ pure
66
+ returns (bytes32)
67
+ {
64
68
  return ALLOWANCE_GRANTED_MAGIC_VALUE;
65
69
  }
66
70
 
@@ -180,10 +184,7 @@ contract TestAdvancedAccessControl is IncoTest {
180
184
  function getBobsProof(AllowanceVoucher memory alicesVoucher) private view returns (AllowanceProof memory) {
181
185
  bytes memory voucherSignature = getAliceSig(alicesVoucher);
182
186
  return AllowanceProof({
183
- sharer: alice,
184
- voucher: alicesVoucher,
185
- voucherSignature: voucherSignature,
186
- requesterArgData: ""
187
+ sharer: alice, voucher: alicesVoucher, voucherSignature: voucherSignature, requesterArgData: ""
187
188
  });
188
189
  }
189
190
 
@@ -46,7 +46,12 @@ abstract contract EncryptedOperations is IEncryptedOperations, BaseAccessControl
46
46
  uint256 indexed counter, ETypes randType, bytes32 indexed upperBound, bytes32 indexed result, uint256 eventId
47
47
  );
48
48
  event EIfThenElse( // can't index >3 fields
49
- ebool control, bytes32 indexed ifTrue, bytes32 indexed ifFalse, bytes32 indexed result, uint256 eventId);
49
+ ebool control,
50
+ bytes32 indexed ifTrue,
51
+ bytes32 indexed ifFalse,
52
+ bytes32 indexed result,
53
+ uint256 eventId
54
+ );
50
55
  event ENot(ebool indexed operand, ebool indexed result, uint256 eventId);
51
56
  event ECast(bytes32 indexed ct, uint8 indexed toType, bytes32 indexed result, uint256 eventId);
52
57
 
@@ -274,8 +279,8 @@ abstract contract EncryptedOperations is IEncryptedOperations, BaseAccessControl
274
279
  }
275
280
 
276
281
  function eCast(bytes32 ct, ETypes toType) external returns (bytes32 result) {
277
- bytes32 baseHandle = keccak256(abi.encodePacked(EOps.Cast, ct));
278
- result = embedTypeVersion(baseHandle, toType);
282
+ require(isTypeSupported(toType), UnsupportedType(toType));
283
+ result = createResultHandle(EOps.Cast, toType, abi.encodePacked(ct));
279
284
  allowTransientInternal(result, msg.sender);
280
285
  uint256 id = getNextEventId();
281
286
  emit ECast(ct, uint8(toType), result, id);
@@ -304,8 +309,8 @@ abstract contract EncryptedOperations is IEncryptedOperations, BaseAccessControl
304
309
  // todo add support in testing framework
305
310
  function eIfThenElse(ebool control, bytes32 ifTrue, bytes32 ifFalse) external returns (bytes32 result) {
306
311
  ETypes returnType = checkEIfThenElseInputs(control, ifTrue, ifFalse);
307
- bytes32 baseHandle = keccak256(abi.encodePacked(EOps.IfThenElse, ebool.unwrap(control), ifTrue, ifFalse));
308
- result = embedTypeVersion(baseHandle, returnType);
312
+ result =
313
+ createResultHandle(EOps.IfThenElse, returnType, abi.encodePacked(ebool.unwrap(control), ifTrue, ifFalse));
309
314
  allowTransientInternal(result, msg.sender);
310
315
  uint256 id = getNextEventId();
311
316
  emit EIfThenElse(control, ifTrue, ifFalse, result, id);
@@ -389,9 +389,10 @@ abstract contract TEELifecycle is
389
389
  }
390
390
 
391
391
  function bootstrapResultDigest(BootstrapResult memory bootstrapResult) public view returns (bytes32) {
392
- return _hashTypedDataV4(
393
- keccak256(abi.encode(BOOTSTRAP_RESULT_STRUCT_HASH, keccak256(bootstrapResult.ecies_pubkey)))
394
- );
392
+ return
393
+ _hashTypedDataV4(
394
+ keccak256(abi.encode(BOOTSTRAP_RESULT_STRUCT_HASH, keccak256(bootstrapResult.ecies_pubkey)))
395
+ );
395
396
  }
396
397
 
397
398
  function upgradeResultDigest(UpgradeResult memory upgradeResult) public view returns (bytes32) {
@@ -232,9 +232,7 @@ contract CreateX {
232
232
 
233
233
  (bool success, bytes memory returnData) = proxy.call{value: msg.value}(data);
234
234
  _requireSuccessfulContractInitialisation({
235
- success: success,
236
- returnData: returnData,
237
- implementation: implementation
235
+ success: success, returnData: returnData, implementation: implementation
238
236
  });
239
237
  }
240
238
 
@@ -420,11 +418,7 @@ contract CreateX {
420
418
  // Note that the safeguarding function `_guard` is called as part of the overloaded function
421
419
  // `deployCreate2AndInit`.
422
420
  newContract = deployCreate2AndInit({
423
- salt: salt,
424
- initCode: initCode,
425
- data: data,
426
- values: values,
427
- refundAddress: msg.sender
421
+ salt: salt, initCode: initCode, data: data, values: values, refundAddress: msg.sender
428
422
  });
429
423
  }
430
424
 
@@ -453,11 +447,7 @@ contract CreateX {
453
447
  // Note that the safeguarding function `_guard` is called as part of the overloaded function
454
448
  // `deployCreate2AndInit`.
455
449
  newContract = deployCreate2AndInit({
456
- salt: _generateSalt(),
457
- initCode: initCode,
458
- data: data,
459
- values: values,
460
- refundAddress: refundAddress
450
+ salt: _generateSalt(), initCode: initCode, data: data, values: values, refundAddress: refundAddress
461
451
  });
462
452
  }
463
453
 
@@ -485,11 +475,7 @@ contract CreateX {
485
475
  // Note that the safeguarding function `_guard` is called as part of the overloaded function
486
476
  // `deployCreate2AndInit`.
487
477
  newContract = deployCreate2AndInit({
488
- salt: _generateSalt(),
489
- initCode: initCode,
490
- data: data,
491
- values: values,
492
- refundAddress: msg.sender
478
+ salt: _generateSalt(), initCode: initCode, data: data, values: values, refundAddress: msg.sender
493
479
  });
494
480
  }
495
481
 
@@ -527,9 +513,7 @@ contract CreateX {
527
513
 
528
514
  (bool success, bytes memory returnData) = proxy.call{value: msg.value}(data);
529
515
  _requireSuccessfulContractInitialisation({
530
- success: success,
531
- returnData: returnData,
532
- implementation: implementation
516
+ success: success, returnData: returnData, implementation: implementation
533
517
  });
534
518
  }
535
519
 
@@ -741,11 +725,7 @@ contract CreateX {
741
725
  // Note that the safeguarding function `_guard` is called as part of the overloaded function
742
726
  // `deployCreate3AndInit`.
743
727
  newContract = deployCreate3AndInit({
744
- salt: salt,
745
- initCode: initCode,
746
- data: data,
747
- values: values,
748
- refundAddress: msg.sender
728
+ salt: salt, initCode: initCode, data: data, values: values, refundAddress: msg.sender
749
729
  });
750
730
  }
751
731
 
@@ -775,11 +755,7 @@ contract CreateX {
775
755
  // Note that the safeguarding function `_guard` is called as part of the overloaded function
776
756
  // `deployCreate3AndInit`.
777
757
  newContract = deployCreate3AndInit({
778
- salt: _generateSalt(),
779
- initCode: initCode,
780
- data: data,
781
- values: values,
782
- refundAddress: refundAddress
758
+ salt: _generateSalt(), initCode: initCode, data: data, values: values, refundAddress: refundAddress
783
759
  });
784
760
  }
785
761
 
@@ -808,11 +784,7 @@ contract CreateX {
808
784
  // Note that the safeguarding function `_guard` is called as part of the overloaded function
809
785
  // `deployCreate3AndInit`.
810
786
  newContract = deployCreate3AndInit({
811
- salt: _generateSalt(),
812
- initCode: initCode,
813
- data: data,
814
- values: values,
815
- refundAddress: msg.sender
787
+ salt: _generateSalt(), initCode: initCode, data: data, values: values, refundAddress: msg.sender
816
788
  });
817
789
  }
818
790
 
@@ -100,10 +100,7 @@ interface ICreateX {
100
100
  pure
101
101
  returns (address computedAddress);
102
102
 
103
- function computeCreate2Address(bytes32 salt, bytes32 initCodeHash)
104
- external
105
- view
106
- returns (address computedAddress);
103
+ function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external view returns (address computedAddress);
107
104
 
108
105
  /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
109
106
  /* CREATE3 */
@@ -40,7 +40,11 @@ contract SessionVerifier is UUPSUpgradeable, OwnableUpgradeable, Version {
40
40
  address account,
41
41
  bytes memory sharerArgData,
42
42
  bytes memory /* requesterArgData */
43
- ) external view returns (bytes32) {
43
+ )
44
+ external
45
+ view
46
+ returns (bytes32)
47
+ {
44
48
  Session memory session = abi.decode(sharerArgData, (Session));
45
49
  if (session.expiresAt >= block.timestamp && session.decrypter == account) {
46
50
  return ALLOWANCE_GRANTED_MAGIC_VALUE;
@@ -6,7 +6,8 @@ import {Test} from "forge-std/Test.sol";
6
6
  contract TestUtils is Test {
7
7
 
8
8
  address private constant ANVIL_ZEROTH_ADDRESS = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266;
9
- uint256 private constant ANVIL_ZEROTH_PRIV_KEY = 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80;
9
+ uint256 private constant ANVIL_ZEROTH_PRIVATE_KEY =
10
+ 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80;
10
11
 
11
12
  uint256 internal alicePrivKey;
12
13
  address internal immutable alice;
@@ -20,8 +21,8 @@ contract TestUtils is Test {
20
21
  address internal immutable eve;
21
22
 
22
23
  // it is convenient for e2e tests to use these well-known addresses for the TEE
23
- address internal constant teeEOA = ANVIL_ZEROTH_ADDRESS;
24
- uint256 internal constant teePrivKey = ANVIL_ZEROTH_PRIV_KEY;
24
+ address internal teeEOA = ANVIL_ZEROTH_ADDRESS;
25
+ uint256 internal teePrivKey = ANVIL_ZEROTH_PRIVATE_KEY;
25
26
 
26
27
  constructor() {
27
28
  (alicePrivKey, alice) = getLabeledKeyPair("alice");
@@ -108,8 +108,7 @@ contract FakeDecryptionAttester is FakeIncoInfraBase, FakeComputeServer {
108
108
  {
109
109
  ETypes resultType = opToResultType(op);
110
110
  decryption = DecryptionAttestation({
111
- handle: inco.getOpResultHandle(op, resultType, abi.encodePacked(lhsHandle, rhsHandle)),
112
- value: encodedResult
111
+ handle: inco.getOpResultHandle(op, resultType, abi.encodePacked(lhsHandle, rhsHandle)), value: encodedResult
113
112
  });
114
113
  signature = signDecryption(decryption);
115
114
  }
@@ -41,9 +41,13 @@ contract MockRemoteAttestation is TestUtils {
41
41
  }
42
42
 
43
43
  // Helper function to create a successful bootstrap result
44
- function successfulBootstrapResult(ITEELifecycle teeLifecycle)
44
+ function successfulBootstrapResult(
45
+ ITEELifecycle teeLifecycle,
46
+ bytes memory eciesPublicKey,
47
+ address signer,
48
+ uint256 signerPrivKey
49
+ )
45
50
  internal
46
- view
47
51
  returns (
48
52
  BootstrapResult memory bootstrapResult,
49
53
  bytes memory quote,
@@ -51,8 +55,7 @@ contract MockRemoteAttestation is TestUtils {
51
55
  bytes32 mrAggregated
52
56
  )
53
57
  {
54
- // FIXME[Silas]: we should pass this value in as part of plan
55
- bytes memory eciesPubkey = hex"02516bda9e68a1c3dce74dc1b6ed7d91a91d51c1e1933947f06331cef59631e9eb";
58
+ bytes memory eciesPubkey = eciesPublicKey;
56
59
  // See DEFAULT_MRTD in attestation/src/remote_attestation.rs
57
60
  bytes memory mrtd =
58
61
  hex"010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101";
@@ -61,8 +64,11 @@ contract MockRemoteAttestation is TestUtils {
61
64
  mrAggregated = hex"c3a67bac251d4946d7b17481d39631676042fe3afab06e70c22105ad8383c19f";
62
65
  bootstrapResult = BootstrapResult({ecies_pubkey: eciesPubkey});
63
66
 
64
- quote = createQuote(mrtd, teeEOA);
65
- signature = signBootstrapResult(bootstrapResult, teePrivKey, teeLifecycle);
67
+ quote = createQuote(mrtd, signer);
68
+ signature = signBootstrapResult(bootstrapResult, signerPrivKey, teeLifecycle);
69
+ // We set the signer address and priv key as part of the bootstrap for non-tee setups
70
+ teeEOA = signer;
71
+ teePrivKey = signerPrivKey;
66
72
  }
67
73
 
68
74
  // Helper function to sign the bootstrap result
@@ -20,6 +20,12 @@ contract IncoTest is MockOpHandler, DeployUtils, FakeDecryptionAttester, MockRem
20
20
  // forge-lint: disable-next-line(screaming-snake-case-immutable)
21
21
  address immutable testDeployer;
22
22
 
23
+ // Constants for testing
24
+ bytes testNetworkPubkey = hex"02516bda9e68a1c3dce74dc1b6ed7d91a91d51c1e1933947f06331cef59631e9eb";
25
+ address private constant ANVIL_ZEROTH_ADDRESS = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266;
26
+ uint256 private constant ANVIL_ZEROTH_PRIVATE_KEY =
27
+ 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80;
28
+
23
29
  constructor() {
24
30
  owner = getLabeledAddress("owner");
25
31
  // extracted from the deploy script running as bare simulation with:
@@ -51,8 +57,9 @@ contract IncoTest is MockOpHandler, DeployUtils, FakeDecryptionAttester, MockRem
51
57
  "generated inco address in Lib.sol does not match address of inco deployed by IncoTest"
52
58
  );
53
59
  vm.startPrank(owner);
54
- (BootstrapResult memory bootstrapResult, bytes memory quote, bytes memory signature, bytes32 mrAggregated) =
55
- successfulBootstrapResult(inco.incoVerifier());
60
+ (BootstrapResult memory bootstrapResult, bytes memory quote, bytes memory signature, bytes32 mrAggregated) = successfulBootstrapResult(
61
+ inco.incoVerifier(), testNetworkPubkey, ANVIL_ZEROTH_ADDRESS, ANVIL_ZEROTH_PRIVATE_KEY
62
+ );
56
63
  inco.incoVerifier().approveNewTeeVersion(mrAggregated);
57
64
  inco.incoVerifier().verifyBootstrapResult(bootstrapResult, quote, signature);
58
65
  inco.incoVerifier().setThreshold(1);
@@ -426,4 +426,13 @@ contract OpsTest is Fee {
426
426
  return encryptedAddress;
427
427
  }
428
428
 
429
+ // ============ CAST OPERATIONS ============
430
+
431
+ function testCast(bytes32 a, ETypes to) external returns (bytes32) {
432
+ bytes32 result = inco.eCast(a, to);
433
+ inco.allow(result, address(this));
434
+ inco.allow(result, msg.sender);
435
+ return result;
436
+ }
437
+
429
438
  }
@@ -9,8 +9,7 @@ import {FakeQuoteVerifier} from "../FakeIncoInfra/FakeQuoteVerifier.sol";
9
9
  contract TEELifecycleMockTest is MockRemoteAttestation, TEELifecycle {
10
10
 
11
11
  // Constants for testing
12
- bytes testNetworkPubkey =
13
- hex"04ff5c6dd72ad7583288b84ee2598e081fe0bc6ef543c342e925a5dfcff9afb2444d25454d7d5dcfadc9ed99477c245efa93caf58d7f58143300d81cc948e7bdf5";
12
+ bytes testNetworkPubkey = hex"02516bda9e68a1c3dce74dc1b6ed7d91a91d51c1e1933947f06331cef59631e9eb";
14
13
  // See DEFAULT_MRTD in attestation/src/remote_attestation.rs
15
14
  bytes testMrtd =
16
15
  hex"010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101";
@@ -37,7 +36,7 @@ contract TEELifecycleMockTest is MockRemoteAttestation, TEELifecycle {
37
36
  hex"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
38
37
 
39
38
  (BootstrapResult memory bootstrapResult, bytes memory quote, bytes memory signature, bytes32 mrAggregated) =
40
- successfulBootstrapResult(this);
39
+ successfulBootstrapResult(this, testNetworkPubkey, teeEOA, teePrivKey);
41
40
 
42
41
  quote = createQuote(badMrtd, teeEOA); // Replace with bad MRTD
43
42
  vm.startPrank(this.owner());
@@ -4,7 +4,12 @@ pragma solidity ^0.8;
4
4
  import {Test, Vm, console} from "forge-std/Test.sol";
5
5
 
6
6
  event EventTooLarge( // can't index >3 fields
7
- bytes32 control, bytes32 indexed ifTrue, bytes32 indexed ifFalse, bytes32 indexed result, uint256 eventId);
7
+ bytes32 control,
8
+ bytes32 indexed ifTrue,
9
+ bytes32 indexed ifFalse,
10
+ bytes32 indexed result,
11
+ uint256 eventId
12
+ );
8
13
 
9
14
  contract Emitter {
10
15
 
@@ -7,12 +7,12 @@ 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 = 1;
10
+ uint8 constant MAJOR_VERSION = 2;
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
14
14
  // consequently, when we do a patch release, we don't need to pump it as it's already pumped
15
15
  // when the previous release was done
16
- uint8 constant PATCH_VERSION = 4;
16
+ uint8 constant PATCH_VERSION = 1;
17
17
 
18
18
  string constant VERIFIER_NAME = "incoVerifier";
@@ -43,9 +43,10 @@ contract Version is IVersion {
43
43
  }
44
44
 
45
45
  function versionString(uint8 major, uint8 minor, uint8 patch) internal pure returns (string memory) {
46
- return string(
47
- abi.encodePacked(Strings.toString(major), "_", Strings.toString(minor), "_", Strings.toString(patch))
48
- );
46
+ return
47
+ string(
48
+ abi.encodePacked(Strings.toString(major), "_", Strings.toString(minor), "_", Strings.toString(patch))
49
+ );
49
50
  }
50
51
 
51
52
  function getName() public view virtual returns (string memory) {