Getting started

Concrete is a fully homomorphic encryption (FHE) library that implements Zama's variant of TFHE. TFHE is based on Learning With Errors (LWE), a well studied cryptographic primitive believed to be secure even against quantum computers.

Concrete is currently released in alpha. The API is not stable and likely to change short term.

Concrete is an open source library. The code is available on Github.

In cryptography, a raw value is called a message (also sometimes called a cleartext), an encoded message is called a plaintext and an encrypted plaintext is called a ciphertext.

Using FHE in a Rust program with Concrete consists in:

  • generating a secret key using secure parameters

  • encoding input messages into fixed-precision plaintexts

  • encrypting plaintexts using the secret key to produce ciphertexts

  • operating homomorphically on ciphertexts

  • decrypting the resulting ciphertexts into plaintexts using the secret key

  • decoding plaintexts to get the final output messages

Here is an example program that adds two ciphertexts:

use concrete::*;

fn main() -> Result<(), CryptoAPIError> {

    // generate a secret key
    let secret_key = LWESecretKey::new(&LWE128_630);

    // the two values to add
    let m1 = 8.2;
    let m2 = 5.6;

    // Encode in [0, 10[ with 8 bits of precision and 1 bit of padding
    let encoder = Encoder::new(0., 10., 8, 1)?;

    // encrypt plaintexts
    let mut c1 = LWE::encode_encrypt(&secret_key, m1, &encoder)?;
    let c2 = LWE::encode_encrypt(&secret_key, m2, &encoder)?;

    // add the two ciphertexts homomorphically, and store in c1

    // decrypt and decode the result
    let m3 = c1.decrypt_decode(&secret_key)?;

    // print the result and compare to non-FHE addition
    println!("Real: {}, FHE: {}", m1 + m2, m3);


Concrete being a library, all functions are wrapped in a Result to let you manage errors the way you see fit for your program.

This guide will walk you through using the Concrete library to build homomorphic programs, explaining the underlying key concepts as they are encountered.

Last updated