BenchmarksStack RankingH33 FHEH33 ZKAPIsPricingPQCTokenDocsWhite PaperBlogAboutSecurity Demo

TFHE: Fast Fully Homomorphic Encryption for Boolean Circuits

TFHE (Torus Fully Homomorphic Encryption) takes a different approach than BFV or CKKS. Instead of operating on large integers or real numbers, TFHE efficiently computes on individual bits. This makes it exceptionally fast for certain types of computation.

The Boolean Approach

Traditional FHE schemes batch many values and perform parallel operations. TFHE instead:

  • Encrypts individual bits
  • Evaluates logic gates (AND, OR, XOR, NOT)
  • Enables any computation expressible as a circuit
  • Achieves very fast gate evaluation

TFHE Gate Speed

A single TFHE gate evaluation takes approximately 10-20 milliseconds on CPU. With GPU acceleration, this drops to microseconds per gate.

How TFHE Works

TFHE uses Learning With Errors over the torus (continuous circle group). Key innovations:

  • Programmable bootstrapping: Refreshes ciphertext while computing a function
  • Efficient key switching: Fast conversion between encryption formats
  • Small keys: More practical key sizes than some alternatives

The programmable bootstrapping is particularly powerful—it simultaneously reduces noise and computes a lookup table function.

TFHE vs BFV/CKKS

Different strengths for different use cases:

  • TFHE: Best for comparisons, conditionals, non-polynomial functions
  • BFV: Best for batched integer arithmetic
  • CKKS: Best for approximate real number computation

TFHE excels when you need operations that are hard to express as polynomials—like comparisons and max/min functions.

Use Cases

Private Comparisons

Comparing encrypted values is natural in TFHE:

// Compare two encrypted 8-bit integers
encrypted_a_greater = compare(encrypted_a, encrypted_b);
// Returns encrypted bit: 1 if a > b, 0 otherwise

Conditional Logic

If-then-else on encrypted conditions:

// Encrypted multiplexer
result = mux(encrypted_condition, encrypted_if_true, encrypted_if_false);

Private Database Queries

TFHE enables encrypted SQL-like operations with range queries and comparisons.

Implementation Libraries

Several high-quality TFHE implementations exist:

  • TFHE-rs: Rust implementation with excellent documentation
  • Concrete: Zama's compiler for FHE programs
  • tfhe-lib: Original C++ implementation

Combining with Other Schemes

Advanced applications sometimes combine schemes:

  • CKKS for neural network layers
  • TFHE for comparison operations
  • Scheme switching between them

This hybrid approach gets the best of each scheme's strengths.

Performance Optimization

To maximize TFHE performance:

  • Minimize circuit depth where possible
  • Use GPU acceleration for parallel gate evaluation
  • Consider multi-threading for independent subcircuits
  • Profile to identify bottleneck gates

TFHE's gate-by-gate approach offers unique advantages for computations requiring comparisons and conditionals. It's a powerful tool in the FHE toolkit.

Ready to Go Quantum-Secure?

Start protecting your users with post-quantum authentication today. 1,000 free auths, no credit card required.

Get Free API Key →