Hi!
I ran into an issue while working on TFHE-rs and trying to learn how to use your framework.
In the first tutorial for high level api I was experimenting with some other parameters, and wanted support for larger numbers. However it seems like the FHEencrypt function does not support larger integers than 16 bit, quite similar to the concrete-python implementation.
Here is the sample code I was currently trying to modify:
use tfhe::{ConfigBuilder, generate_keys, set_server_key, FheUint8};
use tfhe::prelude::*;
fn main() {
let config = ConfigBuilder::all_disabled()
.enable_default_uint8()
.build();
// Client-side
let (client_key, server_key) = generate_keys(config);
let clear_a = 27u8;
let clear_b = 128u8;
let a = FheUint8::encrypt(clear_a, &client_key);
let b = FheUint8::encrypt(clear_b, &client_key);
//Server-side
set_server_key(server_key);
let result = a + b;
//Client-side
let decrypted_result: u8 = result.decrypt(&client_key);
let clear_result = clear_a + clear_b;
assert_eq!(decrypted_result, clear_result);
}
I tried another of your sample code, and then it worked fine with larger numbers, and as far as I could see the reason being that it supports up to 64 bit integers.
Here is the other sample code I tried and modified:
use tfhe::shortint::prelude::*;
fn main() {
// We generate a set of client/server keys
let (client_key, server_key) = gen_keys(PARAM_MESSAGE_2_CARRY_2);
let msg1 = 1;
let msg2 = 0;
let modulus = client_key.parameters.message_modulus.0;
// We use the client key to encrypt two messages:
let ct_1 = client_key.encrypt(msg1);
let ct_2 = client_key.encrypt(msg2);
// We use the server public key to execute an integer circuit:
let ct_3 = server_key.unchecked_add(&ct_1, &ct_2);
// We use the client key to decrypt the output of the circuit:
let output = client_key.decrypt(&ct_3);
assert_eq!(output, (msg1 + msg2) % modulus as u64);
}
Also, I noted that there is a significant difference in run-time on those two examples where I believe the reason being that the latter has less operations than the first sample code. Is it that easy explanation or is it more complex? (The first code use 12 seconds, while the latter use only 1,2 seconds which I found very surprising)