Concrete Framework

Concrete makes Fully Homomorphic Encryption (FHE) research and development simple, so that you can spend more time building secure software and protocols, and less time figuring out how libraries work.  Read our whitepaper here, and star the project on Github:


The Concrete Framework is available. Read more.
The Concrete Framework is available. Read more.
The Concrete Framework is available. Read more.

Concrete 0.2 is built as a framework of libraries, but we greatly suggest to any user to start building applications with the concrete crate.

In its current state, concrete crate is built on top of 3 primitive crate types: respectively, concrete-boolean for boolean type, concrete-shortint for the integers from 2 to 7 bits, and concrete-int for the integer from 4 to 16 bits. Cryptographic operations will be handled by concrete-core.

We have summarized the relation between all concrete crates in the diagram attached.

Concrete

Concrete is a Rust crate (library) meant to abstract away the details of Fully Homomorphic Encryption (FHE) to enable non-cryptographers to build applications that use FHE.

FHE is a powerful cryptographic tool, which allows computation to be performed directly on encrypted data without needing to decrypt it first.

Attached is a simple example of an encrypted addition between two encrypted 8-bit variables.


use concrete::{ConfigBuilder, generate_keys, set_server_key, FheUint8};
use concrete::prelude::*;

fn main() {
    let config = ConfigBuilder::all_disabled()
        .enable_default_uint8()
        .build();

    let (client_key, server_key) = generate_keys(config);

    set_server_key(server_key);

    let clear_a = 27u8;
    let clear_b = 128u8;

    let a = FheUint8::encrypt(clear_a, &client_key);
    let b = FheUint8::encrypt(clear_b, &client_key);

    let result = a + b;

    let decrypted_result: u8 = result.decrypt(&client_key);

    let clear_result = clear_a + clear_b;

    assert_eq!(decrypted_result, clear_result);
}
Copy

Lorem Ipsum Dolor Sit Amet

Lorem ipsum dolor sit amet, et zacarius consectetur adipiscing elit, tempor ut labore et dolore magna aliqua mussum...

Lorem Ipsum Dolor Sit Amet

Lorem ipsum dolor sit amet, et zacarius consectetur adipiscing elit, tempor ut labore et dolore magna aliqua mussum...

Lorem Ipsum Dolor Sit Amet

Lorem ipsum dolor sit amet, et zacarius consectetur adipiscing elit, tempor ut labore et dolore magna aliqua mussum...

Concrete Boolean

This library makes it possible to execute boolean gates over encrypted bits. It allows to execute a boolean circuit on an untrusted server because both circuit inputs and outputs are kept private. Data are indeed encrypted on the client side, before being sent to the server. On the server side every computation is performed on ciphertexts.

The server however has to know the boolean circuit to be evaluated. At the end of the computation, the server returns the encryption of the result to the user.

Attached is a quick example of how the library can be used.

Copy

use concrete_boolean::prelude::*;

fn main() {
   // We generate a set of client/server keys, using the default parameters:
   let (mut client_key, mut server_key) = gen_keys();

   // We use the client secret key to encrypt two messages:
   let ct_1 = client_key.encrypt(true);
   let ct_2 = client_key.encrypt(false);

   // We use the server public key to execute a boolean circuit:
   // if ((NOT ct_2) NAND (ct_1 AND ct_2)) then (NOT ct_2) else (ct_1 AND ct_2)
   let ct_3 = server_key.not(&ct_2);
   let ct_4 = server_key.and(&ct_1, &ct_2);
   let ct_5 = server_key.nand(&ct_3, &ct_4);
   let ct_6 = server_key.mux(&ct_5, &ct_3, &ct_4);

   // We use the client key to decrypt the output of the circuit:
   let output = client_key.decrypt(&ct_6);
   assert_eq!(output, true)
}

Lorem Ipsum Dolor Sit Amet

Lorem ipsum dolor sit amet, et zacarius consectetur adipiscing elit, tempor ut labore et dolore magna aliqua mussum...

Lorem Ipsum Dolor Sit Amet

Lorem ipsum dolor sit amet, et zacarius consectetur adipiscing elit, tempor ut labore et dolore magna aliqua mussum...

Lorem Ipsum Dolor Sit Amet

Lorem ipsum dolor sit amet, et zacarius consectetur adipiscing elit, tempor ut labore et dolore magna aliqua mussum...

Concrete Core

This library contains a set of low-level primitives which can be used to implement Fully Homomorphically Encrypted (FHE) programs.

In a nutshell, fully homomorphic encryption makes it possible to perform arbitrary computations over encrypted data. With FHE, you can perform computations without putting your trust in third-party computation providers.

Attached is an example that shows how to multiply a secret value by a public one homomorphically.


use concrete_commons::dispersion::Variance;
use concrete_commons::parameters::LweDimension;
use concrete_core::prelude::*;
use std::error::Error;

fn main() -> Result<(), Box> {
    let lwe_dimension = LweDimension(750);
    let noise = Variance(2_f64.powf(-104.));
    
    let raw_input = 3_u64 << 59;

    let raw_input_cleatext = 4_u64;

    const UNSAFE_SECRET: u128 = 0;
    let mut engine = DefaultEngine::new(Box::new(UnixSeeder::new(UNSAFE_SECRET)))?;

    let cleartext: Cleartext64 = engine.create_cleartext(&raw_input_cleatext)?;
    let key: LweSecretKey64 = engine.create_lwe_secret_key(lwe_dimension)?;

    let input_plaintext = engine.create_plaintext(&raw_input)?;
    let input_ciphertext = engine.encrypt_lwe_ciphertext(&key, &input_plaintext, noise)?;

    let placeholder_output_plaintext = engine.create_plaintext(&0u64)?;
    let mut ouptut_ciphertext =
        engine.encrypt_lwe_ciphertext(&key, &placeholder_output_plaintext, noise)?;

    engine.discard_mul_lwe_ciphertext_cleartext(
        &mut ouptut_ciphertext,
        &input_ciphertext,
        &cleartext
    )?;

    let decrypted_plaintext = engine.decrypt_lwe_ciphertext(&key, &ouptut_ciphertext)?;
    let raw_decrypted_plaintext = engine.retrieve_plaintext(&decrypted_plaintext)?;

    let output = raw_decrypted_plaintext >> 58;
    let carry = output % 2;
    let output = ((output >> 1) + carry) % (1 << 5);

    assert_eq!(output, 12);

    engine.destroy(cleartext)?;
    engine.destroy(key)?;
    engine.destroy(input_plaintext)?;
    engine.destroy(placeholder_output_plaintext)?;
    engine.destroy(decrypted_plaintext)?;
    engine.destroy(input_ciphertext)?;
    engine.destroy(ouptut_ciphertext)?;

    Ok(())
}
Copy

Start using Concrete Lib

Learn more

The Game of Life : Rebooted

The implementation of Conway's Game of Life using the latest version of Concrete: v0.2.

Read Article

Introducing the Concrete Framework

We are proud to announce the first official release of the Concrete Framework.

Read Article

Announcing Concrete-core v1.0.0-gamma with GPU acceleration

The third major step towards the 1.0.0 release of Zama’s low-level crypto library.

Read Article