githubEdit

MPC Core

The MPC Corearrow-up-right 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 itString

Garbledtext

Ciphertext

Usertext

Functions

circle-info

Since private data types mostly support the same functions, we have chosen to list only the functions pertaining to the itUint64, gtUint64 and ctUint64 types. See MpcCore.solarrow-up-right for the full list of supported 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 balance b) as a result of transferring amount from the account with balance a to the account with balance b, along with an encrypted boolean value indicating whether the transfer would succeed.

  • If a is less than amount, then the resulting values of a and b will remain unchanged.

  • Returns the encrypted balances of two accounts (one starting with balance a, the other starting with balance b) as a result of transferring amount with allowance allowance from the account with balance a to the account with balance b, along with an encrypted boolean value indicating whether the transfer would succeed.

  • If a is less than amount or if amount is greater than allowance, then the resulting values of a and b will remain unchanged.

Arithmetic Functions

  • Returns an encrypted value (either a or b) based on the encrypted boolean input

  • If bit is false, then the returned value is equal to a

  • If bit is true, then the returned value is equal to b

Enums

  • Represent different MPC data types

  • Represent different argument types

Encoding Functions

  • Combines an MPC_TYPE and ARGS into a bytes2 value.

  • Combines two MPC_TYPE values and an ARGS value into a bytes3 value.

  • Combines three MPC_TYPE values and an ARGS value into a bytes4 value.

  • Combines four MPC_TYPE values and an ARGS value into a bytes4 value.

Last updated

Was this helpful?