Crate concrete

source ·
Expand description

Welcome to concrete documentation

The goal of this crate is to make it as easy as possible to write FHE programs by abstracting away most of the FHE details and by providing data types which are as close as possible to the native ones (bool, u8, u16) that we are used to.

Cargo Features

Data Types

This crate exposes 3 kinds of data types, each kind is enabled by activating its corresponding feature. Each kind may have multiple types:

KindCargo FeatureType(s)
BooleansbooleansFheBool
ShortIntsshortintsFheUint2
FheUint3
FheUint4
IntegersintegersFheUint8
FheUint12
FheUint16

Dynamic types

To allow further customization, it is possible to create at runtime new data types which are based on a certain kind.

For example it is possible to create your own 10 bits integer data type.

Example

Creating a 10-bits integer by combining 5 2-bits shortints

// This requires the integers feature
#[cfg(feature = "integers")]
{
    use concrete::prelude::*;
    use concrete::{
        generate_keys, set_server_key, ConfigBuilder, RadixParameters, FheUint2Parameters,
    };

    let mut config = ConfigBuilder::all_disabled();
    let uint10_type = config.add_integer_type(RadixParameters {
        block_parameters: FheUint2Parameters::default().into(),
        num_block: 5,
        wopbs_block_parameters: FheUint2Parameters::wopbs_default().into()
    });

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

    set_server_key(server_key);

    let a = uint10_type.encrypt(177, &client_key);
    let b = uint10_type.encrypt(100, &client_key);

    let c: u64 = (a + b).decrypt(&client_key);
    assert_eq!(c, 277);
}

Serialization

Most of the data types are Serializable and Deserializable via the serde crate and its corresponding feature: serde.

Activating features

To activate features, in your Cargo.toml add:

concrete = { version = "0.2.0-beta", features = ["booleans", "serde"] }

Re-exports

pub use errors::OutOfRangeError;

Modules

The concrete prelude. The purpose of this module is to make it easier to have the most commonly needed traits of this crate.

Structs

Key of the client
The config type
The builder to create your config
Parameters for ‘CRT’ decomposition
struct to create new values of a dynamically defined type of boolean
The encryptor for dynamic shortint
Parameters for [FheBool].
A Generic FHE unsigned integer
A Generic short FHE unsigned integer
KeyCacher
Parameters for ‘radix’ decomposition
Key of the server

Enums

Parameters for integers

Functions

Generates keys using the provided config.
if_then_elsebooleans
The function used to initialize internal keys.

Type Definitions

DynFheBoolbooleans
DynIntegerintegers
DynShortIntshortints
Type dynamically defined shortint.
FheBoolbooleans
FheUint2shortints
An unsigned integer type with 2 bits.
Parameters for the FheUint2 data type.
FheUint3shortints
An unsigned integer type with 3 bits.
Parameters for the FheUint3 data type.
FheUint4shortints
An unsigned integer type with 4 bits.
Parameters for the FheUint4 data type.
FheUint8integers
An unsigned integer type with 8 bits.
FheUint12integers
An unsigned integer type with 12 bits.
FheUint16integers
An unsigned integer type with 16 bits.