fhEVM
WebsiteLibrariesProduct & ServicesDevelopersSupport
0.5
0.5
  • Welcome to fhEVM
  • Getting Started
    • What is fhEVM
    • Deploy on fhEVM native
      • Using Zama Faucet
      • Local dev node
    • Deploy on Ethereum
    • Whitepaper
  • Fundamentals
    • Write contract
      • Using Hardhat
      • Using Remix
      • Other development environment
    • Encrypted types
      • Operations on encrypted types
      • Branching in FHE
      • Generate random number
    • Encrypted inputs
    • Access Control List
    • Decrypt and reencrypt
    • Contracts standard library
  • Guides
    • Decryption
    • Reencryption
    • Build a web application
    • Build with Node
    • Common pitfalls and best practises
    • How can I break a loop ?
    • Gas estimation on devnet
    • Use the CLI
    • Common webpack errors
  • Tutorials
    • See all tutorials
    • Write confidential smart contract with fhEVM
  • References
    • API function specifications
    • fhevmjs function specifications
    • Repositories
  • Developer
    • Contributing
    • Development roadmap
    • Release note
    • Feature request
    • Bug report
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

Was this helpful?

Export as PDF
  1. Fundamentals
  2. Encrypted types

Operations on encrypted types

The TFHE library defines the following operations with FHE ciphertexts:

name
function name
symbol
type

Add

TFHE.add

+

Binary

Sub

TFHE.sub

-

Binary

Mul

TFHE.mul

*

Binary

Div (plaintext divisor)

TFHE.div

Binary

Rem (plaintext divisor)

TFHE.rem

Binary

BitAnd

TFHE.and

&

Binary

BitOr

TFHE.or

|

Binary

BitXor

TFHE.xor

^

Binary

Shift Right

TFHE.shr

Binary

Shift Left

TFHE.shl

Binary

Rotate Right

TFHE.rotr

Binary

Rotate Left

TFHE.rotl

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

Select

TFHE.select

Ternary

Random unsigned int

TFHE.randEuintX()

Random

NOTE: The shift operators TFHE.shr and TFHE.shl can take any encrypted type euintX as a first operand and either a uint8or a euint8 as a second operand, however the second operand will always be computed modulo the number of bits of the first operand. For example, TFHE.shr(euint64 x, 70) will actually be equal to TFHE.shr(euint64 x, 6) because 70 % 64 = 6. This is in contrast to the classical shift operators in Solidity where there is no intermediate modulo operation, so for instance any uint64 shifted right via >> would give a null result.

Zama 5-Question Developer Survey

PreviousEncrypted typesNextBranching in FHE

Last updated 8 months ago

Was this helpful?

Overloaded operators +, -, *, &, ... on encrypted integers are supported (). As of now, overloaded operators will call the versions without an overflow check.

More information about the supported operations can be found in the page or in the .

If you find yourself in search of a missing feature, we encourage you to for upcoming developments. Alternatively, don't hesitate to reach out to us on Discord or visit our community forum.

We want to hear from you! Take 1 minute to share your thoughts and helping us enhance our documentation and libraries. 👉 to participate.

using for
function specifications
TFHE-rs docs
consult our roadmap
Click here