diff --git a/fhevm-engine/Cargo.lock b/fhevm-engine/Cargo.lock index 92898350..c2422278 100644 --- a/fhevm-engine/Cargo.lock +++ b/fhevm-engine/Cargo.lock @@ -549,13 +549,14 @@ dependencies = [ [[package]] name = "concrete-fft" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3144f883422ee22c65d4f408c11b3406513eadc0d50b3d65bfadcb97852817e0" +checksum = "86ff7397e00e903afb03f0adca6a5f3bec3a6e96a7cdb70bdc088e01b125e170" dependencies = [ "aligned-vec", "bytemuck", "dyn-stack", + "js-sys", "num-complex", "pulp", "serde", @@ -563,9 +564,9 @@ dependencies = [ [[package]] name = "concrete-ntt" -version = "0.1.2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f4643dbd5de069e099122ae6c2bbd3db70d69ffec348dfc228448d635f949e" +checksum = "bea708a14b4cfe650eec644eac11889a187404a3a0738a41a5524b0f548850a1" dependencies = [ "aligned-vec", "pulp", @@ -809,9 +810,9 @@ checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] name = "dyn-stack" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe7f8d7bcc523381d3c437b82cf74805de3931de0da69309ae0fe1bdf7a256e" +checksum = "56e53799688f5632f364f8fb387488dd05db9fe45db7011be066fc20e7027f8b" dependencies = [ "bytemuck", "reborrow", @@ -2767,9 +2768,9 @@ dependencies = [ [[package]] name = "tfhe" -version = "0.8.0-alpha.3" +version = "0.8.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b4ec8ada6d84e3b0bc233deb8d51e42edb0ec1cf4bb4343f1e6ed184fff4d7" +checksum = "79019e02932ee4b0f9b5b93369e9e2d4366b0ae13d66a71ca7b068d87232ea8f" dependencies = [ "aligned-vec", "bincode", diff --git a/fhevm-engine/coprocessor/Cargo.toml b/fhevm-engine/coprocessor/Cargo.toml index 13b42e80..1e25cee1 100644 --- a/fhevm-engine/coprocessor/Cargo.toml +++ b/fhevm-engine/coprocessor/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.0" edition = "2021" [target.'cfg(target_arch = "x86_64")'.dependencies] -tfhe = { version = "0.8.0-alpha.2", features = ["boolean", "shortint", "integer", "x86_64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] } +tfhe = { version = "0.8.0-alpha.4", features = ["boolean", "shortint", "integer", "x86_64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] } [target.'cfg(target_arch = "aarch64")'.dependencies] -tfhe = { version = "0.8.0-alpha.2", features = ["boolean", "shortint", "integer", "aarch64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] } +tfhe = { version = "0.8.0-alpha.4", features = ["boolean", "shortint", "integer", "aarch64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] } [dependencies] # Common dependencies diff --git a/fhevm-engine/coprocessor/src/tests/inputs.rs b/fhevm-engine/coprocessor/src/tests/inputs.rs index 566a946b..841232d6 100644 --- a/fhevm-engine/coprocessor/src/tests/inputs.rs +++ b/fhevm-engine/coprocessor/src/tests/inputs.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use tfhe::integer::U256; +use tfhe::integer::{bigint::StaticUnsignedBigInt, U256}; use tonic::metadata::MetadataValue; use crate::{db_queries::query_tenant_keys, server::coprocessor::{fhevm_coprocessor_client::FhevmCoprocessorClient, DebugDecryptRequest, InputToUpload, InputUploadBatch}, tests::utils::{default_api_key, default_tenant_id, setup_test_app}}; @@ -32,9 +32,9 @@ async fn test_fhe_inputs() -> Result<(), Box> { .push(5u128) // TODO: 160 bits test .push(U256::from(7u32)) - // .push(StaticUnsignedBigInt::<8>::from(8u32)) - // .push(StaticUnsignedBigInt::<16>::from(9u32)) - // .push(StaticUnsignedBigInt::<32>::from(10u32)) + .push(StaticUnsignedBigInt::<8>::from(8u32)) + .push(StaticUnsignedBigInt::<16>::from(9u32)) + .push(StaticUnsignedBigInt::<32>::from(10u32)) .build(); let serialized = bincode::serialize(&the_list).unwrap(); @@ -58,7 +58,7 @@ async fn test_fhe_inputs() -> Result<(), Box> { let first_resp = &resp.upload_responses[0]; - assert_eq!(first_resp.input_handles.len(), 7); + assert_eq!(first_resp.input_handles.len(), 10); let mut decr_handles: Vec> = Vec::new(); for handle in &first_resp.input_handles { @@ -74,9 +74,7 @@ async fn test_fhe_inputs() -> Result<(), Box> { ); let resp = client.debug_decrypt_ciphertext(decrypt_request).await?; let resp = resp.get_ref(); - assert_eq!(resp.values.len(), 7); - // TODO: add ebytes support, we only support 256 bits max - // assert_eq!(resp.values.len(), 10); + assert_eq!(resp.values.len(), 10); assert_eq!(resp.values[0].output_type, 0); assert_eq!(resp.values[0].value, "false"); @@ -92,12 +90,12 @@ async fn test_fhe_inputs() -> Result<(), Box> { assert_eq!(resp.values[5].value, "5"); assert_eq!(resp.values[6].output_type, 8); assert_eq!(resp.values[6].value, "7"); - // assert_eq!(resp.values[7].output_type, 9); - // assert_eq!(resp.values[7].value, "8"); - // assert_eq!(resp.values[8].output_type, 10); - // assert_eq!(resp.values[8].value, "9"); - // assert_eq!(resp.values[9].output_type, 11); - // assert_eq!(resp.values[9].value, "10"); + assert_eq!(resp.values[7].output_type, 9); + assert_eq!(resp.values[7].value, "8"); + assert_eq!(resp.values[8].output_type, 10); + assert_eq!(resp.values[8].value, "9"); + assert_eq!(resp.values[9].output_type, 11); + assert_eq!(resp.values[9].value, "10"); Ok(()) } diff --git a/fhevm-engine/executor/Cargo.toml b/fhevm-engine/executor/Cargo.toml index d78d2c23..9806735f 100644 --- a/fhevm-engine/executor/Cargo.toml +++ b/fhevm-engine/executor/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.0" edition = "2021" [target.'cfg(target_arch = "x86_64")'.dependencies] -tfhe = { version = "0.8.0-alpha.2", features = ["boolean", "shortint", "integer", "x86_64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] } +tfhe = { version = "0.8.0-alpha.4", features = ["boolean", "shortint", "integer", "x86_64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] } [target.'cfg(target_arch = "aarch64")'.dependencies] -tfhe = { version = "0.8.0-alpha.2", features = ["boolean", "shortint", "integer", "aarch64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] } +tfhe = { version = "0.8.0-alpha.4", features = ["boolean", "shortint", "integer", "aarch64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] } [dependencies] clap.workspace = true diff --git a/fhevm-engine/fhevm-engine-common/Cargo.toml b/fhevm-engine/fhevm-engine-common/Cargo.toml index f889e791..8665ca64 100644 --- a/fhevm-engine/fhevm-engine-common/Cargo.toml +++ b/fhevm-engine/fhevm-engine-common/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.0" edition = "2021" [target.'cfg(target_arch = "x86_64")'.dependencies] -tfhe = { version = "0.8.0-alpha.2", features = ["boolean", "shortint", "integer", "x86_64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] } +tfhe = { version = "0.8.0-alpha.4", features = ["boolean", "shortint", "integer", "x86_64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] } [target.'cfg(target_arch = "aarch64")'.dependencies] -tfhe = { version = "0.8.0-alpha.2", features = ["boolean", "shortint", "integer", "aarch64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] } +tfhe = { version = "0.8.0-alpha.4", features = ["boolean", "shortint", "integer", "aarch64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] } [dependencies] sha3.workspace = true diff --git a/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs b/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs index 754946d5..c7e644f2 100644 --- a/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs +++ b/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs @@ -272,6 +272,30 @@ pub fn try_expand_ciphertext_list( res.push(SupportedFheCiphertexts::FheUint256(ct)); } + tfhe::FheTypes::Uint512 => { + let ct: tfhe::FheUint512 = expanded + .get(idx) + .expect("Index must exist") + .expect("Must succeed, we just checked this is the type"); + + res.push(SupportedFheCiphertexts::FheBytes64(ct)); + } + tfhe::FheTypes::Uint1024 => { + let ct: tfhe::FheUint1024 = expanded + .get(idx) + .expect("Index must exist") + .expect("Must succeed, we just checked this is the type"); + + res.push(SupportedFheCiphertexts::FheBytes128(ct)); + } + tfhe::FheTypes::Uint2048 => { + let ct: tfhe::FheUint2048 = expanded + .get(idx) + .expect("Index must exist") + .expect("Must succeed, we just checked this is the type"); + + res.push(SupportedFheCiphertexts::FheBytes256(ct)); + } other => { return Err(FhevmError::CiphertextExpansionUnsupportedCiphertextKind( other,