@inco/lightning 0.8.0-devnet-8 → 0.8.0-devnet-9
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 +22 -0
- package/package.json +1 -1
- package/src/CreateXHelper.sol +1 -1
- package/src/IncoLightning.sol +7 -7
- package/src/IncoVerifier.sol +1 -1
- package/src/Lib.devnet.sol +1 -1
- package/src/Lib.sol +1 -1
- package/src/interfaces/automata-interfaces/BELE.sol +1 -1
- package/src/interfaces/automata-interfaces/IPCCSRouter.sol +1 -1
- package/src/interfaces/automata-interfaces/IPcsDao.sol +1 -1
- package/src/interfaces/automata-interfaces/IQuoteVerifier.sol +1 -1
- package/src/interfaces/automata-interfaces/Types.sol +1 -1
- package/src/libs/incoLightning_devnet_v5_203964628.sol +942 -0
- package/src/lightning-parts/AccessControl/AdvancedAccessControl.sol +4 -0
- package/src/lightning-parts/AccessControl/test/TestAdvancedAccessControl.t.sol +15 -0
- package/src/lightning-parts/TEELifecycle.sol +1 -1
- package/src/lightning-parts/TEELifecycle.types.sol +1 -1
- package/src/lightning-parts/interfaces/ITEELifecycle.sol +1 -1
- package/src/pasted-dependencies/ICreateX.sol +1 -1
- package/src/periphery/SessionVerifier.sol +4 -4
- package/src/shared/IOwnable.sol +1 -1
- package/src/shared/IUUPSUpgradable.sol +1 -1
- package/src/test/TEELifecycle/TEELifecycleMockTest.t.sol +1 -1
- package/src/test/TestUpgrade.t.sol +1 -1
- package/src/version/IncoLightningConfig.sol +1 -1
package/manifest.yaml
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
incoLightning_devnet_v5_203964628:
|
|
2
|
+
executor:
|
|
3
|
+
name: incoLightning_devnet_v5_203964628
|
|
4
|
+
majorVersion: 5
|
|
5
|
+
deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
|
|
6
|
+
pepper: devnet
|
|
7
|
+
executorAddress: "0x8D5D75CC00E2Fc84ec4dE085aE1708223591c6b6"
|
|
8
|
+
salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc00c573fb2bf617e75b6210d4"
|
|
9
|
+
deployments:
|
|
10
|
+
- name: incoLightningPreview_5_0_0__203964628
|
|
11
|
+
chainId: "84532"
|
|
12
|
+
chainName: Base Sepolia
|
|
13
|
+
version:
|
|
14
|
+
major: 5
|
|
15
|
+
minor: 0
|
|
16
|
+
patch: 0
|
|
17
|
+
shortSalt: "203964628"
|
|
18
|
+
blockNumber: "37431152"
|
|
19
|
+
deployDate: 2026-02-09T09:49:55.326Z
|
|
20
|
+
commit: v0.8.0-devnet-8-8-ge2e37e00
|
|
21
|
+
active: true
|
|
22
|
+
includesPreviewFeatures: true
|
|
1
23
|
incoLightning_devnet_v4_409204766:
|
|
2
24
|
executor:
|
|
3
25
|
name: incoLightning_devnet_v4_409204766
|
package/package.json
CHANGED
package/src/CreateXHelper.sol
CHANGED
package/src/IncoLightning.sol
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: No License
|
|
2
|
-
pragma solidity ^0.8;
|
|
2
|
+
pragma solidity ^0.8.29;
|
|
3
3
|
|
|
4
4
|
import {IIncoLightning} from "./interfaces/IIncoLightning.sol";
|
|
5
5
|
import {CONTRACT_NAME, MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION} from "./version/IncoLightningConfig.sol";
|
|
@@ -35,10 +35,10 @@ contract IncoLightning is
|
|
|
35
35
|
/// @notice Initializes the IncoLightning contract with deployment configuration
|
|
36
36
|
/// @dev The salt embeds the deployer address, contract name, version, and pepper for deterministic deployment.
|
|
37
37
|
/// This constructor is called once during proxy implementation deployment.
|
|
38
|
-
/// @param
|
|
38
|
+
/// @param _salt Unique salt used for deterministic deployment via CreateX
|
|
39
39
|
/// @param _incoVerifier The verifier contract address for attestation validation
|
|
40
|
-
constructor(bytes32
|
|
41
|
-
Version(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION,
|
|
40
|
+
constructor(bytes32 _salt, IIncoVerifier _incoVerifier)
|
|
41
|
+
Version(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION, _salt, CONTRACT_NAME)
|
|
42
42
|
VerifierAddressGetter(address(_incoVerifier))
|
|
43
43
|
{}
|
|
44
44
|
|
|
@@ -51,9 +51,9 @@ contract IncoLightning is
|
|
|
51
51
|
/// @notice Initializes the proxy with an owner address
|
|
52
52
|
/// @dev Must be called immediately after proxy deployment. Can only be called once.
|
|
53
53
|
/// This sets up the Ownable state for the proxy instance.
|
|
54
|
-
/// @param
|
|
55
|
-
function initialize(address
|
|
56
|
-
__Ownable_init(
|
|
54
|
+
/// @param _owner The address that will own this contract and can authorize upgrades
|
|
55
|
+
function initialize(address _owner) public initializer {
|
|
56
|
+
__Ownable_init(_owner);
|
|
57
57
|
_setAcceptedVersion(2, true);
|
|
58
58
|
}
|
|
59
59
|
|
package/src/IncoVerifier.sol
CHANGED
package/src/Lib.devnet.sol
CHANGED
|
@@ -9,7 +9,7 @@ import { IncoLightning } from "./IncoLightning.sol";
|
|
|
9
9
|
import { ebool, euint256, eaddress, ETypes } from "./Types.sol";
|
|
10
10
|
import { DecryptionAttestation } from "./lightning-parts/DecryptionAttester.types.sol";
|
|
11
11
|
|
|
12
|
-
IncoLightning constant inco = IncoLightning(
|
|
12
|
+
IncoLightning constant inco = IncoLightning(0x8D5D75CC00E2Fc84ec4dE085aE1708223591c6b6);
|
|
13
13
|
address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
|
|
14
14
|
|
|
15
15
|
/// @notice Returns the ETypes enum value encoded in a handle
|
package/src/Lib.sol
CHANGED
|
@@ -9,7 +9,7 @@ import { IncoLightning } from "./IncoLightning.sol";
|
|
|
9
9
|
import { ebool, euint256, eaddress, ETypes } from "./Types.sol";
|
|
10
10
|
import { DecryptionAttestation } from "./lightning-parts/DecryptionAttester.types.sol";
|
|
11
11
|
|
|
12
|
-
IncoLightning constant inco = IncoLightning(
|
|
12
|
+
IncoLightning constant inco = IncoLightning(0x8D5D75CC00E2Fc84ec4dE085aE1708223591c6b6);
|
|
13
13
|
address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
|
|
14
14
|
|
|
15
15
|
/// @notice Returns the ETypes enum value encoded in a handle
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
4
|
// https://github.com/intel/SGXDataCenterAttestationPrimitives/blob/e7604e02331b3377f3766ed3653250e03af72d45/QuoteVerification/QVL/Src/AttestationLibrary/src/CertVerification/X509Constants.h#L64
|
|
5
5
|
uint256 constant TCB_CPUSVN_SIZE = 16;
|
|
@@ -0,0 +1,942 @@
|
|
|
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
|
+
import { DecryptionAttestation } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
|
+
|
|
12
|
+
IncoLightning constant inco = IncoLightning(0x8D5D75CC00E2Fc84ec4dE085aE1708223591c6b6);
|
|
13
|
+
address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
|
|
14
|
+
|
|
15
|
+
/// @notice Returns the ETypes enum value encoded in a handle
|
|
16
|
+
/// @param handle The handle to decode
|
|
17
|
+
/// @return The ETypes value
|
|
18
|
+
function typeOf(bytes32 handle) pure returns (ETypes) {
|
|
19
|
+
return ETypes(uint8(uint256(handle) >> 8));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
library e {
|
|
23
|
+
error CallFailedAfterFeeRefresh();
|
|
24
|
+
|
|
25
|
+
/// @dev slot to store the fee for inco operations
|
|
26
|
+
bytes32 private constant FEE_SLOT = keccak256("inco.fee");
|
|
27
|
+
|
|
28
|
+
/// @notice Returns a sanitized euint256, replacing zero with asEuint256(0)
|
|
29
|
+
/// @param a The euint256 to sanitize
|
|
30
|
+
/// @return The sanitized euint256
|
|
31
|
+
function sanitize(euint256 a) internal returns (euint256) {
|
|
32
|
+
if (euint256.unwrap(a) == bytes32(0)) {
|
|
33
|
+
return asEuint256(0);
|
|
34
|
+
}
|
|
35
|
+
return a;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/// @notice Returns a sanitized ebool, replacing zero with asEbool(false)
|
|
39
|
+
/// @param a The ebool to sanitize
|
|
40
|
+
/// @return The sanitized ebool
|
|
41
|
+
function sanitize(ebool a) internal returns (ebool) {
|
|
42
|
+
if (ebool.unwrap(a) == bytes32(0)) {
|
|
43
|
+
return asEbool(false);
|
|
44
|
+
}
|
|
45
|
+
return a;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// @notice Returns a sanitized eaddress, replacing zero with asEaddress(address(0))
|
|
49
|
+
/// @param a The eaddress to sanitize
|
|
50
|
+
/// @return The sanitized eaddress
|
|
51
|
+
function sanitize(eaddress a) internal returns (eaddress) {
|
|
52
|
+
if (eaddress.unwrap(a) == bytes32(0)) {
|
|
53
|
+
return asEaddress(address(0));
|
|
54
|
+
}
|
|
55
|
+
return a;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/// @notice Alias for sanitize(euint256)
|
|
59
|
+
/// @param a The euint256 to sanitize
|
|
60
|
+
/// @return The sanitized euint256
|
|
61
|
+
function s(euint256 a) internal returns (euint256) {
|
|
62
|
+
return sanitize(a);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/// @notice Alias for sanitize(ebool)
|
|
66
|
+
/// @param a The ebool to sanitize
|
|
67
|
+
/// @return The sanitized ebool
|
|
68
|
+
function s(ebool a) internal returns (ebool) {
|
|
69
|
+
return sanitize(a);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/// @notice Alias for sanitize(eaddress)
|
|
73
|
+
/// @param a The eaddress to sanitize
|
|
74
|
+
/// @return The sanitized eaddress
|
|
75
|
+
function s(eaddress a) internal returns (eaddress) {
|
|
76
|
+
return sanitize(a);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/// @notice Adds two encrypted uint256 values
|
|
80
|
+
/// @param a First operand
|
|
81
|
+
/// @param b Second operand
|
|
82
|
+
/// @return The encrypted sum
|
|
83
|
+
function add(euint256 a, euint256 b) internal returns (euint256) {
|
|
84
|
+
return inco.eAdd(s(a), s(b));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// @notice Adds an encrypted uint256 and a plaintext uint256
|
|
88
|
+
/// @param a Encrypted operand
|
|
89
|
+
/// @param b Plaintext operand
|
|
90
|
+
/// @return The encrypted sum
|
|
91
|
+
function add(euint256 a, uint256 b) internal returns (euint256) {
|
|
92
|
+
return inco.eAdd(s(a), asEuint256(b));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/// @notice Adds a plaintext uint256 and an encrypted uint256
|
|
96
|
+
/// @param a Plaintext operand
|
|
97
|
+
/// @param b Encrypted operand
|
|
98
|
+
/// @return The encrypted sum
|
|
99
|
+
function add(uint256 a, euint256 b) internal returns (euint256) {
|
|
100
|
+
return inco.eAdd(asEuint256(a), s(b));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/// @notice Subtracts two encrypted uint256 values
|
|
104
|
+
/// @param a Encrypted minuend
|
|
105
|
+
/// @param b Encrypted subtrahend
|
|
106
|
+
/// @return The encrypted difference
|
|
107
|
+
function sub(euint256 a, euint256 b) internal returns (euint256) {
|
|
108
|
+
return inco.eSub(s(a), s(b));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// @notice Subtracts a plaintext uint256 from an encrypted uint256
|
|
112
|
+
/// @param a Encrypted minuend
|
|
113
|
+
/// @param b Plaintext subtrahend
|
|
114
|
+
/// @return The encrypted difference
|
|
115
|
+
function sub(euint256 a, uint256 b) internal returns (euint256) {
|
|
116
|
+
return inco.eSub(s(a), asEuint256(b));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/// @notice Subtracts an encrypted uint256 from a plaintext uint256
|
|
120
|
+
/// @param a Plaintext minuend
|
|
121
|
+
/// @param b Encrypted subtrahend
|
|
122
|
+
/// @return The encrypted difference
|
|
123
|
+
function sub(uint256 a, euint256 b) internal returns (euint256) {
|
|
124
|
+
return inco.eSub(asEuint256(a), s(b));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// @notice Multiplies two encrypted uint256 values
|
|
128
|
+
/// @param a Encrypted operand
|
|
129
|
+
/// @param b Encrypted operand
|
|
130
|
+
/// @return The encrypted product
|
|
131
|
+
function mul(euint256 a, euint256 b) internal returns (euint256) {
|
|
132
|
+
return inco.eMul(s(a), s(b));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/// @notice Multiplies an encrypted uint256 and a plaintext uint256
|
|
136
|
+
/// @param a Encrypted operand
|
|
137
|
+
/// @param b Plaintext operand
|
|
138
|
+
/// @return The encrypted product
|
|
139
|
+
function mul(euint256 a, uint256 b) internal returns (euint256) {
|
|
140
|
+
return inco.eMul(s(a), asEuint256(b));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/// @notice Multiplies a plaintext uint256 and an encrypted uint256
|
|
144
|
+
/// @param a Plaintext operand
|
|
145
|
+
/// @param b Encrypted operand
|
|
146
|
+
/// @return The encrypted product
|
|
147
|
+
function mul(uint256 a, euint256 b) internal returns (euint256) {
|
|
148
|
+
return inco.eMul(asEuint256(a), s(b));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/// @notice Divides two encrypted uint256 values
|
|
152
|
+
/// @param a Encrypted Dividend
|
|
153
|
+
/// @param b Encrypted Divisor
|
|
154
|
+
/// @return The encrypted quotient
|
|
155
|
+
function div(euint256 a, euint256 b) internal returns (euint256) {
|
|
156
|
+
return inco.eDiv(s(a), s(b));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/// @notice Divides an encrypted uint256 by a plaintext uint256
|
|
160
|
+
/// @param a Encrypted dividend
|
|
161
|
+
/// @param b Plaintext divisor
|
|
162
|
+
/// @return The encrypted quotient
|
|
163
|
+
function div(euint256 a, uint256 b) internal returns (euint256) {
|
|
164
|
+
return inco.eDiv(s(a), asEuint256(b));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/// @notice Divides a plaintext uint256 by an encrypted uint256
|
|
168
|
+
/// @param a Plaintext dividend
|
|
169
|
+
/// @param b Encrypted divisor
|
|
170
|
+
/// @return The encrypted quotient
|
|
171
|
+
function div(uint256 a, euint256 b) internal returns (euint256) {
|
|
172
|
+
return inco.eDiv(asEuint256(a), s(b));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/// @notice Remainder of two encrypted uint256 values
|
|
176
|
+
/// @param a Encrypted dividend
|
|
177
|
+
/// @param b Encrypted divisor
|
|
178
|
+
/// @return The encrypted remainder
|
|
179
|
+
function rem(euint256 a, euint256 b) internal returns (euint256) {
|
|
180
|
+
return inco.eRem(s(a), s(b));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/// @notice Remainder of an encrypted uint256 and a plaintext uint256
|
|
184
|
+
/// @param a Encrypted dividend
|
|
185
|
+
/// @param b Plaintext divisor
|
|
186
|
+
/// @return The encrypted remainder
|
|
187
|
+
function rem(euint256 a, uint256 b) internal returns (euint256) {
|
|
188
|
+
return inco.eRem(s(a), asEuint256(b));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/// @notice Remainder of a plaintext uint256 and an encrypted uint256
|
|
192
|
+
/// @param a Plaintext dividend
|
|
193
|
+
/// @param b Encrypted divisor
|
|
194
|
+
/// @return The encrypted remainder
|
|
195
|
+
function rem(uint256 a, euint256 b) internal returns (euint256) {
|
|
196
|
+
return inco.eRem(asEuint256(a), s(b));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/// @notice Bitwise AND of two encrypted uint256 values
|
|
200
|
+
/// @param a Encrypted operand
|
|
201
|
+
/// @param b Encrypted operand
|
|
202
|
+
/// @return The encrypted result
|
|
203
|
+
function and(euint256 a, euint256 b) internal returns (euint256) {
|
|
204
|
+
return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/// @notice Bitwise AND of an encrypted uint256 and a plaintext uint256
|
|
208
|
+
/// @param a Encrypted operand
|
|
209
|
+
/// @param b Plaintext operand
|
|
210
|
+
/// @return The encrypted result
|
|
211
|
+
function and(euint256 a, uint256 b) internal returns (euint256) {
|
|
212
|
+
return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/// @notice Bitwise AND of a plaintext uint256 and an encrypted uint256
|
|
216
|
+
/// @param a Plaintext operand
|
|
217
|
+
/// @param b Encrypted operand
|
|
218
|
+
/// @return The encrypted result
|
|
219
|
+
function and(uint256 a, euint256 b) internal returns (euint256) {
|
|
220
|
+
return euint256.wrap(inco.eBitAnd(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/// @notice Bitwise AND of two encrypted bool values
|
|
224
|
+
/// @param a Encrypted operand
|
|
225
|
+
/// @param b Encrypted operand
|
|
226
|
+
/// @return The encrypted result
|
|
227
|
+
function and(ebool a, ebool b) internal returns (ebool) {
|
|
228
|
+
return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/// @notice Bitwise AND of an encrypted bool and a plaintext bool
|
|
232
|
+
/// @param a Encrypted operand
|
|
233
|
+
/// @param b Plaintext operand
|
|
234
|
+
/// @return The encrypted result
|
|
235
|
+
function and(ebool a, bool b) internal returns (ebool) {
|
|
236
|
+
return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/// @notice Bitwise AND of a plaintext bool and an encrypted bool
|
|
240
|
+
/// @param a Plaintext operand
|
|
241
|
+
/// @param b Encrypted operand
|
|
242
|
+
/// @return The encrypted result
|
|
243
|
+
function and(bool a, ebool b) internal returns (ebool) {
|
|
244
|
+
return ebool.wrap(inco.eBitAnd(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/// @notice Bitwise OR of two encrypted uint256 values
|
|
248
|
+
/// @param a Encrypted operand
|
|
249
|
+
/// @param b Encrypted operand
|
|
250
|
+
/// @return The encrypted result
|
|
251
|
+
function or(euint256 a, euint256 b) internal returns (euint256) {
|
|
252
|
+
return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/// @notice Bitwise OR of an encrypted uint256 and a plaintext uint256
|
|
256
|
+
/// @param a Encrypted operand
|
|
257
|
+
/// @param b Plaintext operand
|
|
258
|
+
/// @return The encrypted result
|
|
259
|
+
function or(euint256 a, uint256 b) internal returns (euint256) {
|
|
260
|
+
return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/// @notice Bitwise OR of a plaintext uint256 and an encrypted uint256
|
|
264
|
+
/// @param a Plaintext operand
|
|
265
|
+
/// @param b Encrypted operand
|
|
266
|
+
/// @return The encrypted result
|
|
267
|
+
function or(uint256 a, euint256 b) internal returns (euint256) {
|
|
268
|
+
return euint256.wrap(inco.eBitOr(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/// @notice Bitwise OR of two encrypted bool values
|
|
272
|
+
/// @param a Encrypted operand
|
|
273
|
+
/// @param b Encrypted operand
|
|
274
|
+
/// @return The encrypted result
|
|
275
|
+
function or(ebool a, ebool b) internal returns (ebool) {
|
|
276
|
+
return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/// @notice Bitwise OR of an encrypted bool and a plaintext bool
|
|
280
|
+
/// @param a Encrypted operand
|
|
281
|
+
/// @param b Plaintext operand
|
|
282
|
+
/// @return The encrypted result
|
|
283
|
+
function or(ebool a, bool b) internal returns (ebool) {
|
|
284
|
+
return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/// @notice Bitwise OR of a plaintext bool and an encrypted bool
|
|
288
|
+
/// @param a Plaintext operand
|
|
289
|
+
/// @param b Encrypted operand
|
|
290
|
+
/// @return The encrypted result
|
|
291
|
+
function or(bool a, ebool b) internal returns (ebool) {
|
|
292
|
+
return ebool.wrap(inco.eBitOr(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/// @notice Bitwise XOR of two encrypted uint256 values
|
|
296
|
+
/// @param a Encrypted operand
|
|
297
|
+
/// @param b Encrypted operand
|
|
298
|
+
/// @return The encrypted result
|
|
299
|
+
function xor(euint256 a, euint256 b) internal returns (euint256) {
|
|
300
|
+
return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/// @notice Bitwise XOR of an encrypted uint256 and a plaintext uint256
|
|
304
|
+
/// @param a Encrypted operand
|
|
305
|
+
/// @param b Plaintext operand
|
|
306
|
+
/// @return The encrypted result
|
|
307
|
+
function xor(euint256 a, uint256 b) internal returns (euint256) {
|
|
308
|
+
return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/// @notice Bitwise XOR of a plaintext uint256 and an encrypted uint256
|
|
312
|
+
/// @param a Plaintext operand
|
|
313
|
+
/// @param b Encrypted operand
|
|
314
|
+
/// @return The encrypted result
|
|
315
|
+
function xor(uint256 a, euint256 b) internal returns (euint256) {
|
|
316
|
+
return euint256.wrap(inco.eBitXor(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/// @notice Bitwise XOR of two encrypted bool values
|
|
320
|
+
/// @param a First operand
|
|
321
|
+
/// @param b Second operand
|
|
322
|
+
/// @return The encrypted result
|
|
323
|
+
function xor(ebool a, ebool b) internal returns (ebool) {
|
|
324
|
+
return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/// @notice Bitwise XOR of an encrypted bool and a plaintext bool
|
|
328
|
+
/// @param a Encrypted operand
|
|
329
|
+
/// @param b Plaintext operand
|
|
330
|
+
/// @return The encrypted result
|
|
331
|
+
function xor(ebool a, bool b) internal returns (ebool) {
|
|
332
|
+
return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/// @notice Bitwise XOR of a plaintext bool and an encrypted bool
|
|
336
|
+
/// @param a Plaintext operand
|
|
337
|
+
/// @param b Encrypted operand
|
|
338
|
+
/// @return The encrypted result
|
|
339
|
+
function xor(bool a, ebool b) internal returns (ebool) {
|
|
340
|
+
return ebool.wrap(inco.eBitXor(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/// @notice Left shift of two encrypted uint256 values
|
|
344
|
+
/// @param a Encrypted value to shift
|
|
345
|
+
/// @param b Encrypted shift amount
|
|
346
|
+
/// @return The encrypted result
|
|
347
|
+
function shl(euint256 a, euint256 b) internal returns (euint256) {
|
|
348
|
+
return inco.eShl(s(a), s(b));
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/// @notice Left shift of an encrypted uint256 by a plaintext uint256
|
|
352
|
+
/// @param a Encrypted value to shift
|
|
353
|
+
/// @param b Plaintext shift amount
|
|
354
|
+
/// @return The encrypted result
|
|
355
|
+
function shl(euint256 a, uint256 b) internal returns (euint256) {
|
|
356
|
+
return inco.eShl(s(a), asEuint256(b));
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/// @notice Left shift of a plaintext uint256 by an encrypted uint256
|
|
360
|
+
/// @param a Plaintext value to shift
|
|
361
|
+
/// @param b Encrypted shift amount
|
|
362
|
+
/// @return The encrypted result
|
|
363
|
+
function shl(uint256 a, euint256 b) internal returns (euint256) {
|
|
364
|
+
return inco.eShl(asEuint256(a), s(b));
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/// @notice Right shift of two encrypted uint256 values
|
|
368
|
+
/// @param a Encrypted value to shift
|
|
369
|
+
/// @param b Encrypted shift amount
|
|
370
|
+
/// @return The encrypted result
|
|
371
|
+
function shr(euint256 a, euint256 b) internal returns (euint256) {
|
|
372
|
+
return inco.eShr(s(a), s(b));
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/// @notice Right shift of an encrypted uint256 by a plaintext uint256
|
|
376
|
+
/// @param a Encrypted value to shift
|
|
377
|
+
/// @param b Plaintext shift amount
|
|
378
|
+
/// @return The encrypted result
|
|
379
|
+
function shr(euint256 a, uint256 b) internal returns (euint256) {
|
|
380
|
+
return inco.eShr(s(a), asEuint256(b));
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/// @notice Right shift of a plaintext uint256 by an encrypted uint256
|
|
384
|
+
/// @param a Plaintext value to shift
|
|
385
|
+
/// @param b Encrypted shift amount
|
|
386
|
+
/// @return The encrypted result
|
|
387
|
+
function shr(uint256 a, euint256 b) internal returns (euint256) {
|
|
388
|
+
return inco.eShr(asEuint256(a), s(b));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/// @notice Left rotate of two encrypted uint256 values
|
|
392
|
+
/// @param a Encrypted value to rotate
|
|
393
|
+
/// @param b Encrypted rotate amount
|
|
394
|
+
/// @return The encrypted result
|
|
395
|
+
function rotl(euint256 a, euint256 b) internal returns (euint256) {
|
|
396
|
+
return inco.eRotl(s(a), s(b));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/// @notice Left rotate of an encrypted uint256 by a plaintext uint256
|
|
400
|
+
/// @param a Encrypted value to rotate
|
|
401
|
+
/// @param b Plaintext rotate amount
|
|
402
|
+
/// @return The encrypted result
|
|
403
|
+
function rotl(euint256 a, uint256 b) internal returns (euint256) {
|
|
404
|
+
return inco.eRotl(s(a), asEuint256(b));
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/// @notice Left rotate of a plaintext uint256 by an encrypted uint256
|
|
408
|
+
/// @param a Plaintext value to rotate
|
|
409
|
+
/// @param b Encrypted rotate amount
|
|
410
|
+
/// @return The encrypted result
|
|
411
|
+
function rotl(uint256 a, euint256 b) internal returns (euint256) {
|
|
412
|
+
return inco.eRotl(asEuint256(a), s(b));
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/// @notice Right rotate of two encrypted uint256 values
|
|
416
|
+
/// @param a Encrypted value to rotate
|
|
417
|
+
/// @param b Encrypted rotate amount
|
|
418
|
+
/// @return The encrypted result
|
|
419
|
+
function rotr(euint256 a, euint256 b) internal returns (euint256) {
|
|
420
|
+
return inco.eRotr(s(a), s(b));
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/// @notice Right rotate of an encrypted uint256 by a plaintext uint256
|
|
424
|
+
/// @param a Encrypted value to rotate
|
|
425
|
+
/// @param b Plaintext rotate amount
|
|
426
|
+
/// @return The encrypted result
|
|
427
|
+
function rotr(euint256 a, uint256 b) internal returns (euint256) {
|
|
428
|
+
return inco.eRotr(s(a), asEuint256(b));
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/// @notice Right rotate of a plaintext uint256 by an encrypted uint256
|
|
432
|
+
/// @param a Plaintext value to rotate
|
|
433
|
+
/// @param b Encrypted rotate amount
|
|
434
|
+
/// @return The encrypted result
|
|
435
|
+
function rotr(uint256 a, euint256 b) internal returns (euint256) {
|
|
436
|
+
return inco.eRotr(asEuint256(a), s(b));
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/// @notice Checks equality of two encrypted uint256 values
|
|
440
|
+
/// @param a Encrypted operand
|
|
441
|
+
/// @param b Encrypted operand
|
|
442
|
+
/// @return The encrypted bool result
|
|
443
|
+
function eq(euint256 a, euint256 b) internal returns (ebool) {
|
|
444
|
+
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/// @notice Checks equality of an encrypted uint256 and a plaintext uint256
|
|
448
|
+
/// @param a Encrypted operand
|
|
449
|
+
/// @param b Plaintext operand
|
|
450
|
+
/// @return The encrypted bool result
|
|
451
|
+
function eq(euint256 a, uint256 b) internal returns (ebool) {
|
|
452
|
+
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/// @notice Checks equality of a plaintext uint256 and an encrypted uint256
|
|
456
|
+
/// @param a Plaintext operand
|
|
457
|
+
/// @param b Encrypted operand
|
|
458
|
+
/// @return The encrypted bool result
|
|
459
|
+
function eq(uint256 a, euint256 b) internal returns (ebool) {
|
|
460
|
+
return inco.eEq(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/// @notice Checks equality of an encrypted address and a plaintext address
|
|
464
|
+
/// @param a Encrypted operand
|
|
465
|
+
/// @param b Plaintext operand
|
|
466
|
+
/// @return The encrypted bool result
|
|
467
|
+
function eq(eaddress a, address b) internal returns (ebool) {
|
|
468
|
+
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/// @notice Checks equality of two encrypted addresses
|
|
472
|
+
/// @param a Encrypted operand
|
|
473
|
+
/// @param b Encrypted operand
|
|
474
|
+
/// @return The encrypted bool result
|
|
475
|
+
function eq(eaddress a, eaddress b) internal returns (ebool) {
|
|
476
|
+
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/// @notice Checks equality of a plaintext address and an encrypted address
|
|
480
|
+
/// @param a Plaintext operand
|
|
481
|
+
/// @param b Encrypted operand
|
|
482
|
+
/// @return The encrypted bool result
|
|
483
|
+
function eq(address a, eaddress b) internal returns (ebool) {
|
|
484
|
+
return inco.eEq(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/// @notice Checks inequality of two encrypted uint256 values
|
|
488
|
+
/// @param a Encrypted operand
|
|
489
|
+
/// @param b Encrypted operand
|
|
490
|
+
/// @return The encrypted bool result
|
|
491
|
+
function ne(euint256 a, euint256 b) internal returns (ebool) {
|
|
492
|
+
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/// @notice Checks inequality of an encrypted uint256 and a plaintext uint256
|
|
496
|
+
/// @param a Encrypted operand
|
|
497
|
+
/// @param b Plaintext operand
|
|
498
|
+
/// @return The encrypted bool result
|
|
499
|
+
function ne(euint256 a, uint256 b) internal returns (ebool) {
|
|
500
|
+
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/// @notice Checks inequality of a plaintext uint256 and an encrypted uint256
|
|
504
|
+
/// @param a Plaintext operand
|
|
505
|
+
/// @param b Encrypted operand
|
|
506
|
+
/// @return The encrypted bool result
|
|
507
|
+
function ne(uint256 a, euint256 b) internal returns (ebool) {
|
|
508
|
+
return inco.eNe(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/// @notice Checks inequality of two encrypted addresses
|
|
512
|
+
/// @param a Encrypted operand
|
|
513
|
+
/// @param b Encrypted operand
|
|
514
|
+
/// @return The encrypted bool result
|
|
515
|
+
function ne(eaddress a, eaddress b) internal returns (ebool) {
|
|
516
|
+
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/// @notice Checks inequality of an encrypted address and a plaintext address
|
|
520
|
+
/// @param a Encrypted operand
|
|
521
|
+
/// @param b Plaintext operand
|
|
522
|
+
/// @return The encrypted bool result
|
|
523
|
+
function ne(eaddress a, address b) internal returns (ebool) {
|
|
524
|
+
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/// @notice Checks inequality of a plaintext address and an encrypted address
|
|
528
|
+
/// @param a Plaintext operand
|
|
529
|
+
/// @param b Encrypted operand
|
|
530
|
+
/// @return The encrypted bool result
|
|
531
|
+
function ne(address a, eaddress b) internal returns (ebool) {
|
|
532
|
+
return inco.eNe(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/// @notice Checks if one encrypted uint256 is greater than or equal to another
|
|
536
|
+
/// @param a Encrypted operand
|
|
537
|
+
/// @param b Encrypted operand
|
|
538
|
+
/// @return The encrypted bool result
|
|
539
|
+
function ge(euint256 a, euint256 b) internal returns (ebool) {
|
|
540
|
+
return inco.eGe(s(a), s(b));
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/// @notice Checks if an encrypted uint256 is greater than or equal to a plaintext uint256
|
|
544
|
+
/// @param a Encrypted operand
|
|
545
|
+
/// @param b Plaintext operand
|
|
546
|
+
/// @return The encrypted bool result
|
|
547
|
+
function ge(euint256 a, uint256 b) internal returns (ebool) {
|
|
548
|
+
return inco.eGe(s(a), asEuint256(b));
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/// @notice Checks if a plaintext uint256 is greater than or equal to an encrypted uint256
|
|
552
|
+
/// @param a Plaintext operand
|
|
553
|
+
/// @param b Encrypted operand
|
|
554
|
+
/// @return The encrypted bool result
|
|
555
|
+
function ge(uint256 a, euint256 b) internal returns (ebool) {
|
|
556
|
+
return inco.eGe(asEuint256(a), s(b));
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/// @notice Checks if one encrypted uint256 is greater than another
|
|
560
|
+
/// @param a Encrypted operand
|
|
561
|
+
/// @param b Encrypted operand
|
|
562
|
+
/// @return The encrypted bool result
|
|
563
|
+
function gt(euint256 a, euint256 b) internal returns (ebool) {
|
|
564
|
+
return inco.eGt(s(a), s(b));
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/// @notice Checks if an encrypted uint256 is greater than a plaintext uint256
|
|
568
|
+
/// @param a Encrypted operand
|
|
569
|
+
/// @param b Plaintext operand
|
|
570
|
+
/// @return The encrypted bool result
|
|
571
|
+
function gt(euint256 a, uint256 b) internal returns (ebool) {
|
|
572
|
+
return inco.eGt(s(a), asEuint256(b));
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/// @notice Checks if a plaintext uint256 is greater than an encrypted uint256
|
|
576
|
+
/// @param a Plaintext operand
|
|
577
|
+
/// @param b Encrypted operand
|
|
578
|
+
/// @return The encrypted bool result
|
|
579
|
+
function gt(uint256 a, euint256 b) internal returns (ebool) {
|
|
580
|
+
return inco.eGt(asEuint256(a), s(b));
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/// @notice Checks if one encrypted uint256 is less than or equal to another
|
|
584
|
+
/// @param a Encrypted operand
|
|
585
|
+
/// @param b Encrypted operand
|
|
586
|
+
/// @return The encrypted bool result
|
|
587
|
+
function le(euint256 a, euint256 b) internal returns (ebool) {
|
|
588
|
+
return inco.eLe(s(a), s(b));
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/// @notice Checks if an encrypted uint256 is less than or equal to a plaintext uint256
|
|
592
|
+
/// @param a Encrypted operand
|
|
593
|
+
/// @param b Plaintext operand
|
|
594
|
+
/// @return The encrypted bool result
|
|
595
|
+
function le(euint256 a, uint256 b) internal returns (ebool) {
|
|
596
|
+
return inco.eLe(s(a), asEuint256(b));
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/// @notice Checks if a plaintext uint256 is less than or equal to an encrypted uint256
|
|
600
|
+
/// @param a Plaintext operand
|
|
601
|
+
/// @param b Encrypted operand
|
|
602
|
+
/// @return The encrypted bool result
|
|
603
|
+
function le(uint256 a, euint256 b) internal returns (ebool) {
|
|
604
|
+
return inco.eLe(asEuint256(a), s(b));
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/// @notice Checks if one encrypted uint256 is less than another
|
|
608
|
+
/// @param a Encrypted operand
|
|
609
|
+
/// @param b Encrypted operand
|
|
610
|
+
/// @return The encrypted bool result
|
|
611
|
+
function lt(euint256 a, euint256 b) internal returns (ebool) {
|
|
612
|
+
return inco.eLt(s(a), s(b));
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/// @notice Checks if an encrypted uint256 is less than a plaintext uint256
|
|
616
|
+
/// @param a Encrypted operand
|
|
617
|
+
/// @param b Plaintext operand
|
|
618
|
+
/// @return The encrypted bool result
|
|
619
|
+
function lt(euint256 a, uint256 b) internal returns (ebool) {
|
|
620
|
+
return inco.eLt(s(a), asEuint256(b));
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/// @notice Checks if a plaintext uint256 is less than an encrypted uint256
|
|
624
|
+
/// @param a Plaintext operand
|
|
625
|
+
/// @param b Encrypted operand
|
|
626
|
+
/// @return The encrypted bool result
|
|
627
|
+
function lt(uint256 a, euint256 b) internal returns (ebool) {
|
|
628
|
+
return inco.eLt(asEuint256(a), s(b));
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/// @notice Returns the minimum of two encrypted uint256 values
|
|
632
|
+
/// @param a Encrypted operand
|
|
633
|
+
/// @param b Encrypted operand
|
|
634
|
+
/// @return The encrypted minimum
|
|
635
|
+
function min(euint256 a, euint256 b) internal returns (euint256) {
|
|
636
|
+
return inco.eMin(s(a), s(b));
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/// @notice Returns the minimum of an encrypted uint256 and a plaintext uint256
|
|
640
|
+
/// @param a Encrypted operand
|
|
641
|
+
/// @param b Plaintext operand
|
|
642
|
+
/// @return The encrypted minimum
|
|
643
|
+
function min(euint256 a, uint256 b) internal returns (euint256) {
|
|
644
|
+
return inco.eMin(s(a), asEuint256(b));
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/// @notice Returns the minimum of a plaintext uint256 and an encrypted uint256
|
|
648
|
+
/// @param a Plaintext operand
|
|
649
|
+
/// @param b Encrypted operand
|
|
650
|
+
/// @return The encrypted minimum
|
|
651
|
+
function min(uint256 a, euint256 b) internal returns (euint256) {
|
|
652
|
+
return inco.eMin(asEuint256(a), s(b));
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/// @notice Returns the maximum of two encrypted uint256 values
|
|
656
|
+
/// @param a Encrypted operand
|
|
657
|
+
/// @param b Encrypted operand
|
|
658
|
+
/// @return The encrypted maximum
|
|
659
|
+
function max(euint256 a, euint256 b) internal returns (euint256) {
|
|
660
|
+
return inco.eMax(s(a), s(b));
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/// @notice Returns the maximum of an encrypted uint256 and a plaintext uint256
|
|
664
|
+
/// @param a Encrypted operand
|
|
665
|
+
/// @param b Plaintext operand
|
|
666
|
+
/// @return The encrypted maximum
|
|
667
|
+
function max(euint256 a, uint256 b) internal returns (euint256) {
|
|
668
|
+
return inco.eMax(s(a), asEuint256(b));
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/// @notice Returns the maximum of a plaintext uint256 and an encrypted uint256
|
|
672
|
+
/// @param a Plaintext operand
|
|
673
|
+
/// @param b Encrypted operand
|
|
674
|
+
/// @return The encrypted maximum
|
|
675
|
+
function max(uint256 a, euint256 b) internal returns (euint256) {
|
|
676
|
+
return inco.eMax(asEuint256(a), s(b));
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/// @notice Bitwise NOT of an encrypted bool
|
|
680
|
+
/// @param a Encrypted operand
|
|
681
|
+
/// @return The encrypted result
|
|
682
|
+
function not(ebool a) internal returns (ebool) {
|
|
683
|
+
return inco.eNot(s(a));
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/// @notice Generates a random encrypted uint256 (costs the inco fee)
|
|
687
|
+
/// @dev costs the inco fee
|
|
688
|
+
/// @return The encrypted random value
|
|
689
|
+
function rand() internal returns (euint256) {
|
|
690
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRand.selector, ETypes.Uint256));
|
|
691
|
+
return euint256.wrap(result);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/// @notice Generates a random encrypted uint256 less than a plaintext upper bound (costs the inco fee)
|
|
695
|
+
/// @dev costs the inco fee
|
|
696
|
+
/// @param upperBound The plaintext upper bound
|
|
697
|
+
/// @return The encrypted random value
|
|
698
|
+
function randBounded(uint256 upperBound) internal returns (euint256) {
|
|
699
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(upperBound));
|
|
700
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
701
|
+
return euint256.wrap(result);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/// @notice Generates a random encrypted uint256 less than an encrypted upper bound (costs the inco fee)
|
|
705
|
+
/// @dev costs the inco fee
|
|
706
|
+
/// @param upperBound The encrypted upper bound
|
|
707
|
+
/// @return The encrypted random value
|
|
708
|
+
function randBounded(euint256 upperBound) internal returns (euint256) {
|
|
709
|
+
bytes32 boundHandle = euint256.unwrap(s(upperBound));
|
|
710
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
711
|
+
return euint256.wrap(result);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/// @notice Casts a plaintext uint256 to an encrypted uint256
|
|
715
|
+
/// @param a The plaintext value
|
|
716
|
+
/// @return The encrypted value
|
|
717
|
+
function asEuint256(uint256 a) internal returns (euint256) {
|
|
718
|
+
return inco.asEuint256(a);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/// @notice Casts a plaintext bool to an encrypted bool
|
|
722
|
+
/// @param a The plaintext value
|
|
723
|
+
/// @return The encrypted value
|
|
724
|
+
function asEbool(bool a) internal returns (ebool) {
|
|
725
|
+
return inco.asEbool(a);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/// @notice Casts a plaintext address to an encrypted address
|
|
729
|
+
/// @param a The plaintext value
|
|
730
|
+
/// @return The encrypted value
|
|
731
|
+
function asEaddress(address a) internal returns (eaddress) {
|
|
732
|
+
return inco.asEaddress(a);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/// @notice Casts an encrypted uint256 to an encrypted bool
|
|
736
|
+
/// @param a The encrypted uint256 value
|
|
737
|
+
/// @return The encrypted bool value
|
|
738
|
+
function asEbool(euint256 a) internal returns (ebool) {
|
|
739
|
+
return ebool.wrap(inco.eCast(euint256.unwrap(a), ETypes.Bool));
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/// @notice Casts an encrypted bool to an encrypted uint256
|
|
743
|
+
/// @param a The encrypted bool value
|
|
744
|
+
/// @return The encrypted uint256 value
|
|
745
|
+
function asEuint256(ebool a) internal returns (euint256) {
|
|
746
|
+
return euint256.wrap(inco.eCast(ebool.unwrap(a), ETypes.Uint256));
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/// @notice Creates a new encrypted uint256 assuming msg.sender is the user
|
|
750
|
+
/// @dev costs the inco fee
|
|
751
|
+
function newEuint256(bytes memory ciphertext) internal returns (euint256) {
|
|
752
|
+
return newEuint256(ciphertext, msg.sender);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/// @notice Creates a new encrypted uint256 for the given user.
|
|
756
|
+
/// @dev costs the inco fee
|
|
757
|
+
function newEuint256(bytes memory ciphertext, address user) internal returns (euint256) {
|
|
758
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.newEuint256.selector, ciphertext, user));
|
|
759
|
+
return euint256.wrap(result);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/// @notice Creates a new encrypted bool assuming msg.sender is the user
|
|
763
|
+
/// @dev costs the inco fee
|
|
764
|
+
function newEbool(bytes memory ciphertext) internal returns (ebool) {
|
|
765
|
+
return newEbool(ciphertext, msg.sender);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/// @notice Creates a new encrypted bool for the given user.
|
|
769
|
+
/// @dev costs the inco fee
|
|
770
|
+
function newEbool(bytes memory ciphertext, address user) internal returns (ebool) {
|
|
771
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.newEbool.selector, ciphertext, user));
|
|
772
|
+
return ebool.wrap(result);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/// @notice Creates a new encrypted address assuming msg.sender is the user
|
|
776
|
+
/// @dev costs the inco fee
|
|
777
|
+
function newEaddress(bytes memory ciphertext) internal returns (eaddress) {
|
|
778
|
+
return newEaddress(ciphertext, msg.sender);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/// @notice Creates a new encrypted address for the given user.
|
|
782
|
+
/// @dev costs the inco fee
|
|
783
|
+
function newEaddress(bytes memory ciphertext, address user) internal returns (eaddress) {
|
|
784
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.newEaddress.selector, ciphertext, user));
|
|
785
|
+
return eaddress.wrap(result);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/// @notice Allows an address to access an encrypted uint256
|
|
789
|
+
/// @param a The encrypted uint256
|
|
790
|
+
/// @param to The address to allow
|
|
791
|
+
function allow(euint256 a, address to) internal {
|
|
792
|
+
inco.allow(euint256.unwrap(a), to);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/// @notice Allows an address to access an encrypted bool
|
|
796
|
+
/// @param a The encrypted bool
|
|
797
|
+
/// @param to The address to allow
|
|
798
|
+
function allow(ebool a, address to) internal {
|
|
799
|
+
inco.allow(ebool.unwrap(a), to);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/// @notice Allows an address to access an encrypted address
|
|
803
|
+
/// @param a The encrypted address
|
|
804
|
+
/// @param to The address to allow
|
|
805
|
+
function allow(eaddress a, address to) internal {
|
|
806
|
+
inco.allow(eaddress.unwrap(a), to);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/// @notice Reveals an encrypted uint256
|
|
810
|
+
/// @param a The encrypted uint256
|
|
811
|
+
function reveal(euint256 a) internal {
|
|
812
|
+
inco.reveal(euint256.unwrap(a));
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/// @notice Reveals an encrypted bool
|
|
816
|
+
/// @param a The encrypted bool
|
|
817
|
+
function reveal(ebool a) internal {
|
|
818
|
+
inco.reveal(ebool.unwrap(a));
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/// @notice Reveals an encrypted address
|
|
822
|
+
/// @param a The encrypted address
|
|
823
|
+
function reveal(eaddress a) internal {
|
|
824
|
+
inco.reveal(eaddress.unwrap(a));
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
/// @notice Verifies a decryption attestation for a euint256
|
|
828
|
+
/// @param handle The encrypted handle
|
|
829
|
+
/// @param value The claimed decrypted value
|
|
830
|
+
/// @param signatures The covalidator signatures
|
|
831
|
+
/// @return True if the attestation is valid
|
|
832
|
+
function verifyDecryption(euint256 handle, uint256 value, bytes[] memory signatures) internal view returns (bool) {
|
|
833
|
+
DecryptionAttestation memory attestation = DecryptionAttestation({handle: euint256.unwrap(handle), value: bytes32(value)});
|
|
834
|
+
return inco.incoVerifier().isValidDecryptionAttestation(attestation, signatures);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/// @notice Verifies a decryption attestation for an ebool
|
|
838
|
+
/// @param handle The encrypted handle
|
|
839
|
+
/// @param value The claimed decrypted value
|
|
840
|
+
/// @param signatures The covalidator signatures
|
|
841
|
+
/// @return True if the attestation is valid
|
|
842
|
+
function verifyDecryption(ebool handle, bool value, bytes[] memory signatures) internal view returns (bool) {
|
|
843
|
+
DecryptionAttestation memory attestation = DecryptionAttestation({handle: ebool.unwrap(handle), value: value ? bytes32(uint256(1)) : bytes32(0)});
|
|
844
|
+
return inco.incoVerifier().isValidDecryptionAttestation(attestation, signatures);
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/// @notice Allows this contract to access an encrypted uint256
|
|
848
|
+
/// @param a The encrypted uint256
|
|
849
|
+
function allowThis(euint256 a) internal {
|
|
850
|
+
allow(a, address(this));
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/// @notice Allows this contract to access an encrypted bool
|
|
854
|
+
/// @param a The encrypted bool
|
|
855
|
+
function allowThis(ebool a) internal {
|
|
856
|
+
allow(a, address(this));
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/// @notice Allows this contract to access an encrypted address
|
|
860
|
+
/// @param a The encrypted address
|
|
861
|
+
function allowThis(eaddress a) internal {
|
|
862
|
+
allow(a, address(this));
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
/// @notice Checks if a user is allowed to access an encrypted uint256
|
|
866
|
+
/// @param user The address to check
|
|
867
|
+
/// @param a The encrypted uint256
|
|
868
|
+
/// @return True if allowed, false otherwise
|
|
869
|
+
function isAllowed(address user, euint256 a) internal view returns (bool) {
|
|
870
|
+
return inco.isAllowed(euint256.unwrap(a), user);
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
/// @notice Selects between two encrypted uint256 values based on an encrypted bool
|
|
874
|
+
/// @param control The encrypted bool condition
|
|
875
|
+
/// @param ifTrue Value if control is true
|
|
876
|
+
/// @param ifFalse Value if control is false
|
|
877
|
+
/// @return The selected encrypted uint256
|
|
878
|
+
function select(ebool control, euint256 ifTrue, euint256 ifFalse) internal returns (euint256) {
|
|
879
|
+
return euint256.wrap(inco.eIfThenElse(s(control), euint256.unwrap(s(ifTrue)), euint256.unwrap(s(ifFalse))));
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
/// @notice Selects between two encrypted bool values based on an encrypted bool
|
|
883
|
+
/// @param control The encrypted bool condition
|
|
884
|
+
/// @param ifTrue Value if control is true
|
|
885
|
+
/// @param ifFalse Value if control is false
|
|
886
|
+
/// @return The selected encrypted bool
|
|
887
|
+
function select(ebool control, ebool ifTrue, ebool ifFalse) internal returns (ebool) {
|
|
888
|
+
return ebool.wrap(inco.eIfThenElse(s(control), ebool.unwrap(s(ifTrue)), ebool.unwrap(s(ifFalse))));
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
/// @notice Selects between two encrypted addresses based on an encrypted bool
|
|
892
|
+
/// @param control The encrypted bool condition
|
|
893
|
+
/// @param ifTrue Value if control is true
|
|
894
|
+
/// @param ifFalse Value if control is false
|
|
895
|
+
/// @return The selected encrypted address
|
|
896
|
+
function select(ebool control, eaddress ifTrue, eaddress ifFalse) internal returns (eaddress) {
|
|
897
|
+
return eaddress.wrap(inco.eIfThenElse(s(control), eaddress.unwrap(s(ifTrue)), eaddress.unwrap(s(ifFalse))));
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/// @dev Store fee in the custom slot
|
|
901
|
+
/// @param _fee The fee to store
|
|
902
|
+
function _setFee(uint256 _fee) private {
|
|
903
|
+
bytes32 slot = FEE_SLOT;
|
|
904
|
+
assembly {
|
|
905
|
+
sstore(slot, _fee)
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/// @dev Retrieve fee from the custom slot
|
|
910
|
+
/// @return fee The stored fee
|
|
911
|
+
function _getFee() private view returns (uint256 fee) {
|
|
912
|
+
bytes32 slot = FEE_SLOT;
|
|
913
|
+
assembly {
|
|
914
|
+
fee := sload(slot)
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/// @dev Get current fee with fallback to inco.getFee() if not cached
|
|
919
|
+
function getCurrentFee() private returns (uint256) {
|
|
920
|
+
uint256 cachedFee = _getFee();
|
|
921
|
+
if (cachedFee == 0) {
|
|
922
|
+
cachedFee = inco.getFee();
|
|
923
|
+
_setFee(cachedFee);
|
|
924
|
+
}
|
|
925
|
+
return cachedFee;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/// @dev Execute a call to inco with fee, retrying with fresh fee if it fails
|
|
929
|
+
/// @param callData The encoded function call (use abi.encodeWithSelector)
|
|
930
|
+
/// @return result The bytes32 result from the call
|
|
931
|
+
function _callWithFeeRetry(bytes memory callData) private returns (bytes32) {
|
|
932
|
+
uint256 fee = getCurrentFee();
|
|
933
|
+
(bool success, bytes memory result) = address(inco).call{value: fee}(callData);
|
|
934
|
+
if (!success) {
|
|
935
|
+
fee = inco.getFee();
|
|
936
|
+
_setFee(fee);
|
|
937
|
+
(success, result) = address(inco).call{value: fee}(callData);
|
|
938
|
+
require(success, CallFailedAfterFeeRefresh());
|
|
939
|
+
}
|
|
940
|
+
return abi.decode(result, (bytes32));
|
|
941
|
+
}
|
|
942
|
+
}
|
|
@@ -106,6 +106,9 @@ abstract contract AdvancedAccessControl is
|
|
|
106
106
|
/// @param activeSessionNonce The sharer's current active session nonce
|
|
107
107
|
error InvalidVoucherSessionNonce(bytes32 providedSessionNonce, bytes32 activeSessionNonce);
|
|
108
108
|
|
|
109
|
+
/// @notice Thrown when a voucher's verifyingContract address is the zero address
|
|
110
|
+
error InvalidVerifyingContract();
|
|
111
|
+
|
|
109
112
|
/// @notice Checks if an account is allowed to access a handle using a signed voucher proof
|
|
110
113
|
/// @dev Intended for simulation/off-chain calls. Not a view function as it calls external contracts.
|
|
111
114
|
/// Verification steps:
|
|
@@ -118,6 +121,7 @@ abstract contract AdvancedAccessControl is
|
|
|
118
121
|
/// @param proof The allowance proof containing voucher, signature, and requester data
|
|
119
122
|
/// @return True if access is allowed, false or reverts otherwise
|
|
120
123
|
function isAllowedWithProof(bytes32 handle, address account, AllowanceProof memory proof) public returns (bool) {
|
|
124
|
+
require(proof.voucher.verifyingContract != address(0), InvalidVerifyingContract());
|
|
121
125
|
require(
|
|
122
126
|
IBaseAccessControlList(incoLightningAddress).isAllowed(handle, proof.sharer),
|
|
123
127
|
SharerNotAllowedForHandle(handle, proof.sharer)
|
|
@@ -88,6 +88,21 @@ contract TestAdvancedAccessControl is IncoTest {
|
|
|
88
88
|
incoVerifier = inco.incoVerifier();
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
function testAdvancedSharingWithInvalidVerifyingContract() public {
|
|
92
|
+
AllowanceVoucher memory invalidSessionVoucher = AllowanceVoucher({
|
|
93
|
+
sessionNonce: bytes32(0),
|
|
94
|
+
verifyingContract: address(0),
|
|
95
|
+
callFunction: SessionVerifier.canUseSession.selector,
|
|
96
|
+
sharerArgData: abi.encode(Session({decrypter: bob, expiresAt: block.timestamp + 1 days}))
|
|
97
|
+
});
|
|
98
|
+
AllowanceProof memory bobsProof = getBobsProof(invalidSessionVoucher);
|
|
99
|
+
vm.expectRevert(abi.encodeWithSelector(AdvancedAccessControl.InvalidVerifyingContract.selector));
|
|
100
|
+
incoVerifier.isAllowedWithProof(secretHandle, bob, bobsProof);
|
|
101
|
+
vm.prank(bob);
|
|
102
|
+
vm.expectRevert(abi.encodeWithSelector(AdvancedAccessControl.InvalidVerifyingContract.selector));
|
|
103
|
+
inco.claimHandle(secretHandle, bobsProof);
|
|
104
|
+
}
|
|
105
|
+
|
|
91
106
|
function testAdvancedSharingWithSession() public {
|
|
92
107
|
SessionVerifier sessionVerifier = new SessionVerifier("");
|
|
93
108
|
assertFalse(inco.isAllowed(secretHandle, bob), "bob should't be allowed on secret yet");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// SPDX-License-Identifier: No License
|
|
2
|
-
pragma solidity ^0.8
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
4
|
import {BootstrapResult, UpgradeResult, AddNodeResult} from "../TEELifecycle.types.sol";
|
|
5
5
|
import {IQuoteVerifier} from "../../interfaces/automata-interfaces/IQuoteVerifier.sol";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: No License
|
|
2
|
-
pragma solidity ^0.8;
|
|
2
|
+
pragma solidity ^0.8.29;
|
|
3
3
|
|
|
4
4
|
import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
5
5
|
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
@@ -38,13 +38,13 @@ struct Session {
|
|
|
38
38
|
contract SessionVerifier is UUPSUpgradeable, OwnableUpgradeable, Version {
|
|
39
39
|
|
|
40
40
|
/// @notice Initializes the SessionVerifier with version information
|
|
41
|
-
/// @param
|
|
42
|
-
constructor(bytes32
|
|
41
|
+
/// @param _salt Unique salt used for deterministic deployment via CreateX
|
|
42
|
+
constructor(bytes32 _salt)
|
|
43
43
|
Version(
|
|
44
44
|
SESSION_VERIFIER_MAJOR_VERSION,
|
|
45
45
|
SESSION_VERIFIER_MINOR_VERSION,
|
|
46
46
|
SESSION_VERIFIER_PATCH_VERSION,
|
|
47
|
-
|
|
47
|
+
_salt,
|
|
48
48
|
SESSION_VERIFIER_NAME
|
|
49
49
|
)
|
|
50
50
|
{}
|
package/src/shared/IOwnable.sol
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
4
|
import {TEELifecycle} from "../../lightning-parts/TEELifecycle.sol";
|
|
5
5
|
import {BootstrapResult, AddNodeResult, UpgradeResult} from "../../lightning-parts/TEELifecycle.types.sol";
|
|
@@ -7,7 +7,7 @@ pragma solidity ^0.8;
|
|
|
7
7
|
// UPDATE the CHANGELOG on new versions
|
|
8
8
|
|
|
9
9
|
string constant CONTRACT_NAME = "incoLightning";
|
|
10
|
-
uint8 constant MAJOR_VERSION =
|
|
10
|
+
uint8 constant MAJOR_VERSION = 5;
|
|
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
|