fhEVM
WebsiteLibrariesProduct & ServicesDevelopersSupport
0.1
0.1
  • What is Zama's fhEVM?
  • Getting started
    • Connect wallet
      • Metamask
    • Faucet
      • Zama Devnet
      • Local node
  • Writing contract
    • Getting started
      • Hardhat
      • Remix
      • Docker
    • TFHE Library
    • Function specifications
    • Decryption and control structures
    • Examples
  • Client
    • Getting started
      • Node
      • Browser
      • Template
      • CLI
    • Setup an instance
    • Inputs
    • Reencryption
    • Examples
      • Transfer tokens (node)
      • Get balance (node)
  • Resources
    • Tutorials
    • Repositories
    • Whitepaper
Powered by GitBook

Libraries

  • TFHE-rs
  • Concrete
  • Concrete ML
  • fhEVM

Developers

  • Blog
  • Documentation
  • Github
  • FHE resources

Company

  • About
  • Introduction to FHE
  • Media
  • Careers
On this page
  • Types
  • Operations

Was this helpful?

Export as PDF
  1. Writing contract

TFHE Library

PreviousDockerNextFunction specifications

Last updated 1 year ago

Was this helpful?

The library exposes utility functions for TFHE operations. The goal of the library is to provide a seamless developer experience for writing smart contracts that can operate on confidential data.

Types

The library provides a type system that is checked both at compile time and at run time. The structure and operations related to these types are described in this sections.

We currently support encrypted integers of bit length up to 32 bits.

Our library provides the following types :

  • ebool

  • euint8

  • euint16

  • euint32

These encrypted integers behave as much as possible as Solidity's integer types. However, behaviour such as "revert on overflow" is not supported as this would leak some information of the encrypted integers. Therefore, arithmetic on euint types is , i.e. there is wrap-around on overlow.

In the back-end, encrypted integers are TFHE ciphertexts. The library abstracts away the ciphertexts and presents pointers to ciphertexts, or ciphertext handles, to the smart contract developer. The euint types are wrappers over these handles.

Operations

The library exposes utility functions for operations on TFHE ciphertexts. The list of supported operations is presented below.

name
function name
type

Add

TFHE.add

Binary

Sub

TFHE.sub

Binary

Mul

TFHE.mul

Binary

BitAnd

TFHE.and

Binary

BitOr

TFHE.or

Binary

BitXor

TFHE.xor

Binary

Shift Right

TFHE.shr

Binary

Shift Left

TFHE.shl

Binary

Equal

TFHE.eq

Binary

Not equal

TFHE.ne

Binary

Greater than or equal

TFHE.ge

Binary

Greater than

TFHE.gt

Binary

Less than or equal

TFHE.le

Binary

Less than

TFHE.lt

Binary

Min

TFHE.min

Binary

Max

TFHE.max

Binary

Neg

TFHE.neg

Unary

Not

TFHE.not

Unary

Cmux

TFHE.cmux

Ternary

More information about the supported operations can be found at the .

unchecked
TFHE-rs docs