A question about running TFHE-rs example benchmarks (and scheme switching from BFV)


I am usuing Ubuntu 22.04 and I installed TFHE-rs in the /home/tfhe-rs folder.

Q1. Now, I wonder how I can run the benchmarks listed on this webpage:


Q2. I wonder how I can run any of the benchmark files in the tfhe/benches folder. In fact, I am new in Rust and not very good at running its code. I ran the following code:

cargo run --example pbs_count --features=“integer pbs-stats”

And then Rust runs target/debug/examples/pbs-stats. However, I wonder how I can run other examples in the tfhe/benches folder.

Q3. In the target/release/examples folder, I see libfhe.a and libfhe.so. Is this the compiled library of TFHE-rs? Then, can I use the functions in these libraries as if they were C/C++ functions? Is so, is there any API documentation of libfhe.a?

Q4. In my project, I am trying to do scheme switching from BFV to TFHE, which converts a BFV ciphertext into a TFHE ciphertext encrypting the same value. After I do this conversion, each converted TFHE ciphertext contains a single integer plaintext within the [0, p] range. And my goal is to do bootstrapping on this TFHE ciphertext. As TFHE-rs is very fast for bootstrapping, I want to use its bootstrapping. However, I think TFHE-rs encodes each plaintext integer inside a ciphertext as binary bits, where each bit is separately encrypted as a ciphertext in TFHE-rs, right? If so, I think the scheme switching from BFV to TFHE-rs may not be compatible, because their plaintext representations are different, is this correct?

Q1. Provided you have a GPU and CUDA installed you can likely launch the following command from the repo root

make BENCH_OP_FLAVOR=default bench_integer_gpu

Q2. for benchmark you can check our makefile or use the make help command

in general something like

cargo bench --bench name_of_the_bench

will launch the bench called name_of_the_bench

Q3. There is a C API for the High level API, you can check the tests in tfhe/c_api_tests for usage and doc here High-level API in C | 0.6 | TFHE-rs

You should not use the C API if you can use rust directly

Q4. No TFHE supports integer plaintexts as long as the message is scaled by a given delta value pushing the plaintext bits in the most significant bits of the body

I don’t know how big plaintexts can be in BFV but TFHE cannot encrypt more than ~10 bits per plaintext if you need PBS evaluation and evaluation of the PBS is most efficient up to roughly ~4 bits of plaintext

Does tfhe-rs support scheme switching? If yes, can we switch between TFHE and CKKS?

We do not have CKKS code in TFHE-rs, but I’m guessing that someone who knows both schemes would be able to write code to scheme switch between the two

1 Like