@inco/lightning 0.8.0-devnet-3 → 0.8.0-devnet-4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inco/lightning",
3
- "version": "0.8.0-devnet-3",
3
+ "version": "0.8.0-devnet-4",
4
4
  "repository": "https://github.com/Inco-fhevm/inco-monorepo",
5
5
  "files": [
6
6
  "src/",
@@ -17,52 +17,61 @@ error ExternalHandleDoesNotMatchComputedHandle(
17
17
  uint256 chainId,
18
18
  address aclAddress,
19
19
  address userAddress,
20
- address contractAddress
20
+ address contractAddress,
21
+ int32 version
21
22
  );
22
23
 
23
24
  abstract contract EncryptedInput is IEncryptedInput, BaseAccessControlList, HandleGeneration, Fee {
24
25
 
25
26
  event NewInput(
26
- bytes32 indexed result, address indexed contractAddress, address indexed user, bytes ciphertext, uint256 eventId
27
+ bytes32 indexed result,
28
+ address indexed contractAddress,
29
+ address indexed user,
30
+ int32 version,
31
+ bytes ciphertext,
32
+ uint256 eventId
27
33
  );
28
34
 
29
- function newEuint256(bytes memory input, address user) external payable returns (euint256 newValue) {
35
+ function newEuint256(bytes calldata input, address user) external payable returns (euint256 newValue) {
30
36
  return euint256.wrap(newInput(input, user, ETypes.Uint256));
31
37
  }
32
38
 
33
- function newEbool(bytes memory input, address user) external payable returns (ebool newValue) {
39
+ function newEbool(bytes calldata input, address user) external payable returns (ebool newValue) {
34
40
  return ebool.wrap(newInput(input, user, ETypes.Bool));
35
41
  }
36
42
 
37
- function newEaddress(bytes memory input, address user) external payable returns (eaddress newValue) {
43
+ function newEaddress(bytes calldata input, address user) external payable returns (eaddress newValue) {
38
44
  return eaddress.wrap(newInput(input, user, ETypes.AddressOrUint160OrBytes20));
39
45
  }
40
46
 
41
- function newInput(bytes memory ciphertext, address user, ETypes inputType)
47
+ function newInput(bytes calldata input, address user, ETypes inputType)
42
48
  internal
43
49
  paying
44
50
  returns (bytes32 newHandle)
45
51
  {
46
- newHandle = _newInput(ciphertext, user, inputType);
52
+ newHandle = _newInput(input, user, inputType);
47
53
  }
48
54
 
49
- function newInputNotPaying(bytes memory ciphertext, address user, ETypes inputType)
55
+ function newInputNotPaying(bytes calldata input, address user, ETypes inputType)
50
56
  internal
51
57
  returns (bytes32 newHandle)
52
58
  {
53
- newHandle = _newInput(ciphertext, user, inputType);
59
+ newHandle = _newInput(input, user, inputType);
54
60
  }
55
61
 
56
62
  /// @notice Creates a new input with a prepended handle as a checksum.
57
63
  /// @param input The input that contains the handle prepended to the ciphertext.
58
64
  /// @param user The user address associated with the input.
59
- function _newInput(bytes memory input, address user, ETypes inputType) private returns (bytes32 handle) {
65
+ function _newInput(bytes calldata input, address user, ETypes inputType) private returns (bytes32 handle) {
60
66
  // Since there is no sensible way to handle abi.decode errors (https://github.com/argotorg/solidity/issues/10381)
61
67
  // at least fail early on a conservative minimum length
62
- require(input.length >= 64, "Input too short, should be at least 64 bytes");
68
+ require(input.length >= 68, "Input too short, should be at least 68 bytes");
69
+ // Parse the version from the first 4 bytes.
70
+ bytes4 prefix = bytes4(input[:4]);
71
+ int32 version = int32(uint32(prefix));
63
72
  // Remove external handle prepended to input as a checksum
64
- (bytes32 externalHandle, bytes memory ciphertext) = abi.decode(input, (bytes32, bytes));
65
- handle = getInputHandle(ciphertext, user, msg.sender, inputType);
73
+ (bytes32 externalHandle, bytes memory ciphertext) = abi.decode(input[4:], (bytes32, bytes));
74
+ handle = getInputHandle(ciphertext, user, msg.sender, version, inputType);
66
75
  require(
67
76
  handle == externalHandle,
68
77
  ExternalHandleDoesNotMatchComputedHandle({
@@ -71,14 +80,22 @@ abstract contract EncryptedInput is IEncryptedInput, BaseAccessControlList, Hand
71
80
  chainId: block.chainid,
72
81
  aclAddress: address(this),
73
82
  userAddress: user,
74
- contractAddress: msg.sender
83
+ contractAddress: msg.sender,
84
+ version: version
75
85
  })
76
86
  );
77
87
  // We assume that providing the same handle (which via HADU implies same plaintext, same context, and same
78
88
  // instance of encryption)
79
89
  require(!isAllowed(handle, user), HandleAlreadyExists(handle));
80
90
  uint256 id = getNextEventId();
81
- emit NewInput({result: handle, contractAddress: msg.sender, user: user, ciphertext: ciphertext, eventId: id});
91
+ emit NewInput({
92
+ result: handle,
93
+ contractAddress: msg.sender,
94
+ user: user,
95
+ version: version,
96
+ ciphertext: ciphertext,
97
+ eventId: id
98
+ });
82
99
  setDigest(abi.encodePacked(handle, id));
83
100
  // We allow to user since this is harmless and it is convenient to use the allow mapping to track inputs.
84
101
  // NOTE: the allow must come after emitting the new input event, since allow emits its own event.
@@ -5,8 +5,8 @@ import {euint256, ebool, eaddress} from "../../Types.sol";
5
5
 
6
6
  interface IEncryptedInput {
7
7
 
8
- function newEuint256(bytes memory ciphertext, address user) external payable returns (euint256 newValue);
9
- function newEbool(bytes memory ciphertext, address user) external payable returns (ebool newValue);
10
- function newEaddress(bytes memory ciphertext, address user) external payable returns (eaddress newValue);
8
+ function newEuint256(bytes calldata ciphertext, address user) external payable returns (euint256 newValue);
9
+ function newEbool(bytes calldata ciphertext, address user) external payable returns (ebool newValue);
10
+ function newEaddress(bytes calldata ciphertext, address user) external payable returns (eaddress newValue);
11
11
 
12
12
  }
@@ -21,12 +21,14 @@ contract HandleGeneration is IHandleGeneration, HandleMetadata {
21
21
  generatedHandle = embedTypeVersion(generatedHandle, handleType);
22
22
  }
23
23
 
24
- function getInputHandle(bytes memory ciphertext, address user, address contractAddress, ETypes inputType)
25
- internal
26
- view
27
- returns (bytes32 generatedHandle)
28
- {
29
- return getInputHandle(ciphertext, address(this), user, contractAddress, inputType);
24
+ function getInputHandle(
25
+ bytes memory ciphertext,
26
+ address user,
27
+ address contractAddress,
28
+ int32 version,
29
+ ETypes inputType
30
+ ) internal view returns (bytes32 generatedHandle) {
31
+ return getInputHandle(ciphertext, address(this), user, contractAddress, version, inputType);
30
32
  }
31
33
 
32
34
  function getInputHandle(
@@ -34,6 +36,7 @@ contract HandleGeneration is IHandleGeneration, HandleMetadata {
34
36
  address executorAddress,
35
37
  address user,
36
38
  address contractAddress,
39
+ int32 version,
37
40
  ETypes inputType
38
41
  ) internal view returns (bytes32 generatedHandle) {
39
42
  // Here we ensure that our hashing scheme is binary-compatible between IncoLightning and IncoFhevm, this helps
@@ -49,7 +52,8 @@ contract HandleGeneration is IHandleGeneration, HandleMetadata {
49
52
  block.chainid, // todo cache this
50
53
  executorAddress,
51
54
  user,
52
- contractAddress
55
+ contractAddress,
56
+ version
53
57
  )
54
58
  ),
55
59
  inputType
@@ -105,8 +105,16 @@ contract TestHandleMetadata is
105
105
  {
106
106
  // We need a single word here to get correct encoding
107
107
  bytes memory ciphertext = abi.encode(word);
108
- bytes32 handle = getInputHandle(ciphertext, address(this), user, contractAddress, inputType);
109
- input = abi.encode(handle, ciphertext);
108
+ bytes32 handle = getInputHandle(
109
+ ciphertext,
110
+ address(this),
111
+ user,
112
+ contractAddress,
113
+ 0,
114
+ /* unspecified */
115
+ inputType
116
+ );
117
+ input = abi.encodePacked(int32(0), abi.encode(handle, ciphertext));
110
118
  }
111
119
 
112
120
  // ============ Tests for HandleGeneration functions ============
@@ -143,11 +151,8 @@ contract TestHandleMetadata is
143
151
  // ============ Tests for EncryptedInput internal functions ============
144
152
 
145
153
  /// @notice Expose the internal newInputNotPaying for testing
146
- function exposedNewInputNotPaying(bytes memory ciphertext, address user, ETypes inputType)
147
- public
148
- returns (bytes32)
149
- {
150
- return newInputNotPaying(ciphertext, user, inputType);
154
+ function exposedNewInputNotPaying(bytes calldata input, address user, ETypes inputType) public returns (bytes32) {
155
+ return newInputNotPaying(input, user, inputType);
151
156
  }
152
157
 
153
158
  function testNewInputNotPaying() public {
@@ -167,9 +172,10 @@ contract TestHandleMetadata is
167
172
  returns (bytes memory input)
168
173
  {
169
174
  bytes memory ciphertext = abi.encode(word);
175
+ int32 version = 0; // unspecified
170
176
  // For external calls via this., msg.sender is address(this)
171
- bytes32 handle = getInputHandle(ciphertext, address(this), user, address(this), inputType);
172
- input = abi.encode(handle, ciphertext);
177
+ bytes32 handle = getInputHandle(ciphertext, address(this), user, address(this), version, inputType);
178
+ input = abi.encodePacked(version, abi.encode(handle, ciphertext));
173
179
  }
174
180
 
175
181
  // ============ Tests for EncryptedInput error branches ============
@@ -178,7 +184,7 @@ contract TestHandleMetadata is
178
184
  address self = address(this);
179
185
  // Input less than 64 bytes should revert
180
186
  bytes memory shortInput = hex"deadbeef";
181
- vm.expectRevert("Input too short, should be at least 64 bytes");
187
+ vm.expectRevert("Input too short, should be at least 68 bytes");
182
188
  this.exposedNewInputNotPaying(shortInput, self, ETypes.Uint256);
183
189
  }
184
190
 
@@ -188,10 +194,11 @@ contract TestHandleMetadata is
188
194
  bytes memory ciphertext = abi.encode(ciphertextData);
189
195
  // Create input with wrong handle (just a random bytes32)
190
196
  bytes32 wrongHandle = bytes32(uint256(12345));
191
- bytes memory badInput = abi.encode(wrongHandle, ciphertext);
197
+ int32 version = 0; // unspecified
198
+ bytes memory badInput = abi.encodePacked(version, abi.encode(wrongHandle, ciphertext));
192
199
 
193
200
  // Compute the expected handle for the error message
194
- bytes32 expectedHandle = getInputHandle(ciphertext, address(this), self, address(this), ETypes.Uint256);
201
+ bytes32 expectedHandle = getInputHandle(ciphertext, address(this), self, address(this), version, ETypes.Uint256);
195
202
 
196
203
  vm.expectRevert(
197
204
  abi.encodeWithSelector(
@@ -201,7 +208,8 @@ contract TestHandleMetadata is
201
208
  block.chainid,
202
209
  address(this),
203
210
  self,
204
- address(this)
211
+ address(this),
212
+ version
205
213
  )
206
214
  );
207
215
  this.exposedNewInputNotPaying(badInput, self, ETypes.Uint256);
@@ -19,8 +19,16 @@ contract FakeIncoInfraBase is TestUtils, KVStore, HandleGeneration {
19
19
  {
20
20
  // We need a single word here to get correct encoding
21
21
  bytes memory ciphertext = abi.encode(word);
22
- bytes32 handle = getInputHandle(ciphertext, address(inco), user, contractAddress, inputType);
23
- input = abi.encode(handle, ciphertext);
22
+ bytes32 handle = getInputHandle(
23
+ ciphertext,
24
+ address(inco),
25
+ user,
26
+ contractAddress,
27
+ 0,
28
+ /* unspecified */
29
+ inputType
30
+ );
31
+ input = abi.encodePacked(int32(0), abi.encode(handle, ciphertext));
24
32
  }
25
33
 
26
34
  function fakePrepareEuint256Ciphertext(uint256 value, address userAddress, address contractAddress)
@@ -63,7 +63,7 @@ contract MockOpHandler is FakeIncoInfraBase, FakeComputeServer {
63
63
  } else if (op == EOps.NewInput) {
64
64
  bytes32 result = log.topics[1];
65
65
  // contractAddress and user topics are ignored
66
- (bytes memory ciphertext,) = abi.decode(log.data, (bytes, uint256));
66
+ (, bytes memory ciphertext,) = abi.decode(log.data, (int32, bytes, uint256));
67
67
  handleEInput(result, ciphertext);
68
68
  }
69
69
  }
@@ -1,453 +0,0 @@
1
- // AUTOGENERATED FILE. DO NOT EDIT.
2
- // This file was generated by the IncoLightning library generator.
3
- // The original template is located at Lib.template.sol
4
-
5
- /// SPDX-License-Identifier: No License
6
- pragma solidity ^0.8;
7
-
8
- import {IncoLightning} from "../IncoLightning.sol";
9
- import {ebool, euint256, eaddress, ETypes} from "../Types.sol";
10
-
11
- IncoLightning constant inco = IncoLightning(0x7b98b0482099611B0ebEA0F98f81FF555406794A);
12
- address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
13
-
14
- function typeOf(bytes32 handle) pure returns (ETypes) {
15
- return ETypes(uint8(uint256(handle) >> 8));
16
- }
17
-
18
- library e {
19
-
20
- function sanitize(euint256 a) internal returns (euint256) {
21
- if (euint256.unwrap(a) == bytes32(0)) {
22
- return asEuint256(0);
23
- }
24
- return a;
25
- }
26
-
27
- function sanitize(ebool a) internal returns (ebool) {
28
- if (ebool.unwrap(a) == bytes32(0)) {
29
- return asEbool(false);
30
- }
31
- return a;
32
- }
33
-
34
- function sanitize(eaddress a) internal returns (eaddress) {
35
- if (eaddress.unwrap(a) == bytes32(0)) {
36
- return asEaddress(address(0));
37
- }
38
- return a;
39
- }
40
-
41
- function s(euint256 a) internal returns (euint256) {
42
- return sanitize(a);
43
- }
44
-
45
- function s(ebool a) internal returns (ebool) {
46
- return sanitize(a);
47
- }
48
-
49
- function s(eaddress a) internal returns (eaddress) {
50
- return sanitize(a);
51
- }
52
-
53
- function add(euint256 a, euint256 b) internal returns (euint256) {
54
- return inco.eAdd(s(a), s(b));
55
- }
56
-
57
- function add(euint256 a, uint256 b) internal returns (euint256) {
58
- return inco.eAdd(s(a), asEuint256(b));
59
- }
60
-
61
- function add(uint256 a, euint256 b) internal returns (euint256) {
62
- return inco.eAdd(asEuint256(a), s(b));
63
- }
64
-
65
- function sub(euint256 a, euint256 b) internal returns (euint256) {
66
- return inco.eSub(s(a), s(b));
67
- }
68
-
69
- function sub(euint256 a, uint256 b) internal returns (euint256) {
70
- return inco.eSub(s(a), asEuint256(b));
71
- }
72
-
73
- function sub(uint256 a, euint256 b) internal returns (euint256) {
74
- return inco.eSub(asEuint256(a), s(b));
75
- }
76
-
77
- function mul(euint256 a, euint256 b) internal returns (euint256) {
78
- return inco.eMul(s(a), s(b));
79
- }
80
-
81
- function mul(euint256 a, uint256 b) internal returns (euint256) {
82
- return inco.eMul(s(a), asEuint256(b));
83
- }
84
-
85
- function mul(uint256 a, euint256 b) internal returns (euint256) {
86
- return inco.eMul(asEuint256(a), s(b));
87
- }
88
-
89
- function div(euint256 a, euint256 b) internal returns (euint256) {
90
- return inco.eDiv(s(a), s(b));
91
- }
92
-
93
- function div(euint256 a, uint256 b) internal returns (euint256) {
94
- return inco.eDiv(s(a), asEuint256(b));
95
- }
96
-
97
- function div(uint256 a, euint256 b) internal returns (euint256) {
98
- return inco.eDiv(asEuint256(a), s(b));
99
- }
100
-
101
- function rem(euint256 a, euint256 b) internal returns (euint256) {
102
- return inco.eRem(s(a), s(b));
103
- }
104
-
105
- function rem(euint256 a, uint256 b) internal returns (euint256) {
106
- return inco.eRem(s(a), asEuint256(b));
107
- }
108
-
109
- function rem(uint256 a, euint256 b) internal returns (euint256) {
110
- return inco.eRem(asEuint256(a), s(b));
111
- }
112
-
113
- function and(euint256 a, euint256 b) internal returns (euint256) {
114
- return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
115
- }
116
-
117
- function and(euint256 a, uint256 b) internal returns (euint256) {
118
- return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
119
- }
120
-
121
- function and(uint256 a, euint256 b) internal returns (euint256) {
122
- return euint256.wrap(inco.eBitAnd(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
123
- }
124
-
125
- function and(ebool a, ebool b) internal returns (ebool) {
126
- return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
127
- }
128
-
129
- function and(ebool a, bool b) internal returns (ebool) {
130
- return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
131
- }
132
-
133
- function and(bool a, ebool b) internal returns (ebool) {
134
- return ebool.wrap(inco.eBitAnd(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
135
- }
136
-
137
- function or(euint256 a, euint256 b) internal returns (euint256) {
138
- return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
139
- }
140
-
141
- function or(euint256 a, uint256 b) internal returns (euint256) {
142
- return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
143
- }
144
-
145
- function or(uint256 a, euint256 b) internal returns (euint256) {
146
- return euint256.wrap(inco.eBitOr(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
147
- }
148
-
149
- function or(ebool a, ebool b) internal returns (ebool) {
150
- return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
151
- }
152
-
153
- function or(ebool a, bool b) internal returns (ebool) {
154
- return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
155
- }
156
-
157
- function or(bool a, ebool b) internal returns (ebool) {
158
- return ebool.wrap(inco.eBitOr(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
159
- }
160
-
161
- function xor(euint256 a, euint256 b) internal returns (euint256) {
162
- return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
163
- }
164
-
165
- function xor(euint256 a, uint256 b) internal returns (euint256) {
166
- return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
167
- }
168
-
169
- function xor(uint256 a, euint256 b) internal returns (euint256) {
170
- return euint256.wrap(inco.eBitXor(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
171
- }
172
-
173
- function xor(ebool a, ebool b) internal returns (ebool) {
174
- return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
175
- }
176
-
177
- function xor(ebool a, bool b) internal returns (ebool) {
178
- return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
179
- }
180
-
181
- function xor(bool a, ebool b) internal returns (ebool) {
182
- return ebool.wrap(inco.eBitXor(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
183
- }
184
-
185
- function shl(euint256 a, euint256 b) internal returns (euint256) {
186
- return inco.eShl(s(a), s(b));
187
- }
188
-
189
- function shl(euint256 a, uint256 b) internal returns (euint256) {
190
- return inco.eShl(s(a), asEuint256(b));
191
- }
192
-
193
- function shl(uint256 a, euint256 b) internal returns (euint256) {
194
- return inco.eShl(asEuint256(a), s(b));
195
- }
196
-
197
- function shr(euint256 a, euint256 b) internal returns (euint256) {
198
- return inco.eShr(s(a), s(b));
199
- }
200
-
201
- function shr(euint256 a, uint256 b) internal returns (euint256) {
202
- return inco.eShr(s(a), asEuint256(b));
203
- }
204
-
205
- function shr(uint256 a, euint256 b) internal returns (euint256) {
206
- return inco.eShr(asEuint256(a), s(b));
207
- }
208
-
209
- function rotl(euint256 a, euint256 b) internal returns (euint256) {
210
- return inco.eRotl(s(a), s(b));
211
- }
212
-
213
- function rotl(euint256 a, uint256 b) internal returns (euint256) {
214
- return inco.eRotl(s(a), asEuint256(b));
215
- }
216
-
217
- function rotl(uint256 a, euint256 b) internal returns (euint256) {
218
- return inco.eRotl(asEuint256(a), s(b));
219
- }
220
-
221
- function rotr(euint256 a, euint256 b) internal returns (euint256) {
222
- return inco.eRotr(s(a), s(b));
223
- }
224
-
225
- function rotr(euint256 a, uint256 b) internal returns (euint256) {
226
- return inco.eRotr(s(a), asEuint256(b));
227
- }
228
-
229
- function rotr(uint256 a, euint256 b) internal returns (euint256) {
230
- return inco.eRotr(asEuint256(a), s(b));
231
- }
232
-
233
- function eq(euint256 a, euint256 b) internal returns (ebool) {
234
- return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
235
- }
236
-
237
- function eq(euint256 a, uint256 b) internal returns (ebool) {
238
- return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
239
- }
240
-
241
- function eq(uint256 a, euint256 b) internal returns (ebool) {
242
- return inco.eEq(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
243
- }
244
-
245
- function eq(eaddress a, address b) internal returns (ebool) {
246
- return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
247
- }
248
-
249
- function eq(eaddress a, eaddress b) internal returns (ebool) {
250
- return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
251
- }
252
-
253
- function eq(address a, eaddress b) internal returns (ebool) {
254
- return inco.eEq(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
255
- }
256
-
257
- function ne(euint256 a, euint256 b) internal returns (ebool) {
258
- return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
259
- }
260
-
261
- function ne(euint256 a, uint256 b) internal returns (ebool) {
262
- return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
263
- }
264
-
265
- function ne(uint256 a, euint256 b) internal returns (ebool) {
266
- return inco.eNe(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
267
- }
268
-
269
- function ne(eaddress a, eaddress b) internal returns (ebool) {
270
- return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
271
- }
272
-
273
- function ne(eaddress a, address b) internal returns (ebool) {
274
- return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
275
- }
276
-
277
- function ne(address a, eaddress b) internal returns (ebool) {
278
- return inco.eNe(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
279
- }
280
-
281
- function ge(euint256 a, euint256 b) internal returns (ebool) {
282
- return inco.eGe(s(a), s(b));
283
- }
284
-
285
- function ge(euint256 a, uint256 b) internal returns (ebool) {
286
- return inco.eGe(s(a), asEuint256(b));
287
- }
288
-
289
- function ge(uint256 a, euint256 b) internal returns (ebool) {
290
- return inco.eGe(asEuint256(a), s(b));
291
- }
292
-
293
- function gt(euint256 a, euint256 b) internal returns (ebool) {
294
- return inco.eGt(s(a), s(b));
295
- }
296
-
297
- function gt(euint256 a, uint256 b) internal returns (ebool) {
298
- return inco.eGt(s(a), asEuint256(b));
299
- }
300
-
301
- function gt(uint256 a, euint256 b) internal returns (ebool) {
302
- return inco.eGt(asEuint256(a), s(b));
303
- }
304
-
305
- function le(euint256 a, euint256 b) internal returns (ebool) {
306
- return inco.eLe(s(a), s(b));
307
- }
308
-
309
- function le(euint256 a, uint256 b) internal returns (ebool) {
310
- return inco.eLe(s(a), asEuint256(b));
311
- }
312
-
313
- function le(uint256 a, euint256 b) internal returns (ebool) {
314
- return inco.eLe(asEuint256(a), s(b));
315
- }
316
-
317
- function lt(euint256 a, euint256 b) internal returns (ebool) {
318
- return inco.eLt(s(a), s(b));
319
- }
320
-
321
- function lt(euint256 a, uint256 b) internal returns (ebool) {
322
- return inco.eLt(s(a), asEuint256(b));
323
- }
324
-
325
- function lt(uint256 a, euint256 b) internal returns (ebool) {
326
- return inco.eLt(asEuint256(a), s(b));
327
- }
328
-
329
- function min(euint256 a, euint256 b) internal returns (euint256) {
330
- return inco.eMin(s(a), s(b));
331
- }
332
-
333
- function min(euint256 a, uint256 b) internal returns (euint256) {
334
- return inco.eMin(s(a), asEuint256(b));
335
- }
336
-
337
- function min(uint256 a, euint256 b) internal returns (euint256) {
338
- return inco.eMin(asEuint256(a), s(b));
339
- }
340
-
341
- function max(euint256 a, euint256 b) internal returns (euint256) {
342
- return inco.eMax(s(a), s(b));
343
- }
344
-
345
- function max(euint256 a, uint256 b) internal returns (euint256) {
346
- return inco.eMax(s(a), asEuint256(b));
347
- }
348
-
349
- function max(uint256 a, euint256 b) internal returns (euint256) {
350
- return inco.eMax(asEuint256(a), s(b));
351
- }
352
-
353
- function not(ebool a) internal returns (ebool) {
354
- return inco.eNot(s(a));
355
- }
356
-
357
- function rand() internal returns (euint256) {
358
- return euint256.wrap(inco.eRand(ETypes.Uint256));
359
- }
360
-
361
- function randBounded(uint256 upperBound) internal returns (euint256) {
362
- return euint256.wrap(inco.eRandBounded(euint256.unwrap(asEuint256(upperBound)), ETypes.Uint256));
363
- }
364
-
365
- function randBounded(euint256 upperBound) internal returns (euint256) {
366
- return euint256.wrap(inco.eRandBounded(euint256.unwrap(s(upperBound)), ETypes.Uint256));
367
- }
368
-
369
- function asEuint256(uint256 a) internal returns (euint256) {
370
- return inco.asEuint256(a);
371
- }
372
-
373
- function asEbool(bool a) internal returns (ebool) {
374
- return inco.asEbool(a);
375
- }
376
-
377
- function asEaddress(address a) internal returns (eaddress) {
378
- return inco.asEaddress(a);
379
- }
380
-
381
- function asEbool(euint256 a) internal returns (ebool) {
382
- return ebool.wrap(inco.eCast(euint256.unwrap(a), ETypes.Bool));
383
- }
384
-
385
- function asEuint256(ebool a) internal returns (euint256) {
386
- return euint256.wrap(inco.eCast(ebool.unwrap(a), ETypes.Uint256));
387
- }
388
-
389
- function newEuint256(bytes memory ciphertext, address user) internal returns (euint256) {
390
- return inco.newEuint256(ciphertext, user);
391
- }
392
-
393
- function newEbool(bytes memory ciphertext, address user) internal returns (ebool) {
394
- return inco.newEbool(ciphertext, user);
395
- }
396
-
397
- function newEaddress(bytes memory ciphertext, address user) internal returns (eaddress) {
398
- return inco.newEaddress(ciphertext, user);
399
- }
400
-
401
- function allow(euint256 a, address to) internal {
402
- inco.allow(euint256.unwrap(a), to);
403
- }
404
-
405
- function allow(ebool a, address to) internal {
406
- inco.allow(ebool.unwrap(a), to);
407
- }
408
-
409
- function allow(eaddress a, address to) internal {
410
- inco.allow(eaddress.unwrap(a), to);
411
- }
412
-
413
- function reveal(euint256 a) internal {
414
- inco.reveal(euint256.unwrap(a));
415
- }
416
-
417
- function reveal(ebool a) internal {
418
- inco.reveal(ebool.unwrap(a));
419
- }
420
-
421
- function reveal(eaddress a) internal {
422
- inco.reveal(eaddress.unwrap(a));
423
- }
424
-
425
- function allowThis(euint256 a) internal {
426
- allow(a, address(this));
427
- }
428
-
429
- function allowThis(ebool a) internal {
430
- allow(a, address(this));
431
- }
432
-
433
- function allowThis(eaddress a) internal {
434
- allow(a, address(this));
435
- }
436
-
437
- function isAllowed(address user, euint256 a) internal view returns (bool) {
438
- return inco.isAllowed(euint256.unwrap(a), user);
439
- }
440
-
441
- function select(ebool control, euint256 ifTrue, euint256 ifFalse) internal returns (euint256) {
442
- return euint256.wrap(inco.eIfThenElse(s(control), euint256.unwrap(s(ifTrue)), euint256.unwrap(s(ifFalse))));
443
- }
444
-
445
- function select(ebool control, ebool ifTrue, ebool ifFalse) internal returns (ebool) {
446
- return ebool.wrap(inco.eIfThenElse(s(control), ebool.unwrap(s(ifTrue)), ebool.unwrap(s(ifFalse))));
447
- }
448
-
449
- function select(ebool control, eaddress ifTrue, eaddress ifFalse) internal returns (eaddress) {
450
- return eaddress.wrap(inco.eIfThenElse(s(control), eaddress.unwrap(s(ifTrue)), eaddress.unwrap(s(ifFalse))));
451
- }
452
-
453
- }
@@ -1,453 +0,0 @@
1
- // AUTOGENERATED FILE. DO NOT EDIT.
2
- // This file was generated by the IncoLightning library generator.
3
- // The original template is located at Lib.template.sol
4
-
5
- /// SPDX-License-Identifier: No License
6
- pragma solidity ^0.8;
7
-
8
- import {IncoLightning} from "../IncoLightning.sol";
9
- import {ebool, euint256, eaddress, ETypes} from "../Types.sol";
10
-
11
- IncoLightning constant inco = IncoLightning(0xFb0Bd1a97DD2ECA4c7560b2a35d56474593f3Bab);
12
- address constant deployedBy = 0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38;
13
-
14
- function typeOf(bytes32 handle) pure returns (ETypes) {
15
- return ETypes(uint8(uint256(handle) >> 8));
16
- }
17
-
18
- library e {
19
-
20
- function sanitize(euint256 a) internal returns (euint256) {
21
- if (euint256.unwrap(a) == bytes32(0)) {
22
- return asEuint256(0);
23
- }
24
- return a;
25
- }
26
-
27
- function sanitize(ebool a) internal returns (ebool) {
28
- if (ebool.unwrap(a) == bytes32(0)) {
29
- return asEbool(false);
30
- }
31
- return a;
32
- }
33
-
34
- function sanitize(eaddress a) internal returns (eaddress) {
35
- if (eaddress.unwrap(a) == bytes32(0)) {
36
- return asEaddress(address(0));
37
- }
38
- return a;
39
- }
40
-
41
- function s(euint256 a) internal returns (euint256) {
42
- return sanitize(a);
43
- }
44
-
45
- function s(ebool a) internal returns (ebool) {
46
- return sanitize(a);
47
- }
48
-
49
- function s(eaddress a) internal returns (eaddress) {
50
- return sanitize(a);
51
- }
52
-
53
- function add(euint256 a, euint256 b) internal returns (euint256) {
54
- return inco.eAdd(s(a), s(b));
55
- }
56
-
57
- function add(euint256 a, uint256 b) internal returns (euint256) {
58
- return inco.eAdd(s(a), asEuint256(b));
59
- }
60
-
61
- function add(uint256 a, euint256 b) internal returns (euint256) {
62
- return inco.eAdd(asEuint256(a), s(b));
63
- }
64
-
65
- function sub(euint256 a, euint256 b) internal returns (euint256) {
66
- return inco.eSub(s(a), s(b));
67
- }
68
-
69
- function sub(euint256 a, uint256 b) internal returns (euint256) {
70
- return inco.eSub(s(a), asEuint256(b));
71
- }
72
-
73
- function sub(uint256 a, euint256 b) internal returns (euint256) {
74
- return inco.eSub(asEuint256(a), s(b));
75
- }
76
-
77
- function mul(euint256 a, euint256 b) internal returns (euint256) {
78
- return inco.eMul(s(a), s(b));
79
- }
80
-
81
- function mul(euint256 a, uint256 b) internal returns (euint256) {
82
- return inco.eMul(s(a), asEuint256(b));
83
- }
84
-
85
- function mul(uint256 a, euint256 b) internal returns (euint256) {
86
- return inco.eMul(asEuint256(a), s(b));
87
- }
88
-
89
- function div(euint256 a, euint256 b) internal returns (euint256) {
90
- return inco.eDiv(s(a), s(b));
91
- }
92
-
93
- function div(euint256 a, uint256 b) internal returns (euint256) {
94
- return inco.eDiv(s(a), asEuint256(b));
95
- }
96
-
97
- function div(uint256 a, euint256 b) internal returns (euint256) {
98
- return inco.eDiv(asEuint256(a), s(b));
99
- }
100
-
101
- function rem(euint256 a, euint256 b) internal returns (euint256) {
102
- return inco.eRem(s(a), s(b));
103
- }
104
-
105
- function rem(euint256 a, uint256 b) internal returns (euint256) {
106
- return inco.eRem(s(a), asEuint256(b));
107
- }
108
-
109
- function rem(uint256 a, euint256 b) internal returns (euint256) {
110
- return inco.eRem(asEuint256(a), s(b));
111
- }
112
-
113
- function and(euint256 a, euint256 b) internal returns (euint256) {
114
- return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
115
- }
116
-
117
- function and(euint256 a, uint256 b) internal returns (euint256) {
118
- return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
119
- }
120
-
121
- function and(uint256 a, euint256 b) internal returns (euint256) {
122
- return euint256.wrap(inco.eBitAnd(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
123
- }
124
-
125
- function and(ebool a, ebool b) internal returns (ebool) {
126
- return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
127
- }
128
-
129
- function and(ebool a, bool b) internal returns (ebool) {
130
- return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
131
- }
132
-
133
- function and(bool a, ebool b) internal returns (ebool) {
134
- return ebool.wrap(inco.eBitAnd(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
135
- }
136
-
137
- function or(euint256 a, euint256 b) internal returns (euint256) {
138
- return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
139
- }
140
-
141
- function or(euint256 a, uint256 b) internal returns (euint256) {
142
- return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
143
- }
144
-
145
- function or(uint256 a, euint256 b) internal returns (euint256) {
146
- return euint256.wrap(inco.eBitOr(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
147
- }
148
-
149
- function or(ebool a, ebool b) internal returns (ebool) {
150
- return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
151
- }
152
-
153
- function or(ebool a, bool b) internal returns (ebool) {
154
- return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
155
- }
156
-
157
- function or(bool a, ebool b) internal returns (ebool) {
158
- return ebool.wrap(inco.eBitOr(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
159
- }
160
-
161
- function xor(euint256 a, euint256 b) internal returns (euint256) {
162
- return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
163
- }
164
-
165
- function xor(euint256 a, uint256 b) internal returns (euint256) {
166
- return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
167
- }
168
-
169
- function xor(uint256 a, euint256 b) internal returns (euint256) {
170
- return euint256.wrap(inco.eBitXor(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
171
- }
172
-
173
- function xor(ebool a, ebool b) internal returns (ebool) {
174
- return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
175
- }
176
-
177
- function xor(ebool a, bool b) internal returns (ebool) {
178
- return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
179
- }
180
-
181
- function xor(bool a, ebool b) internal returns (ebool) {
182
- return ebool.wrap(inco.eBitXor(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
183
- }
184
-
185
- function shl(euint256 a, euint256 b) internal returns (euint256) {
186
- return inco.eShl(s(a), s(b));
187
- }
188
-
189
- function shl(euint256 a, uint256 b) internal returns (euint256) {
190
- return inco.eShl(s(a), asEuint256(b));
191
- }
192
-
193
- function shl(uint256 a, euint256 b) internal returns (euint256) {
194
- return inco.eShl(asEuint256(a), s(b));
195
- }
196
-
197
- function shr(euint256 a, euint256 b) internal returns (euint256) {
198
- return inco.eShr(s(a), s(b));
199
- }
200
-
201
- function shr(euint256 a, uint256 b) internal returns (euint256) {
202
- return inco.eShr(s(a), asEuint256(b));
203
- }
204
-
205
- function shr(uint256 a, euint256 b) internal returns (euint256) {
206
- return inco.eShr(asEuint256(a), s(b));
207
- }
208
-
209
- function rotl(euint256 a, euint256 b) internal returns (euint256) {
210
- return inco.eRotl(s(a), s(b));
211
- }
212
-
213
- function rotl(euint256 a, uint256 b) internal returns (euint256) {
214
- return inco.eRotl(s(a), asEuint256(b));
215
- }
216
-
217
- function rotl(uint256 a, euint256 b) internal returns (euint256) {
218
- return inco.eRotl(asEuint256(a), s(b));
219
- }
220
-
221
- function rotr(euint256 a, euint256 b) internal returns (euint256) {
222
- return inco.eRotr(s(a), s(b));
223
- }
224
-
225
- function rotr(euint256 a, uint256 b) internal returns (euint256) {
226
- return inco.eRotr(s(a), asEuint256(b));
227
- }
228
-
229
- function rotr(uint256 a, euint256 b) internal returns (euint256) {
230
- return inco.eRotr(asEuint256(a), s(b));
231
- }
232
-
233
- function eq(euint256 a, euint256 b) internal returns (ebool) {
234
- return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
235
- }
236
-
237
- function eq(euint256 a, uint256 b) internal returns (ebool) {
238
- return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
239
- }
240
-
241
- function eq(uint256 a, euint256 b) internal returns (ebool) {
242
- return inco.eEq(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
243
- }
244
-
245
- function eq(eaddress a, address b) internal returns (ebool) {
246
- return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
247
- }
248
-
249
- function eq(eaddress a, eaddress b) internal returns (ebool) {
250
- return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
251
- }
252
-
253
- function eq(address a, eaddress b) internal returns (ebool) {
254
- return inco.eEq(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
255
- }
256
-
257
- function ne(euint256 a, euint256 b) internal returns (ebool) {
258
- return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
259
- }
260
-
261
- function ne(euint256 a, uint256 b) internal returns (ebool) {
262
- return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
263
- }
264
-
265
- function ne(uint256 a, euint256 b) internal returns (ebool) {
266
- return inco.eNe(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
267
- }
268
-
269
- function ne(eaddress a, eaddress b) internal returns (ebool) {
270
- return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
271
- }
272
-
273
- function ne(eaddress a, address b) internal returns (ebool) {
274
- return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
275
- }
276
-
277
- function ne(address a, eaddress b) internal returns (ebool) {
278
- return inco.eNe(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
279
- }
280
-
281
- function ge(euint256 a, euint256 b) internal returns (ebool) {
282
- return inco.eGe(s(a), s(b));
283
- }
284
-
285
- function ge(euint256 a, uint256 b) internal returns (ebool) {
286
- return inco.eGe(s(a), asEuint256(b));
287
- }
288
-
289
- function ge(uint256 a, euint256 b) internal returns (ebool) {
290
- return inco.eGe(asEuint256(a), s(b));
291
- }
292
-
293
- function gt(euint256 a, euint256 b) internal returns (ebool) {
294
- return inco.eGt(s(a), s(b));
295
- }
296
-
297
- function gt(euint256 a, uint256 b) internal returns (ebool) {
298
- return inco.eGt(s(a), asEuint256(b));
299
- }
300
-
301
- function gt(uint256 a, euint256 b) internal returns (ebool) {
302
- return inco.eGt(asEuint256(a), s(b));
303
- }
304
-
305
- function le(euint256 a, euint256 b) internal returns (ebool) {
306
- return inco.eLe(s(a), s(b));
307
- }
308
-
309
- function le(euint256 a, uint256 b) internal returns (ebool) {
310
- return inco.eLe(s(a), asEuint256(b));
311
- }
312
-
313
- function le(uint256 a, euint256 b) internal returns (ebool) {
314
- return inco.eLe(asEuint256(a), s(b));
315
- }
316
-
317
- function lt(euint256 a, euint256 b) internal returns (ebool) {
318
- return inco.eLt(s(a), s(b));
319
- }
320
-
321
- function lt(euint256 a, uint256 b) internal returns (ebool) {
322
- return inco.eLt(s(a), asEuint256(b));
323
- }
324
-
325
- function lt(uint256 a, euint256 b) internal returns (ebool) {
326
- return inco.eLt(asEuint256(a), s(b));
327
- }
328
-
329
- function min(euint256 a, euint256 b) internal returns (euint256) {
330
- return inco.eMin(s(a), s(b));
331
- }
332
-
333
- function min(euint256 a, uint256 b) internal returns (euint256) {
334
- return inco.eMin(s(a), asEuint256(b));
335
- }
336
-
337
- function min(uint256 a, euint256 b) internal returns (euint256) {
338
- return inco.eMin(asEuint256(a), s(b));
339
- }
340
-
341
- function max(euint256 a, euint256 b) internal returns (euint256) {
342
- return inco.eMax(s(a), s(b));
343
- }
344
-
345
- function max(euint256 a, uint256 b) internal returns (euint256) {
346
- return inco.eMax(s(a), asEuint256(b));
347
- }
348
-
349
- function max(uint256 a, euint256 b) internal returns (euint256) {
350
- return inco.eMax(asEuint256(a), s(b));
351
- }
352
-
353
- function not(ebool a) internal returns (ebool) {
354
- return inco.eNot(s(a));
355
- }
356
-
357
- function rand() internal returns (euint256) {
358
- return euint256.wrap(inco.eRand(ETypes.Uint256));
359
- }
360
-
361
- function randBounded(uint256 upperBound) internal returns (euint256) {
362
- return euint256.wrap(inco.eRandBounded(euint256.unwrap(asEuint256(upperBound)), ETypes.Uint256));
363
- }
364
-
365
- function randBounded(euint256 upperBound) internal returns (euint256) {
366
- return euint256.wrap(inco.eRandBounded(euint256.unwrap(s(upperBound)), ETypes.Uint256));
367
- }
368
-
369
- function asEuint256(uint256 a) internal returns (euint256) {
370
- return inco.asEuint256(a);
371
- }
372
-
373
- function asEbool(bool a) internal returns (ebool) {
374
- return inco.asEbool(a);
375
- }
376
-
377
- function asEaddress(address a) internal returns (eaddress) {
378
- return inco.asEaddress(a);
379
- }
380
-
381
- function asEbool(euint256 a) internal returns (ebool) {
382
- return ebool.wrap(inco.eCast(euint256.unwrap(a), ETypes.Bool));
383
- }
384
-
385
- function asEuint256(ebool a) internal returns (euint256) {
386
- return euint256.wrap(inco.eCast(ebool.unwrap(a), ETypes.Uint256));
387
- }
388
-
389
- function newEuint256(bytes memory ciphertext, address user) internal returns (euint256) {
390
- return inco.newEuint256(ciphertext, user);
391
- }
392
-
393
- function newEbool(bytes memory ciphertext, address user) internal returns (ebool) {
394
- return inco.newEbool(ciphertext, user);
395
- }
396
-
397
- function newEaddress(bytes memory ciphertext, address user) internal returns (eaddress) {
398
- return inco.newEaddress(ciphertext, user);
399
- }
400
-
401
- function allow(euint256 a, address to) internal {
402
- inco.allow(euint256.unwrap(a), to);
403
- }
404
-
405
- function allow(ebool a, address to) internal {
406
- inco.allow(ebool.unwrap(a), to);
407
- }
408
-
409
- function allow(eaddress a, address to) internal {
410
- inco.allow(eaddress.unwrap(a), to);
411
- }
412
-
413
- function reveal(euint256 a) internal {
414
- inco.reveal(euint256.unwrap(a));
415
- }
416
-
417
- function reveal(ebool a) internal {
418
- inco.reveal(ebool.unwrap(a));
419
- }
420
-
421
- function reveal(eaddress a) internal {
422
- inco.reveal(eaddress.unwrap(a));
423
- }
424
-
425
- function allowThis(euint256 a) internal {
426
- allow(a, address(this));
427
- }
428
-
429
- function allowThis(ebool a) internal {
430
- allow(a, address(this));
431
- }
432
-
433
- function allowThis(eaddress a) internal {
434
- allow(a, address(this));
435
- }
436
-
437
- function isAllowed(address user, euint256 a) internal view returns (bool) {
438
- return inco.isAllowed(euint256.unwrap(a), user);
439
- }
440
-
441
- function select(ebool control, euint256 ifTrue, euint256 ifFalse) internal returns (euint256) {
442
- return euint256.wrap(inco.eIfThenElse(s(control), euint256.unwrap(s(ifTrue)), euint256.unwrap(s(ifFalse))));
443
- }
444
-
445
- function select(ebool control, ebool ifTrue, ebool ifFalse) internal returns (ebool) {
446
- return ebool.wrap(inco.eIfThenElse(s(control), ebool.unwrap(s(ifTrue)), ebool.unwrap(s(ifFalse))));
447
- }
448
-
449
- function select(ebool control, eaddress ifTrue, eaddress ifFalse) internal returns (eaddress) {
450
- return eaddress.wrap(inco.eIfThenElse(s(control), eaddress.unwrap(s(ifTrue)), eaddress.unwrap(s(ifFalse))));
451
- }
452
-
453
- }