@coti-io/coti-contracts 1.0.0 → 1.0.2

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.
Files changed (88) hide show
  1. package/.github/workflows/npm-publish.yml +2 -1
  2. package/CONTRIBUTING.md +2 -2
  3. package/LICENSE +1 -1
  4. package/README.md +18 -35
  5. package/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol +152 -0
  6. package/contracts/mocks/utils/mpc/BitwiseTestsContract.sol +11 -1
  7. package/contracts/mocks/utils/mpc/Comparison2TestsContract.sol +8 -0
  8. package/contracts/mocks/utils/mpc/Miscellaneous1TestsContract.sol +33 -4
  9. package/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract.sol +35 -10
  10. package/contracts/mocks/utils/mpc/TransferTestsContract.sol +3 -0
  11. package/contracts/mocks/utils/mpc/TransferWithAllowance64_16TestsContract.sol +222 -0
  12. package/contracts/mocks/utils/mpc/TransferWithAllowance64_32TestsContract.sol +222 -0
  13. package/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol +223 -0
  14. package/contracts/mocks/utils/mpc/TransferWithAllowance64_8TestsContract.sol +222 -0
  15. package/contracts/mocks/utils/mpc/TransferWithAllowanceScalarTestsContract.sol +265 -0
  16. package/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol +281 -0
  17. package/contracts/token/PrivateERC20/PrivateERC20.sol +1 -1
  18. package/contracts/token/PrivateERC721/IERC721Errors.sol +57 -0
  19. package/contracts/token/PrivateERC721/PrivateERC721.sol +1 -1
  20. package/hardhat.config.ts +9 -1
  21. package/package.json +20 -4
  22. package/test/token/PrivateERC20/PrivateERC20.test.ts +2 -2
  23. package/test/utils/mpc/Precompile.test.ts +16 -2
  24. package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.ts +66 -0
  25. package/typechain-types/contracts/mocks/utils/mpc/BitwiseTestsContract.ts +6 -0
  26. package/typechain-types/contracts/mocks/utils/mpc/Comparison2TestsContract.ts +6 -0
  27. package/typechain-types/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract.ts +36 -6
  28. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowance64TestsContract.ts +251 -0
  29. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowanceTestsContract.ts +250 -0
  30. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/index.ts +5 -0
  31. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.ts +389 -0
  32. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_16TestsContract.ts +391 -0
  33. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_32TestsContract.ts +391 -0
  34. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_64TestsContract.ts +391 -0
  35. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_8TestsContract.ts +391 -0
  36. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/index.ts +5 -0
  37. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.ts +391 -0
  38. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_8TestsContract.ts +391 -0
  39. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceScalarTestsContract.ts +306 -0
  40. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferTestsContract.ts +125 -0
  41. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferWithAllowanceTestsContract.ts +125 -0
  42. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/index.ts +5 -0
  43. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.ts +296 -0
  44. package/typechain-types/contracts/mocks/utils/mpc/index.ts +6 -0
  45. package/typechain-types/contracts/token/PrivateERC721/IERC721Errors.ts +69 -0
  46. package/typechain-types/contracts/token/PrivateERC721/index.ts +1 -0
  47. package/typechain-types/factories/contracts/mocks/access/DataPrivacyFramework/DataPrivacyFrameworkMock__factory.ts +1 -1
  48. package/typechain-types/factories/contracts/mocks/token/PrivateERC20/PrivateERC20Mock__factory.ts +1 -1
  49. package/typechain-types/factories/contracts/mocks/token/PrivateERC721/PrivateERC721URIStorageMock__factory.ts +1 -1
  50. package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract__factory.ts +73 -1
  51. package/typechain-types/factories/contracts/mocks/utils/mpc/BitwiseTestsContract__factory.ts +11 -1
  52. package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison1TestsContract__factory.ts +1 -1
  53. package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison2TestsContract__factory.ts +11 -1
  54. package/typechain-types/factories/contracts/mocks/utils/mpc/MinMaxTestsContract__factory.ts +1 -1
  55. package/typechain-types/factories/contracts/mocks/utils/mpc/Miscellaneous1TestsContract__factory.ts +1 -1
  56. package/typechain-types/factories/contracts/mocks/utils/mpc/MiscellaneousTestsContract__factory.ts +1 -1
  57. package/typechain-types/factories/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract__factory.ts +26 -30
  58. package/typechain-types/factories/contracts/mocks/utils/mpc/StringTestsContract__factory.ts +1 -1
  59. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferScalarTestsContract__factory.ts +1 -1
  60. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferTestsContract__factory.ts +1 -1
  61. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowance64TestsContract__factory.ts +294 -0
  62. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowanceTestsContract__factory.ts +292 -0
  63. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/index.ts +5 -0
  64. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract__factory.ts +720 -0
  65. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_16TestsContract__factory.ts +724 -0
  66. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_32TestsContract__factory.ts +724 -0
  67. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_64TestsContract__factory.ts +724 -0
  68. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_8TestsContract__factory.ts +724 -0
  69. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/index.ts +5 -0
  70. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract__factory.ts +724 -0
  71. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_8TestsContract__factory.ts +724 -0
  72. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceScalarTestsContract__factory.ts +507 -0
  73. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferTestsContract__factory.ts +150 -0
  74. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferWithAllowanceTestsContract__factory.ts +150 -0
  75. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/index.ts +5 -0
  76. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract__factory.ts +434 -0
  77. package/typechain-types/factories/contracts/mocks/utils/mpc/index.ts +6 -0
  78. package/typechain-types/factories/contracts/mocks/wallet/PrivateERC20Wallet/PrivateERC20WalletMock__factory.ts +1 -1
  79. package/typechain-types/factories/contracts/onboard/AccountOnboard__factory.ts +1 -1
  80. package/typechain-types/factories/contracts/token/PrivateERC721/IERC721Errors__factory.ts +128 -0
  81. package/typechain-types/factories/contracts/token/PrivateERC721/index.ts +1 -0
  82. package/typechain-types/factories/contracts/utils/mpc/MpcCore__factory.ts +1 -1
  83. package/typechain-types/hardhat.d.ts +126 -0
  84. package/typechain-types/index.ts +12 -0
  85. package/contracts/access/DataPrivacyFramework/README.md +0 -68
  86. package/contracts/token/PrivateERC20/README.md +0 -104
  87. package/contracts/token/PrivateERC721/README.md +0 -282
  88. package/contracts/utils/mpc/README.md +0 -82
@@ -1,282 +0,0 @@
1
- # PrivateERC721
2
-
3
- ## Overview
4
-
5
- `PrivateERC721` is an abstract implementation of the [ERC721 Non-Fungible Token (NFT) Standard](https://eips.ethereum.org/EIPS/eip-721). It includes essential features of the standard, such as token ownership, approval, transfers, and safe transfers. This contract implements key components of the ERC721 standard while maintaining support for token metadata, but without fully implementing the metadata extension.
6
-
7
- ## Prerequisites
8
-
9
- - **Solidity Version**: `^0.8.19`
10
- - **License**: MIT
11
- - **Dependencies**:
12
- - OpenZeppelin’s `Context`, `ERC165`, and `IERC721` contracts.
13
- - `IERC721Receiver` for safe transfer checks.
14
- - `IERC721Errors` interface for custom errors (related to the draft standard [IERC6093](https://eips.ethereum.org/EIPS/eip-6093)).
15
-
16
- ## Table of Contents
17
- - [Events](#events)
18
- - [State Variables](#state-variables)
19
- - [Constructor](#constructor)
20
- - [Functions](#functions)
21
- - [Supports Interface](#supports-interface)
22
- - [Balance Of](#balance-of)
23
- - [Owner Of](#owner-of)
24
- - [Name](#name)
25
- - [Symbol](#symbol)
26
- - [Approve](#approve)
27
- - [Get Approved](#get-approved)
28
- - [Set Approval For All](#set-approval-for-all)
29
- - [Is Approved For All](#is-approved-for-all)
30
- - [Transfer From](#transfer-from)
31
- - [Safe Transfer From](#safe-transfer-from)
32
- - [Private/Internal Functions](#privateinternal-functions)
33
-
34
- ## Events
35
-
36
- ## Event: `Transfer`
37
-
38
- ```solidity
39
- event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
40
- ```
41
-
42
- ### Description:
43
- This event is emitted whenever an ERC-721 token is transferred from one address to another. It occurs during both direct token transfers (`transferFrom`) and safe token transfers (`safeTransferFrom`). This event helps external observers, such as dApps and explorers, to track the movement of tokens.
44
-
45
- ### Parameters:
46
- - **`from`** (`address`): The address of the current owner of the token.
47
- - **`to`** (`address`): The address that is receiving ownership of the token.
48
- - **`tokenId`** (`uint256`): The unique identifier (ID) of the token being transferred.
49
-
50
- ### Important Notes:
51
- - This event is emitted for both `transferFrom` and `safeTransferFrom` operations.
52
- - If a token is minted, `from` will be the zero address (`address(0)`).
53
- - If a token is burned, `to` will be the zero address (`address(0)`).
54
-
55
- ## Event: `Approval`
56
-
57
- ```solidity
58
- event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
59
- ```
60
-
61
- ### Description:
62
- The `Approval` event is emitted when an owner grants or revokes permission to another account (the `approved` address) to transfer a specific token. Each ERC-721 token can only have one approved address at a time. The approval is reset when the token is transferred to a new owner.
63
-
64
- ### Parameters:
65
- - **`owner`** (`address`): The current owner of the token.
66
- - **`approved`** (`address`): The address that is approved to transfer the token. This can be the zero address (`address(0)`) if no account is approved.
67
- - **`tokenId`** (`uint256`): The unique identifier (ID) of the token being approved for transfer.
68
-
69
- ### Important Notes:
70
- - This event is specific to individual tokens, meaning approvals apply to a single `tokenId`.
71
- - Approving the zero address (`address(0)`) clears the previous approval, effectively revoking approval for that token.
72
-
73
- ## Event: `ApprovalForAll`
74
-
75
- ```solidity
76
- event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
77
- ```
78
-
79
- ### Description:
80
- This event is emitted when an owner enables or disables an operator to manage all of their assets. Operators can transfer or manage any token owned by the `owner`. The event allows for bulk approval of all tokens owned by a single account.
81
-
82
- ### Parameters:
83
- - **`owner`** (`address`): The address of the token owner.
84
- - **`operator`** (`address`): The address that is granted or revoked permission to manage all of the owner's tokens.
85
- - **`approved`** (`bool`): A boolean value indicating whether the operator is approved (`true`) or approval is revoked (`false`).
86
-
87
- ### Important Notes:
88
- - This event differs from the `Approval` event because it applies to all tokens owned by the `owner`, not a single token.
89
- - This event is emitted when the `setApprovalForAll` function is called, allowing or revoking an operator’s access to all of the owner's tokens.
90
-
91
- ## State Variables
92
-
93
- - **_name** (`string`): The name of the token collection.
94
- - **_symbol** (`string`): The symbol for the token collection.
95
- - **_owners** (`mapping(uint256 => address)`): Maps a token ID to its owner address.
96
- - **_balances** (`mapping(address => uint256)`): Maps owner addresses to the number of tokens they own.
97
- - **_tokenApprovals** (`mapping(uint256 => address)`): Maps a token ID to the approved address for that token.
98
- - **_operatorApprovals** (`mapping(address => mapping(address => bool))`): Maps an owner to an operator, allowing the operator to manage all tokens owned by that owner.
99
-
100
- ## Constructor
101
-
102
- ```solidity
103
- constructor(string memory name_, string memory symbol_)
104
- ```
105
-
106
- The constructor initializes the contract by setting the name and symbol of the token collection. It accepts the following parameters:
107
-
108
- - **`name_`**: The name of the token collection.
109
- - **`symbol_`**: The symbol for the token collection.
110
-
111
- ## Functions
112
-
113
- ### Supports Interface
114
-
115
- ```solidity
116
- function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool)
117
- ```
118
-
119
- Implements the `supportsInterface` function to check if the contract implements a specific interface (e.g., `IERC721`).
120
-
121
- - **`interfaceId`**: The interface identifier to check.
122
- - **Returns**: `true` if the contract supports the interface, otherwise `false`.
123
-
124
- ### Balance Of
125
-
126
- ```solidity
127
- function balanceOf(address owner) public view virtual returns (uint256)
128
- ```
129
-
130
- Returns the number of tokens owned by the given address.
131
-
132
- - **`owner`**: The address to query.
133
- - **Returns**: The number of tokens owned by the address.
134
- - **Reverts**: `ERC721InvalidOwner` if `owner` is the zero address.
135
-
136
- ### Owner Of
137
-
138
- ```solidity
139
- function ownerOf(uint256 tokenId) public view virtual returns (address)
140
- ```
141
-
142
- Returns the owner of the given `tokenId`.
143
-
144
- - **`tokenId`**: The ID of the token.
145
- - **Returns**: The owner address of the `tokenId`.
146
- - **Reverts**: If the token does not exist.
147
-
148
- ### Name
149
-
150
- ```solidity
151
- function name() public view virtual returns (string memory)
152
- ```
153
-
154
- Returns the name of the token collection.
155
-
156
- ### Symbol
157
-
158
- ```solidity
159
- function symbol() public view virtual returns (string memory)
160
- ```
161
-
162
- Returns the symbol of the token collection.
163
-
164
- ### Approve
165
-
166
- ```solidity
167
- function approve(address to, uint256 tokenId) public virtual
168
- ```
169
-
170
- Approves the given address (`to`) to transfer the specified token on behalf of the owner.
171
-
172
- - **`to`**: The address to be approved.
173
- - **`tokenId`**: The ID of the token to approve.
174
-
175
- ### Get Approved
176
-
177
- ```solidity
178
- function getApproved(uint256 tokenId) public view virtual returns (address)
179
- ```
180
-
181
- Returns the approved address for the given `tokenId`.
182
-
183
- - **`tokenId`**: The ID of the token to check.
184
- - **Returns**: The address approved to transfer the `tokenId`.
185
-
186
- ### Set Approval For All
187
-
188
- ```solidity
189
- function setApprovalForAll(address operator, bool approved) public virtual
190
- ```
191
-
192
- Enables or disables approval for a third-party `operator` to manage all tokens owned by the sender.
193
-
194
- - **`operator`**: The address of the operator.
195
- - **`approved`**: `true` to approve, `false` to revoke approval.
196
-
197
- ### Is Approved For All
198
-
199
- ```solidity
200
- function isApprovedForAll(address owner, address operator) public view virtual returns (bool)
201
- ```
202
-
203
- Checks if the `operator` is approved to manage all tokens owned by `owner`.
204
-
205
- - **`owner`**: The address of the token owner.
206
- - **`operator`**: The address of the operator.
207
- - **Returns**: `true` if the operator is approved, otherwise `false`.
208
-
209
- ### Transfer From
210
-
211
- ```solidity
212
- function transferFrom(address from, address to, uint256 tokenId) public virtual
213
- ```
214
-
215
- Transfers ownership of the `tokenId` from one address to another.
216
-
217
- - **`from`**: The current owner of the token.
218
- - **`to`**: The address receiving the token.
219
- - **`tokenId`**: The ID of the token.
220
- - **Reverts**: `ERC721InvalidReceiver` if `to` is the zero address or if the sender is not authorized to transfer the token.
221
-
222
- ### Safe Transfer From
223
-
224
- ```solidity
225
- function safeTransferFrom(address from, address to, uint256 tokenId) public
226
- ```
227
-
228
- Safely transfers a `tokenId` from one address to another, ensuring the receiver can handle ERC721 tokens.
229
-
230
- - **`from`**: The current owner of the token.
231
- - **`to`**: The address receiving the token.
232
- - **`tokenId`**: The ID of the token.
233
-
234
- ### Private/Internal Functions
235
-
236
- #### `_ownerOf`
237
-
238
- ```solidity
239
- function _ownerOf(uint256 tokenId) internal view virtual returns (address)
240
- ```
241
-
242
- Internal function that returns the owner of the `tokenId`.
243
-
244
- #### `_isAuthorized`
245
-
246
- ```solidity
247
- function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool)
248
- ```
249
-
250
- Checks if `spender` is authorized to manage `owner`'s token or the specific `tokenId`.
251
-
252
- #### `_approve`
253
-
254
- ```solidity
255
- function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual
256
- ```
257
-
258
- Approves the address `to` to manage the `tokenId`. Optionally emits the `Approval` event.
259
-
260
- #### `_mint`
261
-
262
- ```solidity
263
- function _mint(address to, uint256 tokenId) internal
264
- ```
265
-
266
- Mints a new token with the given `tokenId` and transfers it to the address `to`.
267
-
268
- #### `_burn`
269
-
270
- ```solidity
271
- function _burn(uint256 tokenId) internal
272
- ```
273
-
274
- Burns (destroys) the token with the given `tokenId`.
275
-
276
- #### `_checkOnERC721Received`
277
-
278
- ```solidity
279
- function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) private
280
- ```
281
-
282
- Private function to invoke the `IERC721Receiver.onERC721Received` on the target address if it's a contract.
@@ -1,82 +0,0 @@
1
- # MpcCore.sol
2
-
3
- This Solidity library, `MpcCore`, provides core functionalities for secure multi-party computation (MPC) using the COTI protocol. Below is an overview of its components and functions:
4
-
5
- ## Legend
6
-
7
- - it = input text. This structure contains text that was encrypted by user and provided a signature to authenticate it.
8
- - gc = garbled text
9
- - ct = cipher text
10
- - ut = user text. This structure contains 2 types of cipher texts: one by the network and one by the user key. Convenient for operations that require some times to decipher one or another.
11
-
12
- ## Types
13
- The library defines several custom types using `uint256` as the base type:
14
- - `gtBool`, `gtUint8`, `gtUint16`, `gtUint32`, `gtUint64`
15
- - `ctBool`, `ctUint8`, `ctUint16`, `ctUint32`, `ctUint64`
16
- - `lenghts`, use to differentiate the length
17
-
18
- ## Structures
19
- The library defines multiple structures for handling encrypted and signed data:
20
- - `itBool`, `itUint8`, `itUint16`, `itUint32`, `itUint64`: Each structure contains a inputtext (`ctBool`, `ctUint8`, etc.) and a signature (`bytes`).
21
- - `utBool`, `utUint8`, `utUint16`, `utUint32`, `utUint64`: Each structure contains two usertext (`ctBool`, `ctUint8`, etc.) for user and regular data.
22
-
23
- ## Enums
24
- - `MPC_TYPE`: Enum to represent different MPC data types (`SBOOL_T`, `SUINT8_T`, `SUINT16_T`, `SUINT32_T`, `SUINT64_T`).
25
- - `ARGS`: Enum to represent different argument types (`BOTH_SECRET`, `LHS_PUBLIC`, `RHS_PUBLIC`).
26
-
27
- ## Functions
28
- ### Enum Combination Functions
29
- These functions combine enum values into bytes for efficient storage and transfer:
30
- - `combineEnumsToBytes2(MPC_TYPE mpcType, ARGS argsType)`: Combines an `MPC_TYPE` and `ARGS` into a `bytes2` value.
31
- - `combineEnumsToBytes3(MPC_TYPE mpcType1, MPC_TYPE mpcType2, ARGS argsType)`: Combines two `MPC_TYPE` values and an `ARGS` value into a `bytes3` value.
32
- - `combineEnumsToBytes4(MPC_TYPE mpcType1, MPC_TYPE mpcType2, MPC_TYPE mpcType3, ARGS argsType)`: Combines three `MPC_TYPE` values and an `ARGS` value into a `bytes4` value.
33
-
34
- ### Key Management Functions
35
- - `getUserKey(bytes calldata signedEK, bytes calldata signature)`: Retrieves the user's AES encryption key in encrypted format, by using the provided public key to encrypt it - signature is used to validate the account ownership.
36
-
37
- This library is designed to be used as part of a secure multi-party computation framework, facilitating the handling and combination of encrypted and signed data types.
38
-
39
- # MpcInterface.sol
40
-
41
- This Solidity interface, `ExtendedOperations`, defines a set of functions for performing various operations that are essential for secure multi-party computation (MPC) on the COTI network. Below is an overview of its components and functions:
42
-
43
- ## Functions
44
-
45
- ### Onboarding and Offboarding Functions
46
- - `OnBoard(bytes1 metaData, uint256 ct)`: Onboards a new EOA. Metadata is used to define what is the data type being used (8 , 16, 32 , 64). This function is not directly called by others in MpcCore.
47
- - `OffBoard(bytes1 metaData, uint256 ct)`: Offboards an EOA. Metadata is used to define what is the data type being used (8 , 16, 32 , 64). This function is not directly called by others in MpcCore.
48
- - `OffBoardToUser(bytes1 metaData, uint256 ct, bytes calldata addr)`: Offboards an EOA to a user-specified address. Metadata is used to define what is the data type being used (8 , 16, 32 , 64). This function is not directly called by others in MpcCore.
49
- - `SetPublic(bytes1 metaData, uint256 ct)`: Sets the data as public with the given metadata and ciphertext.
50
-
51
- ### Randomness Functions
52
- - `Rand(bytes1 metaData)`: Generates a random value with the given metadata.
53
- - `RandBoundedBits(bytes1 metaData, uint8 numBits)`: Generates a random value with a specified number of bits.
54
-
55
- ### Arithmetic Functions
56
- - `Add(bytes3 metaData, uint256 lhs, uint256 rhs)`: Adds two values.
57
- - `Sub(bytes3 metaData, uint256 lhs, uint256 rhs)`: Subtracts the second value from the first.
58
- - `Mul(bytes3 metaData, uint256 lhs, uint256 rhs)`: Multiplies two values.
59
- - `Div(bytes3 metaData, uint256 lhs, uint256 rhs)`: Divides the first value by the second.
60
- - `Rem(bytes3 metaData, uint256 lhs, uint256 rhs)`: Computes the remainder of the division of two values.
61
-
62
- ### Bitwise Functions
63
- - `And(bytes3 metaData, uint256 lhs, uint256 rhs)`: Performs a bitwise AND operation.
64
- - `Or(bytes3 metaData, uint256 lhs, uint256 rhs)`: Performs a bitwise OR operation.
65
- - `Xor(bytes3 metaData, uint256 lhs, uint256 rhs)`: Performs a bitwise XOR operation.
66
- - `Shl(bytes3 metaData, uint256 lhs, uint256 rhs)`: Performs a bitwise shift left operation.
67
- - `Shr(bytes3 metaData, uint256 lhs, uint256 rhs)`: Performs a bitwise shift right operation.
68
-
69
- ### Comparison Functions
70
- - `Eq(bytes3 metaData, uint256 lhs, uint256 rhs)`: Checks if two values are equal.
71
- - `Ne(bytes3 metaData, uint256 lhs, uint256 rhs)`: Checks if two values are not equal.
72
- - `Ge(bytes3 metaData, uint256 lhs, uint256 rhs)`: Checks if the first value is greater than or equal to the second.
73
- - `Gt(bytes3 metaData, uint256 lhs, uint256 rhs)`: Checks if the first value is greater than the second.
74
- - `Le(bytes3 metaData, uint256 lhs, uint256 rhs)`: Checks if the first value is less than or equal to the second.
75
- - `Lt(bytes3 metaData, uint256 lhs, uint256 rhs)`: Checks if the first value is less than the second.
76
-
77
- ### Validation and Transfer Functions
78
- - `ValidateCiphertext(bytes calldata ciphertext, bytes calldata signature)`: Validates the given ciphertext and signature.
79
- - If the input is not valid, the call will revert with no return data and no additional gas will be consumed.
80
- - `TransferWithAllowance(address from, address to, uint256 amount, bytes calldata signature)`: Transfers the specified amount from one address to another with the provided signature.
81
-
82
- This interface is designed to be implemented by a contract that performs secure multi-party computation, providing essential operations such as arithmetic, bitwise, and comparison functions, as well as onboarding and offboarding participants or data.