@inco/lightning 0.8.0-devnet-4 → 0.8.0-devnet-5
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/README.md +59 -1
- package/manifest.yaml +22 -0
- package/package.json +1 -1
- package/src/DeployUtils.sol +71 -25
- package/src/IncoLightning.sol +27 -7
- package/src/IncoVerifier.sol +18 -1
- package/src/Lib.alphanet.sol +390 -3
- package/src/Lib.demonet.sol +390 -3
- package/src/Lib.devnet.sol +391 -4
- package/src/Lib.sol +391 -4
- package/src/Lib.template.sol +387 -0
- package/src/Lib.testnet.sol +390 -3
- package/src/libs/incoLightning_alphanet_v0_297966649.sol +390 -3
- package/src/libs/incoLightning_alphanet_v1_725458969.sol +390 -3
- package/src/libs/incoLightning_alphanet_v2_976644394.sol +390 -3
- package/src/libs/incoLightning_demonet_v0_863421733.sol +390 -3
- package/src/libs/incoLightning_demonet_v2_467437523.sol +390 -3
- package/src/libs/incoLightning_devnet_v0_340846814.sol +390 -3
- package/src/libs/incoLightning_devnet_v1_904635675.sol +390 -3
- package/src/libs/incoLightning_devnet_v2_295237520.sol +390 -3
- package/src/libs/incoLightning_devnet_v3_976859633.sol +390 -3
- package/src/libs/incoLightning_devnet_v4_409204766.sol +921 -0
- package/src/libs/incoLightning_testnet_v0_183408998.sol +390 -3
- package/src/libs/incoLightning_testnet_v2_889158349.sol +390 -3
- package/src/lightning-parts/AccessControl/AdvancedAccessControl.sol +65 -4
- package/src/lightning-parts/AccessControl/BaseAccessControlList.sol +71 -5
- package/src/lightning-parts/DecryptionAttester.sol +16 -3
- package/src/lightning-parts/EncryptedInput.sol +48 -2
- package/src/lightning-parts/EncryptedOperations.sol +134 -1
- package/src/lightning-parts/Fee.sol +29 -6
- package/src/lightning-parts/primitives/EventCounter.sol +36 -5
- package/src/lightning-parts/primitives/HandleGeneration.sol +38 -6
- package/src/lightning-parts/primitives/HandleMetadata.sol +28 -0
- package/src/lightning-parts/primitives/LightningAddressGetter.sol +10 -0
- package/src/lightning-parts/primitives/VerifierAddressGetter.sol +10 -0
- package/src/lightning-parts/primitives/test/SignatureVerifier.t.sol +0 -2
- package/src/periphery/IncoUtils.sol +1 -0
- package/src/periphery/SessionVerifier.sol +35 -7
- package/src/test/TestFakeInfra.t.sol +536 -1
- package/src/version/IncoLightningConfig.sol +2 -2
package/src/Lib.alphanet.sol
CHANGED
|
@@ -11,6 +11,9 @@ import { ebool, euint256, eaddress, ETypes } from "./Types.sol";
|
|
|
11
11
|
IncoLightning constant inco = IncoLightning(0xc0d693DeEF0A91CE39208676b6da09B822abd199);
|
|
12
12
|
address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
|
|
13
13
|
|
|
14
|
+
/// @notice Returns the ETypes enum value encoded in a handle
|
|
15
|
+
/// @param handle The handle to decode
|
|
16
|
+
/// @return The ETypes value
|
|
14
17
|
function typeOf(bytes32 handle) pure returns (ETypes) {
|
|
15
18
|
return ETypes(uint8(uint256(handle) >> 8));
|
|
16
19
|
}
|
|
@@ -21,6 +24,9 @@ library e {
|
|
|
21
24
|
/// @dev slot to store the fee for inco operations
|
|
22
25
|
bytes32 private constant FEE_SLOT = keccak256("inco.fee");
|
|
23
26
|
|
|
27
|
+
/// @notice Returns a sanitized euint256, replacing zero with asEuint256(0)
|
|
28
|
+
/// @param a The euint256 to sanitize
|
|
29
|
+
/// @return The sanitized euint256
|
|
24
30
|
function sanitize(euint256 a) internal returns (euint256) {
|
|
25
31
|
if (euint256.unwrap(a) == bytes32(0)) {
|
|
26
32
|
return asEuint256(0);
|
|
@@ -28,6 +34,9 @@ library e {
|
|
|
28
34
|
return a;
|
|
29
35
|
}
|
|
30
36
|
|
|
37
|
+
/// @notice Returns a sanitized ebool, replacing zero with asEbool(false)
|
|
38
|
+
/// @param a The ebool to sanitize
|
|
39
|
+
/// @return The sanitized ebool
|
|
31
40
|
function sanitize(ebool a) internal returns (ebool) {
|
|
32
41
|
if (ebool.unwrap(a) == bytes32(0)) {
|
|
33
42
|
return asEbool(false);
|
|
@@ -35,6 +44,9 @@ library e {
|
|
|
35
44
|
return a;
|
|
36
45
|
}
|
|
37
46
|
|
|
47
|
+
/// @notice Returns a sanitized eaddress, replacing zero with asEaddress(address(0))
|
|
48
|
+
/// @param a The eaddress to sanitize
|
|
49
|
+
/// @return The sanitized eaddress
|
|
38
50
|
function sanitize(eaddress a) internal returns (eaddress) {
|
|
39
51
|
if (eaddress.unwrap(a) == bytes32(0)) {
|
|
40
52
|
return asEaddress(address(0));
|
|
@@ -42,358 +54,693 @@ library e {
|
|
|
42
54
|
return a;
|
|
43
55
|
}
|
|
44
56
|
|
|
57
|
+
/// @notice Alias for sanitize(euint256)
|
|
58
|
+
/// @param a The euint256 to sanitize
|
|
59
|
+
/// @return The sanitized euint256
|
|
45
60
|
function s(euint256 a) internal returns (euint256) {
|
|
46
61
|
return sanitize(a);
|
|
47
62
|
}
|
|
48
63
|
|
|
64
|
+
/// @notice Alias for sanitize(ebool)
|
|
65
|
+
/// @param a The ebool to sanitize
|
|
66
|
+
/// @return The sanitized ebool
|
|
49
67
|
function s(ebool a) internal returns (ebool) {
|
|
50
68
|
return sanitize(a);
|
|
51
69
|
}
|
|
52
70
|
|
|
71
|
+
/// @notice Alias for sanitize(eaddress)
|
|
72
|
+
/// @param a The eaddress to sanitize
|
|
73
|
+
/// @return The sanitized eaddress
|
|
53
74
|
function s(eaddress a) internal returns (eaddress) {
|
|
54
75
|
return sanitize(a);
|
|
55
76
|
}
|
|
56
77
|
|
|
78
|
+
/// @notice Adds two encrypted uint256 values
|
|
79
|
+
/// @param a First operand
|
|
80
|
+
/// @param b Second operand
|
|
81
|
+
/// @return The encrypted sum
|
|
57
82
|
function add(euint256 a, euint256 b) internal returns (euint256) {
|
|
58
83
|
return inco.eAdd(s(a), s(b));
|
|
59
84
|
}
|
|
60
85
|
|
|
86
|
+
/// @notice Adds an encrypted uint256 and a plaintext uint256
|
|
87
|
+
/// @param a Encrypted operand
|
|
88
|
+
/// @param b Plaintext operand
|
|
89
|
+
/// @return The encrypted sum
|
|
61
90
|
function add(euint256 a, uint256 b) internal returns (euint256) {
|
|
62
91
|
return inco.eAdd(s(a), asEuint256(b));
|
|
63
92
|
}
|
|
64
93
|
|
|
94
|
+
/// @notice Adds a plaintext uint256 and an encrypted uint256
|
|
95
|
+
/// @param a Plaintext operand
|
|
96
|
+
/// @param b Encrypted operand
|
|
97
|
+
/// @return The encrypted sum
|
|
65
98
|
function add(uint256 a, euint256 b) internal returns (euint256) {
|
|
66
99
|
return inco.eAdd(asEuint256(a), s(b));
|
|
67
100
|
}
|
|
68
101
|
|
|
102
|
+
/// @notice Subtracts two encrypted uint256 values
|
|
103
|
+
/// @param a Encrypted minuend
|
|
104
|
+
/// @param b Encrypted subtrahend
|
|
105
|
+
/// @return The encrypted difference
|
|
69
106
|
function sub(euint256 a, euint256 b) internal returns (euint256) {
|
|
70
107
|
return inco.eSub(s(a), s(b));
|
|
71
108
|
}
|
|
72
109
|
|
|
110
|
+
/// @notice Subtracts a plaintext uint256 from an encrypted uint256
|
|
111
|
+
/// @param a Encrypted minuend
|
|
112
|
+
/// @param b Plaintext subtrahend
|
|
113
|
+
/// @return The encrypted difference
|
|
73
114
|
function sub(euint256 a, uint256 b) internal returns (euint256) {
|
|
74
115
|
return inco.eSub(s(a), asEuint256(b));
|
|
75
116
|
}
|
|
76
117
|
|
|
118
|
+
/// @notice Subtracts an encrypted uint256 from a plaintext uint256
|
|
119
|
+
/// @param a Plaintext minuend
|
|
120
|
+
/// @param b Encrypted subtrahend
|
|
121
|
+
/// @return The encrypted difference
|
|
77
122
|
function sub(uint256 a, euint256 b) internal returns (euint256) {
|
|
78
123
|
return inco.eSub(asEuint256(a), s(b));
|
|
79
124
|
}
|
|
80
125
|
|
|
126
|
+
/// @notice Multiplies two encrypted uint256 values
|
|
127
|
+
/// @param a Encrypted operand
|
|
128
|
+
/// @param b Encrypted operand
|
|
129
|
+
/// @return The encrypted product
|
|
81
130
|
function mul(euint256 a, euint256 b) internal returns (euint256) {
|
|
82
131
|
return inco.eMul(s(a), s(b));
|
|
83
132
|
}
|
|
84
133
|
|
|
134
|
+
/// @notice Multiplies an encrypted uint256 and a plaintext uint256
|
|
135
|
+
/// @param a Encrypted operand
|
|
136
|
+
/// @param b Plaintext operand
|
|
137
|
+
/// @return The encrypted product
|
|
85
138
|
function mul(euint256 a, uint256 b) internal returns (euint256) {
|
|
86
139
|
return inco.eMul(s(a), asEuint256(b));
|
|
87
140
|
}
|
|
88
141
|
|
|
142
|
+
/// @notice Multiplies a plaintext uint256 and an encrypted uint256
|
|
143
|
+
/// @param a Plaintext operand
|
|
144
|
+
/// @param b Encrypted operand
|
|
145
|
+
/// @return The encrypted product
|
|
89
146
|
function mul(uint256 a, euint256 b) internal returns (euint256) {
|
|
90
147
|
return inco.eMul(asEuint256(a), s(b));
|
|
91
148
|
}
|
|
92
149
|
|
|
150
|
+
/// @notice Divides two encrypted uint256 values
|
|
151
|
+
/// @param a Encrypted Dividend
|
|
152
|
+
/// @param b Encrypted Divisor
|
|
153
|
+
/// @return The encrypted quotient
|
|
93
154
|
function div(euint256 a, euint256 b) internal returns (euint256) {
|
|
94
155
|
return inco.eDiv(s(a), s(b));
|
|
95
156
|
}
|
|
96
157
|
|
|
158
|
+
/// @notice Divides an encrypted uint256 by a plaintext uint256
|
|
159
|
+
/// @param a Encrypted dividend
|
|
160
|
+
/// @param b Plaintext divisor
|
|
161
|
+
/// @return The encrypted quotient
|
|
97
162
|
function div(euint256 a, uint256 b) internal returns (euint256) {
|
|
98
163
|
return inco.eDiv(s(a), asEuint256(b));
|
|
99
164
|
}
|
|
100
165
|
|
|
166
|
+
/// @notice Divides a plaintext uint256 by an encrypted uint256
|
|
167
|
+
/// @param a Plaintext dividend
|
|
168
|
+
/// @param b Encrypted divisor
|
|
169
|
+
/// @return The encrypted quotient
|
|
101
170
|
function div(uint256 a, euint256 b) internal returns (euint256) {
|
|
102
171
|
return inco.eDiv(asEuint256(a), s(b));
|
|
103
172
|
}
|
|
104
173
|
|
|
174
|
+
/// @notice Remainder of two encrypted uint256 values
|
|
175
|
+
/// @param a Encrypted dividend
|
|
176
|
+
/// @param b Encrypted divisor
|
|
177
|
+
/// @return The encrypted remainder
|
|
105
178
|
function rem(euint256 a, euint256 b) internal returns (euint256) {
|
|
106
179
|
return inco.eRem(s(a), s(b));
|
|
107
180
|
}
|
|
108
181
|
|
|
182
|
+
/// @notice Remainder of an encrypted uint256 and a plaintext uint256
|
|
183
|
+
/// @param a Encrypted dividend
|
|
184
|
+
/// @param b Plaintext divisor
|
|
185
|
+
/// @return The encrypted remainder
|
|
109
186
|
function rem(euint256 a, uint256 b) internal returns (euint256) {
|
|
110
187
|
return inco.eRem(s(a), asEuint256(b));
|
|
111
188
|
}
|
|
112
189
|
|
|
190
|
+
/// @notice Remainder of a plaintext uint256 and an encrypted uint256
|
|
191
|
+
/// @param a Plaintext dividend
|
|
192
|
+
/// @param b Encrypted divisor
|
|
193
|
+
/// @return The encrypted remainder
|
|
113
194
|
function rem(uint256 a, euint256 b) internal returns (euint256) {
|
|
114
195
|
return inco.eRem(asEuint256(a), s(b));
|
|
115
196
|
}
|
|
116
197
|
|
|
198
|
+
/// @notice Bitwise AND of two encrypted uint256 values
|
|
199
|
+
/// @param a Encrypted operand
|
|
200
|
+
/// @param b Encrypted operand
|
|
201
|
+
/// @return The encrypted result
|
|
117
202
|
function and(euint256 a, euint256 b) internal returns (euint256) {
|
|
118
203
|
return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
|
|
119
204
|
}
|
|
120
205
|
|
|
206
|
+
/// @notice Bitwise AND of an encrypted uint256 and a plaintext uint256
|
|
207
|
+
/// @param a Encrypted operand
|
|
208
|
+
/// @param b Plaintext operand
|
|
209
|
+
/// @return The encrypted result
|
|
121
210
|
function and(euint256 a, uint256 b) internal returns (euint256) {
|
|
122
211
|
return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
|
|
123
212
|
}
|
|
124
213
|
|
|
214
|
+
/// @notice Bitwise AND of a plaintext uint256 and an encrypted uint256
|
|
215
|
+
/// @param a Plaintext operand
|
|
216
|
+
/// @param b Encrypted operand
|
|
217
|
+
/// @return The encrypted result
|
|
125
218
|
function and(uint256 a, euint256 b) internal returns (euint256) {
|
|
126
219
|
return euint256.wrap(inco.eBitAnd(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
|
|
127
220
|
}
|
|
128
221
|
|
|
222
|
+
/// @notice Bitwise AND of two encrypted bool values
|
|
223
|
+
/// @param a Encrypted operand
|
|
224
|
+
/// @param b Encrypted operand
|
|
225
|
+
/// @return The encrypted result
|
|
129
226
|
function and(ebool a, ebool b) internal returns (ebool) {
|
|
130
227
|
return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
|
|
131
228
|
}
|
|
132
229
|
|
|
230
|
+
/// @notice Bitwise AND of an encrypted bool and a plaintext bool
|
|
231
|
+
/// @param a Encrypted operand
|
|
232
|
+
/// @param b Plaintext operand
|
|
233
|
+
/// @return The encrypted result
|
|
133
234
|
function and(ebool a, bool b) internal returns (ebool) {
|
|
134
235
|
return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
|
|
135
236
|
}
|
|
136
237
|
|
|
238
|
+
/// @notice Bitwise AND of a plaintext bool and an encrypted bool
|
|
239
|
+
/// @param a Plaintext operand
|
|
240
|
+
/// @param b Encrypted operand
|
|
241
|
+
/// @return The encrypted result
|
|
137
242
|
function and(bool a, ebool b) internal returns (ebool) {
|
|
138
243
|
return ebool.wrap(inco.eBitAnd(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
|
|
139
244
|
}
|
|
140
245
|
|
|
246
|
+
/// @notice Bitwise OR of two encrypted uint256 values
|
|
247
|
+
/// @param a Encrypted operand
|
|
248
|
+
/// @param b Encrypted operand
|
|
249
|
+
/// @return The encrypted result
|
|
141
250
|
function or(euint256 a, euint256 b) internal returns (euint256) {
|
|
142
251
|
return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
|
|
143
252
|
}
|
|
144
253
|
|
|
254
|
+
/// @notice Bitwise OR of an encrypted uint256 and a plaintext uint256
|
|
255
|
+
/// @param a Encrypted operand
|
|
256
|
+
/// @param b Plaintext operand
|
|
257
|
+
/// @return The encrypted result
|
|
145
258
|
function or(euint256 a, uint256 b) internal returns (euint256) {
|
|
146
259
|
return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
|
|
147
260
|
}
|
|
148
261
|
|
|
262
|
+
/// @notice Bitwise OR of a plaintext uint256 and an encrypted uint256
|
|
263
|
+
/// @param a Plaintext operand
|
|
264
|
+
/// @param b Encrypted operand
|
|
265
|
+
/// @return The encrypted result
|
|
149
266
|
function or(uint256 a, euint256 b) internal returns (euint256) {
|
|
150
267
|
return euint256.wrap(inco.eBitOr(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
|
|
151
268
|
}
|
|
152
269
|
|
|
270
|
+
/// @notice Bitwise OR of two encrypted bool values
|
|
271
|
+
/// @param a Encrypted operand
|
|
272
|
+
/// @param b Encrypted operand
|
|
273
|
+
/// @return The encrypted result
|
|
153
274
|
function or(ebool a, ebool b) internal returns (ebool) {
|
|
154
275
|
return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
|
|
155
276
|
}
|
|
156
277
|
|
|
278
|
+
/// @notice Bitwise OR of an encrypted bool and a plaintext bool
|
|
279
|
+
/// @param a Encrypted operand
|
|
280
|
+
/// @param b Plaintext operand
|
|
281
|
+
/// @return The encrypted result
|
|
157
282
|
function or(ebool a, bool b) internal returns (ebool) {
|
|
158
283
|
return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
|
|
159
284
|
}
|
|
160
285
|
|
|
286
|
+
/// @notice Bitwise OR of a plaintext bool and an encrypted bool
|
|
287
|
+
/// @param a Plaintext operand
|
|
288
|
+
/// @param b Encrypted operand
|
|
289
|
+
/// @return The encrypted result
|
|
161
290
|
function or(bool a, ebool b) internal returns (ebool) {
|
|
162
291
|
return ebool.wrap(inco.eBitOr(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
|
|
163
292
|
}
|
|
164
293
|
|
|
294
|
+
/// @notice Bitwise XOR of two encrypted uint256 values
|
|
295
|
+
/// @param a Encrypted operand
|
|
296
|
+
/// @param b Encrypted operand
|
|
297
|
+
/// @return The encrypted result
|
|
165
298
|
function xor(euint256 a, euint256 b) internal returns (euint256) {
|
|
166
299
|
return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
|
|
167
300
|
}
|
|
168
301
|
|
|
302
|
+
/// @notice Bitwise XOR of an encrypted uint256 and a plaintext uint256
|
|
303
|
+
/// @param a Encrypted operand
|
|
304
|
+
/// @param b Plaintext operand
|
|
305
|
+
/// @return The encrypted result
|
|
169
306
|
function xor(euint256 a, uint256 b) internal returns (euint256) {
|
|
170
307
|
return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
|
|
171
308
|
}
|
|
172
309
|
|
|
310
|
+
/// @notice Bitwise XOR of a plaintext uint256 and an encrypted uint256
|
|
311
|
+
/// @param a Plaintext operand
|
|
312
|
+
/// @param b Encrypted operand
|
|
313
|
+
/// @return The encrypted result
|
|
173
314
|
function xor(uint256 a, euint256 b) internal returns (euint256) {
|
|
174
315
|
return euint256.wrap(inco.eBitXor(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
|
|
175
316
|
}
|
|
176
317
|
|
|
318
|
+
/// @notice Bitwise XOR of two encrypted bool values
|
|
319
|
+
/// @param a First operand
|
|
320
|
+
/// @param b Second operand
|
|
321
|
+
/// @return The encrypted result
|
|
177
322
|
function xor(ebool a, ebool b) internal returns (ebool) {
|
|
178
323
|
return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
|
|
179
324
|
}
|
|
180
325
|
|
|
326
|
+
/// @notice Bitwise XOR of an encrypted bool and a plaintext bool
|
|
327
|
+
/// @param a Encrypted operand
|
|
328
|
+
/// @param b Plaintext operand
|
|
329
|
+
/// @return The encrypted result
|
|
181
330
|
function xor(ebool a, bool b) internal returns (ebool) {
|
|
182
331
|
return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
|
|
183
332
|
}
|
|
184
333
|
|
|
334
|
+
/// @notice Bitwise XOR of a plaintext bool and an encrypted bool
|
|
335
|
+
/// @param a Plaintext operand
|
|
336
|
+
/// @param b Encrypted operand
|
|
337
|
+
/// @return The encrypted result
|
|
185
338
|
function xor(bool a, ebool b) internal returns (ebool) {
|
|
186
339
|
return ebool.wrap(inco.eBitXor(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
|
|
187
340
|
}
|
|
188
341
|
|
|
342
|
+
/// @notice Left shift of two encrypted uint256 values
|
|
343
|
+
/// @param a Encrypted value to shift
|
|
344
|
+
/// @param b Encrypted shift amount
|
|
345
|
+
/// @return The encrypted result
|
|
189
346
|
function shl(euint256 a, euint256 b) internal returns (euint256) {
|
|
190
347
|
return inco.eShl(s(a), s(b));
|
|
191
348
|
}
|
|
192
349
|
|
|
350
|
+
/// @notice Left shift of an encrypted uint256 by a plaintext uint256
|
|
351
|
+
/// @param a Encrypted value to shift
|
|
352
|
+
/// @param b Plaintext shift amount
|
|
353
|
+
/// @return The encrypted result
|
|
193
354
|
function shl(euint256 a, uint256 b) internal returns (euint256) {
|
|
194
355
|
return inco.eShl(s(a), asEuint256(b));
|
|
195
356
|
}
|
|
196
357
|
|
|
358
|
+
/// @notice Left shift of a plaintext uint256 by an encrypted uint256
|
|
359
|
+
/// @param a Plaintext value to shift
|
|
360
|
+
/// @param b Encrypted shift amount
|
|
361
|
+
/// @return The encrypted result
|
|
197
362
|
function shl(uint256 a, euint256 b) internal returns (euint256) {
|
|
198
363
|
return inco.eShl(asEuint256(a), s(b));
|
|
199
364
|
}
|
|
200
365
|
|
|
366
|
+
/// @notice Right shift of two encrypted uint256 values
|
|
367
|
+
/// @param a Encrypted value to shift
|
|
368
|
+
/// @param b Encrypted shift amount
|
|
369
|
+
/// @return The encrypted result
|
|
201
370
|
function shr(euint256 a, euint256 b) internal returns (euint256) {
|
|
202
371
|
return inco.eShr(s(a), s(b));
|
|
203
372
|
}
|
|
204
373
|
|
|
374
|
+
/// @notice Right shift of an encrypted uint256 by a plaintext uint256
|
|
375
|
+
/// @param a Encrypted value to shift
|
|
376
|
+
/// @param b Plaintext shift amount
|
|
377
|
+
/// @return The encrypted result
|
|
205
378
|
function shr(euint256 a, uint256 b) internal returns (euint256) {
|
|
206
379
|
return inco.eShr(s(a), asEuint256(b));
|
|
207
380
|
}
|
|
208
381
|
|
|
382
|
+
/// @notice Right shift of a plaintext uint256 by an encrypted uint256
|
|
383
|
+
/// @param a Plaintext value to shift
|
|
384
|
+
/// @param b Encrypted shift amount
|
|
385
|
+
/// @return The encrypted result
|
|
209
386
|
function shr(uint256 a, euint256 b) internal returns (euint256) {
|
|
210
387
|
return inco.eShr(asEuint256(a), s(b));
|
|
211
388
|
}
|
|
212
389
|
|
|
390
|
+
/// @notice Left rotate of two encrypted uint256 values
|
|
391
|
+
/// @param a Encrypted value to rotate
|
|
392
|
+
/// @param b Encrypted rotate amount
|
|
393
|
+
/// @return The encrypted result
|
|
213
394
|
function rotl(euint256 a, euint256 b) internal returns (euint256) {
|
|
214
395
|
return inco.eRotl(s(a), s(b));
|
|
215
396
|
}
|
|
216
397
|
|
|
398
|
+
/// @notice Left rotate of an encrypted uint256 by a plaintext uint256
|
|
399
|
+
/// @param a Encrypted value to rotate
|
|
400
|
+
/// @param b Plaintext rotate amount
|
|
401
|
+
/// @return The encrypted result
|
|
217
402
|
function rotl(euint256 a, uint256 b) internal returns (euint256) {
|
|
218
403
|
return inco.eRotl(s(a), asEuint256(b));
|
|
219
404
|
}
|
|
220
405
|
|
|
406
|
+
/// @notice Left rotate of a plaintext uint256 by an encrypted uint256
|
|
407
|
+
/// @param a Plaintext value to rotate
|
|
408
|
+
/// @param b Encrypted rotate amount
|
|
409
|
+
/// @return The encrypted result
|
|
221
410
|
function rotl(uint256 a, euint256 b) internal returns (euint256) {
|
|
222
411
|
return inco.eRotl(asEuint256(a), s(b));
|
|
223
412
|
}
|
|
224
413
|
|
|
414
|
+
/// @notice Right rotate of two encrypted uint256 values
|
|
415
|
+
/// @param a Encrypted value to rotate
|
|
416
|
+
/// @param b Encrypted rotate amount
|
|
417
|
+
/// @return The encrypted result
|
|
225
418
|
function rotr(euint256 a, euint256 b) internal returns (euint256) {
|
|
226
419
|
return inco.eRotr(s(a), s(b));
|
|
227
420
|
}
|
|
228
421
|
|
|
422
|
+
/// @notice Right rotate of an encrypted uint256 by a plaintext uint256
|
|
423
|
+
/// @param a Encrypted value to rotate
|
|
424
|
+
/// @param b Plaintext rotate amount
|
|
425
|
+
/// @return The encrypted result
|
|
229
426
|
function rotr(euint256 a, uint256 b) internal returns (euint256) {
|
|
230
427
|
return inco.eRotr(s(a), asEuint256(b));
|
|
231
428
|
}
|
|
232
429
|
|
|
430
|
+
/// @notice Right rotate of a plaintext uint256 by an encrypted uint256
|
|
431
|
+
/// @param a Plaintext value to rotate
|
|
432
|
+
/// @param b Encrypted rotate amount
|
|
433
|
+
/// @return The encrypted result
|
|
233
434
|
function rotr(uint256 a, euint256 b) internal returns (euint256) {
|
|
234
435
|
return inco.eRotr(asEuint256(a), s(b));
|
|
235
436
|
}
|
|
236
437
|
|
|
438
|
+
/// @notice Checks equality of two encrypted uint256 values
|
|
439
|
+
/// @param a Encrypted operand
|
|
440
|
+
/// @param b Encrypted operand
|
|
441
|
+
/// @return The encrypted bool result
|
|
237
442
|
function eq(euint256 a, euint256 b) internal returns (ebool) {
|
|
238
443
|
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
239
444
|
}
|
|
240
445
|
|
|
446
|
+
/// @notice Checks equality of an encrypted uint256 and a plaintext uint256
|
|
447
|
+
/// @param a Encrypted operand
|
|
448
|
+
/// @param b Plaintext operand
|
|
449
|
+
/// @return The encrypted bool result
|
|
241
450
|
function eq(euint256 a, uint256 b) internal returns (ebool) {
|
|
242
451
|
return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
243
452
|
}
|
|
244
453
|
|
|
454
|
+
/// @notice Checks equality of a plaintext uint256 and an encrypted uint256
|
|
455
|
+
/// @param a Plaintext operand
|
|
456
|
+
/// @param b Encrypted operand
|
|
457
|
+
/// @return The encrypted bool result
|
|
245
458
|
function eq(uint256 a, euint256 b) internal returns (ebool) {
|
|
246
459
|
return inco.eEq(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
247
460
|
}
|
|
248
461
|
|
|
462
|
+
/// @notice Checks equality of an encrypted address and a plaintext address
|
|
463
|
+
/// @param a Encrypted operand
|
|
464
|
+
/// @param b Plaintext operand
|
|
465
|
+
/// @return The encrypted bool result
|
|
249
466
|
function eq(eaddress a, address b) internal returns (ebool) {
|
|
250
467
|
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
251
468
|
}
|
|
252
469
|
|
|
470
|
+
/// @notice Checks equality of two encrypted addresses
|
|
471
|
+
/// @param a Encrypted operand
|
|
472
|
+
/// @param b Encrypted operand
|
|
473
|
+
/// @return The encrypted bool result
|
|
253
474
|
function eq(eaddress a, eaddress b) internal returns (ebool) {
|
|
254
475
|
return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
255
476
|
}
|
|
256
477
|
|
|
478
|
+
/// @notice Checks equality of a plaintext address and an encrypted address
|
|
479
|
+
/// @param a Plaintext operand
|
|
480
|
+
/// @param b Encrypted operand
|
|
481
|
+
/// @return The encrypted bool result
|
|
257
482
|
function eq(address a, eaddress b) internal returns (ebool) {
|
|
258
483
|
return inco.eEq(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
259
484
|
}
|
|
260
485
|
|
|
486
|
+
/// @notice Checks inequality of two encrypted uint256 values
|
|
487
|
+
/// @param a Encrypted operand
|
|
488
|
+
/// @param b Encrypted operand
|
|
489
|
+
/// @return The encrypted bool result
|
|
261
490
|
function ne(euint256 a, euint256 b) internal returns (ebool) {
|
|
262
491
|
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
|
|
263
492
|
}
|
|
264
493
|
|
|
494
|
+
/// @notice Checks inequality of an encrypted uint256 and a plaintext uint256
|
|
495
|
+
/// @param a Encrypted operand
|
|
496
|
+
/// @param b Plaintext operand
|
|
497
|
+
/// @return The encrypted bool result
|
|
265
498
|
function ne(euint256 a, uint256 b) internal returns (ebool) {
|
|
266
499
|
return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
|
|
267
500
|
}
|
|
268
501
|
|
|
502
|
+
/// @notice Checks inequality of a plaintext uint256 and an encrypted uint256
|
|
503
|
+
/// @param a Plaintext operand
|
|
504
|
+
/// @param b Encrypted operand
|
|
505
|
+
/// @return The encrypted bool result
|
|
269
506
|
function ne(uint256 a, euint256 b) internal returns (ebool) {
|
|
270
507
|
return inco.eNe(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
|
|
271
508
|
}
|
|
272
509
|
|
|
510
|
+
/// @notice Checks inequality of two encrypted addresses
|
|
511
|
+
/// @param a Encrypted operand
|
|
512
|
+
/// @param b Encrypted operand
|
|
513
|
+
/// @return The encrypted bool result
|
|
273
514
|
function ne(eaddress a, eaddress b) internal returns (ebool) {
|
|
274
515
|
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
|
|
275
516
|
}
|
|
276
517
|
|
|
518
|
+
/// @notice Checks inequality of an encrypted address and a plaintext address
|
|
519
|
+
/// @param a Encrypted operand
|
|
520
|
+
/// @param b Plaintext operand
|
|
521
|
+
/// @return The encrypted bool result
|
|
277
522
|
function ne(eaddress a, address b) internal returns (ebool) {
|
|
278
523
|
return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
|
|
279
524
|
}
|
|
280
525
|
|
|
526
|
+
/// @notice Checks inequality of a plaintext address and an encrypted address
|
|
527
|
+
/// @param a Plaintext operand
|
|
528
|
+
/// @param b Encrypted operand
|
|
529
|
+
/// @return The encrypted bool result
|
|
281
530
|
function ne(address a, eaddress b) internal returns (ebool) {
|
|
282
531
|
return inco.eNe(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
|
|
283
532
|
}
|
|
284
533
|
|
|
534
|
+
/// @notice Checks if one encrypted uint256 is greater than or equal to another
|
|
535
|
+
/// @param a Encrypted operand
|
|
536
|
+
/// @param b Encrypted operand
|
|
537
|
+
/// @return The encrypted bool result
|
|
285
538
|
function ge(euint256 a, euint256 b) internal returns (ebool) {
|
|
286
539
|
return inco.eGe(s(a), s(b));
|
|
287
540
|
}
|
|
288
541
|
|
|
542
|
+
/// @notice Checks if an encrypted uint256 is greater than or equal to a plaintext uint256
|
|
543
|
+
/// @param a Encrypted operand
|
|
544
|
+
/// @param b Plaintext operand
|
|
545
|
+
/// @return The encrypted bool result
|
|
289
546
|
function ge(euint256 a, uint256 b) internal returns (ebool) {
|
|
290
547
|
return inco.eGe(s(a), asEuint256(b));
|
|
291
548
|
}
|
|
292
549
|
|
|
550
|
+
/// @notice Checks if a plaintext uint256 is greater than or equal to an encrypted uint256
|
|
551
|
+
/// @param a Plaintext operand
|
|
552
|
+
/// @param b Encrypted operand
|
|
553
|
+
/// @return The encrypted bool result
|
|
293
554
|
function ge(uint256 a, euint256 b) internal returns (ebool) {
|
|
294
555
|
return inco.eGe(asEuint256(a), s(b));
|
|
295
556
|
}
|
|
296
557
|
|
|
558
|
+
/// @notice Checks if one encrypted uint256 is greater than another
|
|
559
|
+
/// @param a Encrypted operand
|
|
560
|
+
/// @param b Encrypted operand
|
|
561
|
+
/// @return The encrypted bool result
|
|
297
562
|
function gt(euint256 a, euint256 b) internal returns (ebool) {
|
|
298
563
|
return inco.eGt(s(a), s(b));
|
|
299
564
|
}
|
|
300
565
|
|
|
566
|
+
/// @notice Checks if an encrypted uint256 is greater than a plaintext uint256
|
|
567
|
+
/// @param a Encrypted operand
|
|
568
|
+
/// @param b Plaintext operand
|
|
569
|
+
/// @return The encrypted bool result
|
|
301
570
|
function gt(euint256 a, uint256 b) internal returns (ebool) {
|
|
302
571
|
return inco.eGt(s(a), asEuint256(b));
|
|
303
572
|
}
|
|
304
573
|
|
|
574
|
+
/// @notice Checks if a plaintext uint256 is greater than an encrypted uint256
|
|
575
|
+
/// @param a Plaintext operand
|
|
576
|
+
/// @param b Encrypted operand
|
|
577
|
+
/// @return The encrypted bool result
|
|
305
578
|
function gt(uint256 a, euint256 b) internal returns (ebool) {
|
|
306
579
|
return inco.eGt(asEuint256(a), s(b));
|
|
307
580
|
}
|
|
308
581
|
|
|
582
|
+
/// @notice Checks if one encrypted uint256 is less than or equal to another
|
|
583
|
+
/// @param a Encrypted operand
|
|
584
|
+
/// @param b Encrypted operand
|
|
585
|
+
/// @return The encrypted bool result
|
|
309
586
|
function le(euint256 a, euint256 b) internal returns (ebool) {
|
|
310
587
|
return inco.eLe(s(a), s(b));
|
|
311
588
|
}
|
|
312
589
|
|
|
590
|
+
/// @notice Checks if an encrypted uint256 is less than or equal to a plaintext uint256
|
|
591
|
+
/// @param a Encrypted operand
|
|
592
|
+
/// @param b Plaintext operand
|
|
593
|
+
/// @return The encrypted bool result
|
|
313
594
|
function le(euint256 a, uint256 b) internal returns (ebool) {
|
|
314
595
|
return inco.eLe(s(a), asEuint256(b));
|
|
315
596
|
}
|
|
316
597
|
|
|
598
|
+
/// @notice Checks if a plaintext uint256 is less than or equal to an encrypted uint256
|
|
599
|
+
/// @param a Plaintext operand
|
|
600
|
+
/// @param b Encrypted operand
|
|
601
|
+
/// @return The encrypted bool result
|
|
317
602
|
function le(uint256 a, euint256 b) internal returns (ebool) {
|
|
318
603
|
return inco.eLe(asEuint256(a), s(b));
|
|
319
604
|
}
|
|
320
605
|
|
|
606
|
+
/// @notice Checks if one encrypted uint256 is less than another
|
|
607
|
+
/// @param a Encrypted operand
|
|
608
|
+
/// @param b Encrypted operand
|
|
609
|
+
/// @return The encrypted bool result
|
|
321
610
|
function lt(euint256 a, euint256 b) internal returns (ebool) {
|
|
322
611
|
return inco.eLt(s(a), s(b));
|
|
323
612
|
}
|
|
324
613
|
|
|
614
|
+
/// @notice Checks if an encrypted uint256 is less than a plaintext uint256
|
|
615
|
+
/// @param a Encrypted operand
|
|
616
|
+
/// @param b Plaintext operand
|
|
617
|
+
/// @return The encrypted bool result
|
|
325
618
|
function lt(euint256 a, uint256 b) internal returns (ebool) {
|
|
326
619
|
return inco.eLt(s(a), asEuint256(b));
|
|
327
620
|
}
|
|
328
621
|
|
|
622
|
+
/// @notice Checks if a plaintext uint256 is less than an encrypted uint256
|
|
623
|
+
/// @param a Plaintext operand
|
|
624
|
+
/// @param b Encrypted operand
|
|
625
|
+
/// @return The encrypted bool result
|
|
329
626
|
function lt(uint256 a, euint256 b) internal returns (ebool) {
|
|
330
627
|
return inco.eLt(asEuint256(a), s(b));
|
|
331
628
|
}
|
|
332
629
|
|
|
630
|
+
/// @notice Returns the minimum of two encrypted uint256 values
|
|
631
|
+
/// @param a Encrypted operand
|
|
632
|
+
/// @param b Encrypted operand
|
|
633
|
+
/// @return The encrypted minimum
|
|
333
634
|
function min(euint256 a, euint256 b) internal returns (euint256) {
|
|
334
635
|
return inco.eMin(s(a), s(b));
|
|
335
636
|
}
|
|
336
637
|
|
|
638
|
+
/// @notice Returns the minimum of an encrypted uint256 and a plaintext uint256
|
|
639
|
+
/// @param a Encrypted operand
|
|
640
|
+
/// @param b Plaintext operand
|
|
641
|
+
/// @return The encrypted minimum
|
|
337
642
|
function min(euint256 a, uint256 b) internal returns (euint256) {
|
|
338
643
|
return inco.eMin(s(a), asEuint256(b));
|
|
339
644
|
}
|
|
340
645
|
|
|
646
|
+
/// @notice Returns the minimum of a plaintext uint256 and an encrypted uint256
|
|
647
|
+
/// @param a Plaintext operand
|
|
648
|
+
/// @param b Encrypted operand
|
|
649
|
+
/// @return The encrypted minimum
|
|
341
650
|
function min(uint256 a, euint256 b) internal returns (euint256) {
|
|
342
651
|
return inco.eMin(asEuint256(a), s(b));
|
|
343
652
|
}
|
|
344
653
|
|
|
654
|
+
/// @notice Returns the maximum of two encrypted uint256 values
|
|
655
|
+
/// @param a Encrypted operand
|
|
656
|
+
/// @param b Encrypted operand
|
|
657
|
+
/// @return The encrypted maximum
|
|
345
658
|
function max(euint256 a, euint256 b) internal returns (euint256) {
|
|
346
659
|
return inco.eMax(s(a), s(b));
|
|
347
660
|
}
|
|
348
661
|
|
|
662
|
+
/// @notice Returns the maximum of an encrypted uint256 and a plaintext uint256
|
|
663
|
+
/// @param a Encrypted operand
|
|
664
|
+
/// @param b Plaintext operand
|
|
665
|
+
/// @return The encrypted maximum
|
|
349
666
|
function max(euint256 a, uint256 b) internal returns (euint256) {
|
|
350
667
|
return inco.eMax(s(a), asEuint256(b));
|
|
351
668
|
}
|
|
352
669
|
|
|
670
|
+
/// @notice Returns the maximum of a plaintext uint256 and an encrypted uint256
|
|
671
|
+
/// @param a Plaintext operand
|
|
672
|
+
/// @param b Encrypted operand
|
|
673
|
+
/// @return The encrypted maximum
|
|
353
674
|
function max(uint256 a, euint256 b) internal returns (euint256) {
|
|
354
675
|
return inco.eMax(asEuint256(a), s(b));
|
|
355
676
|
}
|
|
356
677
|
|
|
678
|
+
/// @notice Bitwise NOT of an encrypted bool
|
|
679
|
+
/// @param a Encrypted operand
|
|
680
|
+
/// @return The encrypted result
|
|
357
681
|
function not(ebool a) internal returns (ebool) {
|
|
358
682
|
return inco.eNot(s(a));
|
|
359
683
|
}
|
|
360
684
|
|
|
361
|
-
/// @
|
|
685
|
+
/// @notice Generates a random encrypted uint256 (costs the inco fee)
|
|
686
|
+
/// @dev costs the inco fee
|
|
687
|
+
/// @return The encrypted random value
|
|
362
688
|
function rand() internal returns (euint256) {
|
|
363
689
|
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRand.selector, ETypes.Uint256));
|
|
364
690
|
return euint256.wrap(result);
|
|
365
691
|
}
|
|
366
692
|
|
|
367
|
-
/// @
|
|
693
|
+
/// @notice Generates a random encrypted uint256 less than a plaintext upper bound (costs the inco fee)
|
|
694
|
+
/// @dev costs the inco fee
|
|
695
|
+
/// @param upperBound The plaintext upper bound
|
|
696
|
+
/// @return The encrypted random value
|
|
368
697
|
function randBounded(uint256 upperBound) internal returns (euint256) {
|
|
369
698
|
bytes32 boundHandle = euint256.unwrap(asEuint256(upperBound));
|
|
370
699
|
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
371
700
|
return euint256.wrap(result);
|
|
372
701
|
}
|
|
373
702
|
|
|
374
|
-
/// @
|
|
703
|
+
/// @notice Generates a random encrypted uint256 less than an encrypted upper bound (costs the inco fee)
|
|
704
|
+
/// @dev costs the inco fee
|
|
705
|
+
/// @param upperBound The encrypted upper bound
|
|
706
|
+
/// @return The encrypted random value
|
|
375
707
|
function randBounded(euint256 upperBound) internal returns (euint256) {
|
|
376
708
|
bytes32 boundHandle = euint256.unwrap(s(upperBound));
|
|
377
709
|
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
378
710
|
return euint256.wrap(result);
|
|
379
711
|
}
|
|
380
712
|
|
|
713
|
+
/// @notice Casts a plaintext uint256 to an encrypted uint256
|
|
714
|
+
/// @param a The plaintext value
|
|
715
|
+
/// @return The encrypted value
|
|
381
716
|
function asEuint256(uint256 a) internal returns (euint256) {
|
|
382
717
|
return inco.asEuint256(a);
|
|
383
718
|
}
|
|
384
719
|
|
|
720
|
+
/// @notice Casts a plaintext bool to an encrypted bool
|
|
721
|
+
/// @param a The plaintext value
|
|
722
|
+
/// @return The encrypted value
|
|
385
723
|
function asEbool(bool a) internal returns (ebool) {
|
|
386
724
|
return inco.asEbool(a);
|
|
387
725
|
}
|
|
388
726
|
|
|
727
|
+
/// @notice Casts a plaintext address to an encrypted address
|
|
728
|
+
/// @param a The plaintext value
|
|
729
|
+
/// @return The encrypted value
|
|
389
730
|
function asEaddress(address a) internal returns (eaddress) {
|
|
390
731
|
return inco.asEaddress(a);
|
|
391
732
|
}
|
|
392
733
|
|
|
734
|
+
/// @notice Casts an encrypted uint256 to an encrypted bool
|
|
735
|
+
/// @param a The encrypted uint256 value
|
|
736
|
+
/// @return The encrypted bool value
|
|
393
737
|
function asEbool(euint256 a) internal returns (ebool) {
|
|
394
738
|
return ebool.wrap(inco.eCast(euint256.unwrap(a), ETypes.Bool));
|
|
395
739
|
}
|
|
396
740
|
|
|
741
|
+
/// @notice Casts an encrypted bool to an encrypted uint256
|
|
742
|
+
/// @param a The encrypted bool value
|
|
743
|
+
/// @return The encrypted uint256 value
|
|
397
744
|
function asEuint256(ebool a) internal returns (euint256) {
|
|
398
745
|
return euint256.wrap(inco.eCast(ebool.unwrap(a), ETypes.Uint256));
|
|
399
746
|
}
|
|
@@ -437,54 +784,94 @@ library e {
|
|
|
437
784
|
return eaddress.wrap(result);
|
|
438
785
|
}
|
|
439
786
|
|
|
787
|
+
/// @notice Allows an address to access an encrypted uint256
|
|
788
|
+
/// @param a The encrypted uint256
|
|
789
|
+
/// @param to The address to allow
|
|
440
790
|
function allow(euint256 a, address to) internal {
|
|
441
791
|
inco.allow(euint256.unwrap(a), to);
|
|
442
792
|
}
|
|
443
793
|
|
|
794
|
+
/// @notice Allows an address to access an encrypted bool
|
|
795
|
+
/// @param a The encrypted bool
|
|
796
|
+
/// @param to The address to allow
|
|
444
797
|
function allow(ebool a, address to) internal {
|
|
445
798
|
inco.allow(ebool.unwrap(a), to);
|
|
446
799
|
}
|
|
447
800
|
|
|
801
|
+
/// @notice Allows an address to access an encrypted address
|
|
802
|
+
/// @param a The encrypted address
|
|
803
|
+
/// @param to The address to allow
|
|
448
804
|
function allow(eaddress a, address to) internal {
|
|
449
805
|
inco.allow(eaddress.unwrap(a), to);
|
|
450
806
|
}
|
|
451
807
|
|
|
808
|
+
/// @notice Reveals an encrypted uint256
|
|
809
|
+
/// @param a The encrypted uint256
|
|
452
810
|
function reveal(euint256 a) internal {
|
|
453
811
|
inco.reveal(euint256.unwrap(a));
|
|
454
812
|
}
|
|
455
813
|
|
|
814
|
+
/// @notice Reveals an encrypted bool
|
|
815
|
+
/// @param a The encrypted bool
|
|
456
816
|
function reveal(ebool a) internal {
|
|
457
817
|
inco.reveal(ebool.unwrap(a));
|
|
458
818
|
}
|
|
459
819
|
|
|
820
|
+
/// @notice Reveals an encrypted address
|
|
821
|
+
/// @param a The encrypted address
|
|
460
822
|
function reveal(eaddress a) internal {
|
|
461
823
|
inco.reveal(eaddress.unwrap(a));
|
|
462
824
|
}
|
|
463
825
|
|
|
826
|
+
/// @notice Allows this contract to access an encrypted uint256
|
|
827
|
+
/// @param a The encrypted uint256
|
|
464
828
|
function allowThis(euint256 a) internal {
|
|
465
829
|
allow(a, address(this));
|
|
466
830
|
}
|
|
467
831
|
|
|
832
|
+
/// @notice Allows this contract to access an encrypted bool
|
|
833
|
+
/// @param a The encrypted bool
|
|
468
834
|
function allowThis(ebool a) internal {
|
|
469
835
|
allow(a, address(this));
|
|
470
836
|
}
|
|
471
837
|
|
|
838
|
+
/// @notice Allows this contract to access an encrypted address
|
|
839
|
+
/// @param a The encrypted address
|
|
472
840
|
function allowThis(eaddress a) internal {
|
|
473
841
|
allow(a, address(this));
|
|
474
842
|
}
|
|
475
843
|
|
|
844
|
+
/// @notice Checks if a user is allowed to access an encrypted uint256
|
|
845
|
+
/// @param user The address to check
|
|
846
|
+
/// @param a The encrypted uint256
|
|
847
|
+
/// @return True if allowed, false otherwise
|
|
476
848
|
function isAllowed(address user, euint256 a) internal view returns (bool) {
|
|
477
849
|
return inco.isAllowed(euint256.unwrap(a), user);
|
|
478
850
|
}
|
|
479
851
|
|
|
852
|
+
/// @notice Selects between two encrypted uint256 values based on an encrypted bool
|
|
853
|
+
/// @param control The encrypted bool condition
|
|
854
|
+
/// @param ifTrue Value if control is true
|
|
855
|
+
/// @param ifFalse Value if control is false
|
|
856
|
+
/// @return The selected encrypted uint256
|
|
480
857
|
function select(ebool control, euint256 ifTrue, euint256 ifFalse) internal returns (euint256) {
|
|
481
858
|
return euint256.wrap(inco.eIfThenElse(s(control), euint256.unwrap(s(ifTrue)), euint256.unwrap(s(ifFalse))));
|
|
482
859
|
}
|
|
483
860
|
|
|
861
|
+
/// @notice Selects between two encrypted bool values based on an encrypted bool
|
|
862
|
+
/// @param control The encrypted bool condition
|
|
863
|
+
/// @param ifTrue Value if control is true
|
|
864
|
+
/// @param ifFalse Value if control is false
|
|
865
|
+
/// @return The selected encrypted bool
|
|
484
866
|
function select(ebool control, ebool ifTrue, ebool ifFalse) internal returns (ebool) {
|
|
485
867
|
return ebool.wrap(inco.eIfThenElse(s(control), ebool.unwrap(s(ifTrue)), ebool.unwrap(s(ifFalse))));
|
|
486
868
|
}
|
|
487
869
|
|
|
870
|
+
/// @notice Selects between two encrypted addresses based on an encrypted bool
|
|
871
|
+
/// @param control The encrypted bool condition
|
|
872
|
+
/// @param ifTrue Value if control is true
|
|
873
|
+
/// @param ifFalse Value if control is false
|
|
874
|
+
/// @return The selected encrypted address
|
|
488
875
|
function select(ebool control, eaddress ifTrue, eaddress ifFalse) internal returns (eaddress) {
|
|
489
876
|
return eaddress.wrap(inco.eIfThenElse(s(control), eaddress.unwrap(s(ifTrue)), eaddress.unwrap(s(ifFalse))));
|
|
490
877
|
}
|