Secure Operations and Gas

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

To bring a new private data into the gvEVM the function's signature should include an argument of type Inputtext. Then, inside the function, it is necessary to call ValidateCiphertext, which returns a Garbledtext if verification succeeds and an error otherwise. Then, the contract is free to save private data temporarily in Memory, by calling Offboard on the relevant Garbledtext.This returns a private data of type Ciphertext that awaits other commands, namely, the Ciphertext type cannot serve as an operand to secure operations, rather it should be Onboarded again and turn into a Garbledtext first; alternatively, the Ciphertext may be stored permanently by simply assigning it to a state variable of the contract.

List of Operations and Their Required Gas

List of operations supported on Garbledtextand their required gas prices

Operation
Bool
gtUint8
gtUint16
gtUint32
gtUint64

And

12005

12040

12080

12160

12320

Or

12005

12042

12084

12169

12339

Xor

12000

12000

12001

12003

12006

Add

12037

12080

12167

12340

Sub

12080

12165

12337

12679

Mul

12620

14571

22467

54233

Div

12969

15960

28009

76377

Rem

12969

15960

28009

76377

Min

12010

12121

12249

12503

13012

Max

12010

12121

12249

12503

13012

Lt

12005

12080

12166

12337

12679

Gt

12010

12121

12249

12503

13012

Ge

12005

12080

12165

12337

12679

Le

12010

12122

12249

12503

13012

Eq

12000

12037

12079

12164

12334

Ne

12000

12037

12079

12164

12334

Shl

12620

14571

22467

54233

Shr

12969

15960

28009

76377

Not

12000

Other Special Function and Their Required Gas

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

🤩Special Functions

Operation
gtBool
gtUint8
gtUint16
gtUint32
gtUint64

SetPublic

12000

12000

12001

12003

12006

Decrypt

12000

12000

12001

12003

12006

Onboard

47039

47039

47039

47039

47039

47039

47039

47039

47039

47039

Offboard

47039

47040

47040

47042

47045

OffboardToUser

47039

47040

47040

47042

47045

Rand

6000

6000

6000

6000

6000

RandBoundedBits

6000

6000

6000

6000

6000

Mux

12005

12041

12083

12166

12332

Transfer

12201

12413

12837

13685

TransferWithAllowance

12301

12619

13255

14527

The operation GetUserKey that generates an aes key for the user has a gas cost of 47039

Last updated