@inco/lightning 0.8.0-devnet-28 → 0.8.0-devnet-30
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 +17 -0
- package/package.json +1 -1
- package/src/DeployUtils.sol +22 -28
- package/src/Lib.alphanet.sol +28 -2
- package/src/Lib.demonet.sol +28 -2
- package/src/Lib.devnet.sol +28 -2
- package/src/Lib.sol +28 -2
- package/src/Lib.template.sol +46 -2
- package/src/Lib.testnet.sol +28 -2
- package/src/Types.sol +3 -0
- package/src/libs/incoLightning_alphanet_v0_297966649.sol +28 -2
- package/src/libs/incoLightning_alphanet_v1_725458969.sol +28 -2
- package/src/libs/incoLightning_alphanet_v2_976644394.sol +28 -2
- package/src/libs/incoLightning_demonet_v0_863421733.sol +28 -2
- package/src/libs/incoLightning_demonet_v2_467437523.sol +28 -2
- package/src/libs/incoLightning_devnet_v0_340846814.sol +28 -2
- package/src/libs/incoLightning_devnet_v1_904635675.sol +28 -2
- package/src/libs/incoLightning_devnet_v2_295237520.sol +28 -2
- package/src/libs/incoLightning_devnet_v3_976859633.sol +28 -2
- package/src/libs/incoLightning_devnet_v4_409204766.sol +28 -2
- package/src/libs/incoLightning_devnet_v5_203964628.sol +28 -2
- package/src/libs/incoLightning_devnet_v6_281949651.sol +28 -2
- package/src/libs/incoLightning_devnet_v7_24560427.sol +28 -2
- package/src/libs/incoLightning_devnet_v8_985328058.sol +28 -2
- package/src/libs/incoLightning_devnet_v9_269218568.sol +28 -2
- package/src/libs/incoLightning_testnet_v0_183408998.sol +28 -2
- package/src/libs/incoLightning_testnet_v2_889158349.sol +28 -2
- package/src/lightning-parts/AccessControl/interfaces/IBaseAccessControlList.sol +1 -0
- package/src/lightning-parts/EList.sol +1 -1
- package/src/lightning-parts/EncryptedInput.sol +18 -3
- package/src/lightning-parts/EncryptedOperations.sol +0 -14
- package/src/lightning-parts/interfaces/IEncryptedOperations.sol +0 -1
- package/src/lightning-parts/test/HandleMetadata.t.sol +0 -7
- package/src/test/EListTester.sol +4 -0
- package/src/test/FakeIncoInfra/MockOpHandler.sol +7 -9
- package/src/test/FakeIncoInfra/getOpForSelector.sol +0 -2
- package/src/test/IncoTest.sol +17 -5
- package/src/test/OpsTest.sol +3 -2
- package/src/test/TestLib.t.sol +142 -1
- package/src/test/TestUpgrade.t.sol +24 -47
package/manifest.yaml
CHANGED
|
@@ -3,6 +3,7 @@ incoLightning_devnet_v9_269218568:
|
|
|
3
3
|
name: incoLightning_devnet_v9_269218568
|
|
4
4
|
majorVersion: 9
|
|
5
5
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
6
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
6
7
|
pepper: devnet
|
|
7
8
|
executorAddress: "0x6c9132D324231D2F68a1491686b0d4c10ee7d257"
|
|
8
9
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc007202d6e9ea2805def71308"
|
|
@@ -25,6 +26,7 @@ incoLightning_devnet_v8_985328058:
|
|
|
25
26
|
name: incoLightning_devnet_v8_985328058
|
|
26
27
|
majorVersion: 8
|
|
27
28
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
29
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
28
30
|
pepper: devnet
|
|
29
31
|
executorAddress: "0x43119Ad1F673E998CE4f3BB305bB92Bd5ab97E3B"
|
|
30
32
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc009045f766b38e5a773da9ba"
|
|
@@ -47,6 +49,7 @@ incoLightning_devnet_v7_24560427:
|
|
|
47
49
|
name: incoLightning_devnet_v7_24560427
|
|
48
50
|
majorVersion: 7
|
|
49
51
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
52
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
50
53
|
pepper: devnet
|
|
51
54
|
executorAddress: "0xA2275E60cCEd081fFD7373593c44ebc30E6Efe66"
|
|
52
55
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc0057b7694d1492d2775d132b"
|
|
@@ -69,6 +72,7 @@ incoLightning_devnet_v6_281949651:
|
|
|
69
72
|
name: incoLightning_devnet_v6_281949651
|
|
70
73
|
majorVersion: 6
|
|
71
74
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
75
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
72
76
|
pepper: devnet
|
|
73
77
|
executorAddress: "0xDF3830489208461f72Df6E45D0e6cbF9DBB74fe1"
|
|
74
78
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc009531587de02194b1b7a9d3"
|
|
@@ -91,6 +95,7 @@ incoLightning_devnet_v5_203964628:
|
|
|
91
95
|
name: incoLightning_devnet_v5_203964628
|
|
92
96
|
majorVersion: 5
|
|
93
97
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
98
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
94
99
|
pepper: devnet
|
|
95
100
|
executorAddress: "0x8D5D75CC00E2Fc84ec4dE085aE1708223591c6b6"
|
|
96
101
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc00c573fb2bf617e75b6210d4"
|
|
@@ -113,6 +118,7 @@ incoLightning_devnet_v4_409204766:
|
|
|
113
118
|
name: incoLightning_devnet_v4_409204766
|
|
114
119
|
majorVersion: 4
|
|
115
120
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
121
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
116
122
|
pepper: devnet
|
|
117
123
|
executorAddress: "0x4046b737B454b0430FBF29cea070e3337AdE95aD"
|
|
118
124
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc003b3f2c4caeb6f787dcce1e"
|
|
@@ -135,6 +141,7 @@ incoLightning_devnet_v3_976859633:
|
|
|
135
141
|
name: incoLightning_devnet_v3_976859633
|
|
136
142
|
majorVersion: 3
|
|
137
143
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
144
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
138
145
|
pepper: devnet
|
|
139
146
|
executorAddress: "0x4732520194584a04Cac0224e067658619F4086bD"
|
|
140
147
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc00ef1fab551c72a93b0637f1"
|
|
@@ -157,6 +164,7 @@ incoLightning_testnet_v2_889158349:
|
|
|
157
164
|
name: incoLightning_testnet_v2_889158349
|
|
158
165
|
majorVersion: 2
|
|
159
166
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
167
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
160
168
|
pepper: testnet
|
|
161
169
|
executorAddress: "0x168FDc3Ae19A5d5b03614578C58974FF30FCBe92"
|
|
162
170
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc005e0f44aac1a914b715cecd"
|
|
@@ -179,6 +187,7 @@ incoLightning_demonet_v2_467437523:
|
|
|
179
187
|
name: incoLightning_demonet_v2_467437523
|
|
180
188
|
majorVersion: 2
|
|
181
189
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
190
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
182
191
|
pepper: demonet
|
|
183
192
|
executorAddress: "0xA95EAbCE575f5f1e52605358Ee893F6536166378"
|
|
184
193
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc0071f74686446f14c7b469d3"
|
|
@@ -201,6 +210,7 @@ incoLightning_alphanet_v2_976644394:
|
|
|
201
210
|
name: incoLightning_alphanet_v2_976644394
|
|
202
211
|
majorVersion: 2
|
|
203
212
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
213
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
204
214
|
pepper: alphanet
|
|
205
215
|
executorAddress: "0xc0d693DeEF0A91CE39208676b6da09B822abd199"
|
|
206
216
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc000822f11f6e30f933e76d2a"
|
|
@@ -223,6 +233,7 @@ incoLightning_devnet_v2_295237520:
|
|
|
223
233
|
name: incoLightning_devnet_v2_295237520
|
|
224
234
|
majorVersion: 2
|
|
225
235
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
236
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
226
237
|
pepper: devnet
|
|
227
238
|
executorAddress: "0xC64BB070D6F5aa796e79fA19c1008647ffF736ED"
|
|
228
239
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc008d5a963bd519d8493f5190"
|
|
@@ -258,6 +269,7 @@ incoLightning_alphanet_v1_725458969:
|
|
|
258
269
|
name: incoLightning_alphanet_v1_725458969
|
|
259
270
|
majorVersion: 1
|
|
260
271
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
272
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
261
273
|
pepper: alphanet
|
|
262
274
|
executorAddress: "0x28676Cd3b10b03b2FDF105Ba280425b45a674F2A"
|
|
263
275
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc004dfbe338c6966a22bcca19"
|
|
@@ -292,6 +304,7 @@ incoLightning_devnet_v1_904635675:
|
|
|
292
304
|
name: incoLightning_devnet_v1_904635675
|
|
293
305
|
majorVersion: 1
|
|
294
306
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
307
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
295
308
|
pepper: devnet
|
|
296
309
|
executorAddress: "0x3473820DcAa71Af8157b93C7f2bf1c676A2A39A6"
|
|
297
310
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc007d63c0fdca6698ac7cc51b"
|
|
@@ -325,6 +338,7 @@ incoLightning_testnet_v0_183408998:
|
|
|
325
338
|
name: incoLightning_testnet_v0_183408998
|
|
326
339
|
majorVersion: 0
|
|
327
340
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
341
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
328
342
|
pepper: testnet
|
|
329
343
|
executorAddress: "0x63D8135aF4D393B1dB43B649010c8D3EE19FC9fd"
|
|
330
344
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc00d75ffa0caf0797c3f12d66"
|
|
@@ -370,6 +384,7 @@ incoLightning_demonet_v0_863421733:
|
|
|
370
384
|
name: incoLightning_demonet_v0_863421733
|
|
371
385
|
majorVersion: 0
|
|
372
386
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
387
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
373
388
|
pepper: demonet
|
|
374
389
|
executorAddress: "0xeBAFF6D578733E4603b99CBdbb221482F29a78E1"
|
|
375
390
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc00834654f6d289ccc7e5ab25"
|
|
@@ -403,6 +418,7 @@ incoLightning_alphanet_v0_297966649:
|
|
|
403
418
|
name: incoLightning_alphanet_v0_297966649
|
|
404
419
|
majorVersion: 0
|
|
405
420
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
421
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
406
422
|
pepper: alphanet
|
|
407
423
|
executorAddress: "0x4651DfD7729aE5568092E7351fAaD872266d4CBd"
|
|
408
424
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc0023f7798f470fdf5e9da639"
|
|
@@ -436,6 +452,7 @@ incoLightning_devnet_v0_340846814:
|
|
|
436
452
|
name: incoLightning_devnet_v0_340846814
|
|
437
453
|
majorVersion: 0
|
|
438
454
|
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
455
|
+
owner: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
439
456
|
pepper: devnet
|
|
440
457
|
executorAddress: "0x3B22be60Ae699933959CA3cE147C96caa88Ccd3D"
|
|
441
458
|
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc00b001d6742fded0dd599ede"
|
package/package.json
CHANGED
package/src/DeployUtils.sol
CHANGED
|
@@ -90,29 +90,32 @@ contract DeployUtils is Script {
|
|
|
90
90
|
/// @notice Full deployment of IncoLightning and IncoVerifier using configuration
|
|
91
91
|
/// @dev Computes salts from deployer and pepper, then deploys both contracts.
|
|
92
92
|
/// Should be wrapped in prank (testing) or broadcast (production).
|
|
93
|
-
/// @param deployer The address
|
|
93
|
+
/// @param deployer The deployer address used in salt for CreateX permissioned deploy protection
|
|
94
|
+
/// @param owner The address that will own both deployed proxies (can be a multisig)
|
|
94
95
|
/// @param pepper Entropy string to avoid address collision with previous deployments
|
|
95
96
|
/// @param quoteVerifier The Automata quote verifier for TEE attestation validation
|
|
96
97
|
/// @return lightningProxy The deployed IncoLightning proxy
|
|
97
98
|
/// @return verifierProxy The deployed IncoVerifier proxy
|
|
98
|
-
function deployIncoLightningUsingConfig(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
function deployIncoLightningUsingConfig(
|
|
100
|
+
address deployer,
|
|
101
|
+
address owner,
|
|
102
|
+
string memory pepper,
|
|
103
|
+
IQuoteVerifier quoteVerifier
|
|
104
|
+
) internal returns (IIncoLightning lightningProxy, IIncoVerifier verifierProxy) {
|
|
102
105
|
(bytes32 lightningSalt, bytes32 verifierSalt) = getIncoSalts(deployer, pepper);
|
|
103
|
-
lightningProxy = deployLightning(lightningSalt, verifierSalt,
|
|
104
|
-
verifierProxy = deployVerifier(verifierSalt, lightningProxy,
|
|
106
|
+
lightningProxy = deployLightning(lightningSalt, verifierSalt, owner);
|
|
107
|
+
verifierProxy = deployVerifier(verifierSalt, lightningProxy, owner, quoteVerifier);
|
|
105
108
|
console.log(
|
|
106
|
-
"Deploying Inco with executor: %s,
|
|
109
|
+
"Deploying Inco with executor: %s, owner: %s, lightning salt: %s",
|
|
107
110
|
vm.toString(address(lightningProxy)),
|
|
108
|
-
vm.toString(
|
|
111
|
+
vm.toString(owner),
|
|
109
112
|
vm.toString(lightningSalt)
|
|
110
113
|
);
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
/// @notice Computes the standard salts for IncoLightning and IncoVerifier
|
|
114
117
|
/// @dev Uses the contract names and major version from IncoLightningConfig
|
|
115
|
-
/// @param deployer The deployer address
|
|
118
|
+
/// @param deployer The deployer address mixed into the salt for CreateX permissioned deploy protection
|
|
116
119
|
/// @param pepper The pepper string for salt generation
|
|
117
120
|
/// @return lightningSalt Salt for IncoLightning deployment
|
|
118
121
|
/// @return verifierSalt Salt for IncoVerifier deployment
|
|
@@ -130,9 +133,9 @@ contract DeployUtils is Script {
|
|
|
130
133
|
/// computed from salt since it may not be deployed yet.
|
|
131
134
|
/// @param lightningSalt The salt for CreateX deployment
|
|
132
135
|
/// @param verifierSalt The salt used to compute the verifier address
|
|
133
|
-
/// @param
|
|
136
|
+
/// @param owner The address that will own the proxy
|
|
134
137
|
/// @return lightningProxy The deployed proxy cast to IIncoLightning
|
|
135
|
-
function deployLightning(bytes32 lightningSalt, bytes32 verifierSalt, address
|
|
138
|
+
function deployLightning(bytes32 lightningSalt, bytes32 verifierSalt, address owner)
|
|
136
139
|
internal
|
|
137
140
|
returns (IIncoLightning lightningProxy)
|
|
138
141
|
{
|
|
@@ -142,10 +145,7 @@ contract DeployUtils is Script {
|
|
|
142
145
|
deployProxy({
|
|
143
146
|
salt: lightningSalt,
|
|
144
147
|
implem: address(lightningImplem),
|
|
145
|
-
initCall: abi.encodeWithSelector(
|
|
146
|
-
IIncoLightning.initialize.selector,
|
|
147
|
-
deployer // owner
|
|
148
|
-
)
|
|
148
|
+
initCall: abi.encodeWithSelector(IIncoLightning.initialize.selector, owner)
|
|
149
149
|
})
|
|
150
150
|
);
|
|
151
151
|
}
|
|
@@ -155,26 +155,20 @@ contract DeployUtils is Script {
|
|
|
155
155
|
/// so it can be referenced in the verifier.
|
|
156
156
|
/// @param verifierSalt The salt for CreateX deployment
|
|
157
157
|
/// @param lightning The previously deployed IncoLightning proxy
|
|
158
|
-
/// @param
|
|
158
|
+
/// @param owner The address that will own the proxy
|
|
159
159
|
/// @param quoteVerifier The Automata quote verifier for TEE attestation
|
|
160
160
|
/// @return verifierProxy The deployed proxy cast to IIncoVerifier
|
|
161
|
-
function deployVerifier(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
IQuoteVerifier quoteVerifier
|
|
166
|
-
) internal returns (IIncoVerifier verifierProxy) {
|
|
161
|
+
function deployVerifier(bytes32 verifierSalt, IIncoLightning lightning, address owner, IQuoteVerifier quoteVerifier)
|
|
162
|
+
internal
|
|
163
|
+
returns (IIncoVerifier verifierProxy)
|
|
164
|
+
{
|
|
167
165
|
IncoVerifier verifierImplem = new IncoVerifier(address(lightning));
|
|
168
166
|
verifierProxy = IIncoVerifier(
|
|
169
167
|
deployProxy({
|
|
170
168
|
salt: verifierSalt,
|
|
171
169
|
implem: address(verifierImplem),
|
|
172
170
|
initCall: abi.encodeWithSelector(
|
|
173
|
-
IIncoVerifier.initialize.selector,
|
|
174
|
-
deployer, // owner
|
|
175
|
-
VERIFIER_NAME,
|
|
176
|
-
lightning.getMajorVersion(),
|
|
177
|
-
quoteVerifier
|
|
171
|
+
IIncoVerifier.initialize.selector, owner, VERIFIER_NAME, lightning.getMajorVersion(), quoteVerifier
|
|
178
172
|
)
|
|
179
173
|
})
|
|
180
174
|
);
|
package/src/Lib.alphanet.sol
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "./IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "./Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "./Types.sol";
|
|
10
|
+
import { asBool } from "./shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "./lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0xc0d693DeEF0A91CE39208676b6da09B822abd199));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
package/src/Lib.demonet.sol
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "./IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "./Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "./Types.sol";
|
|
10
|
+
import { asBool } from "./shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "./lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0xA95EAbCE575f5f1e52605358Ee893F6536166378));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
package/src/Lib.devnet.sol
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "./IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "./Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "./Types.sol";
|
|
10
|
+
import { asBool } from "./shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "./lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0x6c9132D324231D2F68a1491686b0d4c10ee7d257));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
package/src/Lib.sol
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "./IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "./Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "./Types.sol";
|
|
10
|
+
import { asBool } from "./shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "./lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0x6c9132D324231D2F68a1491686b0d4c10ee7d257));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
package/src/Lib.template.sol
CHANGED
|
@@ -12,8 +12,12 @@ import {
|
|
|
12
12
|
IndexOutOfRange,
|
|
13
13
|
InvalidRange,
|
|
14
14
|
SliceOutOfRange,
|
|
15
|
-
UnsupportedListType
|
|
15
|
+
UnsupportedListType,
|
|
16
|
+
HandleMismatch,
|
|
17
|
+
InvalidTEEAttestation,
|
|
18
|
+
UnexpectedDecryptedValue
|
|
16
19
|
} from "./Types.sol";
|
|
20
|
+
import {asBool} from "./shared/TypeUtils.sol";
|
|
17
21
|
import {DecryptionAttestation, ElementAttestationWithProof} from "./lightning-parts/DecryptionAttester.types.sol";
|
|
18
22
|
|
|
19
23
|
// forge-lint: disable-next-line(screaming-snake-case-const)
|
|
@@ -694,7 +698,9 @@ library e {
|
|
|
694
698
|
/// @dev costs the inco fee
|
|
695
699
|
/// @return The encrypted random value
|
|
696
700
|
function rand() internal returns (euint256) {
|
|
697
|
-
bytes32
|
|
701
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
702
|
+
bytes32 result =
|
|
703
|
+
_callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
698
704
|
return euint256.wrap(result);
|
|
699
705
|
}
|
|
700
706
|
|
|
@@ -1245,4 +1251,42 @@ library e {
|
|
|
1245
1251
|
.isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1246
1252
|
}
|
|
1247
1253
|
|
|
1254
|
+
/**
|
|
1255
|
+
* @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1256
|
+
* @param handle The encrypted handle
|
|
1257
|
+
* @param expected The expected plaintext value
|
|
1258
|
+
* @param decryption The decryption attestation to verify
|
|
1259
|
+
* @param signatures The covalidator signatures for the attestation
|
|
1260
|
+
* @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1261
|
+
*/
|
|
1262
|
+
function requireEqual(
|
|
1263
|
+
ebool handle,
|
|
1264
|
+
bool expected,
|
|
1265
|
+
DecryptionAttestation memory decryption,
|
|
1266
|
+
bytes[] memory signatures
|
|
1267
|
+
) internal view {
|
|
1268
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1269
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1270
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
/**
|
|
1274
|
+
* @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1275
|
+
* @param handle The encrypted handle
|
|
1276
|
+
* @param expected The expected plaintext value
|
|
1277
|
+
* @param decryption The decryption attestation to verify
|
|
1278
|
+
* @param signatures The covalidator signatures for the attestation
|
|
1279
|
+
* @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1280
|
+
*/
|
|
1281
|
+
function requireEqual(
|
|
1282
|
+
euint256 handle,
|
|
1283
|
+
uint256 expected,
|
|
1284
|
+
DecryptionAttestation memory decryption,
|
|
1285
|
+
bytes[] memory signatures
|
|
1286
|
+
) internal view {
|
|
1287
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1288
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1289
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1248
1292
|
}
|
package/src/Lib.testnet.sol
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "./IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "./Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "./Types.sol";
|
|
10
|
+
import { asBool } from "./shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "./lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0x168FDc3Ae19A5d5b03614578C58974FF30FCBe92));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
package/src/Types.sol
CHANGED
|
@@ -264,6 +264,9 @@ error ListTypeMismatch(ETypes lhs, ETypes rhs);
|
|
|
264
264
|
error UnsupportedListType(ETypes listType);
|
|
265
265
|
error UnsupportedType(ETypes actual);
|
|
266
266
|
error UnexpectedType(ETypes actual, bytes32 expectedTypes);
|
|
267
|
+
error HandleMismatch();
|
|
268
|
+
error InvalidTEEAttestation();
|
|
269
|
+
error UnexpectedDecryptedValue();
|
|
267
270
|
|
|
268
271
|
string constant EVM_HOST_CHAIN_PREFIX = "evm/";
|
|
269
272
|
uint8 constant HANDLE_VERSION = 0;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "../IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "../Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "../Types.sol";
|
|
10
|
+
import { asBool } from "../shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0x4651DfD7729aE5568092E7351fAaD872266d4CBd));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|