diff --git a/Makefile b/Makefile index c4e4436d4..663d180c9 100644 --- a/Makefile +++ b/Makefile @@ -289,7 +289,7 @@ clippy_trivium: install_rs_check_toolchain .PHONY: clippy_all_targets # Run clippy lints on all targets (benches, examples, etc.) clippy_all_targets: install_rs_check_toolchain RUSTFLAGS="$(RUSTFLAGS)" cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" clippy --all-targets \ - --features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,zk-pok-experimental \ + --features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,zk-pok \ -p $(TFHE_SPEC) -- --no-deps -D warnings .PHONY: clippy_concrete_csprng # Run clippy lints on concrete-csprng @@ -368,21 +368,21 @@ symlink_c_libs_without_fingerprint: .PHONY: build_c_api # Build the C API for boolean, shortint and integer build_c_api: install_rs_check_toolchain RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) build --profile $(CARGO_PROFILE) \ - --features=$(TARGET_ARCH_FEATURE),boolean-c-api,shortint-c-api,high-level-c-api,zk-pok-experimental,$(FORWARD_COMPAT_FEATURE) \ + --features=$(TARGET_ARCH_FEATURE),boolean-c-api,shortint-c-api,high-level-c-api,zk-pok,$(FORWARD_COMPAT_FEATURE) \ -p $(TFHE_SPEC) @"$(MAKE)" symlink_c_libs_without_fingerprint .PHONY: build_c_api_gpu # Build the C API for boolean, shortint and integer build_c_api_gpu: install_rs_check_toolchain RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) build --profile $(CARGO_PROFILE) \ - --features=$(TARGET_ARCH_FEATURE),boolean-c-api,shortint-c-api,high-level-c-api,zk-pok-experimental,gpu \ + --features=$(TARGET_ARCH_FEATURE),boolean-c-api,shortint-c-api,high-level-c-api,zk-pok,gpu \ -p $(TFHE_SPEC) @"$(MAKE)" symlink_c_libs_without_fingerprint .PHONY: build_c_api_experimental_deterministic_fft # Build the C API for boolean, shortint and integer with experimental deterministic FFT build_c_api_experimental_deterministic_fft: install_rs_check_toolchain RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) build --profile $(CARGO_PROFILE) \ - --features=$(TARGET_ARCH_FEATURE),boolean-c-api,shortint-c-api,high-level-c-api,zk-pok-experimental,experimental-force_fft_algo_dif4,$(FORWARD_COMPAT_FEATURE) \ + --features=$(TARGET_ARCH_FEATURE),boolean-c-api,shortint-c-api,high-level-c-api,zk-pok,experimental-force_fft_algo_dif4,$(FORWARD_COMPAT_FEATURE) \ -p $(TFHE_SPEC) @"$(MAKE)" symlink_c_libs_without_fingerprint @@ -391,7 +391,7 @@ build_web_js_api: install_rs_build_toolchain install_wasm_pack cd tfhe && \ RUSTFLAGS="$(WASM_RUSTFLAGS)" rustup run "$(RS_BUILD_TOOLCHAIN)" \ wasm-pack build --release --target=web \ - -- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api,zk-pok-experimental + -- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api,zk-pok .PHONY: build_web_js_api_parallel # Build the js API targeting the web browser with parallelism support build_web_js_api_parallel: install_rs_check_toolchain install_wasm_pack @@ -399,7 +399,7 @@ build_web_js_api_parallel: install_rs_check_toolchain install_wasm_pack rustup component add rust-src --toolchain $(RS_CHECK_TOOLCHAIN) && \ RUSTFLAGS="$(WASM_RUSTFLAGS) -C target-feature=+atomics,+bulk-memory,+mutable-globals" rustup run $(RS_CHECK_TOOLCHAIN) \ wasm-pack build --release --target=web \ - -- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api,parallel-wasm-api,zk-pok-experimental \ + -- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api,parallel-wasm-api,zk-pok \ -Z build-std=panic_abort,std .PHONY: build_node_js_api # Build the js API targeting nodejs @@ -407,7 +407,7 @@ build_node_js_api: install_rs_build_toolchain install_wasm_pack cd tfhe && \ RUSTFLAGS="$(WASM_RUSTFLAGS)" rustup run "$(RS_BUILD_TOOLCHAIN)" \ wasm-pack build --release --target=nodejs \ - -- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api,zk-pok-experimental + -- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api,zk-pok .PHONY: build_concrete_csprng # Build concrete_csprng build_concrete_csprng: install_rs_build_toolchain @@ -417,10 +417,10 @@ build_concrete_csprng: install_rs_build_toolchain .PHONY: test_core_crypto # Run the tests of the core_crypto module including experimental ones test_core_crypto: install_rs_build_toolchain install_rs_check_toolchain RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \ - --features=$(TARGET_ARCH_FEATURE),experimental,zk-pok-experimental -p $(TFHE_SPEC) -- core_crypto:: + --features=$(TARGET_ARCH_FEATURE),experimental,zk-pok -p $(TFHE_SPEC) -- core_crypto:: @if [[ "$(AVX512_SUPPORT)" == "ON" ]]; then \ RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) test --profile $(CARGO_PROFILE) \ - --features=$(TARGET_ARCH_FEATURE),experimental,zk-pok-experimental,$(AVX512_FEATURE) -p $(TFHE_SPEC) -- core_crypto::; \ + --features=$(TARGET_ARCH_FEATURE),experimental,zk-pok,$(AVX512_FEATURE) -p $(TFHE_SPEC) -- core_crypto::; \ fi .PHONY: test_core_crypto_cov # Run the tests of the core_crypto module with code coverage @@ -591,7 +591,7 @@ test_integer_cov: install_rs_check_toolchain install_tarpaulin .PHONY: test_high_level_api # Run all the tests for high_level_api test_high_level_api: install_rs_build_toolchain RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \ - --features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,zk-pok-experimental -p $(TFHE_SPEC) \ + --features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,zk-pok -p $(TFHE_SPEC) \ -- high_level_api:: test_high_level_api_gpu: install_rs_build_toolchain install_cargo_nextest @@ -602,14 +602,14 @@ test_high_level_api_gpu: install_rs_build_toolchain install_cargo_nextest .PHONY: test_user_doc # Run tests from the .md documentation test_user_doc: install_rs_build_toolchain RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) --doc \ - --features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,pbs-stats,zk-pok-experimental \ + --features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,pbs-stats,zk-pok \ -p $(TFHE_SPEC) \ -- test_user_docs:: .PHONY: test_user_doc_gpu # Run tests for GPU from the .md documentation test_user_doc_gpu: install_rs_build_toolchain RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) --doc \ - --features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,gpu,zk-pok-experimental -p $(TFHE_SPEC) \ + --features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,internal-keycache,gpu,zk-pok -p $(TFHE_SPEC) \ -- test_user_docs:: .PHONY: test_fhe_strings # Run tests for fhe_strings example @@ -648,7 +648,7 @@ test_concrete_csprng: install_rs_build_toolchain RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \ --features=$(TARGET_ARCH_FEATURE) -p concrete-csprng -.PHONY: test_zk_pok # Run tfhe-zk-pok-experimental tests +.PHONY: test_zk_pok # Run tfhe-zk-pok tests test_zk_pok: install_rs_build_toolchain RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \ -p tfhe-zk-pok @@ -814,7 +814,7 @@ bench_integer_zk: install_rs_check_toolchain RUSTFLAGS="$(RUSTFLAGS)" \ cargo $(CARGO_RS_CHECK_TOOLCHAIN) bench \ --bench zk-pke-bench \ - --features=$(TARGET_ARCH_FEATURE),integer,internal-keycache,zk-pok-experimental,nightly-avx512 \ + --features=$(TARGET_ARCH_FEATURE),integer,internal-keycache,zk-pok,nightly-avx512 \ -p $(TFHE_SPEC) -- .PHONY: bench_shortint # Run benchmarks for shortint diff --git a/scripts/integer-tests.sh b/scripts/integer-tests.sh index 2b1123842..6402950b8 100755 --- a/scripts/integer-tests.sh +++ b/scripts/integer-tests.sh @@ -155,7 +155,7 @@ cargo "${RUST_TOOLCHAIN}" nextest run \ --cargo-profile "${cargo_profile}" \ --package "${tfhe_package}" \ --profile ci \ - --features="${ARCH_FEATURE}",integer,internal-keycache,zk-pok-experimental,"${avx512_feature}" \ + --features="${ARCH_FEATURE}",integer,internal-keycache,zk-pok,"${avx512_feature}" \ --test-threads "${test_threads}" \ -E "$filter_expression" diff --git a/scripts/shortint-tests.sh b/scripts/shortint-tests.sh index b493b9f86..dc7df504f 100755 --- a/scripts/shortint-tests.sh +++ b/scripts/shortint-tests.sh @@ -120,7 +120,7 @@ and not test(~smart_add_and_mul)""" # This test is too slow --cargo-profile "${cargo_profile}" \ --package "${tfhe_package}" \ --profile ci \ - --features="${ARCH_FEATURE}",shortint,internal-keycache,zk-pok-experimental \ + --features="${ARCH_FEATURE}",shortint,internal-keycache,zk-pok \ --test-threads "${n_threads_small}" \ -E "${filter_expression_small_params}" diff --git a/tfhe/Cargo.toml b/tfhe/Cargo.toml index ce55f93d7..1dd4b18d9 100644 --- a/tfhe/Cargo.toml +++ b/tfhe/Cargo.toml @@ -92,7 +92,7 @@ shortint = ["dep:sha3"] integer = ["shortint"] internal-keycache = ["dep:lazy_static", "dep:fs2"] gpu = ["dep:tfhe-cuda-backend"] -zk-pok-experimental = ["dep:tfhe-zk-pok"] +zk-pok = ["dep:tfhe-zk-pok"] pbs-stats = [] @@ -150,7 +150,7 @@ aarch64-unix = ["aarch64", "seeder_unix"] [package.metadata.docs.rs] # TODO: manage builds for docs.rs based on their documentation https://docs.rs/about -features = ["x86_64-unix", "boolean", "shortint", "integer", "gpu"] +features = ["x86_64-unix", "boolean", "shortint", "integer", "gpu", "zk-pok"] rustdoc-args = ["--html-in-header", "katex-header.html"] ########### @@ -223,7 +223,7 @@ required-features = ["integer", "internal-keycache"] name = "zk-pke-bench" path = "benches/integer/zk_pke.rs" harness = false -required-features = ["integer", "zk-pok-experimental", "internal-keycache"] +required-features = ["integer", "zk-pok", "internal-keycache"] [[bench]] name = "hlapi" diff --git a/tfhe/build.rs b/tfhe/build.rs index ae11ff367..ee078e570 100644 --- a/tfhe/build.rs +++ b/tfhe/build.rs @@ -57,8 +57,8 @@ fn gen_c_api() { "integer", #[cfg(feature = "gpu")] "gpu", - #[cfg(feature = "zk-pok-experimental")] - "zk-pok-experimental", + #[cfg(feature = "zk-pok")] + "zk-pok", ]; let parse_expand_vec = if parse_expand_features_vec.is_empty() { diff --git a/tfhe/docs/guides/zk-pok.md b/tfhe/docs/guides/zk-pok.md index 85074902c..7b9398cea 100644 --- a/tfhe/docs/guides/zk-pok.md +++ b/tfhe/docs/guides/zk-pok.md @@ -5,7 +5,7 @@ This document explains how to implement the zero-knowledge proofs function for c **TFHE-rs** can generate zero-knowledge proofs to verify that the compact public key encryption process is correct. In other words, **TFHE-rs** generates the proof without revealing any information other than the already known range of the encrypted message. This technique is derived from [Libert’s work](https://eprint.iacr.org/2023/800). {% hint style="info" %} -You can enable this feature using the flag: `--features=zk-pok-experimental` when building **TFHE-rs**. +You can enable this feature using the flag: `--features=zk-pok` when building **TFHE-rs**. {% endhint %} Using this feature is straightforward: during encryption, the client generates the proof, and the server validates it before conducting any homomorphic computations. The following example demonstrates how a client can encrypt and prove a ciphertext, and how a server can verify the ciphertext and compute it: diff --git a/tfhe/src/c_api/high_level_api/compact_list.rs b/tfhe/src/c_api/high_level_api/compact_list.rs index 485a9d098..67ce1a3fa 100644 --- a/tfhe/src/c_api/high_level_api/compact_list.rs +++ b/tfhe/src/c_api/high_level_api/compact_list.rs @@ -12,7 +12,7 @@ use crate::c_api::high_level_api::u256::U256; use crate::c_api::high_level_api::utils::{ impl_destroy_on_type, impl_serialize_deserialize_on_type, CApiIntegerType, }; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] use crate::c_api::high_level_api::zk::{CompactPkePublicParams, ZkComputeLoad}; use crate::c_api::utils::{catch_panic, get_mut_checked, get_ref_checked}; use std::ffi::c_int; @@ -24,11 +24,11 @@ pub struct CompactCiphertextList(crate::high_level_api::CompactCiphertextList); impl_destroy_on_type!(CompactCiphertextList); impl_serialize_deserialize_on_type!(CompactCiphertextList); -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] pub struct ProvenCompactCiphertextList(crate::high_level_api::ProvenCompactCiphertextList); -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] impl_destroy_on_type!(ProvenCompactCiphertextList); -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] impl_serialize_deserialize_on_type!(ProvenCompactCiphertextList); #[no_mangle] @@ -73,7 +73,7 @@ pub unsafe extern "C" fn compact_ciphertext_list_builder_build_packed( }) } -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] #[no_mangle] pub unsafe extern "C" fn compact_ciphertext_list_builder_build_with_proof_packed( builder: *const CompactCiphertextListBuilder, @@ -167,7 +167,7 @@ pub unsafe extern "C" fn compact_ciphertext_list_expand( }) } -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] #[no_mangle] pub unsafe extern "C" fn proven_compact_ciphertext_list_verify_and_expand( compact_list: *const ProvenCompactCiphertextList, diff --git a/tfhe/src/c_api/high_level_api/mod.rs b/tfhe/src/c_api/high_level_api/mod.rs index 3f645e151..790f24a73 100644 --- a/tfhe/src/c_api/high_level_api/mod.rs +++ b/tfhe/src/c_api/high_level_api/mod.rs @@ -14,7 +14,7 @@ pub mod u2048; pub mod u256; pub mod u512; mod utils; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] mod zk; #[derive(Copy, Clone, PartialEq, Eq, Debug)] diff --git a/tfhe/src/core_crypto/algorithms/lwe_encryption.rs b/tfhe/src/core_crypto/algorithms/lwe_encryption.rs index 74869806f..a13188285 100644 --- a/tfhe/src/core_crypto/algorithms/lwe_encryption.rs +++ b/tfhe/src/core_crypto/algorithms/lwe_encryption.rs @@ -5,7 +5,7 @@ use crate::core_crypto::algorithms::slice_algorithms::*; use crate::core_crypto::algorithms::*; use crate::core_crypto::commons::ciphertext_modulus::CiphertextModulusKind; use crate::core_crypto::commons::generators::{EncryptionRandomGenerator, SecretRandomGenerator}; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] use crate::core_crypto::commons::math::random::BoundedDistribution; use crate::core_crypto::commons::math::random::{ ActivatedRandomGenerator, Distribution, RandomGenerable, RandomGenerator, Uniform, @@ -15,7 +15,7 @@ use crate::core_crypto::commons::parameters::*; use crate::core_crypto::commons::traits::*; use crate::core_crypto::entities::*; use rayon::prelude::*; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] use tfhe_zk_pok::proofs::pke::{commit, prove}; /// Convenience function to share the core logic of the LWE encryption between all functions needing @@ -1693,17 +1693,17 @@ where /// These are needed by the zero-knowledge proof struct CompactPublicKeyRandomVectors { // This is 'r' - #[cfg_attr(not(feature = "zk-pok-experimental"), allow(unused))] + #[cfg_attr(not(feature = "zk-pok"), allow(unused))] binary_random_vector: Vec, // This is e1 - #[cfg_attr(not(feature = "zk-pok-experimental"), allow(unused))] + #[cfg_attr(not(feature = "zk-pok"), allow(unused))] mask_noise: Vec, // This is e2 - #[cfg_attr(not(feature = "zk-pok-experimental"), allow(unused))] + #[cfg_attr(not(feature = "zk-pok"), allow(unused))] body_noise: Vec, } -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] fn verify_zero_knowledge_preconditions( lwe_compact_public_key: &LweCompactPublicKey, ciphertext_count: LweCiphertextCount, @@ -2080,7 +2080,7 @@ pub fn encrypt_lwe_ciphertext_with_compact_public_key< /// // Check we recovered the original message /// assert_eq!(cleartext, msg.0); /// ``` -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] #[allow(clippy::too_many_arguments)] pub fn encrypt_and_prove_lwe_ciphertext_with_compact_public_key< Scalar, @@ -2570,7 +2570,7 @@ pub fn encrypt_lwe_compact_ciphertext_list_with_compact_public_key< /// // Check we recovered the original messages /// assert_eq!(&cleartexts, output_plaintext_list.as_ref()); /// ``` -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] #[allow(clippy::too_many_arguments)] pub fn encrypt_and_prove_lwe_compact_ciphertext_list_with_compact_public_key< Scalar, @@ -3090,7 +3090,7 @@ pub fn par_encrypt_lwe_compact_ciphertext_list_with_compact_public_key< /// // Check we recovered the original messages /// assert_eq!(&cleartexts, output_plaintext_list.as_ref()); /// ``` -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] #[allow(clippy::too_many_arguments)] pub fn par_encrypt_and_prove_lwe_compact_ciphertext_list_with_compact_public_key< Scalar, diff --git a/tfhe/src/core_crypto/algorithms/mod.rs b/tfhe/src/core_crypto/algorithms/mod.rs index 6bed3630a..a94edac4c 100644 --- a/tfhe/src/core_crypto/algorithms/mod.rs +++ b/tfhe/src/core_crypto/algorithms/mod.rs @@ -27,7 +27,7 @@ pub mod lwe_programmable_bootstrapping; pub mod lwe_public_key_generation; pub mod lwe_secret_key_generation; pub mod lwe_wopbs; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] pub mod lwe_zero_knowledge_verification; pub mod misc; pub mod polynomial_algorithms; @@ -75,7 +75,7 @@ pub use lwe_programmable_bootstrapping::*; pub use lwe_public_key_generation::*; pub use lwe_secret_key_generation::*; pub use lwe_wopbs::*; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] pub use lwe_zero_knowledge_verification::*; pub use seeded_ggsw_ciphertext_decompression::*; pub use seeded_ggsw_ciphertext_list_decompression::*; diff --git a/tfhe/src/core_crypto/algorithms/test/lwe_encryption.rs b/tfhe/src/core_crypto/algorithms/test/lwe_encryption.rs index 4ee7f140d..a894bbeb6 100644 --- a/tfhe/src/core_crypto/algorithms/test/lwe_encryption.rs +++ b/tfhe/src/core_crypto/algorithms/test/lwe_encryption.rs @@ -1,9 +1,9 @@ use super::*; use crate::core_crypto::commons::generators::DeterministicSeeder; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] use crate::core_crypto::commons::math::random::RandomGenerator; use crate::core_crypto::commons::test_tools; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] use rand::Rng; #[cfg(not(tarpaulin))] @@ -996,7 +996,7 @@ create_parametrized_test!(lwe_compact_public_encrypt_decrypt_custom_mod { TEST_PARAMS_4_BITS_NATIVE_U64 }); -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] fn lwe_compact_public_encrypt_prove_verify_decrypt_custom_mod( params: ClassicTestParams, ) where @@ -1093,12 +1093,12 @@ fn lwe_compact_public_encrypt_prove_verify_decrypt_custom_mod( } } -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] create_parametrized_test!(lwe_compact_public_encrypt_prove_verify_decrypt_custom_mod { TEST_PARAMS_4_BITS_NATIVE_U64 }); -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] #[test] fn test_par_compact_lwe_list_public_key_encryption_and_proof() { use rand::Rng; diff --git a/tfhe/src/core_crypto/entities/mod.rs b/tfhe/src/core_crypto/entities/mod.rs index bf356db37..afa037b5a 100644 --- a/tfhe/src/core_crypto/entities/mod.rs +++ b/tfhe/src/core_crypto/entities/mod.rs @@ -58,7 +58,7 @@ pub use crate::core_crypto::fft_impl::fft64::crypto::ggsw::{ FourierGgswCiphertext, FourierGgswCiphertextList, FourierGgswLevelMatrix, FourierGgswLevelRow, }; pub use crate::core_crypto::fft_impl::fft64::math::polynomial::FourierPolynomial; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] pub use crate::zk::*; pub use cleartext::*; pub use compressed_modulus_switched_lwe_ciphertext::*; diff --git a/tfhe/src/error.rs b/tfhe/src/error.rs index 43a7811f1..51667eb48 100644 --- a/tfhe/src/error.rs +++ b/tfhe/src/error.rs @@ -5,7 +5,7 @@ pub enum ErrorKind { Message(String), /// The zero knowledge proof and the content it is supposed to prove /// failed to correctly prove - #[cfg(feature = "zk-pok-experimental")] + #[cfg(feature = "zk-pok")] InvalidZkProof, } @@ -30,7 +30,7 @@ impl Display for Error { ErrorKind::Message(msg) => { write!(f, "{msg}") } - #[cfg(feature = "zk-pok-experimental")] + #[cfg(feature = "zk-pok")] ErrorKind::InvalidZkProof => { write!(f, "The zero knowledge proof and the content it is supposed to prove were not valid") } diff --git a/tfhe/src/high_level_api/compact_list.rs b/tfhe/src/high_level_api/compact_list.rs index 021b2c84b..ae197a538 100644 --- a/tfhe/src/high_level_api/compact_list.rs +++ b/tfhe/src/high_level_api/compact_list.rs @@ -13,7 +13,7 @@ use crate::integer::parameters::{ use crate::integer::BooleanBlock; use crate::named::Named; use crate::shortint::{Ciphertext, MessageModulus}; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] use crate::zk::{CompactPkePublicParams, ZkComputeLoad}; use crate::{CompactPublicKey, FheBool, FheInt, FheUint}; @@ -93,16 +93,16 @@ impl ParameterSetConformant for CompactCiphertextList { } } -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] #[derive(Clone, Serialize, Deserialize)] pub struct ProvenCompactCiphertextList(crate::integer::ciphertext::ProvenCompactCiphertextList); -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] impl Named for ProvenCompactCiphertextList { const NAME: &'static str = "high_level_api::ProvenCompactCiphertextList"; } -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] impl ProvenCompactCiphertextList { pub fn builder(pk: &CompactPublicKey) -> CompactCiphertextListBuilder { CompactCiphertextListBuilder::new(pk) @@ -393,7 +393,7 @@ impl CompactCiphertextListBuilder { .expect("Internal error, invalid parameters should not have been allowed") } - #[cfg(feature = "zk-pok-experimental")] + #[cfg(feature = "zk-pok")] pub fn build_with_proof_packed( &self, public_params: &CompactPkePublicParams, @@ -409,7 +409,7 @@ impl CompactCiphertextListBuilder { mod tests { use super::*; use crate::prelude::*; - #[cfg(feature = "zk-pok-experimental")] + #[cfg(feature = "zk-pok")] use crate::zk::CompactPkeCrs; use crate::{set_server_key, FheInt64, FheUint16, FheUint2, FheUint32}; @@ -466,7 +466,7 @@ mod tests { } } - #[cfg(feature = "zk-pok-experimental")] + #[cfg(feature = "zk-pok")] #[test] fn test_proven_compact_list() { use crate::shortint::parameters::classic::tuniform::p_fail_2_minus_64::ks_pbs::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64; @@ -528,7 +528,7 @@ mod tests { } } - #[cfg(feature = "zk-pok-experimental")] + #[cfg(feature = "zk-pok")] #[test] fn test_proven_compact_list_with_casting() { use crate::shortint::parameters::compact_public_key_only::PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64; diff --git a/tfhe/src/high_level_api/mod.rs b/tfhe/src/high_level_api/mod.rs index 4a4baa648..17825ed40 100644 --- a/tfhe/src/high_level_api/mod.rs +++ b/tfhe/src/high_level_api/mod.rs @@ -51,7 +51,7 @@ expand_pub_use_fhe_type!( ); pub use crate::integer::parameters::CompactCiphertextListConformanceParams; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] pub use compact_list::ProvenCompactCiphertextList; pub use compact_list::{ CompactCiphertextList, CompactCiphertextListBuilder, CompactCiphertextListExpander, @@ -72,7 +72,7 @@ mod compact_list; pub(in crate::high_level_api) mod details; /// The tfhe prelude. pub mod prelude; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] mod zk; /// Devices supported by tfhe-rs diff --git a/tfhe/src/integer/ciphertext/compact_list.rs b/tfhe/src/integer/ciphertext/compact_list.rs index 7d446a67e..82952fa47 100644 --- a/tfhe/src/integer/ciphertext/compact_list.rs +++ b/tfhe/src/integer/ciphertext/compact_list.rs @@ -13,7 +13,7 @@ use crate::shortint::{Ciphertext, MessageModulus}; use rayon::prelude::*; use serde::{Deserialize, Serialize}; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] use crate::zk::{CompactPkePublicParams, ZkComputeLoad}; fn extract_message_and_carries(packed_blocks: Vec, sks: &ServerKey) -> Vec { @@ -203,7 +203,7 @@ impl CompactCiphertextListBuilder { }) } - #[cfg(feature = "zk-pok-experimental")] + #[cfg(feature = "zk-pok")] pub fn build_with_proof( &self, public_params: &CompactPkePublicParams, @@ -221,7 +221,7 @@ impl CompactCiphertextListBuilder { }) } - #[cfg(feature = "zk-pok-experimental")] + #[cfg(feature = "zk-pok")] pub fn build_with_proof_packed( &self, public_params: &CompactPkePublicParams, @@ -506,7 +506,7 @@ impl CompactCiphertextList { } } -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] #[derive(Clone, Serialize, Deserialize)] pub struct ProvenCompactCiphertextList { pub(crate) ct_list: crate::shortint::ciphertext::ProvenCompactCiphertextList, @@ -515,7 +515,7 @@ pub struct ProvenCompactCiphertextList { pub(crate) info: Vec, } -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] impl ProvenCompactCiphertextList { pub fn builder(pk: &CompactPublicKey) -> CompactCiphertextListBuilder { CompactCiphertextListBuilder::new(pk) @@ -589,7 +589,7 @@ impl ProvenCompactCiphertextList { } } -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] #[cfg(test)] mod tests { use crate::integer::ciphertext::CompactCiphertextList; diff --git a/tfhe/src/integer/mod.rs b/tfhe/src/integer/mod.rs index b4a9f7da1..d783033e5 100755 --- a/tfhe/src/integer/mod.rs +++ b/tfhe/src/integer/mod.rs @@ -67,7 +67,7 @@ pub mod wopbs; #[cfg(feature = "gpu")] pub mod gpu; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] pub use ciphertext::ProvenCompactCiphertextList; pub use bigint::i256::I256; diff --git a/tfhe/src/js_on_wasm_api/js_high_level_api/integers.rs b/tfhe/src/js_on_wasm_api/js_high_level_api/integers.rs index 46a0d1071..322e19e48 100644 --- a/tfhe/src/js_on_wasm_api/js_high_level_api/integers.rs +++ b/tfhe/src/js_on_wasm_api/js_high_level_api/integers.rs @@ -3,7 +3,7 @@ use crate::high_level_api::prelude::*; use crate::integer::bigint::{StaticUnsignedBigInt, U1024, U2048, U512}; use crate::integer::{I256, U256}; use crate::js_on_wasm_api::js_high_level_api::keys::TfheCompactPublicKey; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] use crate::js_on_wasm_api::js_high_level_api::zk::{CompactPkePublicParams, ZkComputeLoad}; use crate::js_on_wasm_api::js_high_level_api::{catch_panic, catch_panic_result, into_js_error}; use js_sys::BigInt; @@ -669,7 +669,7 @@ pub struct CompactCiphertextListExpander(crate::high_level_api::CompactCiphertex #[wasm_bindgen] pub struct CompactCiphertextList(crate::high_level_api::CompactCiphertextList); -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] #[wasm_bindgen] pub struct ProvenCompactCiphertextList(crate::high_level_api::ProvenCompactCiphertextList); @@ -732,7 +732,7 @@ impl CompactCiphertextList { } } -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] #[wasm_bindgen] impl ProvenCompactCiphertextList { #[wasm_bindgen] @@ -948,7 +948,7 @@ impl CompactCiphertextListBuilder { }) } - #[cfg(feature = "zk-pok-experimental")] + #[cfg(feature = "zk-pok")] pub fn build_with_proof_packed( &self, public_params: &CompactPkePublicParams, diff --git a/tfhe/src/js_on_wasm_api/js_high_level_api/mod.rs b/tfhe/src/js_on_wasm_api/js_high_level_api/mod.rs index 208c9e1cf..3bd913841 100644 --- a/tfhe/src/js_on_wasm_api/js_high_level_api/mod.rs +++ b/tfhe/src/js_on_wasm_api/js_high_level_api/mod.rs @@ -5,7 +5,7 @@ pub(crate) mod integers; // using Self does not work well with #[wasm_bindgen] macro #[allow(clippy::use_self)] pub(crate) mod keys; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] mod zk; pub(crate) fn into_js_error(e: E) -> wasm_bindgen::JsError { diff --git a/tfhe/src/lib.rs b/tfhe/src/lib.rs index 6570816b0..fc84408c0 100644 --- a/tfhe/src/lib.rs +++ b/tfhe/src/lib.rs @@ -110,7 +110,7 @@ mod js_on_wasm_api; feature = "shortint", feature = "boolean", feature = "integer", - feature = "zk-pok-experimental" + feature = "zk-pok" ))] mod test_user_docs; @@ -132,7 +132,7 @@ pub mod conformance; pub mod named; pub mod error; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] pub mod zk; pub use error::{Error, ErrorKind}; diff --git a/tfhe/src/shortint/ciphertext/mod.rs b/tfhe/src/shortint/ciphertext/mod.rs index b39060e84..63f3dbd9b 100644 --- a/tfhe/src/shortint/ciphertext/mod.rs +++ b/tfhe/src/shortint/ciphertext/mod.rs @@ -9,8 +9,8 @@ pub use compact_list::*; pub use compressed::*; pub use compressed_modulus_switched_ciphertext::*; pub use standard::*; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] pub use zk::*; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] mod zk; diff --git a/tfhe/src/shortint/engine/mod.rs b/tfhe/src/shortint/engine/mod.rs index 22d8debe8..bb0ce861e 100644 --- a/tfhe/src/shortint/engine/mod.rs +++ b/tfhe/src/shortint/engine/mod.rs @@ -7,7 +7,7 @@ use crate::core_crypto::commons::computation_buffers::ComputationBuffers; use crate::core_crypto::commons::generators::{ DeterministicSeeder, EncryptionRandomGenerator, SecretRandomGenerator, }; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] use crate::core_crypto::commons::math::random::RandomGenerator; use crate::core_crypto::commons::math::random::{ActivatedRandomGenerator, Seeder}; use crate::core_crypto::entities::*; @@ -284,7 +284,7 @@ pub struct ShortintEngine { /// A seeder that can be called to generate 128 bits seeds, useful to create new /// [`EncryptionRandomGenerator`] to encrypt seeded types. pub(crate) seeder: DeterministicSeeder, - #[cfg(feature = "zk-pok-experimental")] + #[cfg(feature = "zk-pok")] pub(crate) random_generator: RandomGenerator, pub(crate) computation_buffers: ComputationBuffers, ciphertext_buffers: Memory, @@ -329,7 +329,7 @@ impl ShortintEngine { deterministic_seeder.seed(), &mut deterministic_seeder, ), - #[cfg(feature = "zk-pok-experimental")] + #[cfg(feature = "zk-pok")] random_generator: RandomGenerator::new(deterministic_seeder.seed()), seeder: deterministic_seeder, computation_buffers: ComputationBuffers::default(), diff --git a/tfhe/src/shortint/public_key/compact.rs b/tfhe/src/shortint/public_key/compact.rs index 8db9faa6c..926d3eb53 100644 --- a/tfhe/src/shortint/public_key/compact.rs +++ b/tfhe/src/shortint/public_key/compact.rs @@ -4,14 +4,14 @@ use crate::core_crypto::prelude::{ Container, LweCiphertextCount, LweCompactCiphertextListOwned, LweCompactPublicKeyOwned, LweSecretKey, Plaintext, PlaintextList, SeededLweCompactPublicKeyOwned, }; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] use crate::shortint::ciphertext::ProvenCompactCiphertextList; use crate::shortint::ciphertext::{CompactCiphertextList, Degree, NoiseLevel}; use crate::shortint::client_key::secret_encryption_key::SecretEncryptionKeyView; use crate::shortint::engine::ShortintEngine; use crate::shortint::parameters::compact_public_key_only::CompactPublicKeyEncryptionParameters; use crate::shortint::{CarryModulus, ClientKey, MessageModulus}; -#[cfg(feature = "zk-pok-experimental")] +#[cfg(feature = "zk-pok")] use crate::zk::{CompactPkePublicParams, ZkComputeLoad}; use crate::Error; use serde::{Deserialize, Serialize}; @@ -244,7 +244,7 @@ impl CompactPublicKey { Self { key, parameters } } - #[cfg(feature = "zk-pok-experimental")] + #[cfg(feature = "zk-pok")] pub fn encrypt_and_prove( &self, message: u64, @@ -358,7 +358,7 @@ impl CompactPublicKey { } } - #[cfg(feature = "zk-pok-experimental")] + #[cfg(feature = "zk-pok")] pub fn encrypt_and_prove_slice( &self, messages: &[u64],