MPC Core
The MPC Core is a library that simplifies interactions with the precompiled contracts which provide core functionalities for secure multi-party computation (MPC) using the COTI protocol.
Usage
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "@coti-io/coti-contracts/contracts/utils/mpc/MpcCore.sol";
contract MyContract { ... }Types
Inputtext
struct itBool
struct itUint8
struct itUint16
struct itUint32
struct itUint64
struct itStringGarbledtext
Ciphertext
Usertext
Functions
Special Functions
Retrieves the user's AES encryption key in encrypted format, by using the provided RSA public key to encrypt it.
A valid signature using the EOA private key is used to validate the account ownership.
Verifies that a given inputtext has a valid signature and onboards it into the gcEVM, returning a Garbledtext™ value.
If the input is not valid, the call will revert with no return data and no additional gas will be consumed.
The function onboards a given Ciphertext to the gcEVM, resulting in a Garbledtext™ value.
Must be invoked with ciphertext encrypted by the system AES key, such as ciphertexts that are generated by calling
offboard.
The function offboards the given Garbledtext™ from the gcEVM, resulting in a Ciphertext.
The offboarding process uses the network AES key to encrypt the value inside the Garbledtext™.
The function offboards the given Garbledtext™ from the gcEVM, resulting in a Ciphertext.
The offboarding process uses the user AES key associated with the given address to encrypt the value inside the Garbledtext™.
The function offboards the given Garbledtext™ from the gcEVM, resulting in a struct containing two Ciphertexts.
The offboarding process uses both the network AES key and the user AES key associated with the given address to encrypt the value inside the Garbledtext™.
Returns the clear value of the given Ciphertext.
Onboards the given clear input to the gcEVM, resulting in a Garbledtext™.
Generates an encrypted random value in Garbledtext™ form.
Generates an encrypted random value that falls within the range of [0, 2^numBits] in Garbledtext™ form.
Returns the encrypted balances of two accounts (one starting with balance
a, the other starting with balanceb) as a result of transferringamountfrom the account with balanceato the account with balanceb, along with an encrypted boolean value indicating whether the transfer would succeed.If
ais less thanamount, then the resulting values ofaandbwill remain unchanged.
Returns the encrypted balances of two accounts (one starting with balance
a, the other starting with balanceb) as a result of transferringamountwith allowanceallowancefrom the account with balanceato the account with balanceb, along with an encrypted boolean value indicating whether the transfer would succeed.If
ais less thanamountor ifamountis greater thanallowance, then the resulting values ofaandbwill remain unchanged.
Arithmetic Functions
Returns an encrypted value (either
aorb) based on the encrypted boolean inputIf
bitis false, then the returned value is equal toaIf
bitis true, then the returned value is equal tob
Enums
Represent different MPC data types
Represent different argument types
Encoding Functions
Combines an
MPC_TYPEandARGSinto abytes2value.
Combines two
MPC_TYPEvalues and anARGSvalue into abytes3value.
Combines three
MPC_TYPEvalues and anARGSvalue into abytes4value.
Combines four
MPC_TYPEvalues and anARGSvalue into abytes4value.
Last updated
Was this helpful?