zama-ai / tfhe-rs

TFHE-rs: A Pure Rust implementation of the TFHE Scheme for Boolean and Integer Arithmetics Over Encrypted Data.
Other
826 stars 126 forks source link

Error while building #1299

Closed Sameeksha0709 closed 5 days ago

Sameeksha0709 commented 1 week ago

HI while i am building the example code i am getting the below error

unresolved import tfhe::prelude --> src/main.rs:1:11 | 1 | use tfhe::prelude::*; | ^^^^^^^ could not find prelude in tfhe

error[E0432]: unresolved imports tfhe::generate_keys, tfhe::set_server_key, tfhe::ConfigBuilder, tfhe::FheUint32, tfhe::FheUint8 --> src/main.rs:2:12 2 use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint32, FheUint8}; ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^ ^^^^^^^^ no FheUint8 in the root
no FheUint32 in the root
no ConfigBuilder in the root
no set_server_key in the root
no generate_keys in the root

For more information about this error, try rustc --explain E0432. error: could not compile my_tfhe_project (bin "my_tfhe_project") due to 2 previous error

IceTDrinker commented 1 week ago

@Sameeksha0709 see the Importing section in the documentation

https://docs.zama.ai/tfhe-rs/get-started/installation

Sameeksha0709 commented 1 week ago

Hi i followed the same but still getting the error

IceTDrinker commented 1 week ago

@Sameeksha0709 can you share a github repo so that we can see what's happening ?

Sameeksha0709 commented 1 week ago

Hi i am working on RPI4. this will work for rpi4?

IceTDrinker commented 1 week ago

What is RPI4 ?

Sameeksha0709 commented 1 week ago

Raspeberry Pi-4

IceTDrinker commented 1 week ago

for the features try

--features=aarch64-unix,integer

it should compile

IceTDrinker commented 1 week ago

if it does not then we need to see what code you have

Sameeksha0709 commented 1 week ago

Hi I am getting this error now cargo run --features aarch64-unix,integer Finished dev profile [unoptimized + debuginfo] target(s) in 0.09s Running target/debug/my_tfhe_project thread 'main' panicked at /home/pi2/.cargo/registry/src/index.crates.io-6f17d22bba15001f/concrete-csprng-0.4.0/src/generators/implem/aarch64/block_cipher.rs:26:13: The ArmAesBlockCipher requires both aes and neon aarch64 CPU features. aes feature available: false neon feature available: true . note: run with RUST_BACKTRACE=1 environment variable to display a backtrace //My code is use tfhe::{ConfigBuilder, generate_keys, set_server_key, FheUint8}; use tfhe::prelude::*;

fn main() { let config = ConfigBuilder::default().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);

}

IceTDrinker commented 1 week ago

@Sameeksha0709 then use

--features=seeder_unix,integer

Sameeksha0709 commented 1 week ago

~/my_tfhe_project $ pi2@raspberrypi:~/my_tfhe_project $ cargo run --features seeder_unix,integer Finished dev profile [unoptimized + debuginfo] target(s) in 0.11s Running target/debug/my_tfhe_project thread 'main' panicked at /home/pi2/.cargo/registry/src/index.crates.io-6f17d22bba15001f/concrete-csprng-0.4.0/src/generators/implem/aarch64/block_cipher.rs:26:13: The ArmAesBlockCipher requires both aes and neon aarch64 CPU features. aes feature available: false neon feature available: true . note: run with RUST_BACKTRACE=1 environment variable to display a backtrace still getting same error

IceTDrinker commented 1 week ago

ok, we likely have a bug then, let me check

IceTDrinker commented 1 week ago

however do note that running on a raspberry pi 4 is likley going to be very, very, very slow

IceTDrinker commented 1 week ago

sorry in your Cargo.toml

you must have:

tfhe = { ..., features = ["seeder_unix", "integer"] }

you can remove the features from your cargo run

Sameeksha0709 commented 1 week ago

Thanks It's working now

Sameeksha0709 commented 1 week ago

HI can you tell me why running on rpi is slow for TFHE-rs while with open-fhe library it's not that much slow

tmontaigu commented 1 week ago

make sure you compile and run with --release

IceTDrinker commented 1 week ago

@Sameeksha0709 were you able to solve the performance problem with the --release suggestion ?

Sameeksha0709 commented 5 days ago

Hi, it's working fine. Can I use this library for writing code in C programming?

Sameeksha0709 commented 5 days ago

I am more comfortable with c

IceTDrinker commented 5 days ago

You have a C API binding for the HL API.

We do not recommend using it because of the ffi transition it adds vs. writing rust code.

See https://docs.zama.ai/tfhe-rs/guides/c_api

If you build the C API you will need to adapt the features as we discussed in this issue.

I'll mark the issue as resolved as the original problem has been fixed.

If you have other questions don't hesitate to open another issue.

Cheers