COTI V2 Documentation
  • Welcome
  • Networks
    • Faucet
    • Contracts Addresses
    • Adding the COTI Network to Metamask
  • How COTI Works
    • Introduction
      • EVM Introduction
      • Conceptual Overview
      • Use Cases and Applications
      • COTI Architecture
    • Advanced Topics
      • Garbled Circuits
      • AES Keys
      • Precompiles
      • Whitepaper
      • COTI vs others
  • Build on COTI
    • Core Concepts
      • Account Onboarding Procedure
      • Private Data Types
      • Supported Operations on Private Data Types
    • Quickstart
    • Guides
      • Basic Private Smart Contract
      • Account Onboard
      • Sending a Transaction with Encrypted Inputs
      • Resolving a Transaction's Encrypted Outputs
      • Writing a Private Smart Contract
      • Dos and Don'ts
        • Proper Use of Types
        • No Constant/Immutable Secret Types
        • No Public Contract Variables
      • Best Practices
        • Careful Onboarding
        • Careful Decrypting
        • Don't loop over an array without an index
        • Check Overflow
    • Tools
      • TypeScript SDK
      • Ethers.js
      • Python SDK
      • Web3.py
      • Contracts Library
        • MPC Core
        • Data Privacy Framework
        • Tokens
          • Private ERC20
          • Private ERC721
        • Onboard
      • Hardhat
      • Remix Plugin
      • COTI MetaMask Snap
      • Developer Sandbox
  • Running a COTI Node
    • COTI Node Ecosystem Litepaper
  • COTI Bridge
    • Swap COTI V1 Funds to COTI V2
  • Support and Community
    • Glossary
    • Telegram
    • Discord
    • GitHub
    • X
    • YouTube
  • COTI Builders Program
Powered by GitBook
On this page
  • List of Operations and Their Required Gas
  • Other Special Function and Their Required Gas units

Was this helpful?

Edit on GitHub
  1. Build on COTI
  2. Core Concepts

Supported Operations on Private Data Types

Secure operations are supported via our gcEVM extension, which is implemented through a set of precompiled contracts.

To introduce a new private datum into the gcEVM, the function should include an argument of type Inputtext. Inside the function, you must call ValidateCiphertext, which validates the input and returns a Garbledtext if successful or an error otherwise. Note that values of type Garbledtext can be used in secure computations, and can also be converted into a Ciphertext type by calling Offboard. Values of type Ciphertext can be stored temporarily in memory or permanently as a state variable. Note that values of type Ciphertext cannot be used for secure computations, and therefore must be converted back into a Garbledtext type by calling Onboard in order to perform additional secure computations on them.

List of Operations and Their Required Gas

Each operation within the network requires a specific amount of gas. It's important to note that the following gas allocations are intended to be proportional and serve as initial estimates. The final determination of gas requirements will be made at a later stage, taking into account various factors such as network performance, usage patterns, and protocol optimizations.

List of arithmetic operations supported using Garbledtext and their required Gas units

Operation
Bool
gtUint8
gtUint16
gtUint32
gtUint64
gtUint128
gtUint256
gtString**

And

12005

12040

12080

12160

12320

26126

52742

Or

12005

12042

12084

12169

12339

26164

52818

Xor

12000

12000

12001

12003

12006

25498

51486

Shl

12620

14571

22467

54233

226190

698489

Shr

12969

15960

28009

76377

248333

698498

Add

12037

12080

12167

12340

65491

275564

CheckedAdd

26252

26318

26407

26577

115473

375554

CheckedAddWithOverflowBit

12738

12781

12857

13041

103457

389274

Sub

12080

12165

12337

12679

66518

278659

CheckedSub

26341

26403

26576

26917

142480

522302

CheckedSubWithOverflowBit

12781

12866

13038

13380

104484

392369

Mul

12620

14571

22467

54233

2702996

37473014

CheckedMul

26859

28754

36684

68536

3722546

50361135

CheckedMulWithOverflowBit

13321

15272

23168

54934

3673338

50272807

Div

12969

15960

28009

76377

Rem

12969

15960

28009

76377

Min

12010

12121

12249

12503

13012

118320

302289

Max

12010

12121

12249

12503

13012

118986

303621

Lt

12005

12080

12166

12337

12679

52366

156113

Gt

12010

12121

12249

12503

13012

53032

157445

Ge

12005

12080

12165

12337

12679

52699

157101

Le

12010

12122

12249

12503

13012

52688

156446

Eq

12000

12037

12079

12164

12334

38650

89992

12334

Ne

12000

12037

12079

12164

12334

38650

89992

12334

Not

12000

** Note that the gas units listed for the gtString type are for every 8 characters in the string. This is due to the way encrypted strings are represented in memory/storage.

Other Special Function and Their Required Gas units

Operation
gtBool
gtUint8
gtUint16
gtUint32
gtUint64
gtUint128
gtUint256
gtString**

SetPublic

12000

12000

12001

12003

12006

25064

50591

12006

Decrypt

12000

12000

12001

12003

12006

24969

50038

12006

Onboard

47039

47039

47039

47039

47039

99442

199389

47039

ValidateCiphertext

47039

47039

47039

47039

47039

97624

196779

47039

Offboard

47039

47040

47040

47042

47045

95207

190885

47045

OffboardToUser

47039

47040

47040

47042

47045

95818

192112

47045

OffBoardCombined

94078

94080

94080

94084

94090

191485

384025

94090

Rand

6000

6000

6000

6000

6000

12940

26319

RandBoundedBits

6000

6000

6000

6000

6000

13191

26858

Mux

12005

12041

12083

12166

12332

26200

50038

Transfer

12201

12413

12837

13685

237367

817758

TransferWithAllowance

12301

12619

13255

14527

395565

1318764

** Note that the gas units listed for the gtString type are for every 8 characters in the string. This is due to the way encrypted strings are represented in memory/storage.

PreviousPrivate Data TypesNextQuickstart

Last updated 19 days ago

Was this helpful?

A more detailed explanation on the functionality of these functions can be found in the .

MPC Core library