@coti-io/coti-contracts 0.1.0
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/.github/workflows/npm-publish.yml +52 -0
- package/CODE_OF_CONDUCT.md +44 -0
- package/CONTRIBUTING.md +101 -0
- package/LICENSE +201 -0
- package/README.md +48 -0
- package/contracts/access/DataPrivacyFramework/DataPrivacyFramework.sol +480 -0
- package/contracts/access/DataPrivacyFramework/README.md +68 -0
- package/contracts/access/DataPrivacyFramework/extensions/DataPrivacyFrameworkMpc.sol +1139 -0
- package/contracts/mocks/README.md +5 -0
- package/contracts/mocks/access/DataPrivacyFramework/DataPrivacyFrameworkMock.sol +9 -0
- package/contracts/mocks/token/PrivateERC20/PrivateERC20Mock.sol +17 -0
- package/contracts/mocks/token/PrivateERC721/PrivateERC721URIStorageMock.sol +34 -0
- package/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol +431 -0
- package/contracts/mocks/utils/mpc/BitwiseTestsContract.sol +361 -0
- package/contracts/mocks/utils/mpc/Comparison1Tests.Contract.sol +307 -0
- package/contracts/mocks/utils/mpc/Comparison2TestsContract.sol +307 -0
- package/contracts/mocks/utils/mpc/MinMaxTestsContract.sol +297 -0
- package/contracts/mocks/utils/mpc/Miscellaneous1TestsContract.sol +185 -0
- package/contracts/mocks/utils/mpc/Miscellaneous2TestsContract.sol +448 -0
- package/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol +81 -0
- package/contracts/mocks/utils/mpc/README.md +486 -0
- package/contracts/mocks/utils/mpc/ShiftTestsContract.sol +311 -0
- package/contracts/mocks/utils/mpc/StringTestsContract.sol +59 -0
- package/contracts/mocks/utils/mpc/TransferScalarTestsContract.sol +271 -0
- package/contracts/mocks/utils/mpc/TransferTestsContract.sol +715 -0
- package/contracts/mocks/wallet/PrivateERC20Wallet/PrivateERC20WalletMock.sol +25 -0
- package/contracts/onboard/AccountOnboard.sol +21 -0
- package/contracts/onboard/README.md +65 -0
- package/contracts/package.json +11 -0
- package/contracts/token/PrivateERC20/IPrivateERC20.sol +142 -0
- package/contracts/token/PrivateERC20/PrivateERC20.sol +478 -0
- package/contracts/token/PrivateERC20/README.md +104 -0
- package/contracts/token/PrivateERC721/PrivateERC721.sol +458 -0
- package/contracts/token/PrivateERC721/README.md +282 -0
- package/contracts/token/PrivateERC721/extensions/PrivateERC721URIStorage.sol +87 -0
- package/contracts/utils/mpc/MpcCore.sol +3215 -0
- package/contracts/utils/mpc/MpcInterface.sol +41 -0
- package/contracts/utils/mpc/README.md +82 -0
- package/hardhat.config.ts +18 -0
- package/package.json +14 -0
- package/test/access/DataPrivacyFramework/DataPrivacyFramework.test.ts +780 -0
- package/test/onboard/AccountOnboard.test.ts +45 -0
- package/test/token/PrivateERC20/PrivateERC20.test.ts +546 -0
- package/test/token/PrivateERC721/PrivateERC721.test.ts +223 -0
- package/test/utils/accounts.ts +55 -0
- package/test/utils/mpc/Precompile.test.ts +113 -0
- package/test/utils/mpc/String.test.ts +227 -0
- package/tsconfig.json +11 -0
- package/typechain-types/@openzeppelin/contracts/index.ts +9 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/IERC4906.ts +462 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/index.ts +6 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721.ts +393 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721Receiver.ts +110 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/token/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/utils/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/ERC165.ts +94 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/IERC165.ts +94 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
- package/typechain-types/@openzeppelin/index.ts +5 -0
- package/typechain-types/common.ts +131 -0
- package/typechain-types/contracts/access/DataPrivacyFramework/DataPrivacyFramework.ts +598 -0
- package/typechain-types/contracts/access/DataPrivacyFramework/extensions/DataPrivacyFrameworkMpc.ts +598 -0
- package/typechain-types/contracts/access/DataPrivacyFramework/extensions/index.ts +4 -0
- package/typechain-types/contracts/access/DataPrivacyFramework/index.ts +6 -0
- package/typechain-types/contracts/access/index.ts +5 -0
- package/typechain-types/contracts/index.ts +13 -0
- package/typechain-types/contracts/mocks/access/DataPrivacyFramework/DataPrivacyFrameworkMock.ts +598 -0
- package/typechain-types/contracts/mocks/access/DataPrivacyFramework/index.ts +4 -0
- package/typechain-types/contracts/mocks/access/index.ts +5 -0
- package/typechain-types/contracts/mocks/index.ts +11 -0
- package/typechain-types/contracts/mocks/token/PrivateERC20/PrivateERC20Mock.ts +543 -0
- package/typechain-types/contracts/mocks/token/PrivateERC20/index.ts +4 -0
- package/typechain-types/contracts/mocks/token/PrivateERC721/PrivateERC721URIStorageMock.ts +576 -0
- package/typechain-types/contracts/mocks/token/PrivateERC721/index.ts +4 -0
- package/typechain-types/contracts/mocks/token/index.ts +7 -0
- package/typechain-types/contracts/mocks/utils/index.ts +5 -0
- package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.ts +354 -0
- package/typechain-types/contracts/mocks/utils/mpc/BitwiseTestsContract.ts +340 -0
- package/typechain-types/contracts/mocks/utils/mpc/Comparison1Tests.Contract.sol/Comparison1TestsContract.ts +340 -0
- package/typechain-types/contracts/mocks/utils/mpc/Comparison1Tests.Contract.sol/index.ts +4 -0
- package/typechain-types/contracts/mocks/utils/mpc/Comparison2TestsContract.ts +340 -0
- package/typechain-types/contracts/mocks/utils/mpc/MinMaxTestsContract.ts +321 -0
- package/typechain-types/contracts/mocks/utils/mpc/Miscellaneous1TestsContract.ts +199 -0
- package/typechain-types/contracts/mocks/utils/mpc/Miscellaneous2TestsContract.ts +384 -0
- package/typechain-types/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/OffboardToUserKeyTestContract.ts +218 -0
- package/typechain-types/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/index.ts +4 -0
- package/typechain-types/contracts/mocks/utils/mpc/ShiftTestsContract.ts +339 -0
- package/typechain-types/contracts/mocks/utils/mpc/StringTestsContract.ts +211 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferScalarTestsContract.ts +266 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferTestsContract.ts +288 -0
- package/typechain-types/contracts/mocks/utils/mpc/index.ts +17 -0
- package/typechain-types/contracts/mocks/wallet/PrivateERC20Wallet/PrivateERC20WalletMock.ts +173 -0
- package/typechain-types/contracts/mocks/wallet/PrivateERC20Wallet/index.ts +4 -0
- package/typechain-types/contracts/mocks/wallet/index.ts +5 -0
- package/typechain-types/contracts/onboard/AccountOnboard.ts +135 -0
- package/typechain-types/contracts/onboard/index.ts +4 -0
- package/typechain-types/contracts/token/PrivateERC20/IPrivateERC20.ts +437 -0
- package/typechain-types/contracts/token/PrivateERC20/PrivateERC20.ts +505 -0
- package/typechain-types/contracts/token/PrivateERC20/index.ts +5 -0
- package/typechain-types/contracts/token/PrivateERC721/PrivateERC721.ts +409 -0
- package/typechain-types/contracts/token/PrivateERC721/extensions/PrivateERC721URIStorage.ts +501 -0
- package/typechain-types/contracts/token/PrivateERC721/extensions/index.ts +4 -0
- package/typechain-types/contracts/token/PrivateERC721/index.ts +6 -0
- package/typechain-types/contracts/token/index.ts +7 -0
- package/typechain-types/contracts/utils/index.ts +5 -0
- package/typechain-types/contracts/utils/mpc/MpcInterface.sol/ExtendedOperations.ts +698 -0
- package/typechain-types/contracts/utils/mpc/MpcInterface.sol/index.ts +4 -0
- package/typechain-types/contracts/utils/mpc/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/index.ts +6 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC4906__factory.ts +339 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors__factory.ts +127 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors__factory.ts +111 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors__factory.ts +128 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721Receiver__factory.ts +59 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721__factory.ts +307 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/ERC165__factory.ts +41 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/IERC165__factory.ts +41 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/index.ts +4 -0
- package/typechain-types/factories/contracts/access/DataPrivacyFramework/DataPrivacyFramework__factory.ts +621 -0
- package/typechain-types/factories/contracts/access/DataPrivacyFramework/extensions/DataPrivacyFrameworkMpc__factory.ts +621 -0
- package/typechain-types/factories/contracts/access/DataPrivacyFramework/extensions/index.ts +4 -0
- package/typechain-types/factories/contracts/access/DataPrivacyFramework/index.ts +5 -0
- package/typechain-types/factories/contracts/access/index.ts +4 -0
- package/typechain-types/factories/contracts/index.ts +8 -0
- package/typechain-types/factories/contracts/mocks/access/DataPrivacyFramework/DataPrivacyFrameworkMock__factory.ts +670 -0
- package/typechain-types/factories/contracts/mocks/access/DataPrivacyFramework/index.ts +4 -0
- package/typechain-types/factories/contracts/mocks/access/index.ts +4 -0
- package/typechain-types/factories/contracts/mocks/index.ts +7 -0
- package/typechain-types/factories/contracts/mocks/token/PrivateERC20/PrivateERC20Mock__factory.ts +615 -0
- package/typechain-types/factories/contracts/mocks/token/PrivateERC20/index.ts +4 -0
- package/typechain-types/factories/contracts/mocks/token/PrivateERC721/PrivateERC721URIStorageMock__factory.ts +630 -0
- package/typechain-types/factories/contracts/mocks/token/PrivateERC721/index.ts +4 -0
- package/typechain-types/factories/contracts/mocks/token/index.ts +5 -0
- package/typechain-types/factories/contracts/mocks/utils/index.ts +4 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract__factory.ts +374 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/BitwiseTestsContract__factory.ts +361 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison1Tests.Contract.sol/Comparison1TestsContract__factory.ts +361 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison1Tests.Contract.sol/index.ts +4 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison2TestsContract__factory.ts +361 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/MinMaxTestsContract__factory.ts +337 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/Miscellaneous1TestsContract__factory.ts +236 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/Miscellaneous2TestsContract__factory.ts +432 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/OffboardToUserKeyTestContract__factory.ts +245 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/index.ts +4 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/ShiftTestsContract__factory.ts +374 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/StringTestsContract__factory.ts +264 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferScalarTestsContract__factory.ts +360 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferTestsContract__factory.ts +441 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/index.ts +15 -0
- package/typechain-types/factories/contracts/mocks/wallet/PrivateERC20Wallet/PrivateERC20WalletMock__factory.ts +194 -0
- package/typechain-types/factories/contracts/mocks/wallet/PrivateERC20Wallet/index.ts +4 -0
- package/typechain-types/factories/contracts/mocks/wallet/index.ts +4 -0
- package/typechain-types/factories/contracts/onboard/AccountOnboard__factory.ts +104 -0
- package/typechain-types/factories/contracts/onboard/index.ts +4 -0
- package/typechain-types/factories/contracts/token/PrivateERC20/IPrivateERC20__factory.ts +406 -0
- package/typechain-types/factories/contracts/token/PrivateERC20/PrivateERC20__factory.ts +532 -0
- package/typechain-types/factories/contracts/token/PrivateERC20/index.ts +5 -0
- package/typechain-types/factories/contracts/token/PrivateERC721/PrivateERC721__factory.ts +439 -0
- package/typechain-types/factories/contracts/token/PrivateERC721/extensions/PrivateERC721URIStorage__factory.ts +512 -0
- package/typechain-types/factories/contracts/token/PrivateERC721/extensions/index.ts +4 -0
- package/typechain-types/factories/contracts/token/PrivateERC721/index.ts +5 -0
- package/typechain-types/factories/contracts/token/index.ts +5 -0
- package/typechain-types/factories/contracts/utils/index.ts +4 -0
- package/typechain-types/factories/contracts/utils/mpc/MpcInterface.sol/ExtendedOperations__factory.ts +919 -0
- package/typechain-types/factories/contracts/utils/mpc/MpcInterface.sol/index.ts +4 -0
- package/typechain-types/factories/contracts/utils/mpc/index.ts +4 -0
- package/typechain-types/factories/index.ts +5 -0
- package/typechain-types/hardhat.d.ts +621 -0
- package/typechain-types/index.ts +72 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.19;
|
|
4
|
+
|
|
5
|
+
interface ExtendedOperations {
|
|
6
|
+
|
|
7
|
+
function OnBoard(bytes1 metaData, uint256 ct) external returns (uint256 result);
|
|
8
|
+
function OffBoard(bytes1 metaData, uint256 ct) external returns (uint256 result);
|
|
9
|
+
function OffBoardToUser(bytes1 metaData, uint256 ct, bytes calldata addr) external returns (uint256 result);
|
|
10
|
+
function SetPublic(bytes1 metaData, uint256 ct) external returns (uint256 result);
|
|
11
|
+
function Rand(bytes1 metaData) external returns (uint256 result);
|
|
12
|
+
function RandBoundedBits(bytes1 metaData, uint8 numBits) external returns (uint256 result);
|
|
13
|
+
|
|
14
|
+
function Add(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
15
|
+
function Sub(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
16
|
+
function Mul(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
17
|
+
function Div(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
18
|
+
function Rem(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
19
|
+
function And(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
20
|
+
function Or(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
21
|
+
function Xor(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
22
|
+
function Shl(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
23
|
+
function Shr(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
24
|
+
function Eq(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
25
|
+
function Ne(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
26
|
+
function Ge(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
27
|
+
function Gt(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
28
|
+
function Le(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
29
|
+
function Lt(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
30
|
+
function Min(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
31
|
+
function Max(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
|
|
32
|
+
function Decrypt(bytes1 metaData, uint256 a) external returns (uint256 result);
|
|
33
|
+
function Mux(bytes3 metaData, uint256 bit, uint256 a,uint256 b) external returns (uint256 result);
|
|
34
|
+
function Not(bytes1 metaData, uint256 a) external returns (uint256 result);
|
|
35
|
+
function Transfer(bytes4 metaData, uint256 a, uint256 b, uint256 amount) external returns (uint256 new_a, uint256 new_b, uint256 res);
|
|
36
|
+
function TransferWithAllowance(bytes4 metaData, uint256 a, uint256 b, uint256 amount, uint256 allowance) external returns (uint256 new_a, uint256 new_b, uint256 res, uint256 new_allowance);
|
|
37
|
+
function ValidateCiphertext(bytes1 metaData, uint256 ciphertext, bytes calldata signature) external returns (uint256 result);
|
|
38
|
+
function GetUserKey(bytes calldata signedEK) external view returns (bytes memory encryptedKey);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
address constant MPC_PRECOMPILE = address(0x0000000000000000000000000000000000000064);
|
|
@@ -0,0 +1,82 @@
|
|
|
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.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HardhatUserConfig } from "hardhat/config";
|
|
2
|
+
import "@nomicfoundation/hardhat-toolbox";
|
|
3
|
+
|
|
4
|
+
import dotenv from "dotenv"
|
|
5
|
+
dotenv.config()
|
|
6
|
+
|
|
7
|
+
const config: HardhatUserConfig = {
|
|
8
|
+
defaultNetwork: "devnet",
|
|
9
|
+
solidity: "0.8.20",
|
|
10
|
+
networks: {
|
|
11
|
+
devnet: {
|
|
12
|
+
url: "https://devnet.coti.io/rpc",
|
|
13
|
+
chainId: 13068200,
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default config;
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@coti-io/coti-contracts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"devDependencies": {
|
|
6
|
+
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
|
|
7
|
+
"hardhat": "^2.22.8"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@coti-io/coti-ethers": "^0.1.1-b",
|
|
11
|
+
"@openzeppelin/contracts": "^5.0.2",
|
|
12
|
+
"dotenv": "^16.4.5"
|
|
13
|
+
}
|
|
14
|
+
}
|