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