Available on crate feature
integer
only.Expand description
Welcome to the TFHE-rs integer
module documentation!
Special module attributes
cbindgen:ignore
Description
This library makes it possible to execute modular operations over encrypted integer.
It allows to execute an integer circuit on an untrusted server because both circuit inputs outputs are kept private.
Data are encrypted on the client side, before being sent to the server. On the server side every computation is performed on ciphertexts
Quick Example
The following piece of code shows how to generate keys and run a integer circuit homomorphically.
use tfhe::integer::gen_keys_radix;
use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2;
//4 blocks for the radix decomposition
let number_of_blocks = 4;
// Modulus = (2^2)*4 = 2^8 (from the parameters chosen and the number of blocks
let modulus = 1 << 8;
// Generation of the client/server keys, using the default parameters:
let (mut client_key, mut server_key) =
gen_keys_radix(&PARAM_MESSAGE_2_CARRY_2, number_of_blocks);
let msg1 = 153;
let msg2 = 125;
// Encryption of two messages using the client key:
let ct_1 = client_key.encrypt(msg1);
let ct_2 = client_key.encrypt(msg2);
// Homomorphic evaluation of an integer circuit (here, an addition) using the server key:
let ct_3 = server_key.unchecked_add(&ct_1, &ct_2);
// Decryption of the ciphertext using the client key:
let output = client_key.decrypt(&ct_3);
assert_eq!(output, (msg1 + msg2) % modulus);
Warning
This uses cryptographic parameters from the concrete-shortint
crates.
Currently, the radix approach is only compatible with parameter sets such
that the message and carry buffers have the same size.
Re-exports
pub use ciphertext::CompressedRadixCiphertextBig;
pub use ciphertext::CompressedRadixCiphertextSmall;
pub use ciphertext::CrtCiphertext;
pub use ciphertext::IntegerCiphertext;
pub use ciphertext::RadixCiphertextBig;
pub use ciphertext::RadixCiphertextSmall;
pub use client_key::ClientKey;
pub use client_key::CrtClientKey;
pub use client_key::RadixClientKey;
pub use public_key::CompressedPublicKeyBig;
pub use public_key::CompressedPublicKeySmall;
pub use public_key::PublicKeyBig;
pub use public_key::PublicKeySmall;
pub use server_key::CheckError;
pub use server_key::ServerKey;
pub use u256::U256;
Modules
- This module implements the ciphertext structures.
- This module implements the generation of the client keys structs
- Module with the definition of the encryption PublicKey.
- Module with the definition of the ServerKey.
- Module with the definition of the WopbsKey (WithOut padding PBS Key).
Functions
- Generate a couple of client and server keys with given parameters
- Generate a couple of client and server keys with given parameters
- Generate a couple of client and server keys with given parameters