├── .cargo └── config.toml ├── .config └── nextest.toml ├── .editorconfig ├── .gitbook.yaml ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── actionlint.yaml ├── actions │ └── gpu_setup │ │ └── action.yml ├── dependabot.yaml ├── pull_request_template.md └── workflows │ ├── approve_label.yml │ ├── aws_tfhe_backward_compat_tests.yml │ ├── aws_tfhe_fast_tests.yml │ ├── aws_tfhe_integer_tests.yml │ ├── aws_tfhe_signed_integer_tests.yml │ ├── aws_tfhe_tests.yml │ ├── aws_tfhe_wasm_tests.yml │ ├── benchmark_boolean.yml │ ├── benchmark_core_crypto.yml │ ├── benchmark_dex.yml │ ├── benchmark_erc20.yml │ ├── benchmark_gpu.yml │ ├── benchmark_gpu_4090.yml │ ├── benchmark_gpu_common.yml │ ├── benchmark_gpu_dex.yml │ ├── benchmark_gpu_dex_common.yml │ ├── benchmark_gpu_dex_weekly.yml │ ├── benchmark_gpu_erc20.yml │ ├── benchmark_gpu_erc20_common.yml │ ├── benchmark_gpu_erc20_weekly.yml │ ├── benchmark_gpu_weekly.yml │ ├── benchmark_hpu_integer.yml │ ├── benchmark_integer.yml │ ├── benchmark_shortint.yml │ ├── benchmark_signed_integer.yml │ ├── benchmark_tfhe_fft.yml │ ├── benchmark_tfhe_ntt.yml │ ├── benchmark_tfhe_zk_pok.yml │ ├── benchmark_wasm_client.yml │ ├── benchmark_zk_pke.yml │ ├── cargo_build.yml │ ├── cargo_build_tfhe_fft.yml │ ├── cargo_build_tfhe_ntt.yml │ ├── cargo_test_fft.yml │ ├── cargo_test_ntt.yml │ ├── check_commit.yml │ ├── ci_lint.yml │ ├── code_coverage.yml │ ├── csprng_randomness_tests.yml │ ├── data_pr_close.yml │ ├── gpu_4090_tests.yml │ ├── gpu_fast_h100_tests.yml │ ├── gpu_fast_tests.yml │ ├── gpu_full_h100_tests.yml │ ├── gpu_full_multi_gpu_tests.yml │ ├── gpu_integer_long_run_tests.yml │ ├── gpu_pcc.yml │ ├── gpu_signed_integer_classic_tests.yml │ ├── gpu_signed_integer_h100_tests.yml │ ├── gpu_signed_integer_tests.yml │ ├── gpu_unsigned_integer_classic_tests.yml │ ├── gpu_unsigned_integer_h100_tests.yml │ ├── gpu_unsigned_integer_tests.yml │ ├── hpu_hlapi_tests.yml │ ├── integer_long_run_tests.yml │ ├── m1_tests.yml │ ├── make_release.yml │ ├── make_release_cuda.yml │ ├── make_release_hpu.yml │ ├── make_release_tfhe_csprng.yml │ ├── make_release_tfhe_fft.yml │ ├── make_release_tfhe_ntt.yml │ ├── make_release_tfhe_versionable.yml │ ├── make_release_zk_pok.yml │ ├── parameters_check.yml │ ├── placeholder_workflow.yml │ ├── sync_on_push.yml │ └── verify_tagged_commit.yml ├── .gitignore ├── .lfsconfig ├── .linelint.yml ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.toml ├── LICENSE ├── Makefile ├── README.md ├── _typos.toml ├── apps └── trivium │ ├── Cargo.toml │ ├── README.md │ ├── benches │ ├── kreyvium_bool.rs │ ├── kreyvium_byte.rs │ ├── kreyvium_shortint.rs │ ├── trivium.rs │ ├── trivium_bool.rs │ ├── trivium_byte.rs │ └── trivium_shortint.rs │ └── src │ ├── kreyvium │ ├── kreyvium.rs │ ├── kreyvium_byte.rs │ ├── kreyvium_shortint.rs │ ├── mod.rs │ └── test.rs │ ├── lib.rs │ ├── static_deque │ ├── mod.rs │ ├── static_byte_deque.rs │ └── static_deque.rs │ ├── trans_ciphering │ └── mod.rs │ └── trivium │ ├── mod.rs │ ├── test.rs │ ├── trivium_bool.rs │ ├── trivium_byte.rs │ └── trivium_shortint.rs ├── backends ├── tfhe-cuda-backend │ ├── Cargo.toml │ ├── LICENSE │ ├── README.md │ ├── build.rs │ ├── cuda │ │ ├── .cmake-format-config.py │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── CPPLINT.cfg │ │ ├── check_cuda.cu │ │ ├── format_tfhe_cuda_backend.sh │ │ ├── include │ │ │ ├── ciphertext.h │ │ │ ├── device.h │ │ │ ├── fft │ │ │ │ └── fft128.h │ │ │ ├── helper_multi_gpu.h │ │ │ ├── integer │ │ │ │ ├── compression │ │ │ │ │ ├── compression.h │ │ │ │ │ └── compression_utilities.h │ │ │ │ ├── integer.h │ │ │ │ ├── integer_utilities.h │ │ │ │ └── radix_ciphertext.h │ │ │ ├── keyswitch │ │ │ │ ├── keyswitch.h │ │ │ │ └── ks_enums.h │ │ │ ├── linear_algebra.h │ │ │ ├── pbs │ │ │ │ ├── pbs_enums.h │ │ │ │ ├── pbs_multibit_utilities.h │ │ │ │ ├── pbs_utilities.h │ │ │ │ ├── programmable_bootstrap.h │ │ │ │ └── programmable_bootstrap_multibit.h │ │ │ └── zk │ │ │ │ ├── zk.h │ │ │ │ └── zk_utilities.h │ │ ├── src │ │ │ ├── CMakeLists.txt │ │ │ ├── crypto │ │ │ │ ├── ciphertext.cu │ │ │ │ ├── ciphertext.cuh │ │ │ │ ├── gadget.cuh │ │ │ │ ├── ggsw.cuh │ │ │ │ ├── keyswitch.cu │ │ │ │ ├── keyswitch.cuh │ │ │ │ ├── packing_keyswitch.cuh │ │ │ │ └── torus.cuh │ │ │ ├── device.cu │ │ │ ├── fft │ │ │ │ ├── bnsmfft.cuh │ │ │ │ ├── twiddles.cu │ │ │ │ └── twiddles.cuh │ │ │ ├── fft128 │ │ │ │ ├── f128.cuh │ │ │ │ ├── fft128.cu │ │ │ │ ├── fft128.cuh │ │ │ │ ├── twiddles.cu │ │ │ │ └── twiddles.cuh │ │ │ ├── integer │ │ │ │ ├── abs.cu │ │ │ │ ├── abs.cuh │ │ │ │ ├── bitwise_ops.cu │ │ │ │ ├── bitwise_ops.cuh │ │ │ │ ├── cast.cu │ │ │ │ ├── cast.cuh │ │ │ │ ├── cmux.cu │ │ │ │ ├── cmux.cuh │ │ │ │ ├── comparison.cu │ │ │ │ ├── comparison.cuh │ │ │ │ ├── compression │ │ │ │ │ ├── compression.cu │ │ │ │ │ └── compression.cuh │ │ │ │ ├── div_rem.cu │ │ │ │ ├── div_rem.cuh │ │ │ │ ├── integer.cu │ │ │ │ ├── integer.cuh │ │ │ │ ├── multiplication.cu │ │ │ │ ├── multiplication.cuh │ │ │ │ ├── negation.cu │ │ │ │ ├── negation.cuh │ │ │ │ ├── radix_ciphertext.cu │ │ │ │ ├── radix_ciphertext.cuh │ │ │ │ ├── scalar_addition.cu │ │ │ │ ├── scalar_addition.cuh │ │ │ │ ├── scalar_bitops.cu │ │ │ │ ├── scalar_bitops.cuh │ │ │ │ ├── scalar_comparison.cu │ │ │ │ ├── scalar_comparison.cuh │ │ │ │ ├── scalar_mul.cu │ │ │ │ ├── scalar_mul.cuh │ │ │ │ ├── scalar_rotate.cu │ │ │ │ ├── scalar_rotate.cuh │ │ │ │ ├── scalar_shifts.cu │ │ │ │ ├── scalar_shifts.cuh │ │ │ │ ├── shift_and_rotate.cu │ │ │ │ ├── shift_and_rotate.cuh │ │ │ │ └── subtraction.cuh │ │ │ ├── linearalgebra │ │ │ │ ├── addition.cu │ │ │ │ ├── addition.cuh │ │ │ │ ├── multiplication.cu │ │ │ │ ├── multiplication.cuh │ │ │ │ ├── negation.cu │ │ │ │ └── negation.cuh │ │ │ ├── pbs │ │ │ │ ├── bootstrapping_key.cu │ │ │ │ ├── bootstrapping_key.cuh │ │ │ │ ├── programmable_bootstrap.cu │ │ │ │ ├── programmable_bootstrap.cuh │ │ │ │ ├── programmable_bootstrap_amortized.cu │ │ │ │ ├── programmable_bootstrap_amortized.cuh │ │ │ │ ├── programmable_bootstrap_cg_classic.cuh │ │ │ │ ├── programmable_bootstrap_cg_multibit.cuh │ │ │ │ ├── programmable_bootstrap_classic.cu │ │ │ │ ├── programmable_bootstrap_classic.cuh │ │ │ │ ├── programmable_bootstrap_classic_128.cu │ │ │ │ ├── programmable_bootstrap_classic_128.cuh │ │ │ │ ├── programmable_bootstrap_multibit.cu │ │ │ │ ├── programmable_bootstrap_multibit.cuh │ │ │ │ ├── programmable_bootstrap_tbc_classic.cuh │ │ │ │ └── programmable_bootstrap_tbc_multibit.cuh │ │ │ ├── polynomial │ │ │ │ ├── dot_product.cuh │ │ │ │ ├── functions.cuh │ │ │ │ ├── parameters.cuh │ │ │ │ └── polynomial_math.cuh │ │ │ ├── types │ │ │ │ ├── complex │ │ │ │ │ └── operations.cuh │ │ │ │ └── int128.cuh │ │ │ ├── utils │ │ │ │ ├── helper.cuh │ │ │ │ ├── helper_debug.cuh │ │ │ │ ├── helper_multi_gpu.cu │ │ │ │ ├── helper_multi_gpu.cuh │ │ │ │ ├── helper_profile.cu │ │ │ │ ├── helper_profile.cuh │ │ │ │ └── kernel_dimensions.cuh │ │ │ └── zk │ │ │ │ ├── expand.cu │ │ │ │ ├── expand.cuh │ │ │ │ ├── zk.cu │ │ │ │ └── zk.cuh │ │ └── tests_and_benchmarks │ │ │ ├── CMakeLists.txt │ │ │ ├── benchmarks │ │ │ ├── CMakeLists.txt │ │ │ ├── benchmark_fft.cpp │ │ │ ├── benchmark_pbs.cpp │ │ │ └── main.cpp │ │ │ ├── include │ │ │ ├── setup_and_teardown.h │ │ │ └── utils.h │ │ │ ├── setup_and_teardown.cpp │ │ │ ├── tests │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ ├── test_classical_pbs.cpp │ │ │ ├── test_fft.cpp │ │ │ ├── test_keyswitch.cpp │ │ │ └── test_multibit_pbs.cpp │ │ │ └── utils.cpp │ ├── get_os_name.sh │ ├── src │ │ ├── bindings.rs │ │ ├── cuda_bind.rs │ │ ├── ffi.rs │ │ └── lib.rs │ └── wrapper.h └── tfhe-hpu-backend │ ├── .gitattributes │ ├── .gitignore │ ├── Cargo.toml │ ├── LICENSE │ ├── README.md │ ├── build.rs │ ├── config_store │ ├── sim │ │ ├── custom_iop │ │ │ ├── cust_0.asm │ │ │ ├── cust_1.asm │ │ │ ├── cust_10.asm │ │ │ ├── cust_16.asm │ │ │ ├── cust_17.asm │ │ │ ├── cust_18.asm │ │ │ ├── cust_19.asm │ │ │ ├── cust_2.asm │ │ │ ├── cust_20.asm │ │ │ ├── cust_21.asm │ │ │ ├── cust_3.asm │ │ │ ├── cust_8.asm │ │ │ └── cust_9.asm │ │ ├── hpu_config.toml │ │ ├── hpu_regif_core_cfg_1in3.toml │ │ ├── hpu_regif_core_cfg_3in3.toml │ │ ├── hpu_regif_core_prc_1in3.toml │ │ ├── hpu_regif_core_prc_3in3.toml │ │ └── tb_hpu_regif_dummy.toml │ ├── u55c_gf64 │ │ ├── README.md │ │ ├── custom_iop │ │ │ ├── cust_0.asm │ │ │ ├── cust_1.asm │ │ │ ├── cust_10.asm │ │ │ ├── cust_16.asm │ │ │ ├── cust_17.asm │ │ │ ├── cust_18.asm │ │ │ ├── cust_19.asm │ │ │ ├── cust_2.asm │ │ │ ├── cust_20.asm │ │ │ ├── cust_21.asm │ │ │ ├── cust_3.asm │ │ │ ├── cust_8.asm │ │ │ └── cust_9.asm │ │ ├── hpu_config.toml │ │ ├── hpu_msplit_3parts.xclbin │ │ ├── hpu_msplit_3parts.xclbin.info │ │ ├── hpu_msplit_3parts.xclbin.link_summary │ │ └── hpu_regif_core.toml │ └── v80 │ │ ├── README.md │ │ ├── custom_iop │ │ ├── cust_0.asm │ │ ├── cust_1.asm │ │ ├── cust_10.asm │ │ ├── cust_16.asm │ │ ├── cust_17.asm │ │ ├── cust_18.asm │ │ ├── cust_19.asm │ │ ├── cust_2.asm │ │ ├── cust_20.asm │ │ ├── cust_21.asm │ │ ├── cust_3.asm │ │ ├── cust_4.asm │ │ ├── cust_8.asm │ │ └── cust_9.asm │ │ ├── hpu_config.toml │ │ ├── hpu_regif_core_cfg_1in3.toml │ │ ├── hpu_regif_core_cfg_3in3.toml │ │ ├── hpu_regif_core_prc_1in3.toml │ │ └── hpu_regif_core_prc_3in3.toml │ ├── figures │ └── tfhe-hpu-backend.excalidraw.png │ ├── python │ ├── README │ ├── bin │ │ └── demo.py │ ├── data │ │ └── trace.json │ ├── lib │ │ ├── example.json │ │ └── isctrace │ │ │ ├── __init__.py │ │ │ ├── analysis.py │ │ │ ├── fmt.py │ │ │ ├── hw.py │ │ │ └── mockup.py │ └── requirements.txt │ └── src │ ├── asm │ ├── dop │ │ ├── arg.rs │ │ ├── dop_macro.rs │ │ ├── field.rs │ │ ├── fmt.rs │ │ ├── mod.rs │ │ ├── opcode.rs │ │ └── pbs_macro.rs │ ├── iop │ │ ├── arg.rs │ │ ├── field.rs │ │ ├── fmt.rs │ │ ├── iop_macro.rs │ │ ├── mod.rs │ │ └── opcode.rs │ ├── mod.rs │ └── tests │ │ ├── dop.asm │ │ ├── iop.asm │ │ └── mod.rs │ ├── entities │ ├── glwe_ciphertext.rs │ ├── glwe_lookuptable.rs │ ├── lwe_bootstrap_key.rs │ ├── lwe_ciphertext.rs │ ├── lwe_keyswitch_key.rs │ ├── mod.rs │ ├── parameters.rs │ └── traits │ │ ├── container.rs │ │ └── mod.rs │ ├── ffi │ ├── mod.rs │ ├── sim │ │ ├── ipc.rs │ │ └── mod.rs │ ├── v80 │ │ ├── ami.rs │ │ ├── mem_alloc.rs │ │ ├── mod.rs │ │ └── qdma.rs │ └── xrt │ │ ├── cxx │ │ ├── hpu_hw.cc │ │ ├── hpu_hw.h │ │ ├── mem_zone.cc │ │ ├── mem_zone.h │ │ └── mod.rs │ │ └── mod.rs │ ├── fw │ ├── fw_impl │ │ ├── demo.rs │ │ ├── ilp.rs │ │ ├── llt │ │ │ ├── kogge.rs │ │ │ ├── mod.rs │ │ │ └── vardeg.rs │ │ └── mod.rs │ ├── isc_sim │ │ ├── mod.rs │ │ ├── pe.rs │ │ ├── pool.rs │ │ ├── report.rs │ │ └── scheduler.rs │ ├── metavar.rs │ ├── mod.rs │ ├── program.rs │ └── rtl │ │ ├── config.rs │ │ ├── macros.rs │ │ └── mod.rs │ ├── interface │ ├── backend.rs │ ├── cmd.rs │ ├── config.rs │ ├── device.rs │ ├── io_dump.rs │ ├── memory │ │ ├── ciphertext.rs │ │ ├── huge.rs │ │ └── mod.rs │ ├── mod.rs │ ├── rtl │ │ ├── mod.rs │ │ ├── params.rs │ │ └── runtime.rs │ └── variable.rs │ ├── isc_trace │ ├── fmt.rs │ ├── fmt │ │ └── test │ │ │ ├── data.rs │ │ │ └── mod.rs │ ├── mod.rs │ └── packed_struct.rs │ ├── lib.rs │ ├── prelude.rs │ └── utils │ ├── dop_fmt.rs │ ├── fw.rs │ ├── hputil.rs │ └── iop_fmt.rs ├── ci ├── benchmark_parser.py ├── ec2_products_cost.json ├── fft_benchmark_parser.py ├── lattice_estimator.sage ├── ntt_benchmark_parser.py ├── parse_integer_benches_to_csv.py ├── slab.toml ├── webdriver.py └── webdriver_requirements.txt ├── codecov.yml ├── katex-header.html ├── mockups └── tfhe-hpu-mockup │ ├── Cargo.toml │ ├── Justfile │ ├── LICENSE │ ├── README.md │ ├── figures │ └── tfhe-hpu-mockup.excalidraw.png │ ├── params │ ├── gaussian_44b.toml │ ├── gaussian_44b_fast.toml │ ├── gaussian_64b.toml │ ├── gaussian_64b_fast.toml │ ├── gaussian_64b_pfail64.toml │ ├── gaussian_64b_pfail64_psi64.toml │ ├── tuniform_64b_fast.toml │ └── tuniform_64b_pfail64_psi64.toml │ └── src │ ├── ipc.rs │ ├── lib.rs │ ├── mockup.rs │ └── modules │ ├── memory │ ├── ddr.rs │ ├── hbm.rs │ └── mod.rs │ ├── mod.rs │ ├── params.rs │ ├── regmap.rs │ └── ucore.rs ├── rustfmt.toml ├── scripts ├── backward_compat_data_version.py ├── c_api_tests.sh ├── check_cargo_min_ver.sh ├── check_current_param_export.py ├── clippy_driver.sh ├── clone_backward_compat_data.sh ├── cpu_count.sh ├── dieharder_test.sh ├── generate_all_vec_for_lattice_estimator.py ├── integer-tests.sh ├── no_dbg_calls.sh ├── no_tfhe_typo.sh ├── shortint-tests.sh ├── test_filtering.py └── utils │ ├── __init__.py │ └── utils.py ├── setup_hpu.sh ├── tasks ├── Cargo.toml └── src │ ├── check_tfhe_docs_are_tested.rs │ ├── format_latex_doc.rs │ ├── main.rs │ └── utils.rs ├── tests ├── Cargo.toml ├── backward_compatibility │ ├── high_level_api.rs │ ├── mod.rs │ └── shortint.rs └── backward_compatibility_tests.rs ├── tfhe-benchmark ├── Cargo.toml ├── LICENSE ├── benches │ ├── boolean │ │ └── bench.rs │ ├── core_crypto │ │ ├── ks_bench.rs │ │ ├── ks_pbs_bench.rs │ │ ├── modulus_switch_noise_reduction.rs │ │ ├── pbs128_bench.rs │ │ └── pbs_bench.rs │ ├── high_level_api │ │ ├── bench.rs │ │ ├── dex.rs │ │ └── erc20.rs │ ├── integer │ │ ├── bench.rs │ │ ├── glwe_packing_compression.rs │ │ ├── oprf.rs │ │ ├── signed_bench.rs │ │ └── zk_pke.rs │ └── shortint │ │ ├── bench.rs │ │ ├── casting.rs │ │ ├── glwe_packing_compression.rs │ │ └── oprf.rs └── src │ ├── bin │ ├── boolean_key_sizes.rs │ ├── hlapi_compact_pk_ct_sizes.rs │ ├── shortint_key_sizes.rs │ └── wasm_benchmarks_parser.rs │ ├── lib.rs │ ├── params.rs │ ├── params_aliases.rs │ └── utilities.rs ├── tfhe-csprng ├── Cargo.toml ├── LICENSE ├── README.md ├── benches │ └── benchmark.rs ├── examples │ └── generate.rs └── src │ ├── generators │ ├── aes_ctr │ │ ├── block_cipher.rs │ │ ├── generic.rs │ │ ├── index.rs │ │ ├── mod.rs │ │ ├── parallel.rs │ │ └── states.rs │ ├── default.rs │ ├── implem │ │ ├── aarch64 │ │ │ ├── block_cipher.rs │ │ │ ├── generator.rs │ │ │ ├── mod.rs │ │ │ └── parallel.rs │ │ ├── aesni │ │ │ ├── block_cipher.rs │ │ │ ├── generator.rs │ │ │ ├── mod.rs │ │ │ └── parallel.rs │ │ ├── mod.rs │ │ └── soft │ │ │ ├── block_cipher.rs │ │ │ ├── generator.rs │ │ │ ├── mod.rs │ │ │ └── parallel.rs │ └── mod.rs │ ├── lib.rs │ └── seeders │ ├── implem │ ├── apple_secure_enclave_seeder.rs │ ├── mod.rs │ ├── rdseed.rs │ └── unix.rs │ └── mod.rs ├── tfhe-fft ├── .gitignore ├── Cargo.toml ├── LICENSE ├── Makefile ├── README.md ├── benches │ └── fft.rs ├── katex-header.html ├── rustfmt.toml └── src │ ├── dif16.rs │ ├── dif2.rs │ ├── dif4.rs │ ├── dif8.rs │ ├── dit16.rs │ ├── dit2.rs │ ├── dit4.rs │ ├── dit8.rs │ ├── fft128 │ ├── f128_ops.rs │ └── mod.rs │ ├── fft_simd.rs │ ├── lib.rs │ ├── nat.rs │ ├── ordered.rs │ ├── time │ ├── mod.rs │ └── wasm.rs │ ├── unordered.rs │ └── x86.rs ├── tfhe-ntt ├── .gitignore ├── Cargo.toml ├── LICENSE ├── README.md ├── benches │ ├── lib.rs │ └── ntt.rs ├── examples │ ├── mul_poly_native.rs │ └── mul_poly_prime.rs ├── katex-header.html ├── rustfmt.toml └── src │ ├── fastdiv.rs │ ├── lib.rs │ ├── native128.rs │ ├── native32.rs │ ├── native64.rs │ ├── native_binary128.rs │ ├── native_binary32.rs │ ├── native_binary64.rs │ ├── prime.rs │ ├── prime32.rs │ ├── prime32 │ ├── generic.rs │ ├── less_than_30bit.rs │ ├── less_than_31bit.rs │ └── shoup.rs │ ├── prime64.rs │ ├── prime64 │ ├── generic_solinas.rs │ ├── less_than_50bit.rs │ ├── less_than_51bit.rs │ ├── less_than_62bit.rs │ ├── less_than_63bit.rs │ └── shoup.rs │ ├── product.rs │ ├── roots.rs │ └── u256_impl.rs ├── tfhe-zk-pok ├── .gitignore ├── Cargo.toml ├── LICENSE ├── benches │ ├── pke_v1.rs │ ├── pke_v2.rs │ └── utils.rs └── src │ ├── backward_compatibility │ ├── mod.rs │ ├── pke.rs │ └── pke_v2.rs │ ├── curve_446 │ └── mod.rs │ ├── curve_api.rs │ ├── curve_api │ ├── bls12_381.rs │ ├── bls12_446.rs │ └── msm.rs │ ├── four_squares.rs │ ├── lib.rs │ ├── proofs │ ├── binary.rs │ ├── index.rs │ ├── mod.rs │ ├── pke.rs │ ├── pke_v2.rs │ ├── range.rs │ └── rlwe.rs │ └── serialization.rs ├── tfhe ├── .gitignore ├── CMakeLists.txt ├── Cargo.toml ├── LICENSE ├── build.rs ├── c_api_tests │ ├── .clang-format │ ├── CMakeLists.txt │ ├── test_boolean_keygen.c │ ├── test_boolean_server_key.c │ ├── test_c_doc.c │ ├── test_compressed_list.c │ ├── test_high_level_128_bits.c │ ├── test_high_level_2048.c │ ├── test_high_level_256_bits.c │ ├── test_high_level_array.c │ ├── test_high_level_boolean.c │ ├── test_high_level_compact_list.c │ ├── test_high_level_custom_integers.c │ ├── test_high_level_error.c │ ├── test_high_level_integers.c │ ├── test_high_level_integers_cuda.c │ ├── test_high_level_threading.c │ ├── test_high_level_zk.c │ ├── test_micro_bench_and.c │ ├── test_shortint_keygen.c │ ├── test_shortint_pbs.c │ └── test_shortint_server_key.c ├── cbindgen.toml ├── docs │ ├── .gitbook │ │ └── assets │ │ │ ├── build1.png │ │ │ ├── build2.png │ │ │ ├── build3.png │ │ │ ├── doc_header_tfhe-rs.png │ │ │ ├── start1.png │ │ │ ├── start2.png │ │ │ └── start3.png │ ├── README.md │ ├── SUMMARY.md │ ├── _static │ │ ├── carry.png │ │ ├── ciphertext-representation.png │ │ ├── cpu_gpu_hpu_integer_benchmark_fheuint64_tuniform_2m64_ciphertext.svg │ │ ├── cpu_integer_benchmark_tuniform_2m128_ciphertext.svg │ │ ├── cpu_integer_benchmark_tuniform_2m128_plaintext.svg │ │ ├── cpu_integer_benchmark_tuniform_2m64_ciphertext.svg │ │ ├── cpu_integer_benchmark_tuniform_2m64_plaintext.svg │ │ ├── cpu_pbs_benchmark_tuniform_2m128.svg │ │ ├── cpu_pbs_benchmark_tuniform_2m40.svg │ │ ├── cpu_pbs_benchmark_tuniform_2m64.svg │ │ ├── gpu_integer_benchmark_h100x1_multi_bit_tuniform_2m128_ciphertext.svg │ │ ├── gpu_integer_benchmark_h100x1_multi_bit_tuniform_2m128_plaintext.svg │ │ ├── gpu_integer_benchmark_h100x2_multi_bit_tuniform_2m128_ciphertext.svg │ │ ├── gpu_integer_benchmark_h100x2_multi_bit_tuniform_2m128_plaintext.svg │ │ ├── gpu_pbs_benchmark_tuniform_2m128.svg │ │ ├── gpu_pbs_benchmark_tuniform_2m40.svg │ │ ├── gpu_pbs_benchmark_tuniform_2m64.svg │ │ ├── hpu_integer_benchmark_hpux1_tuniform_2m64_ciphertext.svg │ │ ├── hpu_integer_benchmark_hpux1_tuniform_2m64_plaintext.svg │ │ ├── integer-ciphertext.png │ │ ├── lwe.png │ │ ├── multisum.png │ │ ├── overflow.png │ │ ├── sha256.png │ │ └── tfhe-rs-doc-home.png │ ├── configuration │ │ ├── gpu_acceleration │ │ │ ├── array_type.md │ │ │ ├── benchmark.md │ │ │ ├── compressing_ciphertexts.md │ │ │ ├── gpu_operations.md │ │ │ ├── multi_gpu.md │ │ │ ├── run_on_gpu.md │ │ │ └── zk-pok.md │ │ ├── hpu_acceleration │ │ │ ├── benchmark.md │ │ │ └── run_on_hpu.md │ │ ├── parallelized_pbs.md │ │ └── rust_configuration.md │ ├── explanations │ │ └── tfhe-deep-dive.md │ ├── fhe-computation │ │ ├── advanced-features │ │ │ ├── README.md │ │ │ ├── encrypted-prf.md │ │ │ ├── overflow_operations.md │ │ │ ├── public_key.md │ │ │ ├── rayon_crate.md │ │ │ ├── trivial_ciphertext.md │ │ │ └── zk-pok.md │ │ ├── compute │ │ │ ├── README.md │ │ │ ├── configure-and-generate-keys.md │ │ │ ├── decrypt-data.md │ │ │ ├── encrypt-data.md │ │ │ ├── parameters.md │ │ │ └── set-the-server-key.md │ │ ├── data-handling │ │ │ ├── README.md │ │ │ ├── compress.md │ │ │ ├── data_versioning.md │ │ │ └── serialization.md │ │ ├── operations │ │ │ ├── README.md │ │ │ ├── arithmetic-operations.md │ │ │ ├── bitwise-operations.md │ │ │ ├── boolean-operations.md │ │ │ ├── casting-operations.md │ │ │ ├── comparison-operations.md │ │ │ ├── dot-product.md │ │ │ ├── min-max-operations.md │ │ │ ├── string-operations.md │ │ │ └── ternary-conditional-operations.md │ │ ├── tooling │ │ │ ├── README.md │ │ │ ├── debug.md │ │ │ ├── pbs-stats.md │ │ │ └── trait_bounds.md │ │ └── types │ │ │ ├── README.md │ │ │ ├── array.md │ │ │ ├── integer.md │ │ │ └── strings.md │ ├── getting_started │ │ ├── README.md │ │ ├── benchmarks │ │ │ ├── README.md │ │ │ ├── cpu │ │ │ │ ├── README.md │ │ │ │ ├── cpu_integer_operations.md │ │ │ │ └── cpu_programmable_bootstrapping.md │ │ │ ├── gpu │ │ │ │ ├── README.md │ │ │ │ ├── gpu_integer_operations.md │ │ │ │ └── gpu_programmable_bootstrapping.md │ │ │ ├── hpu │ │ │ │ ├── README.md │ │ │ │ └── hpu_integer_operations.md │ │ │ └── zk_proof_benchmarks.md │ │ ├── installation.md │ │ ├── quick_start.md │ │ └── security_and_cryptography.md │ ├── integration │ │ ├── c_api.md │ │ └── js_on_wasm_api.md │ ├── references │ │ ├── core-crypto-api │ │ │ ├── README.md │ │ │ ├── presentation.md │ │ │ └── tutorial.md │ │ └── fine-grained-apis │ │ │ ├── README.md │ │ │ ├── boolean │ │ │ ├── README.md │ │ │ ├── operations.md │ │ │ ├── parameters.md │ │ │ └── serialization.md │ │ │ ├── integer │ │ │ ├── README.md │ │ │ ├── operations.md │ │ │ ├── parameters.md │ │ │ └── serialization.md │ │ │ ├── quick_start.md │ │ │ └── shortint │ │ │ ├── README.md │ │ │ ├── operations.md │ │ │ ├── parameters.md │ │ │ └── serialization.md │ └── tutorials │ │ ├── ascii_fhe_string.md │ │ ├── parity_bit.md │ │ ├── see-all-tutorials.md │ │ └── sha256_bool.md ├── examples │ ├── dark_market │ │ ├── fhe.rs │ │ ├── improved_parallel_fhe.rs │ │ ├── improved_plain.rs │ │ ├── main.rs │ │ ├── parallel_fhe.rs │ │ └── plain.rs │ ├── dist_tuniform.rs │ ├── hpu │ │ ├── bench.rs │ │ ├── hlapi.rs │ │ └── matmul.rs │ ├── pbs_count.rs │ ├── regex_engine │ │ ├── ciphertext.rs │ │ ├── engine.rs │ │ ├── execution.rs │ │ ├── main.rs │ │ └── parser.rs │ ├── sha256.rs │ ├── sha256_bool │ │ ├── boolean_ops.rs │ │ ├── main.rs │ │ ├── padding.rs │ │ └── sha256_function.rs │ └── utilities │ │ ├── generates_test_keys.rs │ │ ├── micro_bench_and.rs │ │ ├── params_to_file.rs │ │ └── print_doc_bench_parameters.rs ├── js_on_wasm_tests │ ├── .prettierignore │ ├── Makefile │ ├── index.js │ ├── package.json │ ├── test-hlapi-signed.js │ ├── test-hlapi-unsigned.js │ └── test.js ├── katex-header.html ├── src │ ├── boolean │ │ ├── backward_compatibility │ │ │ ├── ciphertext.rs │ │ │ ├── client_key.rs │ │ │ ├── key_switching_key.rs │ │ │ ├── mod.rs │ │ │ ├── parameters.rs │ │ │ ├── public_key.rs │ │ │ └── server_key.rs │ │ ├── ciphertext │ │ │ └── mod.rs │ │ ├── client_key │ │ │ └── mod.rs │ │ ├── engine │ │ │ ├── bootstrapping.rs │ │ │ ├── mod.rs │ │ │ └── tests.rs │ │ ├── key_switching_key │ │ │ ├── mod.rs │ │ │ └── test.rs │ │ ├── keycache.rs │ │ ├── mod.rs │ │ ├── parameters │ │ │ ├── mod.rs │ │ │ └── params.rs │ │ ├── prelude.rs │ │ ├── public_key │ │ │ ├── compressed.rs │ │ │ ├── mod.rs │ │ │ └── standard.rs │ │ └── server_key │ │ │ ├── mod.rs │ │ │ └── tests.rs │ ├── c_api │ │ ├── boolean │ │ │ ├── ciphertext.rs │ │ │ ├── client_key.rs │ │ │ ├── destroy.rs │ │ │ ├── mod.rs │ │ │ ├── parameters.rs │ │ │ ├── public_key.rs │ │ │ └── server_key.rs │ │ ├── buffer.rs │ │ ├── core_crypto │ │ │ └── mod.rs │ │ ├── error.rs │ │ ├── high_level_api │ │ │ ├── array.rs │ │ │ ├── booleans.rs │ │ │ ├── compact_list.rs │ │ │ ├── compressed_ciphertext_list.rs │ │ │ ├── config.rs │ │ │ ├── i1024.rs │ │ │ ├── i128.rs │ │ │ ├── i2048.rs │ │ │ ├── i256.rs │ │ │ ├── i512.rs │ │ │ ├── integers.rs │ │ │ ├── keys.rs │ │ │ ├── mod.rs │ │ │ ├── threading.rs │ │ │ ├── u1024.rs │ │ │ ├── u128.rs │ │ │ ├── u2048.rs │ │ │ ├── u256.rs │ │ │ ├── u512.rs │ │ │ ├── utils.rs │ │ │ └── zk.rs │ │ ├── mod.rs │ │ ├── shortint │ │ │ ├── ciphertext.rs │ │ │ ├── client_key.rs │ │ │ ├── destroy.rs │ │ │ ├── mod.rs │ │ │ ├── parameters.rs │ │ │ ├── public_key.rs │ │ │ └── server_key │ │ │ │ ├── add.rs │ │ │ │ ├── bitwise_op.rs │ │ │ │ ├── comp_op.rs │ │ │ │ ├── div_mod.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── mul.rs │ │ │ │ ├── neg.rs │ │ │ │ ├── pbs.rs │ │ │ │ ├── scalar_add.rs │ │ │ │ ├── scalar_mul.rs │ │ │ │ ├── scalar_sub.rs │ │ │ │ ├── shift.rs │ │ │ │ └── sub.rs │ │ └── utils.rs │ ├── conformance.rs │ ├── core_crypto │ │ ├── algorithms │ │ │ ├── ggsw_conversion.rs │ │ │ ├── ggsw_encryption.rs │ │ │ ├── glwe_encryption.rs │ │ │ ├── glwe_keyswitch.rs │ │ │ ├── glwe_keyswitch_key_generation.rs │ │ │ ├── glwe_linear_algebra.rs │ │ │ ├── glwe_sample_extraction.rs │ │ │ ├── glwe_secret_key_generation.rs │ │ │ ├── lwe_bootstrap_key_conversion.rs │ │ │ ├── lwe_bootstrap_key_generation.rs │ │ │ ├── lwe_compact_ciphertext_list_expansion.rs │ │ │ ├── lwe_compact_public_key_generation.rs │ │ │ ├── lwe_encryption.rs │ │ │ ├── lwe_keyswitch.rs │ │ │ ├── lwe_keyswitch_key_generation.rs │ │ │ ├── lwe_linear_algebra.rs │ │ │ ├── lwe_multi_bit_bootstrap_key_conversion.rs │ │ │ ├── lwe_multi_bit_bootstrap_key_generation.rs │ │ │ ├── lwe_multi_bit_programmable_bootstrapping.rs │ │ │ ├── lwe_packing_keyswitch.rs │ │ │ ├── lwe_packing_keyswitch_key_generation.rs │ │ │ ├── lwe_private_functional_packing_keyswitch.rs │ │ │ ├── lwe_private_functional_packing_keyswitch_key_generation.rs │ │ │ ├── lwe_programmable_bootstrapping │ │ │ │ ├── fft128_pbs.rs │ │ │ │ ├── fft64_pbs.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── ntt64_bnf_pbs.rs │ │ │ │ └── ntt64_pbs.rs │ │ │ ├── lwe_public_key_generation.rs │ │ │ ├── lwe_secret_key_generation.rs │ │ │ ├── lwe_wopbs.rs │ │ │ ├── lwe_zero_knowledge_verification.rs │ │ │ ├── misc.rs │ │ │ ├── mod.rs │ │ │ ├── modulus_switch_noise_reduction.rs │ │ │ ├── polynomial_algorithms.rs │ │ │ ├── seeded_ggsw_ciphertext_decompression.rs │ │ │ ├── seeded_ggsw_ciphertext_list_decompression.rs │ │ │ ├── seeded_glwe_ciphertext_decompression.rs │ │ │ ├── seeded_glwe_ciphertext_list_decompression.rs │ │ │ ├── seeded_lwe_bootstrap_key_decompression.rs │ │ │ ├── seeded_lwe_ciphertext_decompression.rs │ │ │ ├── seeded_lwe_ciphertext_list_decompression.rs │ │ │ ├── seeded_lwe_compact_public_key_decompression.rs │ │ │ ├── seeded_lwe_keyswitch_key_decompression.rs │ │ │ ├── seeded_lwe_multi_bit_bootstrap_key_decompression.rs │ │ │ ├── seeded_lwe_packing_keyswitch_key_decompression.rs │ │ │ ├── seeded_lwe_public_key_decompression.rs │ │ │ ├── slice_algorithms.rs │ │ │ └── test │ │ │ │ ├── ggsw_encryption.rs │ │ │ │ ├── glwe_encryption.rs │ │ │ │ ├── glwe_linear_algebra.rs │ │ │ │ ├── glwe_sample_extraction.rs │ │ │ │ ├── lwe_bootstrap_key_generation.rs │ │ │ │ ├── lwe_compact_public_key_generation.rs │ │ │ │ ├── lwe_encryption.rs │ │ │ │ ├── lwe_keyswitch.rs │ │ │ │ ├── lwe_keyswitch_key_generation.rs │ │ │ │ ├── lwe_linear_algebra.rs │ │ │ │ ├── lwe_multi_bit_bootstrap_key_generation.rs │ │ │ │ ├── lwe_multi_bit_programmable_bootstrapping.rs │ │ │ │ ├── lwe_packing_keyswitch.rs │ │ │ │ ├── lwe_packing_keyswitch_key_generation.rs │ │ │ │ ├── lwe_private_functional_packing_keyswitch.rs │ │ │ │ ├── lwe_programmable_bootstrapping.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── modulus_switch_compression.rs │ │ │ │ ├── modulus_switch_noise_reduction.rs │ │ │ │ ├── noise_distribution │ │ │ │ ├── lwe_encryption_noise.rs │ │ │ │ ├── lwe_hpu_noise.rs │ │ │ │ ├── lwe_keyswitch_noise.rs │ │ │ │ ├── lwe_multi_bit_programmable_bootstrapping_noise.rs │ │ │ │ ├── lwe_programmable_bootstrapping_noise.rs │ │ │ │ ├── mod.rs │ │ │ │ └── variance_formula │ │ │ │ │ ├── lwe_keyswitch.rs │ │ │ │ │ ├── lwe_programmable_bootstrap.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── secure_noise.rs │ │ │ │ └── params.rs │ │ ├── backward_compatibility │ │ │ ├── commons │ │ │ │ ├── ciphertext_modulus.rs │ │ │ │ ├── dispersion.rs │ │ │ │ ├── math │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── random │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── mod.rs │ │ │ │ └── parameters.rs │ │ │ ├── entities │ │ │ │ ├── cleartext.rs │ │ │ │ ├── compressed_modulus_switched_glwe_ciphertext.rs │ │ │ │ ├── compressed_modulus_switched_lwe_ciphertext.rs │ │ │ │ ├── compressed_modulus_switched_multi_bit_lwe_ciphertext.rs │ │ │ │ ├── ggsw_ciphertext.rs │ │ │ │ ├── ggsw_ciphertext_list.rs │ │ │ │ ├── glwe_ciphertext.rs │ │ │ │ ├── glwe_ciphertext_list.rs │ │ │ │ ├── glwe_keyswitch_key.rs │ │ │ │ ├── glwe_secret_key.rs │ │ │ │ ├── gsw_ciphertext.rs │ │ │ │ ├── lwe_bootstrap_key.rs │ │ │ │ ├── lwe_bootstrap_key_chunk.rs │ │ │ │ ├── lwe_ciphertext.rs │ │ │ │ ├── lwe_ciphertext_list.rs │ │ │ │ ├── lwe_compact_ciphertext_list.rs │ │ │ │ ├── lwe_compact_public_key.rs │ │ │ │ ├── lwe_keyswitch_key.rs │ │ │ │ ├── lwe_keyswitch_key_chunk.rs │ │ │ │ ├── lwe_multi_bit_bootstrap_key.rs │ │ │ │ ├── lwe_packing_keyswitch_key.rs │ │ │ │ ├── lwe_private_functional_packing_keyswitch_key.rs │ │ │ │ ├── lwe_private_functional_packing_keyswitch_key_list.rs │ │ │ │ ├── lwe_public_key.rs │ │ │ │ ├── lwe_secret_key.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── ntt_ggsw_ciphertext.rs │ │ │ │ ├── ntt_ggsw_ciphertext_list.rs │ │ │ │ ├── ntt_lwe_bootstrap_key.rs │ │ │ │ ├── packed_integers.rs │ │ │ │ ├── plaintext.rs │ │ │ │ ├── plaintext_list.rs │ │ │ │ ├── polynomial.rs │ │ │ │ ├── polynomial_list.rs │ │ │ │ ├── seeded_ggsw_ciphertext.rs │ │ │ │ ├── seeded_ggsw_ciphertext_list.rs │ │ │ │ ├── seeded_glwe_ciphertext.rs │ │ │ │ ├── seeded_glwe_ciphertext_list.rs │ │ │ │ ├── seeded_lwe_bootstrap_key.rs │ │ │ │ ├── seeded_lwe_bootstrap_key_chunk.rs │ │ │ │ ├── seeded_lwe_ciphertext.rs │ │ │ │ ├── seeded_lwe_ciphertext_list.rs │ │ │ │ ├── seeded_lwe_compact_public_key.rs │ │ │ │ ├── seeded_lwe_keyswitch_key.rs │ │ │ │ ├── seeded_lwe_keyswitch_key_chunk.rs │ │ │ │ ├── seeded_lwe_multi_bit_bootstrap_key.rs │ │ │ │ ├── seeded_lwe_packing_keyswitch_key.rs │ │ │ │ └── seeded_lwe_public_key.rs │ │ │ ├── fft_impl │ │ │ │ └── mod.rs │ │ │ └── mod.rs │ │ ├── commons │ │ │ ├── ciphertext_modulus.rs │ │ │ ├── computation_buffers.rs │ │ │ ├── dispersion.rs │ │ │ ├── generators │ │ │ │ ├── encryption │ │ │ │ │ ├── mask_random_generator.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── noise_random_generator.rs │ │ │ │ │ └── test.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── secret.rs │ │ │ │ └── seeder.rs │ │ │ ├── math │ │ │ │ ├── decomposition │ │ │ │ │ ├── decomposer.rs │ │ │ │ │ ├── iter.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── term.rs │ │ │ │ │ └── tests.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── ntt │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── ntt64.rs │ │ │ │ ├── random │ │ │ │ │ ├── gaussian.rs │ │ │ │ │ ├── generator.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── t_uniform.rs │ │ │ │ │ ├── tests.rs │ │ │ │ │ ├── uniform.rs │ │ │ │ │ ├── uniform_binary.rs │ │ │ │ │ └── uniform_ternary.rs │ │ │ │ └── torus │ │ │ │ │ └── mod.rs │ │ │ ├── mod.rs │ │ │ ├── noise_formulas │ │ │ │ ├── lwe_keyswitch.rs │ │ │ │ ├── lwe_multi_bit_programmable_bootstrap.rs │ │ │ │ ├── lwe_programmable_bootstrap.rs │ │ │ │ ├── mod.rs │ │ │ │ └── secure_noise.rs │ │ │ ├── numeric │ │ │ │ ├── float.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── signed.rs │ │ │ │ └── unsigned.rs │ │ │ ├── parameters.rs │ │ │ ├── traits │ │ │ │ ├── container.rs │ │ │ │ ├── contiguous_entity_container.rs │ │ │ │ ├── create_from.rs │ │ │ │ ├── encryptable.rs │ │ │ │ └── mod.rs │ │ │ └── utils.rs │ │ ├── entities │ │ │ ├── cleartext.rs │ │ │ ├── compressed_modulus_switched_glwe_ciphertext.rs │ │ │ ├── compressed_modulus_switched_lwe_ciphertext.rs │ │ │ ├── compressed_modulus_switched_multi_bit_lwe_ciphertext.rs │ │ │ ├── ggsw_ciphertext.rs │ │ │ ├── ggsw_ciphertext_list.rs │ │ │ ├── glwe_ciphertext.rs │ │ │ ├── glwe_ciphertext_list.rs │ │ │ ├── glwe_keyswitch_key.rs │ │ │ ├── glwe_secret_key.rs │ │ │ ├── gsw_ciphertext.rs │ │ │ ├── lwe_bootstrap_key.rs │ │ │ ├── lwe_bootstrap_key_chunk.rs │ │ │ ├── lwe_ciphertext.rs │ │ │ ├── lwe_ciphertext_list.rs │ │ │ ├── lwe_compact_ciphertext_list.rs │ │ │ ├── lwe_compact_public_key.rs │ │ │ ├── lwe_keyswitch_key.rs │ │ │ ├── lwe_keyswitch_key_chunk.rs │ │ │ ├── lwe_multi_bit_bootstrap_key.rs │ │ │ ├── lwe_packing_keyswitch_key.rs │ │ │ ├── lwe_private_functional_packing_keyswitch_key.rs │ │ │ ├── lwe_private_functional_packing_keyswitch_key_list.rs │ │ │ ├── lwe_public_key.rs │ │ │ ├── lwe_secret_key.rs │ │ │ ├── mod.rs │ │ │ ├── ntt_ggsw_ciphertext.rs │ │ │ ├── ntt_ggsw_ciphertext_list.rs │ │ │ ├── ntt_lwe_bootstrap_key.rs │ │ │ ├── packed_integers.rs │ │ │ ├── plaintext.rs │ │ │ ├── plaintext_list.rs │ │ │ ├── polynomial.rs │ │ │ ├── polynomial_list.rs │ │ │ ├── seeded_ggsw_ciphertext.rs │ │ │ ├── seeded_ggsw_ciphertext_list.rs │ │ │ ├── seeded_glwe_ciphertext.rs │ │ │ ├── seeded_glwe_ciphertext_list.rs │ │ │ ├── seeded_lwe_bootstrap_key.rs │ │ │ ├── seeded_lwe_bootstrap_key_chunk.rs │ │ │ ├── seeded_lwe_ciphertext.rs │ │ │ ├── seeded_lwe_ciphertext_list.rs │ │ │ ├── seeded_lwe_compact_public_key.rs │ │ │ ├── seeded_lwe_keyswitch_key.rs │ │ │ ├── seeded_lwe_keyswitch_key_chunk.rs │ │ │ ├── seeded_lwe_multi_bit_bootstrap_key.rs │ │ │ ├── seeded_lwe_packing_keyswitch_key.rs │ │ │ └── seeded_lwe_public_key.rs │ │ ├── experimental │ │ │ ├── algorithms │ │ │ │ ├── glwe_fast_keyswitch.rs │ │ │ │ ├── glwe_partial_sample_extraction.rs │ │ │ │ ├── lwe_shrinking_keyswitch.rs │ │ │ │ ├── lwe_shrinking_keyswitch_key_generation.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── partial_glwe_secret_key_generation.rs │ │ │ │ ├── pseudo_ggsw_conversion.rs │ │ │ │ ├── pseudo_ggsw_encryption.rs │ │ │ │ ├── shared_glwe_secret_key_generation.rs │ │ │ │ ├── shared_lwe_secret_key_generation.rs │ │ │ │ └── test │ │ │ │ │ ├── lwe_fast_keyswitch.rs │ │ │ │ │ ├── lwe_stair_keyswitch.rs │ │ │ │ │ └── mod.rs │ │ │ ├── commons │ │ │ │ ├── mod.rs │ │ │ │ └── parameters.rs │ │ │ ├── entities │ │ │ │ ├── fourier_pseudo_ggsw_ciphertext.rs │ │ │ │ ├── lwe_shrinking_keyswitch_key.rs │ │ │ │ ├── mod.rs │ │ │ │ └── pseudo_ggsw_ciphertext.rs │ │ │ ├── mod.rs │ │ │ └── prelude.rs │ │ ├── fft_impl │ │ │ ├── common.rs │ │ │ ├── fft128 │ │ │ │ ├── crypto │ │ │ │ │ ├── bootstrap.rs │ │ │ │ │ ├── ggsw.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tests.rs │ │ │ │ ├── math │ │ │ │ │ ├── fft │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ └── tests.rs │ │ │ │ │ └── mod.rs │ │ │ │ └── mod.rs │ │ │ ├── fft128_u128 │ │ │ │ ├── crypto │ │ │ │ │ ├── bootstrap.rs │ │ │ │ │ ├── ggsw.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tests.rs │ │ │ │ ├── math │ │ │ │ │ ├── fft │ │ │ │ │ │ └── mod.rs │ │ │ │ │ └── mod.rs │ │ │ │ └── mod.rs │ │ │ ├── fft64 │ │ │ │ ├── crypto │ │ │ │ │ ├── bootstrap.rs │ │ │ │ │ ├── ggsw.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── tests.rs │ │ │ │ │ └── wop_pbs │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ └── tests.rs │ │ │ │ ├── math │ │ │ │ │ ├── decomposition.rs │ │ │ │ │ ├── fft │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── tests.rs │ │ │ │ │ │ └── x86.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── polynomial.rs │ │ │ │ └── mod.rs │ │ │ └── mod.rs │ │ ├── gpu │ │ │ ├── algorithms │ │ │ │ ├── glwe_linear_algebra.rs │ │ │ │ ├── glwe_sample_extraction.rs │ │ │ │ ├── lwe_keyswitch.rs │ │ │ │ ├── lwe_linear_algebra.rs │ │ │ │ ├── lwe_multi_bit_programmable_bootstrapping.rs │ │ │ │ ├── lwe_packing_keyswitch.rs │ │ │ │ ├── lwe_programmable_bootstrapping.rs │ │ │ │ ├── mod.rs │ │ │ │ └── test │ │ │ │ │ ├── fft.rs │ │ │ │ │ ├── glwe_dot_product_with_clear.rs │ │ │ │ │ ├── glwe_sample_extraction.rs │ │ │ │ │ ├── lwe_keyswitch.rs │ │ │ │ │ ├── lwe_linear_algebra.rs │ │ │ │ │ ├── lwe_multi_bit_programmable_bootstrapping.rs │ │ │ │ │ ├── lwe_packing_keyswitch.rs │ │ │ │ │ ├── lwe_programmable_bootstrapping.rs │ │ │ │ │ ├── lwe_programmable_bootstrapping_128.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── modulus_switch_noise_reduction.rs │ │ │ │ │ └── noise_distribution │ │ │ │ │ ├── lwe_multi_bit_programmable_bootstrapping_noise.rs │ │ │ │ │ ├── lwe_programmable_bootstrapping_noise.rs │ │ │ │ │ └── mod.rs │ │ │ ├── entities │ │ │ │ ├── glwe_ciphertext_list.rs │ │ │ │ ├── lwe_bootstrap_key.rs │ │ │ │ ├── lwe_ciphertext_list.rs │ │ │ │ ├── lwe_compact_ciphertext_list.rs │ │ │ │ ├── lwe_keyswitch_key.rs │ │ │ │ ├── lwe_multi_bit_bootstrap_key.rs │ │ │ │ ├── lwe_packing_keyswitch_key.rs │ │ │ │ └── mod.rs │ │ │ ├── mod.rs │ │ │ ├── slice.rs │ │ │ └── vec.rs │ │ ├── hpu │ │ │ ├── algorithms │ │ │ │ ├── mod.rs │ │ │ │ ├── modswitch.rs │ │ │ │ └── order.rs │ │ │ ├── entities │ │ │ │ ├── glwe_ciphertext.rs │ │ │ │ ├── glwe_lookuptable.rs │ │ │ │ ├── lwe_bootstrap_key.rs │ │ │ │ ├── lwe_ciphertext.rs │ │ │ │ ├── lwe_keyswitch_key.rs │ │ │ │ └── mod.rs │ │ │ └── mod.rs │ │ ├── keycache.rs │ │ ├── mod.rs │ │ ├── prelude.rs │ │ └── seeders.rs │ ├── error.rs │ ├── high_level_api │ │ ├── array │ │ │ ├── clear_ops.rs │ │ │ ├── cpu │ │ │ │ ├── booleans.rs │ │ │ │ ├── integers.rs │ │ │ │ └── mod.rs │ │ │ ├── dynamic │ │ │ │ ├── booleans.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── signed.rs │ │ │ │ └── unsigned.rs │ │ │ ├── gpu │ │ │ │ ├── booleans.rs │ │ │ │ ├── integers.rs │ │ │ │ └── mod.rs │ │ │ ├── helpers.rs │ │ │ ├── mod.rs │ │ │ ├── ops.rs │ │ │ ├── stride.rs │ │ │ ├── tests │ │ │ │ ├── booleans.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── signed.rs │ │ │ │ └── unsigned.rs │ │ │ └── traits.rs │ │ ├── backward_compatibility │ │ │ ├── booleans.rs │ │ │ ├── compact_list.rs │ │ │ ├── compressed_ciphertext_list.rs │ │ │ ├── config.rs │ │ │ ├── integers.rs │ │ │ ├── keys.rs │ │ │ ├── mod.rs │ │ │ ├── strings.rs │ │ │ └── tag.rs │ │ ├── booleans │ │ │ ├── base.rs │ │ │ ├── compressed.rs │ │ │ ├── encrypt.rs │ │ │ ├── inner.rs │ │ │ ├── mod.rs │ │ │ ├── oprf.rs │ │ │ ├── squashed_noise.rs │ │ │ └── tests.rs │ │ ├── compact_list.rs │ │ ├── compressed_ciphertext_list.rs │ │ ├── config.rs │ │ ├── details.rs │ │ ├── errors.rs │ │ ├── global_state.rs │ │ ├── gpu_utils.rs │ │ ├── integers │ │ │ ├── mod.rs │ │ │ ├── oprf.rs │ │ │ ├── signed │ │ │ │ ├── base.rs │ │ │ │ ├── compressed.rs │ │ │ │ ├── encrypt.rs │ │ │ │ ├── inner.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── ops.rs │ │ │ │ ├── overflowing_ops.rs │ │ │ │ ├── scalar_ops.rs │ │ │ │ ├── squashed_noise.rs │ │ │ │ ├── static_.rs │ │ │ │ └── tests │ │ │ │ │ ├── cpu.rs │ │ │ │ │ ├── gpu.rs │ │ │ │ │ └── mod.rs │ │ │ └── unsigned │ │ │ │ ├── base.rs │ │ │ │ ├── compressed.rs │ │ │ │ ├── encrypt.rs │ │ │ │ ├── inner.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── ops.rs │ │ │ │ ├── overflowing_ops.rs │ │ │ │ ├── scalar_ops.rs │ │ │ │ ├── squashed_noise.rs │ │ │ │ ├── static_.rs │ │ │ │ └── tests │ │ │ │ ├── cpu.rs │ │ │ │ ├── gpu.rs │ │ │ │ ├── hpu.rs │ │ │ │ └── mod.rs │ │ ├── keys │ │ │ ├── client.rs │ │ │ ├── inner.rs │ │ │ ├── key_switching_key.rs │ │ │ ├── mod.rs │ │ │ ├── public.rs │ │ │ └── server.rs │ │ ├── mod.rs │ │ ├── prelude.rs │ │ ├── strings │ │ │ ├── ascii │ │ │ │ ├── comp.rs │ │ │ │ ├── contains.rs │ │ │ │ ├── find.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── no_pattern.rs │ │ │ │ ├── replace.rs │ │ │ │ ├── strip.rs │ │ │ │ └── trim.rs │ │ │ ├── mod.rs │ │ │ ├── tests │ │ │ │ ├── cpu.rs │ │ │ │ └── mod.rs │ │ │ └── traits.rs │ │ ├── tag.rs │ │ ├── tests │ │ │ ├── gpu_selection.rs │ │ │ ├── mod.rs │ │ │ ├── noise_squashing.rs │ │ │ └── tags_on_entities.rs │ │ ├── traits.rs │ │ ├── utils.rs │ │ └── zk.rs │ ├── integer │ │ ├── backward_compatibility │ │ │ ├── ciphertext │ │ │ │ └── mod.rs │ │ │ ├── client_key │ │ │ │ └── mod.rs │ │ │ ├── key_switching_key.rs │ │ │ ├── list_compression.rs │ │ │ ├── mod.rs │ │ │ ├── noise_squashing.rs │ │ │ ├── public_key │ │ │ │ └── mod.rs │ │ │ └── server_key │ │ │ │ └── mod.rs │ │ ├── bigint │ │ │ ├── algorithms.rs │ │ │ ├── i256.rs │ │ │ ├── i512.rs │ │ │ ├── mod.rs │ │ │ ├── static_signed.rs │ │ │ ├── static_unsigned.rs │ │ │ ├── u256.rs │ │ │ └── u512.rs │ │ ├── block_decomposition.rs │ │ ├── ciphertext │ │ │ ├── base.rs │ │ │ ├── boolean_value.rs │ │ │ ├── compact_list.rs │ │ │ ├── compressed.rs │ │ │ ├── compressed_ciphertext_list.rs │ │ │ ├── compressed_modulus_switched_ciphertext.rs │ │ │ ├── integer_ciphertext.rs │ │ │ ├── mod.rs │ │ │ ├── squashed_noise.rs │ │ │ └── utils.rs │ │ ├── client_key │ │ │ ├── crt.rs │ │ │ ├── mod.rs │ │ │ ├── radix.rs │ │ │ ├── secret_encryption_key.rs │ │ │ └── utils.rs │ │ ├── compression_keys.rs │ │ ├── encryption.rs │ │ ├── gpu │ │ │ ├── ciphertext │ │ │ │ ├── boolean_value.rs │ │ │ │ ├── compact_list.rs │ │ │ │ ├── compressed_ciphertext_list.rs │ │ │ │ ├── info.rs │ │ │ │ └── mod.rs │ │ │ ├── client_key │ │ │ │ ├── mod.rs │ │ │ │ └── radix.rs │ │ │ ├── key_switching_key │ │ │ │ └── mod.rs │ │ │ ├── list_compression │ │ │ │ ├── compressed_server_keys.rs │ │ │ │ ├── mod.rs │ │ │ │ └── server_keys.rs │ │ │ ├── mod.rs │ │ │ ├── server_key │ │ │ │ ├── mod.rs │ │ │ │ └── radix │ │ │ │ │ ├── abs.rs │ │ │ │ │ ├── add.rs │ │ │ │ │ ├── bitwise_op.rs │ │ │ │ │ ├── cmux.rs │ │ │ │ │ ├── comparison.rs │ │ │ │ │ ├── div_mod.rs │ │ │ │ │ ├── even_odd.rs │ │ │ │ │ ├── ilog2.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── mul.rs │ │ │ │ │ ├── neg.rs │ │ │ │ │ ├── oprf.rs │ │ │ │ │ ├── rotate.rs │ │ │ │ │ ├── scalar_add.rs │ │ │ │ │ ├── scalar_bitwise_op.rs │ │ │ │ │ ├── scalar_comparison.rs │ │ │ │ │ ├── scalar_div_mod.rs │ │ │ │ │ ├── scalar_mul.rs │ │ │ │ │ ├── scalar_rotate.rs │ │ │ │ │ ├── scalar_shift.rs │ │ │ │ │ ├── scalar_sub.rs │ │ │ │ │ ├── shift.rs │ │ │ │ │ ├── sub.rs │ │ │ │ │ ├── tests_long_run │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── test_erc20.rs │ │ │ │ │ ├── test_random_op_sequence.rs │ │ │ │ │ ├── test_signed_erc20.rs │ │ │ │ │ └── test_signed_random_op_sequence.rs │ │ │ │ │ ├── tests_signed │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── test_abs.rs │ │ │ │ │ ├── test_add.rs │ │ │ │ │ ├── test_bitwise_op.rs │ │ │ │ │ ├── test_cmux.rs │ │ │ │ │ ├── test_comparison.rs │ │ │ │ │ ├── test_div_mod.rs │ │ │ │ │ ├── test_ilog2.rs │ │ │ │ │ ├── test_mul.rs │ │ │ │ │ ├── test_neg.rs │ │ │ │ │ ├── test_rotate.rs │ │ │ │ │ ├── test_scalar_add.rs │ │ │ │ │ ├── test_scalar_bitwise_op.rs │ │ │ │ │ ├── test_scalar_comparison.rs │ │ │ │ │ ├── test_scalar_div_mod.rs │ │ │ │ │ ├── test_scalar_mul.rs │ │ │ │ │ ├── test_scalar_rotate.rs │ │ │ │ │ ├── test_scalar_shift.rs │ │ │ │ │ ├── test_scalar_sub.rs │ │ │ │ │ ├── test_shift.rs │ │ │ │ │ ├── test_sub.rs │ │ │ │ │ └── test_vector_comparisons.rs │ │ │ │ │ ├── tests_unsigned │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── test_add.rs │ │ │ │ │ ├── test_bitwise_op.rs │ │ │ │ │ ├── test_cmux.rs │ │ │ │ │ ├── test_comparison.rs │ │ │ │ │ ├── test_div_mod.rs │ │ │ │ │ ├── test_ilog2.rs │ │ │ │ │ ├── test_mul.rs │ │ │ │ │ ├── test_neg.rs │ │ │ │ │ ├── test_rotate.rs │ │ │ │ │ ├── test_scalar_add.rs │ │ │ │ │ ├── test_scalar_bitwise_op.rs │ │ │ │ │ ├── test_scalar_comparison.rs │ │ │ │ │ ├── test_scalar_div_mod.rs │ │ │ │ │ ├── test_scalar_mul.rs │ │ │ │ │ ├── test_scalar_rotate.rs │ │ │ │ │ ├── test_scalar_shift.rs │ │ │ │ │ ├── test_scalar_sub.rs │ │ │ │ │ ├── test_shift.rs │ │ │ │ │ ├── test_sub.rs │ │ │ │ │ ├── test_vector_comparisons.rs │ │ │ │ │ └── test_vector_find.rs │ │ │ │ │ ├── vector_comparisons.rs │ │ │ │ │ └── vector_find.rs │ │ │ └── zk │ │ │ │ └── mod.rs │ │ ├── hpu │ │ │ ├── ciphertext │ │ │ │ └── mod.rs │ │ │ └── mod.rs │ │ ├── key_switching_key │ │ │ ├── mod.rs │ │ │ └── test.rs │ │ ├── keycache.rs │ │ ├── mod.rs │ │ ├── noise_squashing │ │ │ ├── keys.rs │ │ │ ├── mod.rs │ │ │ └── tests.rs │ │ ├── oprf.rs │ │ ├── parameters │ │ │ └── mod.rs │ │ ├── prelude.rs │ │ ├── public_key │ │ │ ├── compact.rs │ │ │ ├── compressed.rs │ │ │ ├── mod.rs │ │ │ ├── standard.rs │ │ │ └── tests.rs │ │ ├── server_key │ │ │ ├── comparator.rs │ │ │ ├── crt │ │ │ │ ├── add_crt.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── mul_crt.rs │ │ │ │ ├── neg_crt.rs │ │ │ │ ├── scalar_add_crt.rs │ │ │ │ ├── scalar_mul_crt.rs │ │ │ │ ├── scalar_sub_crt.rs │ │ │ │ ├── sub_crt.rs │ │ │ │ └── tests.rs │ │ │ ├── crt_parallel │ │ │ │ ├── add_crt.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── mul_crt.rs │ │ │ │ ├── neg_crt.rs │ │ │ │ ├── scalar_add_crt.rs │ │ │ │ ├── scalar_mul_crt.rs │ │ │ │ ├── scalar_sub_crt.rs │ │ │ │ ├── sub_crt.rs │ │ │ │ └── tests.rs │ │ │ ├── mod.rs │ │ │ ├── radix │ │ │ │ ├── add.rs │ │ │ │ ├── bitwise_op.rs │ │ │ │ ├── comparison.rs │ │ │ │ ├── even_odd.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── mul.rs │ │ │ │ ├── neg.rs │ │ │ │ ├── scalar_add.rs │ │ │ │ ├── scalar_mul.rs │ │ │ │ ├── scalar_sub.rs │ │ │ │ ├── shift.rs │ │ │ │ ├── slice.rs │ │ │ │ ├── sub.rs │ │ │ │ └── tests.rs │ │ │ └── radix_parallel │ │ │ │ ├── abs.rs │ │ │ │ ├── add.rs │ │ │ │ ├── bit_extractor.rs │ │ │ │ ├── bitwise_op.rs │ │ │ │ ├── block_shift.rs │ │ │ │ ├── cmux.rs │ │ │ │ ├── comparison.rs │ │ │ │ ├── count_zeros_ones.rs │ │ │ │ ├── div_mod.rs │ │ │ │ ├── ilog2.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── modulus_switch_compression.rs │ │ │ │ ├── mul.rs │ │ │ │ ├── neg.rs │ │ │ │ ├── reverse_bits.rs │ │ │ │ ├── rotate.rs │ │ │ │ ├── scalar_add.rs │ │ │ │ ├── scalar_bitwise_op.rs │ │ │ │ ├── scalar_comparison.rs │ │ │ │ ├── scalar_div_mod.rs │ │ │ │ ├── scalar_dot_prod.rs │ │ │ │ ├── scalar_mul.rs │ │ │ │ ├── scalar_rotate.rs │ │ │ │ ├── scalar_shift.rs │ │ │ │ ├── scalar_sub.rs │ │ │ │ ├── shift.rs │ │ │ │ ├── slice.rs │ │ │ │ ├── sub.rs │ │ │ │ ├── sum.rs │ │ │ │ ├── tests_cases_unsigned.rs │ │ │ │ ├── tests_long_run │ │ │ │ ├── mod.rs │ │ │ │ ├── test_erc20.rs │ │ │ │ ├── test_random_op_sequence.rs │ │ │ │ ├── test_signed_erc20.rs │ │ │ │ └── test_signed_random_op_sequence.rs │ │ │ │ ├── tests_signed │ │ │ │ ├── mod.rs │ │ │ │ ├── modulus_switch_compression.rs │ │ │ │ ├── test_abs.rs │ │ │ │ ├── test_add.rs │ │ │ │ ├── test_bitwise_op.rs │ │ │ │ ├── test_block_shift.rs │ │ │ │ ├── test_cmux.rs │ │ │ │ ├── test_comparison.rs │ │ │ │ ├── test_count_zeros_ones.rs │ │ │ │ ├── test_div_rem.rs │ │ │ │ ├── test_ilog2.rs │ │ │ │ ├── test_mul.rs │ │ │ │ ├── test_neg.rs │ │ │ │ ├── test_rotate.rs │ │ │ │ ├── test_scalar_add.rs │ │ │ │ ├── test_scalar_bitwise_op.rs │ │ │ │ ├── test_scalar_comparison.rs │ │ │ │ ├── test_scalar_div_mod.rs │ │ │ │ ├── test_scalar_dot_prod.rs │ │ │ │ ├── test_scalar_mul.rs │ │ │ │ ├── test_scalar_rotate.rs │ │ │ │ ├── test_scalar_shift.rs │ │ │ │ ├── test_scalar_sub.rs │ │ │ │ ├── test_shift.rs │ │ │ │ ├── test_sub.rs │ │ │ │ └── test_vector_comparisons.rs │ │ │ │ ├── tests_unsigned │ │ │ │ ├── mod.rs │ │ │ │ ├── modulus_switch_compression.rs │ │ │ │ ├── test_add.rs │ │ │ │ ├── test_bitwise_op.rs │ │ │ │ ├── test_block_rotate.rs │ │ │ │ ├── test_block_shift.rs │ │ │ │ ├── test_cmux.rs │ │ │ │ ├── test_comparison.rs │ │ │ │ ├── test_count_zeros_ones.rs │ │ │ │ ├── test_div_mod.rs │ │ │ │ ├── test_ilog2.rs │ │ │ │ ├── test_mul.rs │ │ │ │ ├── test_neg.rs │ │ │ │ ├── test_rotate.rs │ │ │ │ ├── test_scalar_add.rs │ │ │ │ ├── test_scalar_bitwise_op.rs │ │ │ │ ├── test_scalar_comparison.rs │ │ │ │ ├── test_scalar_div_mod.rs │ │ │ │ ├── test_scalar_dot_prod.rs │ │ │ │ ├── test_scalar_mul.rs │ │ │ │ ├── test_scalar_rotate.rs │ │ │ │ ├── test_scalar_shift.rs │ │ │ │ ├── test_scalar_sub.rs │ │ │ │ ├── test_shift.rs │ │ │ │ ├── test_slice.rs │ │ │ │ ├── test_sub.rs │ │ │ │ ├── test_sum.rs │ │ │ │ ├── test_vector_comparisons.rs │ │ │ │ └── test_vector_find.rs │ │ │ │ ├── vector_comparisons.rs │ │ │ │ └── vector_find.rs │ │ ├── tests.rs │ │ └── wopbs │ │ │ ├── mod.rs │ │ │ └── test.rs │ ├── js_on_wasm_api │ │ ├── boolean.rs │ │ ├── js_high_level_api │ │ │ ├── config.rs │ │ │ ├── integers.rs │ │ │ ├── keys.rs │ │ │ ├── mod.rs │ │ │ └── zk.rs │ │ ├── mod.rs │ │ └── shortint.rs │ ├── keycache │ │ └── mod.rs │ ├── lib.rs │ ├── named.rs │ ├── safe_serialization.rs │ ├── shortint │ │ ├── atomic_pattern │ │ │ ├── compressed │ │ │ │ ├── ks32.rs │ │ │ │ ├── mod.rs │ │ │ │ └── standard.rs │ │ │ ├── ks32.rs │ │ │ ├── mod.rs │ │ │ └── standard.rs │ │ ├── backward_compatibility │ │ │ ├── atomic_pattern.rs │ │ │ ├── ciphertext │ │ │ │ └── mod.rs │ │ │ ├── client_key │ │ │ │ ├── atomic_pattern.rs │ │ │ │ └── mod.rs │ │ │ ├── key_switching_key.rs │ │ │ ├── list_compression.rs │ │ │ ├── mod.rs │ │ │ ├── noise_squashing.rs │ │ │ ├── parameters │ │ │ │ ├── compact_public_key_only.rs │ │ │ │ ├── key_switching.rs │ │ │ │ ├── list_compression.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── modulus_switch_noise_reduction.rs │ │ │ │ └── noise_squashing.rs │ │ │ ├── public_key │ │ │ │ └── mod.rs │ │ │ └── server_key │ │ │ │ ├── mod.rs │ │ │ │ └── modulus_switch_noise_reduction.rs │ │ ├── ciphertext │ │ │ ├── common.rs │ │ │ ├── compact_list.rs │ │ │ ├── compressed.rs │ │ │ ├── compressed_ciphertext_list.rs │ │ │ ├── compressed_modulus_switched_ciphertext.rs │ │ │ ├── mod.rs │ │ │ ├── squashed_noise.rs │ │ │ ├── standard.rs │ │ │ └── zk.rs │ │ ├── client_key │ │ │ ├── atomic_pattern │ │ │ │ ├── ks32.rs │ │ │ │ ├── mod.rs │ │ │ │ └── standard.rs │ │ │ ├── mod.rs │ │ │ └── secret_encryption_key.rs │ │ ├── encoding.rs │ │ ├── engine │ │ │ ├── client_side.rs │ │ │ ├── mod.rs │ │ │ ├── public_side.rs │ │ │ ├── server_side.rs │ │ │ └── wopbs │ │ │ │ └── mod.rs │ │ ├── key_switching_key │ │ │ ├── mod.rs │ │ │ └── test.rs │ │ ├── keycache.rs │ │ ├── list_compression │ │ │ ├── compressed_server_keys.rs │ │ │ ├── compression.rs │ │ │ ├── mod.rs │ │ │ ├── private_key.rs │ │ │ └── server_keys.rs │ │ ├── mod.rs │ │ ├── noise_squashing │ │ │ ├── compressed_server_key.rs │ │ │ ├── mod.rs │ │ │ ├── private_key.rs │ │ │ ├── server_key.rs │ │ │ └── tests.rs │ │ ├── oprf.rs │ │ ├── parameters │ │ │ ├── aliases.rs │ │ │ ├── classic.rs │ │ │ ├── compact_public_key_only.rs │ │ │ ├── coverage_parameters.rs │ │ │ ├── hpu.rs │ │ │ ├── key_switching.rs │ │ │ ├── ks32.rs │ │ │ ├── list_compression.rs │ │ │ ├── mod.rs │ │ │ ├── multi_bit.rs │ │ │ ├── noise_squashing.rs │ │ │ ├── parameters_wopbs.rs │ │ │ ├── parameters_wopbs_message_carry.rs │ │ │ ├── parameters_wopbs_only.rs │ │ │ ├── test_params.rs │ │ │ ├── v0_10 │ │ │ │ ├── classic │ │ │ │ │ ├── compact_pk │ │ │ │ │ │ ├── gaussian │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── gaussian │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tuniform │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── compact_public_key_only │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── key_switching │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── list_compression.rs │ │ │ │ ├── mod.rs │ │ │ │ └── multi_bit │ │ │ │ │ ├── gaussian │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tuniform │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ └── mod.rs │ │ │ ├── v0_11 │ │ │ │ ├── classic │ │ │ │ │ ├── compact_pk │ │ │ │ │ │ ├── gaussian │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── gaussian │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tuniform │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── compact_public_key_only │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── key_switching │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── list_compression.rs │ │ │ │ ├── mod.rs │ │ │ │ └── multi_bit │ │ │ │ │ ├── gaussian │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tuniform │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ └── mod.rs │ │ │ ├── v1_0 │ │ │ │ ├── classic │ │ │ │ │ ├── compact_pk │ │ │ │ │ │ ├── gaussian │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── gaussian │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tuniform │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── compact_public_key_only │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── key_switching │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── list_compression │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ └── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── mod.rs │ │ │ │ └── multi_bit │ │ │ │ │ ├── gaussian │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tuniform │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ └── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ └── mod.rs │ │ │ ├── v1_1 │ │ │ │ ├── classic │ │ │ │ │ ├── compact_pk │ │ │ │ │ │ ├── gaussian │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── gaussian │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tuniform │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── compact_public_key_only │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── key_switching │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── list_compression │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ └── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── multi_bit │ │ │ │ │ ├── gaussian │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tuniform │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ └── noise_squashing │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_128 │ │ │ │ │ └── mod.rs │ │ │ ├── v1_2 │ │ │ │ ├── classic │ │ │ │ │ ├── compact_pk │ │ │ │ │ │ ├── gaussian │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── gaussian │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tuniform │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── compact_public_key_only │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── hpu.rs │ │ │ │ ├── key_switching │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── ks32 │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tuniform │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── list_compression │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ └── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── multi_bit │ │ │ │ │ ├── gaussian │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tuniform │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ └── noise_squashing │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_128 │ │ │ │ │ └── mod.rs │ │ │ └── v1_3 │ │ │ │ ├── classic │ │ │ │ ├── compact_pk │ │ │ │ │ ├── gaussian │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ └── mod.rs │ │ │ │ ├── gaussian │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ └── pbs_ks.rs │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── mod.rs │ │ │ │ └── tuniform │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ └── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ └── mod.rs │ │ │ │ ├── compact_public_key_only │ │ │ │ ├── mod.rs │ │ │ │ └── p_fail_2_minus_128 │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ └── mod.rs │ │ │ │ ├── hpu.rs │ │ │ │ ├── key_switching │ │ │ │ ├── mod.rs │ │ │ │ └── p_fail_2_minus_128 │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ └── mod.rs │ │ │ │ ├── ks32 │ │ │ │ ├── mod.rs │ │ │ │ └── tuniform │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── p_fail_2_minus_128 │ │ │ │ │ ├── ks_pbs │ │ │ │ │ └── mod.rs │ │ │ │ │ └── mod.rs │ │ │ │ ├── list_compression │ │ │ │ ├── mod.rs │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ └── mod.rs │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ └── mod.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── multi_bit │ │ │ │ ├── gaussian │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── mod.rs │ │ │ │ └── tuniform │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── p_fail_2_minus_128 │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── p_fail_2_minus_40 │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ └── mod.rs │ │ │ │ │ └── p_fail_2_minus_64 │ │ │ │ │ ├── ks_pbs.rs │ │ │ │ │ ├── ks_pbs_gpu.rs │ │ │ │ │ └── mod.rs │ │ │ │ └── noise_squashing │ │ │ │ ├── mod.rs │ │ │ │ └── p_fail_2_minus_128 │ │ │ │ └── mod.rs │ │ ├── prelude.rs │ │ ├── public_key │ │ │ ├── compact.rs │ │ │ ├── compressed.rs │ │ │ ├── mod.rs │ │ │ └── standard.rs │ │ ├── server_key │ │ │ ├── add.rs │ │ │ ├── bitwise_op.rs │ │ │ ├── bivariate_pbs.rs │ │ │ ├── comp_op.rs │ │ │ ├── compressed.rs │ │ │ ├── div_mod.rs │ │ │ ├── mod.rs │ │ │ ├── modulus_switch_noise_reduction.rs │ │ │ ├── modulus_switched_compression.rs │ │ │ ├── mul.rs │ │ │ ├── neg.rs │ │ │ ├── scalar_add.rs │ │ │ ├── scalar_bitwise_op.rs │ │ │ ├── scalar_div_mod.rs │ │ │ ├── scalar_mul.rs │ │ │ ├── scalar_sub.rs │ │ │ ├── shift.rs │ │ │ ├── sub.rs │ │ │ └── tests │ │ │ │ ├── mod.rs │ │ │ │ ├── modulus_switch_compression.rs │ │ │ │ ├── noise_level.rs │ │ │ │ ├── parameterized_test.rs │ │ │ │ ├── parameterized_test_bivariate_pbs_compliant.rs │ │ │ │ └── shortint_compact_pk.rs │ │ └── wopbs │ │ │ ├── mod.rs │ │ │ └── test.rs │ ├── strings │ │ ├── backward_compatibility │ │ │ └── mod.rs │ │ ├── char_iter.rs │ │ ├── ciphertext.rs │ │ ├── client_key.rs │ │ ├── mod.rs │ │ ├── server_key │ │ │ ├── comp.rs │ │ │ ├── mod.rs │ │ │ ├── no_patterns.rs │ │ │ ├── pattern │ │ │ │ ├── contains.rs │ │ │ │ ├── find.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── replace.rs │ │ │ │ ├── split │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── split_iters.rs │ │ │ │ └── strip.rs │ │ │ └── trim.rs │ │ └── test_functions │ │ │ ├── mod.rs │ │ │ ├── test_common.rs │ │ │ ├── test_compact.rs │ │ │ ├── test_compression.rs │ │ │ ├── test_concat.rs │ │ │ ├── test_contains.rs │ │ │ ├── test_find_replace.rs │ │ │ ├── test_split.rs │ │ │ ├── test_up_low_case.rs │ │ │ └── test_whitespace.rs │ ├── test_user_docs.rs │ └── zk │ │ ├── backward_compatibility.rs │ │ └── mod.rs ├── tests │ ├── hpu.rs │ ├── zk_wasm_x86_test.rs │ └── zk_wasm_x86_test │ │ ├── index.js │ │ └── package.json └── web_wasm_parallel_tests │ ├── .gitignore │ ├── .prettierignore │ ├── Makefile │ ├── babel.config.js │ ├── favicon.ico │ ├── index.html │ ├── index.js │ ├── jest.config.js │ ├── package-lock.json │ ├── package.json │ ├── serve.json │ └── worker.js ├── toolchain.txt └── utils ├── param_dedup ├── Cargo.toml └── src │ └── main.rs ├── tfhe-lints ├── .cargo │ └── config.toml ├── Cargo.toml ├── README.md ├── rust-toolchain ├── src │ ├── lib.rs │ ├── serialize_without_versionize.rs │ └── utils.rs └── ui │ ├── main.rs │ └── main.stderr ├── tfhe-versionable-derive ├── Cargo.toml └── src │ ├── associated.rs │ ├── dispatch_type.rs │ ├── lib.rs │ ├── transparent.rs │ ├── version_type.rs │ ├── versionize_attribute.rs │ └── versionize_impl.rs └── tfhe-versionable ├── Cargo.toml ├── README.md ├── examples ├── associated_bounds.rs ├── bounds.rs ├── convert.rs ├── deprecation.rs ├── failed_upgrade.rs ├── manual_impl.rs ├── not_versioned.rs ├── recursive.rs ├── simple.rs ├── skip.rs ├── transparent.rs ├── transparent_then_not.rs ├── upgrades.rs └── vec.rs ├── src ├── deprecation.rs ├── derived_traits.rs ├── lib.rs └── upgrade.rs └── tests ├── bounds_private_in_public.rs ├── convert_with_bounds.rs ├── convert_with_generics.rs ├── derive_macro.rs ├── formats.rs ├── skip_enum.rs ├── testcases ├── enum.rs ├── struct.rs └── unit.rs ├── types.rs └── unsized.rs /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | xtask = "run --manifest-path ./tasks/Cargo.toml --" 3 | 4 | # Accessed by wasm-bindgen when testing for the wasm target 5 | [target.wasm32-unknown-unknown] 6 | runner = 'wasm-bindgen-test-runner' 7 | -------------------------------------------------------------------------------- /.config/nextest.toml: -------------------------------------------------------------------------------- 1 | [profile.ci] 2 | # Print out output for failing tests as soon as they fail, and also at the end 3 | # of the run (for easy scrollability). 4 | failure-output = "final" 5 | fail-fast = false 6 | retries = 0 7 | slow-timeout = "5m" 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | # 4 space indentation for rust and toml 12 | [*.{rs,toml}] 13 | charset = utf-8 14 | indent_style = space 15 | indent_size = 4 16 | 17 | # 2 for c and js 18 | [*.{js,json,c,h}] 19 | charset = utf-8 20 | indent_style = space 21 | indent_size = 2 22 | -------------------------------------------------------------------------------- /.gitbook.yaml: -------------------------------------------------------------------------------- 1 | root: ./tfhe/docs 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report a problem with TFHE-rs 4 | title: '' 5 | labels: triage_required 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behaviour 15 | 1. first step 16 | 2. second step 17 | 3. etc 18 | 19 | **Expected behaviour** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Evidence** 23 | If applicable, add material to help explain your problem (e.g. screenshots, logs, artifacts, etc.). 24 | 25 | **Configuration(please complete the following information):** 26 | - OS: [e.g. Ubuntu 20.04] 27 | 28 | 29 | **Additional context** 30 | Add any other context about the problem here. 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for TFHE-rs 4 | title: '' 5 | labels: feature_request 6 | assignees: '' 7 | 8 | --- 9 | 10 | **What is the problem you want to solve and can not with the current version?** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/actionlint.yaml: -------------------------------------------------------------------------------- 1 | self-hosted-runner: 2 | # Labels of self-hosted runner in array of strings. 3 | labels: 4 | - m1mac 5 | - 4090-desktop 6 | - large_windows_16_latest 7 | - large_ubuntu_16 8 | - large_ubuntu_16-22.04 9 | - v80-desktop 10 | # Configuration variables in array of strings defined in your repository or 11 | # organization. `null` means disabling configuration variables check. 12 | # Empty array means no configuration variable is allowed. 13 | config-variables: null 14 | -------------------------------------------------------------------------------- /.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | # Check for updates to GitHub Actions every sunday 8 | interval: "weekly" 9 | day: "sunday" 10 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 2 | closes: _please link all relevant issues_ 3 | 4 | ### PR content/description 5 | 6 | ### Check-list: 7 | 8 | * [ ] Tests for the changes have been added (for bug fixes / features) 9 | * [ ] Docs have been added / updated (for bug fixes / features) 10 | * [ ] Relevant issues are marked as resolved/closed, related issues are linked in the description 11 | * [ ] Check for breaking changes (including serialization changes) and add them to commit message following the conventional commit [specification][conventional-breaking] 12 | 13 | [conventional-breaking]: https://www.conventionalcommits.org/en/v1.0.0/#commit-message-with-description-and-breaking-change-footer 14 | -------------------------------------------------------------------------------- /.github/workflows/placeholder_workflow.yml: -------------------------------------------------------------------------------- 1 | # Placeholder workflow file allowing running it without having to merge to main first 2 | name: Placeholder Workflow 3 | 4 | on: 5 | workflow_dispatch: 6 | 7 | permissions: {} 8 | 9 | jobs: 10 | placeholder: 11 | name: Placeholder 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - run: | 16 | echo "Hello this is a Placeholder Workflow" 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .idea/ 3 | .vscode/ 4 | 5 | # Path we use for internal-keycache during tests 6 | /keys/ 7 | # In case of symlinked keys 8 | /keys 9 | 10 | **/*.rmeta 11 | **/Cargo.lock 12 | **/*.bin 13 | 14 | # Some of our bench outputs 15 | /tfhe/benchmarks_parameters 16 | /tfhe-zk-pok/benchmarks_parameters 17 | **/*.csv 18 | 19 | # dieharder run log 20 | dieharder_run.log 21 | 22 | # Coverage reports 23 | /coverage/ 24 | 25 | # Cuda local build 26 | backends/tfhe-cuda-backend/cuda/cmake-build-debug/ 27 | 28 | # WASM tests 29 | tfhe/web_wasm_parallel_tests/server.PID 30 | venv/ 31 | web-test-runner/ 32 | node_modules/ 33 | package-lock.json 34 | 35 | # Python .env 36 | .env 37 | __pycache__ 38 | 39 | # Dir used for backward compatibility test data 40 | # First directive is to ignore symlinks 41 | tests/tfhe-backward-compat-data 42 | ci/ 43 | -------------------------------------------------------------------------------- /.lfsconfig: -------------------------------------------------------------------------------- 1 | [lfs] 2 | fetchexclude = * 3 | -------------------------------------------------------------------------------- /.linelint.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - .git 3 | - target 4 | - tfhe/build 5 | - venv 6 | - web-test-runner 7 | - tfhe/benchmarks_parameters 8 | - tfhe/web_wasm_parallel_tests/node_modules 9 | - tfhe/web_wasm_parallel_tests/dist 10 | - keys 11 | - coverage 12 | - utils/tfhe-lints/ui/main.stderr 13 | 14 | rules: 15 | # checks if file ends in a newline character 16 | end-of-file: 17 | enable: true 18 | single-new-line: true 19 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Specifying a path without code owners means that path won't have owners and is akin to a negation 2 | # i.e. the `core_crypto` dir is owned and needs owner approval/review, but not the `gpu` sub dir 3 | # See https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#example-of-a-codeowners-file 4 | /tfhe/src/core_crypto/ @IceTDrinker 5 | /tfhe/src/core_crypto/gpu 6 | 7 | /tfhe/src/shortint/ @mayeul-zama 8 | 9 | /tfhe/src/integer/ @tmontaigu 10 | /tfhe/src/integer/gpu 11 | 12 | /tfhe/src/high_level_api/ @tmontaigu 13 | 14 | /Makefile @IceTDrinker @soonum 15 | 16 | /.github/ @soonum 17 | 18 | /CODEOWNERS @IceTDrinker 19 | -------------------------------------------------------------------------------- /_typos.toml: -------------------------------------------------------------------------------- 1 | [default] 2 | extend-ignore-identifiers-re = [ 3 | # Related to serialized object 4 | "ser", 5 | "unser", 6 | # Used when dumping tfhe-rs parameters set into Sage format 7 | "ND.*", 8 | # Related to FHE strings example handling "banana" 9 | "ba", 10 | "enc_ba", 11 | # Example with string replacing "hello" with "herlo" 12 | "herlo", 13 | # Example in trivium 14 | "C9217BA0D762ACA1", 15 | "0x[0-9a-fA-F]+" 16 | ] 17 | 18 | [files] 19 | extend-exclude = [ 20 | "backends/tfhe-cuda-backend/cuda/src/fft128/twiddles.cu", 21 | "backends/tfhe-cuda-backend/cuda/src/fft/twiddles.cu", 22 | "backends/tfhe-hpu-backend/config_store/**/*.link_summary", 23 | ] 24 | -------------------------------------------------------------------------------- /apps/trivium/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tfhe-trivium" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | rayon = "1" 10 | tfhe = { path = "../../tfhe", features = ["boolean", "shortint", "integer"] } 11 | 12 | [dev-dependencies] 13 | criterion = { version = "0.5.1", features = ["html_reports"] } 14 | 15 | [profile.devo] 16 | inherits = "dev" 17 | opt-level = 3 18 | lto = "off" 19 | debug-assertions = false 20 | 21 | [[bench]] 22 | name = "trivium" 23 | harness = false 24 | -------------------------------------------------------------------------------- /apps/trivium/src/kreyvium/mod.rs: -------------------------------------------------------------------------------- 1 | #[allow(clippy::module_inception)] 2 | mod kreyvium; 3 | pub use kreyvium::KreyviumStream; 4 | 5 | mod kreyvium_byte; 6 | pub use kreyvium_byte::KreyviumStreamByte; 7 | 8 | mod kreyvium_shortint; 9 | pub use kreyvium_shortint::KreyviumStreamShortint; 10 | 11 | #[cfg(test)] 12 | mod test; 13 | -------------------------------------------------------------------------------- /apps/trivium/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::too_long_first_doc_paragraph)] 2 | 3 | mod static_deque; 4 | 5 | mod kreyvium; 6 | pub use kreyvium::{KreyviumStream, KreyviumStreamByte, KreyviumStreamShortint}; 7 | 8 | mod trivium; 9 | pub use trivium::{TriviumStream, TriviumStreamByte, TriviumStreamShortint}; 10 | 11 | mod trans_ciphering; 12 | pub use trans_ciphering::TransCiphering; 13 | -------------------------------------------------------------------------------- /apps/trivium/src/static_deque/mod.rs: -------------------------------------------------------------------------------- 1 | #[allow(clippy::module_inception)] 2 | mod static_deque; 3 | pub use static_deque::StaticDeque; 4 | 5 | mod static_byte_deque; 6 | pub use static_byte_deque::{StaticByteDeque, StaticByteDequeInput}; 7 | -------------------------------------------------------------------------------- /apps/trivium/src/trivium/mod.rs: -------------------------------------------------------------------------------- 1 | mod trivium_bool; 2 | pub use trivium_bool::TriviumStream; 3 | 4 | mod trivium_byte; 5 | pub use trivium_byte::TriviumStreamByte; 6 | 7 | mod trivium_shortint; 8 | pub use trivium_shortint::TriviumStreamShortint; 9 | 10 | #[cfg(test)] 11 | mod test; 12 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tfhe-cuda-backend" 3 | version = "0.10.0" 4 | edition = "2021" 5 | authors = ["Zama team"] 6 | license = "BSD-3-Clause-Clear" 7 | description = "Cuda implementation of TFHE-rs primitives." 8 | homepage = "https://www.zama.ai/" 9 | documentation = "https://docs.zama.ai/tfhe-rs" 10 | repository = "https://github.com/zama-ai/tfhe-rs" 11 | readme = "README.md" 12 | keywords = ["fully", "homomorphic", "encryption", "fhe", "cryptography"] 13 | 14 | [build-dependencies] 15 | cmake = { version = "0.1" } 16 | pkg-config = { version = "0.3" } 17 | bindgen = "0.71" 18 | 19 | [features] 20 | experimental-multi-arch = [] 21 | profile = [] 22 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/.cmake-format-config.py: -------------------------------------------------------------------------------- 1 | # ----------------------------- 2 | # Options effecting formatting. 3 | # ----------------------------- 4 | with section("format"): 5 | 6 | # How wide to allow formatted cmake files 7 | line_width = 120 8 | 9 | # How many spaces to tab for indent 10 | tab_size = 2 11 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | include/cuda_config.h 3 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | set noparent 2 | linelength=240 3 | filter=-legal/copyright,-readability/todo,-runtime/references,-build/c++17 4 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/check_cuda.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) { 4 | cudaDeviceProp dP; 5 | float min_cc = 3.0; 6 | 7 | int rc = cudaGetDeviceProperties(&dP, 0); 8 | if (rc != cudaSuccess) { 9 | cudaError_t error = cudaGetLastError(); 10 | printf("CUDA error: %s", cudaGetErrorString(error)); 11 | return rc; /* Failure */ 12 | } 13 | if ((dP.major + (dP.minor / 10)) < min_cc) { 14 | printf("Min Compute Capability of %2.1f required: %d.%d found\n Not " 15 | "Building CUDA Code", 16 | min_cc, dP.major, dP.minor); 17 | return 1; /* Failure */ 18 | } else { 19 | printf("-arch=sm_%d%d", dP.major, dP.minor); 20 | return 0; /* Success */ 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/include/fft/fft128.h: -------------------------------------------------------------------------------- 1 | #include 2 | extern "C" { 3 | void cuda_fourier_transform_forward_as_torus_f128_async( 4 | void *stream, uint32_t gpu_index, void *re0, void *re1, void *im0, 5 | void *im1, void const *standard, uint32_t const N, 6 | const uint32_t number_of_samples); 7 | 8 | void cuda_fourier_transform_forward_as_integer_f128_async( 9 | void *stream, uint32_t gpu_index, void *re0, void *re1, void *im0, 10 | void *im1, void const *standard, uint32_t const N, 11 | const uint32_t number_of_samples); 12 | 13 | void cuda_fourier_transform_backward_as_torus_f128_async( 14 | void *stream, uint32_t gpu_index, void *standard, void const *re0, 15 | void const *re1, void const *im0, void const *im1, uint32_t const N, 16 | const uint32_t number_of_samples); 17 | } 18 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/include/integer/radix_ciphertext.h: -------------------------------------------------------------------------------- 1 | #ifndef CUDA_RADIX_CIPHERTEXT_H 2 | #define CUDA_RADIX_CIPHERTEXT_H 3 | 4 | void release_radix_ciphertext_async(cudaStream_t const stream, 5 | uint32_t const gpu_index, 6 | CudaRadixCiphertextFFI *data, 7 | const bool gpu_memory_allocated); 8 | 9 | void reset_radix_ciphertext_blocks(CudaRadixCiphertextFFI *data, 10 | uint32_t new_num_blocks); 11 | 12 | void into_radix_ciphertext(CudaRadixCiphertextFFI *radix, void *lwe_array, 13 | const uint32_t num_radix_blocks, 14 | const uint32_t lwe_dimension); 15 | #endif 16 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/include/keyswitch/ks_enums.h: -------------------------------------------------------------------------------- 1 | #ifndef CUDA_KS_ENUMS_H 2 | #define CUDA_KS_ENUMS_H 3 | 4 | enum KS_TYPE { BIG_TO_SMALL = 0, SMALL_TO_BIG = 1 }; 5 | 6 | #endif // CUDA_KS_ENUMS_H 7 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/include/pbs/pbs_enums.h: -------------------------------------------------------------------------------- 1 | #ifndef CUDA_PBS_ENUMS_H 2 | #define CUDA_PBS_ENUMS_H 3 | #include 4 | enum PBS_TYPE { MULTI_BIT = 0, CLASSICAL = 1 }; 5 | enum PBS_VARIANT { DEFAULT = 0, CG = 1, TBC = 2 }; 6 | 7 | extern "C" { 8 | typedef struct { 9 | void *const *ptr; 10 | uint32_t num_zeros; 11 | double ms_bound; 12 | double ms_r_sigma; 13 | double ms_input_variance; 14 | } CudaModulusSwitchNoiseReductionKeyFFI; 15 | } 16 | 17 | #endif // CUDA_PBS_ENUMS_H 18 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE SOURCES "*.cu") 2 | add_library(tfhe_cuda_backend STATIC ${SOURCES}) 3 | set_target_properties(tfhe_cuda_backend PROPERTIES CUDA_SEPARABLE_COMPILATION ON CUDA_RESOLVE_DEVICE_SYMBOLS ON) 4 | target_link_libraries(tfhe_cuda_backend PUBLIC cudart OpenMP::OpenMP_CXX) 5 | target_include_directories(tfhe_cuda_backend PRIVATE .) 6 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/src/fft/twiddles.cuh: -------------------------------------------------------------------------------- 1 | #ifndef GPU_BOOTSTRAP_TWIDDLES_CUH 2 | #define GPU_BOOTSTRAP_TWIDDLES_CUH 3 | 4 | /* 5 | * 'negtwiddles' are stored in device memory to profit caching 6 | */ 7 | extern __device__ double2 negtwiddles[8192]; 8 | #endif 9 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/src/fft128/twiddles.cuh: -------------------------------------------------------------------------------- 1 | #ifndef CUDA_FFT128_TWIDDLES_CUH 2 | #define CUDA_FFT128_TWIDDLES_CUH 3 | 4 | /* 5 | * 'negtwiddles' are stored in device memory to profit caching 6 | */ 7 | extern __device__ double neg_twiddles_re_hi[4096]; 8 | extern __device__ double neg_twiddles_re_lo[4096]; 9 | extern __device__ double neg_twiddles_im_hi[4096]; 10 | extern __device__ double neg_twiddles_im_lo[4096]; 11 | #endif 12 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/src/integer/cast.cu: -------------------------------------------------------------------------------- 1 | #include "cast.cuh" 2 | 3 | void extend_radix_with_trivial_zero_blocks_msb_64( 4 | CudaRadixCiphertextFFI *output, CudaRadixCiphertextFFI const *input, 5 | void *const *streams, uint32_t const *gpu_indexes) { 6 | host_extend_radix_with_trivial_zero_blocks_msb( 7 | output, input, (cudaStream_t *)streams, gpu_indexes); 8 | } 9 | 10 | void trim_radix_blocks_lsb_64(CudaRadixCiphertextFFI *output, 11 | CudaRadixCiphertextFFI const *input, 12 | void *const *streams, 13 | uint32_t const *gpu_indexes) { 14 | 15 | host_trim_radix_blocks_lsb(output, input, (cudaStream_t *)streams, 16 | gpu_indexes); 17 | } 18 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/src/integer/negation.cu: -------------------------------------------------------------------------------- 1 | #include "integer/negation.cuh" 2 | 3 | void cuda_negate_integer_radix_ciphertext_64( 4 | void *const *streams, uint32_t const *gpu_indexes, uint32_t gpu_count, 5 | CudaRadixCiphertextFFI *lwe_array_out, 6 | CudaRadixCiphertextFFI const *lwe_array_in, uint32_t message_modulus, 7 | uint32_t carry_modulus, uint32_t num_radix_blocks) { 8 | 9 | host_integer_radix_negation( 10 | (cudaStream_t *)(streams), gpu_indexes, gpu_count, lwe_array_out, 11 | lwe_array_in, message_modulus, carry_modulus, num_radix_blocks); 12 | } 13 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/src/integer/scalar_addition.cu: -------------------------------------------------------------------------------- 1 | #include "integer/scalar_addition.cuh" 2 | 3 | void cuda_scalar_addition_integer_radix_ciphertext_64_inplace( 4 | void *const *streams, uint32_t const *gpu_indexes, uint32_t gpu_count, 5 | CudaRadixCiphertextFFI *lwe_array, void const *scalar_input, 6 | void const *h_scalar_input, uint32_t num_scalars, uint32_t message_modulus, 7 | uint32_t carry_modulus) { 8 | 9 | host_integer_radix_scalar_addition_inplace( 10 | (cudaStream_t *)(streams), gpu_indexes, gpu_count, lwe_array, 11 | static_cast(scalar_input), 12 | static_cast(h_scalar_input), num_scalars, 13 | message_modulus, carry_modulus); 14 | } 15 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/src/utils/helper_profile.cuh: -------------------------------------------------------------------------------- 1 | #ifndef HELPER_PROFILE 2 | #define HELPER_PROFILE 3 | 4 | #ifdef USE_NVTOOLS 5 | #include 6 | #endif 7 | 8 | void cuda_nvtx_label_with_color(const char *name); 9 | void cuda_nvtx_pop(); 10 | 11 | #define PUSH_RANGE(name) \ 12 | { cuda_nvtx_label_with_color(name); } 13 | #define POP_RANGE() \ 14 | { cuda_nvtx_pop(); } 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/tests_and_benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | option(TFHE_CUDA_BACKEND_BUILD_TESTS "Build the test tool" OFF) 2 | option(TFHE_CUDA_BACKEND_BUILD_BENCHMARKS "Build the benchmark tool" OFF) 3 | 4 | if(TFHE_CUDA_BACKEND_BUILD_TESTS) 5 | message(STATUS "Building the test tool") 6 | add_subdirectory(tests) 7 | endif() 8 | 9 | if(TFHE_CUDA_BACKEND_BUILD_BENCHMARKS) 10 | message(STATUS "Building the benchmark tool") 11 | add_subdirectory(benchmarks) 12 | endif() 13 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/cuda/tests_and_benchmarks/benchmarks/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | BENCHMARK_MAIN(); 4 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/get_os_name.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cat /etc/os-release | grep "\" | sed "s/NAME=\"//g" | sed "s/\"//g" 4 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/src/ffi.rs: -------------------------------------------------------------------------------- 1 | #![allow(warnings)] 2 | pub type c_void = std::ffi::c_void; 3 | pub type c_uint = std::ffi::c_uint; 4 | pub type c_uchar = std::ffi::c_uchar; 5 | pub type c_ushort = std::ffi::c_ushort; 6 | pub type c_ulong = std::ffi::c_ulong; 7 | pub type c_schar = std::ffi::c_schar; 8 | pub type c_int = std::ffi::c_int; 9 | pub type c_short = std::ffi::c_short; 10 | pub type c_long = std::ffi::c_long; 11 | pub type c_char = std::ffi::c_char; 12 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[allow(warnings)] 2 | pub mod bindings; 3 | pub mod cuda_bind; 4 | pub mod ffi; 5 | -------------------------------------------------------------------------------- /backends/tfhe-cuda-backend/wrapper.h: -------------------------------------------------------------------------------- 1 | // These files must be added to the headers vec in the build.rs to check for file changes 2 | #include "cuda/include/ciphertext.h" 3 | #include "cuda/include/integer/compression/compression.h" 4 | #include "cuda/include/integer/integer.h" 5 | #include "cuda/include/zk/zk.h" 6 | #include "cuda/include/keyswitch/keyswitch.h" 7 | #include "cuda/include/keyswitch/ks_enums.h" 8 | #include "cuda/include/linear_algebra.h" 9 | #include "cuda/include/fft/fft128.h" 10 | #include "cuda/include/pbs/programmable_bootstrap.h" 11 | #include "cuda/include/pbs/programmable_bootstrap_multibit.h" 12 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/.gitattributes: -------------------------------------------------------------------------------- 1 | *.xclbin filter=lfs diff=lfs merge=lfs -text 2 | *.pdi filter=lfs diff=lfs merge=lfs -text 3 | python/lib/example.json filter=lfs diff=lfs merge=lfs -text 4 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/.gitignore: -------------------------------------------------------------------------------- 1 | ngt_* 2 | config 3 | kogge_cfg.toml 4 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/custom_iop/cust_0.asm: -------------------------------------------------------------------------------- 1 | # CUST_0 2 | # Simple IOp to check the xfer between Hpu/Cpu 3 | # Construct constant in dest slot -> 249 (0xf9) 4 | SUB R0 R0 R0 5 | ADDS R0 R0 1 6 | ST TD[0].0 R0 7 | SUB R1 R1 R1 8 | ADDS R1 R1 2 9 | ST TD[0].1 R1 10 | SUB R2 R2 R2 11 | ADDS R2 R2 3 12 | ST TD[0].2 R2 13 | SUB R3 R3 R3 14 | ADDS R3 R3 3 15 | ST TD[0].3 R3 16 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/custom_iop/cust_1.asm: -------------------------------------------------------------------------------- 1 | # CUST_1 2 | # Simple IOp to check the xfer between Hpu/Cpu 3 | # Dest <- Src_a 4 | LD R0 TS[0].0 5 | LD R1 TS[0].1 6 | LD R2 TS[0].2 7 | LD R3 TS[0].3 8 | ST TD[0].0 R0 9 | ST TD[0].1 R1 10 | ST TD[0].2 R2 11 | ST TD[0].3 R3 12 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/custom_iop/cust_10.asm: -------------------------------------------------------------------------------- 1 | ; CUST_8 2 | ; Simple IOp to check the ALU operation 3 | ; Dst[0].0 <- Src[0].0 + Src[1].0 4 | LD R1 TS[0].0 5 | LD R2 TS[1].0 6 | ADD R0 R1 R2 7 | ST TD[0].0 R0 8 | 9 | ; Dst[0].1 <- Src[0].1 + Src[1].1 10 | LD R5 TS[0].1 11 | LD R6 TS[1].1 12 | ADD R4 R5 R6 13 | ST TD[0].2 R4 14 | 15 | ; Dst[0].2 <- Src[0].2 + Src[1].2 16 | LD R9 TS[0].2 17 | LD R10 TS[1].2 18 | ADD R8 R9 R10 19 | ST TD[0].2 R8 20 | 21 | ; Dst[0].3 <- Src[0].3 + Src[1].3 22 | LD R13 TS[0].3 23 | LD R14 TS[1].3 24 | ADD R12 R13 R14 25 | ST TD[0].3 R0 26 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/custom_iop/cust_16.asm: -------------------------------------------------------------------------------- 1 | # CUST_16 2 | # Simple IOp to check PBS behavior 3 | # Dest <- PBSNone(Src_a.0) 4 | LD R0 TS[0].0 5 | PBS_F R0 R0 PbsNone 6 | ST TD[0].0 R0 7 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/custom_iop/cust_17.asm: -------------------------------------------------------------------------------- 1 | # CUST_17 2 | # Simple IOp to check PBS behavior 3 | # Dest <- PBSNone(Src_a) 4 | LD R0 TS[0].0 5 | PBS R0 R0 PbsNone 6 | ST TD[0].0 R0 7 | LD R1 TS[0].1 8 | PBS R1 R1 PbsNone 9 | ST TD[0].1 R1 10 | LD R2 TS[0].2 11 | PBS R2 R2 PbsNone 12 | ST TD[0].2 R2 13 | LD R3 TS[0].3 14 | PBS_F R3 R3 PbsNone 15 | ST TD[0].3 R3 16 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/custom_iop/cust_18.asm: -------------------------------------------------------------------------------- 1 | ; CUST_18 2 | ; Simple IOp to check extraction pattern 3 | ; Correct result: 4 | ; * Dst[0,1] <- Src[0][0,1] 5 | ; * Dst[2,3] <- Src[1][0,1] 6 | 7 | ; Pack Src[0][0,1] with a Mac and extract Carry/Msg in Dst[0][0,1] 8 | LD R0 TS[0].0 9 | LD R1 TS[0].1 10 | MAC R3 R1 R0 4 11 | PBS R4 R3 PbsMsgOnly 12 | PBS R5 R3 PbsCarryInMsg 13 | ST TD[0].0 R4 14 | ST TD[0].1 R5 15 | 16 | ; Pack Src[1][0,1] with a Mac and extract Carry/Msg in Dst[0][2,3] 17 | LD R10 TS[1].0 18 | LD R11 TS[1].1 19 | MAC R13 R11 R10 4 20 | PBS R14 R13 PbsMsgOnly 21 | PBS R15 R13 PbsCarryInMsg 22 | ST TD[0].2 R14 23 | ST TD[0].3 R15 24 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/custom_iop/cust_19.asm: -------------------------------------------------------------------------------- 1 | ; CUST_19 2 | ; Simple IOp to check PbsMl2 3 | ; Correct result: 4 | ; * Dst[0][0] <- Src[0][0] 5 | ; * Dst[0][1] <- 0 6 | ; * Dst[0][2] <- Src[0][0] +1 7 | ; * Dst[0][3] <- 0 8 | ; i.e Cust_19(0x2) => 0x32 9 | 10 | ; Construct a 0 for destination padding 11 | SUB R16 R16 R16 12 | 13 | ; Apply PbsMl2 on Src[0] result goes in dest[0][0-3] (0-padded) 14 | LD R0 TS[0].0 15 | PBS_ML2_F R0 R0 PbsTestMany2 16 | ST TD[0].0 R0 17 | ST TD[0].1 R16 18 | ST TD[0].2 R1 19 | ST TD[0].3 R16 20 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/custom_iop/cust_2.asm: -------------------------------------------------------------------------------- 1 | # CUST_2 2 | # Simple IOp to check the xfer between Hpu/Cpu 3 | # Dest <- Src_b 4 | LD R0 TS[1].0 5 | LD R1 TS[1].1 6 | LD R2 TS[1].2 7 | LD R3 TS[1].3 8 | ST TD[0].0 R0 9 | ST TD[0].1 R1 10 | ST TD[0].2 R2 11 | ST TD[0].3 R3 12 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/custom_iop/cust_20.asm: -------------------------------------------------------------------------------- 1 | ; CUST_20 2 | ; Simple IOp to check PbsMl4 3 | ; Correct result: 4 | ; * Dst[0][0] <- Src[0][0] 5 | ; * Dst[0][1] <- Src[0][0] +1 6 | ; * Dst[0][2] <- Src[0][0] +2 7 | ; * Dst[0][3] <- Src[0][0] +3 8 | ; i.e Cust_20(0x0) => 0xe4 9 | 10 | SUB R16 R16 R16 11 | ST TD[0].0 R0 12 | ST TD[0].1 R0 13 | ST TD[0].2 R0 14 | ST TD[0].3 R0 15 | 16 | ; Apply PbsMl4 on Src[0] result goes in dest[0][0-3] 17 | LD R0 TS[0].0 18 | PBS_ML4_F R0 R0 PbsTestMany4 19 | ST TD[0].0 R0 20 | ST TD[0].1 R1 21 | ST TD[0].2 R2 22 | ST TD[0].3 R3 23 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/custom_iop/cust_21.asm: -------------------------------------------------------------------------------- 1 | ; CUST_21 2 | ; Simple IOp to check PbsMl8 3 | ; WARN: This operation required 16b ct width 4 | ; Correct result: 5 | ; * Dst[0][0] <- Src[0][0] 6 | ; * Dst[0][1] <- Src[0][0] +1 7 | ; * Dst[0][2] <- Src[0][0] +2 8 | ; * Dst[0][3] <- Src[0][0] +3 9 | ; * Dst[0][4] <- Src[0][0] +4 10 | ; * Dst[0][5] <- Src[0][0] +5 11 | ; * Dst[0][6] <- Src[0][0] +6 12 | ; * Dst[0][7] <- Src[0][0] +7 13 | 14 | ; Apply PbsMl8 on Src[0] result goes in dest[0][0-7] 15 | LD R0 TS[0].0 16 | PBS_ML8_F R0 R0 PbsTestMany8 17 | ST TD[0].0 R0 18 | ST TD[0].1 R1 19 | ST TD[0].2 R2 20 | ST TD[0].3 R3 21 | ST TD[0].4 R4 22 | ST TD[0].5 R5 23 | ST TD[0].6 R6 24 | ST TD[0].7 R7 25 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/custom_iop/cust_3.asm: -------------------------------------------------------------------------------- 1 | # CUST_3 2 | # Simple IOp to check isc behavior 3 | # Generate obvious deps and check that isc correctly issued the dop 4 | # Correct result must bu Dest <- Src[0] 5 | LD R0 TS[0].0 6 | LD R1 TS[0].1 7 | LD R2 TS[0].2 8 | LD R3 TS[0].3 9 | PBS R4 R0 PbsNone 10 | ST TD[0].0 R4 11 | PBS R4 R1 PbsNone 12 | ST TD[0].1 R4 13 | PBS R4 R2 PbsNone 14 | ST TD[0].2 R4 15 | PBS_F R4 R3 PbsNone 16 | ST TD[0].3 R4 17 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/custom_iop/cust_8.asm: -------------------------------------------------------------------------------- 1 | ; CUST_8 2 | ; Simple IOp to check the ALU operation 3 | ; Dst[0].0 <- Src[0].0 + Src[1].0 4 | LD R1 TS[0].0 5 | LD R2 TS[1].0 6 | ADD R0 R1 R2 7 | ST TD[0].0 R0 8 | 9 | ; Dst[0].1 <- Src[0].1 - Src[1].1 10 | LD R5 TS[0].1 11 | LD R6 TS[1].1 12 | SUB R4 R5 R6 13 | ST TD[0].1 R4 14 | 15 | ; Dst[0].2 <- Src[0].2 + (Src[1].2 *4) 16 | LD R9 TS[0].2 17 | LD R10 TS[1].2 18 | MAC R8 R9 R10 4 19 | ST TD[0].2 R8 20 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/custom_iop/cust_9.asm: -------------------------------------------------------------------------------- 1 | ; CUST_9 2 | ; Simple IOp to check the ALU Scalar operation 3 | ; Dst[0].0 <- Src[0].0 + Imm[0].0 4 | LD R1 TS[0].0 5 | ADDS R0 R1 TI[0].0 6 | ST TD[0].0 R0 7 | 8 | ; Dst[0].1 <- Src[0].1 - Imm[0].1 9 | LD R5 TS[0].1 10 | SUBS R4 R5 TI[0].1 11 | ST TD[0].1 R4 12 | 13 | ; Dst[0].2 <- Imm[0].2 - Src[0].2 14 | LD R9 TS[0].2 15 | SSUB R8 R9 TI[0].2 16 | ST TD[0].2 R8 17 | 18 | ; Dst[0].3 <- Src[0].3 * Imm[0].3 19 | LD R13 TS[0].3 20 | MULS R12 R13 TI[0].3 21 | ST TD[0].3 R12 22 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/sim/tb_hpu_regif_dummy.toml: -------------------------------------------------------------------------------- 1 | module_name="tb_hpu_regif_dummy" 2 | description="Fake registers needed by the mockup" 3 | word_size_b = 32 4 | offset = 0x40000 5 | range = 0x10000 6 | ext_pkg = ["axi_if_common_param_pkg", "axi_if_shell_axil_pkg"] 7 | 8 | # ============================================================================== 9 | [section.WorkAck] 10 | description="Purpose of this section" 11 | 12 | [section.WorkAck.register.workq] 13 | description="Insert work in workq and read status" 14 | owner="Kernel" 15 | read_access="Read" 16 | write_access="WriteNotify" 17 | 18 | [section.WorkAck.register.ackq] 19 | description="Pop ack from in ackq" 20 | owner="Kernel" 21 | read_access="ReadNotify" 22 | write_access="None" 23 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/README.md: -------------------------------------------------------------------------------- 1 | # Fpga version 2 | 3 | Built with the following command: (i.e. xrt/run_syn_hpu_msplit_3parts_64b.sh) 4 | ``` 5 | just zaxl-build hpu_msplit_3parts 3 "0:300" "-F TOP_MSPLIT TOP_MSPLIT_1 -F TOP_BATCH TOP_BATCH_TOPhpu_BPBS8_TPBS32 -F TOP_PCMAX TOP_PCMAX_pem2_glwe1_bsk8_ksk8 -F TOP_PC TOP_PC_pem2_glwe1_bsk4_ksk4 -F APPLICATION APPLI_msg2_carry2 -F NTT_MOD NTT_MOD_goldilocks -F NTT_CORE_ARCH NTT_CORE_ARCH_gf64 -F NTT_CORE_R_PSI NTT_CORE_R2_PSI16 -F NTT_CORE_RDX_CUT NTT_CORE_RDX_CUT_n5c5c1 -F NTT_CORE_DIV NTT_CORE_DIV_1 -F BSK_SLOT_CUT BSK_SLOT8_CUT4 -F KSK_SLOT_CUT KSK_SLOT8_CUT4 -F KSLB KSLB_x2y32z3 -F HPU_PART HPU_PART_gf64 -F AXI_DATA_W AXI_DATA_W_512" "1:${PROJECT_DIR}/hw/output/micro_code/ucore_fw.elf" 'D:MEMORY_FILE_PATH=\\\"${PROJECT_DIR}/hw/\\\"' | tee build_out.log 6 | ``` 7 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/custom_iop/cust_0.asm: -------------------------------------------------------------------------------- 1 | # CUST_0 2 | # Simple IOp to check the xfer between Hpu/Cpu 3 | # Construct constant in dest slot -> 249 (0xf9) 4 | SUB R0 R0 R0 5 | ADDS R0 R0 1 6 | ST TD[0].0 R0 7 | SUB R1 R1 R1 8 | ADDS R1 R1 2 9 | ST TD[0].1 R1 10 | SUB R2 R2 R2 11 | ADDS R2 R2 3 12 | ST TD[0].2 R2 13 | SUB R3 R3 R3 14 | ADDS R3 R3 3 15 | ST TD[0].3 R3 16 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/custom_iop/cust_1.asm: -------------------------------------------------------------------------------- 1 | # CUST_1 2 | # Simple IOp to check the xfer between Hpu/Cpu 3 | # Dest <- Src_a 4 | LD R0 TS[0].0 5 | LD R1 TS[0].1 6 | LD R2 TS[0].2 7 | LD R3 TS[0].3 8 | ST TD[0].0 R0 9 | ST TD[0].1 R1 10 | ST TD[0].2 R2 11 | ST TD[0].3 R3 12 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/custom_iop/cust_10.asm: -------------------------------------------------------------------------------- 1 | ; CUST_8 2 | ; Simple IOp to check the ALU operation 3 | ; Dst[0].0 <- Src[0].0 + Src[1].0 4 | LD R1 TS[0].0 5 | LD R2 TS[1].0 6 | ADD R0 R1 R2 7 | ST TD[0].0 R0 8 | 9 | ; Dst[0].1 <- Src[0].1 + Src[1].1 10 | LD R5 TS[0].1 11 | LD R6 TS[1].1 12 | ADD R4 R5 R6 13 | ST TD[0].2 R4 14 | 15 | ; Dst[0].2 <- Src[0].2 + Src[1].2 16 | LD R9 TS[0].2 17 | LD R10 TS[1].2 18 | ADD R8 R9 R10 19 | ST TD[0].2 R8 20 | 21 | ; Dst[0].3 <- Src[0].3 + Src[1].3 22 | LD R13 TS[0].3 23 | LD R14 TS[1].3 24 | ADD R12 R13 R14 25 | ST TD[0].3 R0 26 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/custom_iop/cust_16.asm: -------------------------------------------------------------------------------- 1 | # CUST_16 2 | # Simple IOp to check PBS behavior 3 | # Dest <- PBSNone(Src_a.0) 4 | LD R0 TS[0].0 5 | PBS_F R0 R0 PbsNone 6 | ST TD[0].0 R0 7 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/custom_iop/cust_17.asm: -------------------------------------------------------------------------------- 1 | # CUST_17 2 | # Simple IOp to check PBS behavior 3 | # Dest <- PBSNone(Src_a) 4 | LD R0 TS[0].0 5 | PBS R0 R0 PbsNone 6 | ST TD[0].0 R0 7 | LD R1 TS[0].1 8 | PBS R1 R1 PbsNone 9 | ST TD[0].1 R1 10 | LD R2 TS[0].2 11 | PBS R2 R2 PbsNone 12 | ST TD[0].2 R2 13 | LD R3 TS[0].3 14 | PBS_F R3 R3 PbsNone 15 | ST TD[0].3 R3 16 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/custom_iop/cust_18.asm: -------------------------------------------------------------------------------- 1 | ; CUST_18 2 | ; Simple IOp to check extraction pattern 3 | ; Correct result: 4 | ; * Dst[0,1] <- Src[0][0,1] 5 | ; * Dst[2,3] <- Src[1][0,1] 6 | 7 | ; Pack Src[0][0,1] with a Mac and extract Carry/Msg in Dst[0][0,1] 8 | LD R0 TS[0].0 9 | LD R1 TS[0].1 10 | MAC R3 R1 R0 4 11 | PBS R4 R3 PbsMsgOnly 12 | PBS R5 R3 PbsCarryInMsg 13 | ST TD[0].0 R4 14 | ST TD[0].1 R5 15 | 16 | ; Pack Src[1][0,1] with a Mac and extract Carry/Msg in Dst[0][2,3] 17 | LD R10 TS[1].0 18 | LD R11 TS[1].1 19 | MAC R13 R11 R10 4 20 | PBS R14 R13 PbsMsgOnly 21 | PBS R15 R13 PbsCarryInMsg 22 | ST TD[0].2 R14 23 | ST TD[0].3 R15 24 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/custom_iop/cust_19.asm: -------------------------------------------------------------------------------- 1 | ; CUST_19 2 | ; Simple IOp to check PbsMl2 3 | ; Correct result: 4 | ; * Dst[0][0] <- Src[0][0] 5 | ; * Dst[0][1] <- 0 6 | ; * Dst[0][2] <- Src[0][0] +1 7 | ; * Dst[0][3] <- 0 8 | ; i.e Cust_19(0x2) => 0x32 9 | 10 | ; Construct a 0 for destination padding 11 | SUB R16 R16 R16 12 | 13 | ; Apply PbsMl2 on Src[0] result goes in dest[0][0-3] (0-padded) 14 | LD R0 TS[0].0 15 | PBS_ML2_F R0 R0 PbsTestMany2 16 | ST TD[0].0 R0 17 | ST TD[0].1 R16 18 | ST TD[0].2 R1 19 | ST TD[0].3 R16 20 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/custom_iop/cust_2.asm: -------------------------------------------------------------------------------- 1 | # CUST_2 2 | # Simple IOp to check the xfer between Hpu/Cpu 3 | # Dest <- Src_b 4 | LD R0 TS[1].0 5 | LD R1 TS[1].1 6 | LD R2 TS[1].2 7 | LD R3 TS[1].3 8 | ST TD[0].0 R0 9 | ST TD[0].1 R1 10 | ST TD[0].2 R2 11 | ST TD[0].3 R3 12 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/custom_iop/cust_20.asm: -------------------------------------------------------------------------------- 1 | ; CUST_20 2 | ; Simple IOp to check PbsMl4 3 | ; Correct result: 4 | ; * Dst[0][0] <- Src[0][0] 5 | ; * Dst[0][1] <- Src[0][0] +1 6 | ; * Dst[0][2] <- Src[0][0] +2 7 | ; * Dst[0][3] <- Src[0][0] +3 8 | ; i.e Cust_20(0x0) => 0xe4 9 | 10 | SUB R16 R16 R16 11 | ST TD[0].0 R0 12 | ST TD[0].1 R0 13 | ST TD[0].2 R0 14 | ST TD[0].3 R0 15 | 16 | ; Apply PbsMl4 on Src[0] result goes in dest[0][0-3] 17 | LD R0 TS[0].0 18 | PBS_ML4_F R0 R0 PbsTestMany4 19 | ST TD[0].0 R0 20 | ST TD[0].1 R1 21 | ST TD[0].2 R2 22 | ST TD[0].3 R3 23 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/custom_iop/cust_21.asm: -------------------------------------------------------------------------------- 1 | ; CUST_21 2 | ; Simple IOp to check PbsMl8 3 | ; WARN: This operation required 16b ct width 4 | ; Correct result: 5 | ; * Dst[0][0] <- Src[0][0] 6 | ; * Dst[0][1] <- Src[0][0] +1 7 | ; * Dst[0][2] <- Src[0][0] +2 8 | ; * Dst[0][3] <- Src[0][0] +3 9 | ; * Dst[0][4] <- Src[0][0] +4 10 | ; * Dst[0][5] <- Src[0][0] +5 11 | ; * Dst[0][6] <- Src[0][0] +6 12 | ; * Dst[0][7] <- Src[0][0] +7 13 | 14 | ; Apply PbsMl8 on Src[0] result goes in dest[0][0-7] 15 | LD R0 TS[0].0 16 | PBS_ML8_F R0 R0 PbsTestMany8 17 | ST TD[0].0 R0 18 | ST TD[0].1 R1 19 | ST TD[0].2 R2 20 | ST TD[0].3 R3 21 | ST TD[0].4 R4 22 | ST TD[0].5 R5 23 | ST TD[0].6 R6 24 | ST TD[0].7 R7 25 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/custom_iop/cust_3.asm: -------------------------------------------------------------------------------- 1 | # CUST_3 2 | # Simple IOp to check isc behavior 3 | # Generate obvious deps and check that isc correctly issued the dop 4 | # Correct result must bu Dest <- Src[0] 5 | LD R0 TS[0].0 6 | LD R1 TS[0].1 7 | LD R2 TS[0].2 8 | LD R3 TS[0].3 9 | PBS R4 R0 PbsNone 10 | ST TD[0].0 R4 11 | PBS R4 R1 PbsNone 12 | ST TD[0].1 R4 13 | PBS R4 R2 PbsNone 14 | ST TD[0].2 R4 15 | PBS_F R4 R3 PbsNone 16 | ST TD[0].3 R4 17 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/custom_iop/cust_8.asm: -------------------------------------------------------------------------------- 1 | ; CUST_8 2 | ; Simple IOp to check the ALU operation 3 | ; Dst[0].0 <- Src[0].0 + Src[1].0 4 | LD R1 TS[0].0 5 | LD R2 TS[1].0 6 | ADD R0 R1 R2 7 | ST TD[0].0 R0 8 | 9 | ; Dst[0].1 <- Src[0].1 - Src[1].1 10 | LD R5 TS[0].1 11 | LD R6 TS[1].1 12 | SUB R4 R5 R6 13 | ST TD[0].1 R4 14 | 15 | ; Dst[0].2 <- Src[0].2 + (Src[1].2 *4) 16 | LD R9 TS[0].2 17 | LD R10 TS[1].2 18 | MAC R8 R9 R10 4 19 | ST TD[0].2 R8 20 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/custom_iop/cust_9.asm: -------------------------------------------------------------------------------- 1 | ; CUST_9 2 | ; Simple IOp to check the ALU Scalar operation 3 | ; Dst[0].0 <- Src[0].0 + Imm[0].0 4 | LD R1 TS[0].0 5 | ADDS R0 R1 TI[0].0 6 | ST TD[0].0 R0 7 | 8 | ; Dst[0].1 <- Src[0].1 - Imm[0].1 9 | LD R5 TS[0].1 10 | SUBS R4 R5 TI[0].1 11 | ST TD[0].1 R4 12 | 13 | ; Dst[0].2 <- Imm[0].2 - Src[0].2 14 | LD R9 TS[0].2 15 | SSUB R8 R9 TI[0].2 16 | ST TD[0].2 R8 17 | 18 | ; Dst[0].3 <- Src[0].3 * Imm[0].3 19 | LD R13 TS[0].3 20 | MULS R12 R13 TI[0].3 21 | ST TD[0].3 R12 22 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/u55c_gf64/hpu_msplit_3parts.xclbin: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:35ad67cf9760e37256a6c92cf29ea67334690b724fd3b7b859919ee9b0bde6d3 3 | size 78194785 4 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/v80/custom_iop/cust_0.asm: -------------------------------------------------------------------------------- 1 | # CUST_0 2 | # Simple IOp to check the xfer between Hpu/Cpu 3 | # Construct constant in dest slot -> 249 (0xf9) 4 | SUB R0 R0 R0 5 | ADDS R0 R0 1 6 | ST TD[0].0 R0 7 | SUB R1 R1 R1 8 | ADDS R1 R1 2 9 | ST TD[0].1 R1 10 | SUB R2 R2 R2 11 | ADDS R2 R2 3 12 | ST TD[0].2 R2 13 | SUB R3 R3 R3 14 | ADDS R3 R3 3 15 | ST TD[0].3 R3 16 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/v80/custom_iop/cust_1.asm: -------------------------------------------------------------------------------- 1 | # CUST_1 2 | # Simple IOp to check the xfer between Hpu/Cpu 3 | # Dest <- Src_a 4 | LD R0 TS[0].0 5 | LD R1 TS[0].1 6 | LD R2 TS[0].2 7 | LD R3 TS[0].3 8 | ST TD[0].0 R0 9 | ST TD[0].1 R1 10 | ST TD[0].2 R2 11 | ST TD[0].3 R3 12 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/v80/custom_iop/cust_10.asm: -------------------------------------------------------------------------------- 1 | ; CUST_8 2 | ; Simple IOp to check the ALU operation 3 | ; Dst[0].0 <- Src[0].0 + Src[1].0 4 | LD R1 TS[0].0 5 | LD R2 TS[1].0 6 | ADD R0 R1 R2 7 | ST TD[0].0 R0 8 | 9 | ; Dst[0].1 <- Src[0].1 + Src[1].1 10 | LD R5 TS[0].1 11 | LD R6 TS[1].1 12 | ADD R4 R5 R6 13 | ST TD[0].2 R4 14 | 15 | ; Dst[0].2 <- Src[0].2 + Src[1].2 16 | LD R9 TS[0].2 17 | LD R10 TS[1].2 18 | ADD R8 R9 R10 19 | ST TD[0].2 R8 20 | 21 | ; Dst[0].3 <- Src[0].3 + Src[1].3 22 | LD R13 TS[0].3 23 | LD R14 TS[1].3 24 | ADD R12 R13 R14 25 | ST TD[0].3 R0 26 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/v80/custom_iop/cust_16.asm: -------------------------------------------------------------------------------- 1 | # CUST_16 2 | # Simple IOp to check PBS behavior 3 | # Dest <- PBSNone(Src_a.0) 4 | LD R0 TS[0].0 5 | PBS_F R0 R0 PbsNone 6 | ST TD[0].0 R0 7 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/v80/custom_iop/cust_17.asm: -------------------------------------------------------------------------------- 1 | # CUST_17 2 | # Simple IOp to check PBS behavior 3 | # Dest <- PBSNone(Src_a) 4 | LD R0 TS[0].0 5 | PBS R0 R0 PbsNone 6 | ST TD[0].0 R0 7 | LD R1 TS[0].1 8 | PBS R1 R1 PbsNone 9 | ST TD[0].1 R1 10 | LD R2 TS[0].2 11 | PBS R2 R2 PbsNone 12 | ST TD[0].2 R2 13 | LD R3 TS[0].3 14 | PBS_F R3 R3 PbsNone 15 | ST TD[0].3 R3 16 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/v80/custom_iop/cust_18.asm: -------------------------------------------------------------------------------- 1 | ; CUST_18 2 | ; Simple IOp to check extraction pattern 3 | ; Correct result: 4 | ; * Dst[0,1] <- Src[0][0,1] 5 | ; * Dst[2,3] <- Src[1][0,1] 6 | 7 | ; Pack Src[0][0,1] with a Mac and extract Carry/Msg in Dst[0][0,1] 8 | LD R0 TS[0].0 9 | LD R1 TS[0].1 10 | MAC R3 R1 R0 4 11 | PBS R4 R3 PbsMsgOnly 12 | PBS R5 R3 PbsCarryInMsg 13 | ST TD[0].0 R4 14 | ST TD[0].1 R5 15 | 16 | ; Pack Src[1][0,1] with a Mac and extract Carry/Msg in Dst[0][2,3] 17 | LD R10 TS[1].0 18 | LD R11 TS[1].1 19 | MAC R13 R11 R10 4 20 | PBS R14 R13 PbsMsgOnly 21 | PBS R15 R13 PbsCarryInMsg 22 | ST TD[0].2 R14 23 | ST TD[0].3 R15 24 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/v80/custom_iop/cust_19.asm: -------------------------------------------------------------------------------- 1 | ; CUST_19 2 | ; Simple IOp to check PbsMl2 3 | ; Correct result: 4 | ; * Dst[0][0] <- Src[0][0] 5 | ; * Dst[0][1] <- 0 6 | ; * Dst[0][2] <- Src[0][0] +1 7 | ; * Dst[0][3] <- 0 8 | ; i.e Cust_19(0x2) => 0x32 9 | 10 | ; Construct a 0 for destination padding 11 | SUB R16 R16 R16 12 | 13 | ; Apply PbsMl2 on Src[0] result goes in dest[0][0-3] (0-padded) 14 | LD R0 TS[0].0 15 | PBS_ML2_F R0 R0 PbsTestMany2 16 | ST TD[0].0 R0 17 | ST TD[0].1 R16 18 | ST TD[0].2 R1 19 | ST TD[0].3 R16 20 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/v80/custom_iop/cust_2.asm: -------------------------------------------------------------------------------- 1 | # CUST_2 2 | # Simple IOp to check the xfer between Hpu/Cpu 3 | # Dest <- Src_b 4 | LD R0 TS[1].0 5 | LD R1 TS[1].1 6 | LD R2 TS[1].2 7 | LD R3 TS[1].3 8 | ST TD[0].0 R0 9 | ST TD[0].1 R1 10 | ST TD[0].2 R2 11 | ST TD[0].3 R3 12 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/v80/custom_iop/cust_20.asm: -------------------------------------------------------------------------------- 1 | ; CUST_20 2 | ; Simple IOp to check PbsMl4 3 | ; Correct result: 4 | ; * Dst[0][0] <- Src[0][0] 5 | ; * Dst[0][1] <- Src[0][0] +1 6 | ; * Dst[0][2] <- Src[0][0] +2 7 | ; * Dst[0][3] <- Src[0][0] +3 8 | ; i.e Cust_20(0x0) => 0xe4 9 | 10 | SUB R16 R16 R16 11 | ST TD[0].0 R0 12 | ST TD[0].1 R0 13 | ST TD[0].2 R0 14 | ST TD[0].3 R0 15 | 16 | ; Apply PbsMl4 on Src[0] result goes in dest[0][0-3] 17 | LD R0 TS[0].0 18 | PBS_ML4_F R0 R0 PbsTestMany4 19 | ST TD[0].0 R0 20 | ST TD[0].1 R1 21 | ST TD[0].2 R2 22 | ST TD[0].3 R3 23 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/v80/custom_iop/cust_21.asm: -------------------------------------------------------------------------------- 1 | ; CUST_21 2 | ; Simple IOp to check PbsMl8 3 | ; WARN: This operation required 16b ct width 4 | ; Correct result: 5 | ; * Dst[0][0] <- Src[0][0] 6 | ; * Dst[0][1] <- Src[0][0] +1 7 | ; * Dst[0][2] <- Src[0][0] +2 8 | ; * Dst[0][3] <- Src[0][0] +3 9 | ; * Dst[0][4] <- Src[0][0] +4 10 | ; * Dst[0][5] <- Src[0][0] +5 11 | ; * Dst[0][6] <- Src[0][0] +6 12 | ; * Dst[0][7] <- Src[0][0] +7 13 | 14 | ; Apply PbsMl8 on Src[0] result goes in dest[0][0-7] 15 | LD R0 TS[0].0 16 | PBS_ML8_F R0 R0 PbsTestMany8 17 | ST TD[0].0 R0 18 | ST TD[0].1 R1 19 | ST TD[0].2 R2 20 | ST TD[0].3 R3 21 | ST TD[0].4 R4 22 | ST TD[0].5 R5 23 | ST TD[0].6 R6 24 | ST TD[0].7 R7 25 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/v80/custom_iop/cust_3.asm: -------------------------------------------------------------------------------- 1 | # CUST_3 2 | # Simple IOp to check isc behavior 3 | # Generate obvious deps and check that isc correctly issued the dop 4 | # Correct result must bu Dest <- Src[0] 5 | LD R0 TS[0].0 6 | LD R1 TS[0].1 7 | LD R2 TS[0].2 8 | LD R3 TS[0].3 9 | PBS R4 R0 PbsNone 10 | ST TD[0].0 R4 11 | PBS R4 R1 PbsNone 12 | ST TD[0].1 R4 13 | PBS R4 R2 PbsNone 14 | ST TD[0].2 R4 15 | PBS_F R4 R3 PbsNone 16 | ST TD[0].3 R4 17 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/v80/custom_iop/cust_8.asm: -------------------------------------------------------------------------------- 1 | ; CUST_8 2 | ; Simple IOp to check the ALU operation 3 | ; Dst[0].0 <- Src[0].0 + Src[1].0 4 | LD R1 TS[0].0 5 | LD R2 TS[1].0 6 | ADD R0 R1 R2 7 | ST TD[0].0 R0 8 | 9 | ; Dst[0].1 <- Src[0].1 - Src[1].1 10 | LD R5 TS[0].1 11 | LD R6 TS[1].1 12 | SUB R4 R5 R6 13 | ST TD[0].1 R4 14 | 15 | ; Dst[0].2 <- Src[0].2 + (Src[1].2 *4) 16 | LD R9 TS[0].2 17 | LD R10 TS[1].2 18 | MAC R8 R9 R10 4 19 | ST TD[0].2 R8 20 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/config_store/v80/custom_iop/cust_9.asm: -------------------------------------------------------------------------------- 1 | ; CUST_9 2 | ; Simple IOp to check the ALU Scalar operation 3 | ; Dst[0].0 <- Src[0].0 + Imm[0].0 4 | LD R1 TS[0].0 5 | ADDS R0 R1 TI[0].0 6 | ST TD[0].0 R0 7 | 8 | ; Dst[0].1 <- Src[0].1 - Imm[0].1 9 | LD R5 TS[0].1 10 | SUBS R4 R5 TI[0].1 11 | ST TD[0].1 R4 12 | 13 | ; Dst[0].2 <- Imm[0].2 - Src[0].2 14 | LD R9 TS[0].2 15 | SSUB R8 R9 TI[0].2 16 | ST TD[0].2 R8 17 | 18 | ; Dst[0].3 <- Src[0].3 * Imm[0].3 19 | LD R13 TS[0].3 20 | MULS R12 R13 TI[0].3 21 | ST TD[0].3 R12 22 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/figures/tfhe-hpu-backend.excalidraw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/backends/tfhe-hpu-backend/figures/tfhe-hpu-backend.excalidraw.png -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/python/README: -------------------------------------------------------------------------------- 1 | This contains a small library to read trace files retrieved from the hardware or the mockup. 2 | 3 | To run, please add the lib directory to your PYTHONPATH: 4 | 5 | export PYTHONPATH=$(readlink -m ./lib) 6 | 7 | Make sure you start from a fresh python virtual environment and install the requirements in 8 | requirements.txt: 9 | 10 | python -m venv new_env 11 | source new_env/bin/activate 12 | pip3 install -r requirements.txt 13 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/python/bin/demo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from pandas import DataFrame 4 | from isctrace.analysis import Refilled, Retired, Trace 5 | 6 | freq_mhz = 300 7 | 8 | iops = Trace.from_hw("data/trace.json") 9 | 10 | def analyze_iop(iop): 11 | retired = Retired(iop) 12 | 13 | # Print the retired instructions as a table 14 | print(retired.to_df().to_string()) 15 | 16 | # Print a batch latency table 17 | latency_table = retired.pbs_latency_table(freq_mhz=freq_mhz).drop(columns='data') 18 | print(latency_table) 19 | 20 | # And the runtime 21 | runtime = retired.runtime_us(freq_mhz=freq_mhz) 22 | print(f"batches: {latency_table['count'].sum()}") 23 | print(f"Runtime: {runtime}us") 24 | 25 | if __name__ == "__main__": 26 | analyze_iop(iops[0]) 27 | 28 | # vim: fdm=marker 29 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/python/lib/example.json: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c3701d5e7d53eef6478a1b03a2c8e32cf5d20c1eb6829e754fe1ced4a0a16bed 3 | size 693363 4 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/python/lib/isctrace/__init__.py: -------------------------------------------------------------------------------- 1 | from . import hw 2 | from . import fmt 3 | from . import analysis 4 | from . import mockup 5 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/python/requirements.txt: -------------------------------------------------------------------------------- 1 | pandas == 2.2.3 2 | numpy == 1.26.3 3 | logging 4 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/src/asm/tests/dop.asm: -------------------------------------------------------------------------------- 1 | ; DOp Asm snippets sample that depicts all available format 2 | ; with the != available arguments modes 3 | ; Test LD with various template format 4 | LD R1 @0x400 5 | LD R2 @386 6 | LD R3 TS[8].4 7 | LD R3 TD[8].4 8 | LD R4 TH.60 9 | 10 | ; Test ST with various template format 11 | ST @0x400 R1 12 | ST @386 R2 13 | ST TS[8].4 R3 14 | ST TD[4].0 R4 15 | ST TH.60 R4 16 | 17 | ; Test Arith operation 18 | ADD R2 R1 R3 19 | SUB R2 R1 R3 20 | MUL R2 R1 R3 21 | MAC R2 R1 R3 4 22 | 23 | ; Test ArithMsg operation with various immediat template format 24 | ADDS R2 R1 10 25 | SUBS R2 R1 TI[4].0 26 | SSUB R2 R1 TI[2].4 27 | SUBS R2 R1 TI[4].0 28 | 29 | ; Test Pbs operation 30 | PBS R2 R1 PbsNone 31 | PBS_F R2 R1 PbsCarryInMsg 32 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/src/entities/traits/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod container; 2 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/src/interface/memory/mod.rs: -------------------------------------------------------------------------------- 1 | // Xrt required memory allocation to be page aligned 2 | pub(crate) const MEM_PAGE_SIZE_B: usize = 4096; 3 | 4 | /// Compute the minimal size to keep page alignment 5 | pub fn page_align(size_b: usize) -> usize { 6 | size_b.div_ceil(MEM_PAGE_SIZE_B) * MEM_PAGE_SIZE_B 7 | } 8 | 9 | pub(crate) mod ciphertext; 10 | pub(crate) mod huge; 11 | pub use ciphertext::{CiphertextBundle, CiphertextMemory, CiphertextMemoryProperties}; 12 | pub use huge::{HugeMemory, HugeMemoryProperties}; 13 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/src/interface/rtl/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod params; 2 | pub mod runtime; 3 | 4 | use crate::ffi; 5 | use hw_regmap::FlatRegmap; 6 | /// Trait used to extract/parse information from Rtl registers 7 | pub trait FromRtl { 8 | fn from_rtl(ffi_hw: &mut ffi::HpuHw, regmap: &FlatRegmap) -> Self; 9 | } 10 | -------------------------------------------------------------------------------- /backends/tfhe-hpu-backend/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(all(feature = "hw-v80", feature = "hw-xrt"))] 2 | compile_error! {"hw-v80 and hw-xrt features are used to select the targeted fpga family. Only one fpga family can be used at a time thus these features are mutually exclusive. Only enable one of them at a time. "} 3 | 4 | mod entities; 5 | 6 | #[cfg(not(feature = "utils"))] 7 | mod ffi; 8 | #[cfg(feature = "utils")] 9 | pub mod ffi; 10 | #[cfg(feature = "utils")] 11 | pub mod isc_trace; 12 | 13 | pub mod interface; 14 | 15 | pub mod asm; 16 | pub mod fw; 17 | 18 | pub mod prelude; 19 | -------------------------------------------------------------------------------- /ci/ec2_products_cost.json: -------------------------------------------------------------------------------- 1 | { 2 | "m6i.metal": 7.168, 3 | "hpc7a.96xlarge": 7.7252, 4 | "p3.2xlarge": 3.06, 5 | "p3.8xlarge": 12.24, 6 | "p4d.24xlarge": 32.7726, 7 | "p5.48xlarge": 98.32, 8 | "rtx4090": 0.04, 9 | "n3-H100x1": 1.52, 10 | "n3-H100x8-NVLink": 12.48, 11 | "n3-H100x8": 12.16, 12 | "n3-H100x4": 6.08, 13 | "n3-H100x2": 3.04, 14 | "n3-L40x1": 0.80, 15 | "n3-H100x8-SXM5": 24 16 | } 17 | -------------------------------------------------------------------------------- /ci/webdriver_requirements.txt: -------------------------------------------------------------------------------- 1 | beautifulsoup4==4.12.3 2 | selenium==4.26.0 3 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | # Disable patch checks in GitHub until all tfhe-rs layers have coverage implemented. 4 | patch: false 5 | -------------------------------------------------------------------------------- /mockups/tfhe-hpu-mockup/figures/tfhe-hpu-mockup.excalidraw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/mockups/tfhe-hpu-mockup/figures/tfhe-hpu-mockup.excalidraw.png -------------------------------------------------------------------------------- /mockups/tfhe-hpu-mockup/src/modules/mod.rs: -------------------------------------------------------------------------------- 1 | //! Hpu Simulation model 2 | 3 | pub(crate) mod memory; 4 | pub(crate) use memory::{DdrMem, HbmBank, HBM_BANK_NB}; 5 | 6 | // mod regfile; 7 | pub(crate) mod regmap; 8 | pub(crate) use regmap::{RegisterEvent, RegisterMap}; 9 | 10 | pub(crate) mod ucore; 11 | pub(crate) use ucore::UCore; 12 | 13 | pub(crate) mod params; 14 | 15 | pub use tfhe::tfhe_hpu_backend::fw::isc_sim as isc; 16 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | unstable_features = true 2 | imports_granularity="Module" 3 | format_code_in_doc_comments = true 4 | wrap_comments = true 5 | comment_width = 100 6 | -------------------------------------------------------------------------------- /scripts/backward_compat_data_version.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | try: 4 | import tomllib # Python v3.11+ 5 | except ModuleNotFoundError: 6 | import pip._vendor.tomli as tomllib # the same tomllib that's now included in Python v3.11+ 7 | 8 | 9 | fname = "tests/Cargo.toml" 10 | with open(fname, "rb") as f: 11 | data = tomllib.load(f) 12 | 13 | dev_dependencies = data["dev-dependencies"] 14 | 15 | branch_name = dev_dependencies["tfhe-backward-compat-data"]["branch"] 16 | 17 | print(branch_name) 18 | -------------------------------------------------------------------------------- /scripts/clippy_driver.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eu 4 | 5 | exec clippy-driver ${CLIPPYFLAGS} $@ 6 | -------------------------------------------------------------------------------- /scripts/clone_backward_compat_data.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if [ $# -lt 3 ]; then 6 | echo "invalid arguments, usage:\n" 7 | echo "$0 git_url branch dest_path" 8 | exit 1 9 | fi 10 | 11 | if ! git lfs env 2>/dev/null >/dev/null; then 12 | echo "git lfs is not installed, please install it and try again" 13 | exit 1 14 | fi 15 | 16 | if [ -d $3 ]; then 17 | cd $3 && git remote set-branches origin '*' && git fetch --depth 1 && git reset --hard origin/$2 && git clean -dfx 18 | 19 | else 20 | git clone $1 -b $2 --depth 1 $3 21 | fi 22 | -------------------------------------------------------------------------------- /scripts/cpu_count.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | nproc_bin=nproc 4 | 5 | # macOS detects CPUs differently 6 | if [[ $(uname) == "Darwin" ]]; then 7 | nproc_bin="sysctl -n hw.logicalcpu" 8 | fi 9 | 10 | ${nproc_bin} 11 | -------------------------------------------------------------------------------- /scripts/no_dbg_calls.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | THIS_SCRIPT_NAME="$(basename "$0")" 6 | 7 | TMP_FILE="$(mktemp)" 8 | 9 | COUNT="$(git grep -rniI "dbg!" . | grep -v "${THIS_SCRIPT_NAME}" | \ 10 | tee "${TMP_FILE}" | wc -l | tr -d '[:space:]')" 11 | 12 | cat "${TMP_FILE}" 13 | rm -rf "${TMP_FILE}" 14 | 15 | if [[ "${COUNT}" == "0" ]]; then 16 | exit 0 17 | else 18 | echo "dbg macro calls detected, see output log above" 19 | exit 1 20 | fi 21 | -------------------------------------------------------------------------------- /scripts/no_tfhe_typo.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | THIS_SCRIPT_NAME="$(basename "$0")" 6 | 7 | TMP_FILE="$(mktemp)" 8 | 9 | COUNT="$(git grep -rniI "thfe\|tfhr\|thfr" . | grep -v "${THIS_SCRIPT_NAME}" | \ 10 | tee "${TMP_FILE}" | wc -l | tr -d '[:space:]')" 11 | 12 | cat "${TMP_FILE}" 13 | rm -rf "${TMP_FILE}" 14 | 15 | if [[ "${COUNT}" == "0" ]]; then 16 | exit 0 17 | else 18 | echo "tfhe typo detected, see output log above" 19 | exit 1 20 | fi 21 | -------------------------------------------------------------------------------- /scripts/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .utils import * 2 | -------------------------------------------------------------------------------- /tasks/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tasks" 3 | version = "0.0.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | clap = "=4.5.30" 10 | log = "0.4" 11 | simplelog = "0.12" 12 | walkdir = "2.5.0" 13 | no-comment = "0.0.3" 14 | -------------------------------------------------------------------------------- /tasks/src/utils.rs: -------------------------------------------------------------------------------- 1 | use std::path::{Path, PathBuf}; 2 | 3 | pub fn project_root() -> PathBuf { 4 | Path::new(&env!("CARGO_MANIFEST_DIR")) 5 | .ancestors() 6 | .nth(1) 7 | .unwrap() 8 | .to_path_buf() 9 | } 10 | -------------------------------------------------------------------------------- /tests/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tests" 3 | version = "0.1.0" 4 | edition = "2021" 5 | publish = false 6 | 7 | [dev-dependencies] 8 | tfhe = { path = "../tfhe" } 9 | tfhe-versionable = { path = "../utils/tfhe-versionable" } 10 | tfhe-backward-compat-data = { git = "https://github.com/zama-ai/tfhe-backward-compat-data.git", branch = "v0.7", default-features = false, features = [ 11 | "load", 12 | ] } 13 | ron = "0.8" 14 | cargo_toml = "0.22" 15 | 16 | 17 | [[test]] 18 | name = "backward_compatibility_tests" 19 | path = "backward_compatibility_tests.rs" 20 | 21 | [features] 22 | shortint = ["tfhe/shortint"] 23 | integer = ["shortint", "tfhe/integer"] 24 | zk-pok = ["tfhe/zk-pok"] 25 | -------------------------------------------------------------------------------- /tests/backward_compatibility/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "integer")] 2 | pub mod high_level_api; 3 | #[cfg(feature = "shortint")] 4 | pub mod shortint; 5 | -------------------------------------------------------------------------------- /tfhe-benchmark/benches/shortint/oprf.rs: -------------------------------------------------------------------------------- 1 | use benchmark::params_aliases::*; 2 | use criterion::{black_box, criterion_group, Criterion}; 3 | use tfhe::keycache::NamedParam; 4 | use tfhe::shortint::keycache::KEY_CACHE; 5 | use tfhe_csprng::seeders::Seed; 6 | 7 | fn oprf(c: &mut Criterion) { 8 | let bench_name = "shortint-oprf"; 9 | 10 | let mut bench_group = c.benchmark_group(bench_name); 11 | 12 | let param = BENCH_PARAM_MESSAGE_2_CARRY_2_KS_PBS; 13 | 14 | let keys = KEY_CACHE.get_from_param(param); 15 | let sks = keys.server_key(); 16 | 17 | bench_group.bench_function(format!("2-bits-oprf::{}", param.name()), |b| { 18 | b.iter(|| { 19 | _ = black_box(sks.generate_oblivious_pseudo_random(Seed(0), 2)); 20 | }) 21 | }); 22 | } 23 | 24 | criterion_group!(oprf2, oprf); 25 | 26 | fn main() { 27 | oprf2(); 28 | Criterion::default().configure_from_args().final_summary(); 29 | } 30 | -------------------------------------------------------------------------------- /tfhe-benchmark/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod params; 2 | pub mod params_aliases; 3 | pub mod utilities; 4 | -------------------------------------------------------------------------------- /tfhe-csprng/src/generators/aes_ctr/block_cipher.rs: -------------------------------------------------------------------------------- 1 | use crate::generators::aes_ctr::{AES_CALLS_PER_BATCH, BYTES_PER_AES_CALL, BYTES_PER_BATCH}; 2 | 3 | /// Represents a key used in the AES block cipher. 4 | #[derive(Clone, Copy)] 5 | pub struct AesKey(pub u128); 6 | 7 | /// A trait for AES block ciphers. 8 | /// 9 | /// Note: 10 | /// ----- 11 | /// 12 | /// The block cipher is used in a batched manner (to reduce amortized cost on special hardware). 13 | /// For this reason we only expose a `generate_batch` method. 14 | pub trait AesBlockCipher: Clone + Send + Sync { 15 | /// Instantiate a new generator from a secret key. 16 | fn new(key: AesKey) -> Self; 17 | /// Generates the batch corresponding to the given index. 18 | fn generate_batch(&mut self, data: [u128; AES_CALLS_PER_BATCH]) -> [u8; BYTES_PER_BATCH]; 19 | /// Generate next bytes 20 | fn generate_next(&mut self, data: u128) -> [u8; BYTES_PER_AES_CALL]; 21 | } 22 | -------------------------------------------------------------------------------- /tfhe-csprng/src/generators/implem/aarch64/mod.rs: -------------------------------------------------------------------------------- 1 | //! A module implementing a random number generator, using the aarch64 `neon` and `aes` 2 | //! instructions. 3 | //! 4 | //! This module implements a cryptographically secure pseudorandom number generator 5 | //! (CS-PRNG), using a fast block cipher. The implementation is based on the 6 | //! [intel aesni white paper 323641-001 revision 3.0](https://www.intel.com/content/dam/doc/white-paper/advanced-encryption-standard-new-instructions-set-paper.pdf). 7 | 8 | mod block_cipher; 9 | pub use block_cipher::ArmAesBlockCipher; 10 | 11 | mod generator; 12 | pub use generator::*; 13 | 14 | #[cfg(feature = "parallel")] 15 | mod parallel; 16 | #[cfg(feature = "parallel")] 17 | pub use parallel::*; 18 | -------------------------------------------------------------------------------- /tfhe-csprng/src/generators/implem/aesni/mod.rs: -------------------------------------------------------------------------------- 1 | //! A module implementing a random number generator, using the x86_64 `aesni` instructions. 2 | //! 3 | //! This module implements a cryptographically secure pseudorandom number generator 4 | //! (CS-PRNG), using a fast block cipher. The implementation is based on the 5 | //! [intel aesni white paper 323641-001 revision 3.0](https://www.intel.com/content/dam/doc/white-paper/advanced-encryption-standard-new-instructions-set-paper.pdf). 6 | 7 | mod block_cipher; 8 | pub use block_cipher::AesniBlockCipher; 9 | 10 | mod generator; 11 | pub use generator::*; 12 | 13 | #[cfg(feature = "parallel")] 14 | mod parallel; 15 | #[cfg(feature = "parallel")] 16 | pub use parallel::*; 17 | -------------------------------------------------------------------------------- /tfhe-csprng/src/generators/implem/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(target_arch = "x86_64")] 2 | mod aesni; 3 | #[cfg(target_arch = "x86_64")] 4 | pub use aesni::*; 5 | 6 | #[cfg(target_arch = "aarch64")] 7 | mod aarch64; 8 | #[cfg(target_arch = "aarch64")] 9 | pub use aarch64::*; 10 | 11 | mod soft; 12 | pub use soft::*; 13 | -------------------------------------------------------------------------------- /tfhe-csprng/src/generators/implem/soft/mod.rs: -------------------------------------------------------------------------------- 1 | //! A module using a software fallback implementation of random number generator. 2 | 3 | mod block_cipher; 4 | pub use block_cipher::SoftwareBlockCipher; 5 | 6 | mod generator; 7 | pub use generator::*; 8 | 9 | #[cfg(feature = "parallel")] 10 | mod parallel; 11 | #[cfg(feature = "parallel")] 12 | pub use parallel::*; 13 | -------------------------------------------------------------------------------- /tfhe-csprng/src/seeders/implem/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(target_os = "macos")] 2 | mod apple_secure_enclave_seeder; 3 | #[cfg(target_os = "macos")] 4 | pub use apple_secure_enclave_seeder::AppleSecureEnclaveSeeder; 5 | 6 | #[cfg(target_arch = "x86_64")] 7 | mod rdseed; 8 | #[cfg(target_arch = "x86_64")] 9 | pub use rdseed::RdseedSeeder; 10 | 11 | #[cfg(target_family = "unix")] 12 | mod unix; 13 | #[cfg(target_family = "unix")] 14 | pub use unix::UnixSeeder; 15 | -------------------------------------------------------------------------------- /tfhe-fft/.gitignore: -------------------------------------------------------------------------------- 1 | benchmarks_parameters/ 2 | -------------------------------------------------------------------------------- /tfhe-fft/rustfmt.toml: -------------------------------------------------------------------------------- 1 | unstable_features = true 2 | imports_granularity="Crate" 3 | format_code_in_doc_comments = true 4 | wrap_comments = true 5 | comment_width = 100 6 | -------------------------------------------------------------------------------- /tfhe-fft/src/nat.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | // TODO: remove this allow, clippy has a false positive on this for Plus2, Plus3 and Plus4 3 | 4 | pub struct Successor(pub N); 5 | pub struct Zero; 6 | pub type N0 = Zero; 7 | pub type N1 = Successor; 8 | pub type N2 = Successor; 9 | pub type N3 = Successor; 10 | pub type N4 = Successor; 11 | pub type N5 = Successor; 12 | pub type N6 = Successor; 13 | pub type N7 = Successor; 14 | pub type N8 = Successor; 15 | pub type N9 = Successor; 16 | 17 | pub trait Nat { 18 | const VALUE: usize; 19 | } 20 | 21 | impl Nat for Zero { 22 | const VALUE: usize = 0; 23 | } 24 | impl Nat for Successor { 25 | const VALUE: usize = N::VALUE + 1; 26 | } 27 | 28 | pub type Plus1 = Successor; 29 | pub type Plus2 = Successor>; 30 | pub type Plus3 = Successor>; 31 | pub type Plus4 = Successor>; 32 | -------------------------------------------------------------------------------- /tfhe-fft/src/time/mod.rs: -------------------------------------------------------------------------------- 1 | //! The standard API for Instant is not available in Wasm runtimes. 2 | //! This module replaces the Instant type from std to a custom implementation. 3 | 4 | #[cfg(target_arch = "wasm32")] 5 | mod wasm; 6 | 7 | #[cfg(target_arch = "wasm32")] 8 | pub(crate) use wasm::Instant; 9 | 10 | #[cfg(not(target_arch = "wasm32"))] 11 | pub(crate) use std::time::Instant; 12 | -------------------------------------------------------------------------------- /tfhe-fft/src/time/wasm.rs: -------------------------------------------------------------------------------- 1 | pub(crate) struct Instant { 2 | start: f64, 3 | } 4 | 5 | impl Instant { 6 | /// This function only has a millisecond resolution on some platforms like the chrome browser 7 | pub fn now() -> Self { 8 | let now = js_sys::Date::new_0().get_time(); 9 | Self { start: now } 10 | } 11 | 12 | /// This function only has a millisecond resolution on some platforms like the chrome browser, 13 | /// which means it can easily return 0 when called on quick code 14 | pub fn elapsed(&self) -> core::time::Duration { 15 | let now = js_sys::Date::new_0().get_time(); 16 | core::time::Duration::from_millis((now - self.start) as u64) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tfhe-ntt/.gitignore: -------------------------------------------------------------------------------- 1 | benchmarks_parameters/ 2 | -------------------------------------------------------------------------------- /tfhe-ntt/benches/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | 3 | mod ntt; 4 | -------------------------------------------------------------------------------- /tfhe-ntt/rustfmt.toml: -------------------------------------------------------------------------------- 1 | unstable_features = true 2 | imports_granularity="Crate" 3 | format_code_in_doc_comments = true 4 | wrap_comments = true 5 | comment_width = 100 6 | -------------------------------------------------------------------------------- /tfhe-zk-pok/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /tfhe-zk-pok/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod curve_446; 2 | pub mod curve_api; 3 | pub mod proofs; 4 | pub mod serialization; 5 | 6 | pub mod backward_compatibility; 7 | mod four_squares; 8 | -------------------------------------------------------------------------------- /tfhe/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /tfhe/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # tfhe/CMakeLists.txt 2 | cmake_minimum_required(VERSION 3.16) 3 | project(tfhe-c-api C) 4 | set(SOURCE c_api_tests/*.c) 5 | enable_testing() 6 | add_subdirectory(c_api_tests) 7 | -------------------------------------------------------------------------------- /tfhe/c_api_tests/.clang-format: -------------------------------------------------------------------------------- 1 | ColumnLimit: 100 2 | -------------------------------------------------------------------------------- /tfhe/docs/.gitbook/assets/build1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/.gitbook/assets/build1.png -------------------------------------------------------------------------------- /tfhe/docs/.gitbook/assets/build2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/.gitbook/assets/build2.png -------------------------------------------------------------------------------- /tfhe/docs/.gitbook/assets/build3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/.gitbook/assets/build3.png -------------------------------------------------------------------------------- /tfhe/docs/.gitbook/assets/doc_header_tfhe-rs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/.gitbook/assets/doc_header_tfhe-rs.png -------------------------------------------------------------------------------- /tfhe/docs/.gitbook/assets/start1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/.gitbook/assets/start1.png -------------------------------------------------------------------------------- /tfhe/docs/.gitbook/assets/start2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/.gitbook/assets/start2.png -------------------------------------------------------------------------------- /tfhe/docs/.gitbook/assets/start3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/.gitbook/assets/start3.png -------------------------------------------------------------------------------- /tfhe/docs/_static/carry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/_static/carry.png -------------------------------------------------------------------------------- /tfhe/docs/_static/ciphertext-representation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/_static/ciphertext-representation.png -------------------------------------------------------------------------------- /tfhe/docs/_static/integer-ciphertext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/_static/integer-ciphertext.png -------------------------------------------------------------------------------- /tfhe/docs/_static/lwe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/_static/lwe.png -------------------------------------------------------------------------------- /tfhe/docs/_static/multisum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/_static/multisum.png -------------------------------------------------------------------------------- /tfhe/docs/_static/overflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/_static/overflow.png -------------------------------------------------------------------------------- /tfhe/docs/_static/sha256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/_static/sha256.png -------------------------------------------------------------------------------- /tfhe/docs/_static/tfhe-rs-doc-home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/docs/_static/tfhe-rs-doc-home.png -------------------------------------------------------------------------------- /tfhe/docs/configuration/gpu_acceleration/benchmark.md: -------------------------------------------------------------------------------- 1 | # Benchmarks 2 | 3 | Please refer to the [GPU benchmarks](../../getting_started/benchmarks/gpu/README.md) for detailed performance benchmark results. 4 | 5 | {% hint style="warning" %} 6 | When measuring GPU times on your own on Linux, set the environment variable `CUDA_MODULE_LOADING=EAGER` to avoid CUDA API overheads during the first kernel execution. 7 | {% endhint %} 8 | -------------------------------------------------------------------------------- /tfhe/docs/configuration/hpu_acceleration/benchmark.md: -------------------------------------------------------------------------------- 1 | # Benchmarks 2 | 3 | Please refer to the [HPU benchmarks](../../getting_started/benchmarks/hpu/README.md) for detailed performance benchmark results. 4 | -------------------------------------------------------------------------------- /tfhe/docs/fhe-computation/advanced-features/README.md: -------------------------------------------------------------------------------- 1 | # Advanced features 2 | -------------------------------------------------------------------------------- /tfhe/docs/fhe-computation/compute/decrypt-data.md: -------------------------------------------------------------------------------- 1 | # Decrypt data 2 | 3 | This document provides instructions on how to decrypt data. 4 | 5 | To decrypt data, use the `decrypt` method from the `FheDecrypt` trait: 6 | 7 | ```rust 8 | use tfhe::prelude::*; 9 | use tfhe::{generate_keys, ConfigBuilder, FheUint8}; 10 | 11 | fn main() { 12 | let config = ConfigBuilder::default().build(); 13 | 14 | let (client_key, server_key) = generate_keys(config); 15 | 16 | let clear_a = 27u8; 17 | let clear_b = 128u8; 18 | 19 | let a = FheUint8::encrypt(clear_a, &client_key); 20 | let b = FheUint8::encrypt(clear_b, &client_key); 21 | 22 | let decrypted_a: u8 = a.decrypt(&client_key); 23 | let decrypted_b: u8 = b.decrypt(&client_key); 24 | 25 | assert_eq!(decrypted_a, clear_a); 26 | assert_eq!(decrypted_b, clear_b); 27 | } 28 | ``` 29 | -------------------------------------------------------------------------------- /tfhe/docs/fhe-computation/compute/encrypt-data.md: -------------------------------------------------------------------------------- 1 | # Encrypt data 2 | 3 | This document explains how to encrypt data. 4 | 5 | To encrypt data, use the `encrypt` method from the `FheEncrypt` trait. This crate provides types that implement either `FheEncrypt` or `FheTryEncrypt` or both, to enable encryption. 6 | 7 | Here is an example: 8 | 9 | ```rust 10 | use tfhe::prelude::*; 11 | use tfhe::{generate_keys, ConfigBuilder, FheUint8}; 12 | 13 | fn main() { 14 | let config = ConfigBuilder::default().build(); 15 | 16 | let (client_key, server_key) = generate_keys(config); 17 | 18 | let clear_a = 27u8; 19 | let clear_b = 128u8; 20 | 21 | let a = FheUint8::encrypt(clear_a, &client_key); 22 | let b = FheUint8::encrypt(clear_b, &client_key); 23 | } 24 | ``` 25 | -------------------------------------------------------------------------------- /tfhe/docs/fhe-computation/compute/set-the-server-key.md: -------------------------------------------------------------------------------- 1 | # Set the server key 2 | 3 | This document explains how to call the function `set_server_key`. 4 | 5 | This function will **move** the server key to an internal state of the crate and manage the details for a simpler interface. 6 | 7 | Here is an example: 8 | 9 | ```rust 10 | use tfhe::{ConfigBuilder, generate_keys, set_server_key}; 11 | 12 | fn main() { 13 | let config = ConfigBuilder::default().build(); 14 | 15 | let (client_key, server_key) = generate_keys(config); 16 | 17 | set_server_key(server_key); 18 | } 19 | ``` 20 | -------------------------------------------------------------------------------- /tfhe/docs/fhe-computation/data-handling/README.md: -------------------------------------------------------------------------------- 1 | # Data handling 2 | -------------------------------------------------------------------------------- /tfhe/docs/fhe-computation/operations/boolean-operations.md: -------------------------------------------------------------------------------- 1 | # Boolean Operations 2 | 3 | This document details the Booleans operations supported by **TFHE-rs**. 4 | 5 | Native homomorphic Booleans support the following common Boolean operations: 6 | 7 | | name | symbol | type | 8 | | ------------------------------------------------------------- | ------ | ------ | 9 | | [BitAnd](https://doc.rust-lang.org/std/ops/trait.BitAnd.html) | `&` | Binary | 10 | | [BitOr](https://doc.rust-lang.org/std/ops/trait.BitOr.html) | `\|` | Binary | 11 | | [BitXor](https://doc.rust-lang.org/std/ops/trait.BitXor.html) | `^` | Binary | 12 | | [Not](https://doc.rust-lang.org/std/ops/trait.Not.html) | `!` | Unary | 13 | -------------------------------------------------------------------------------- /tfhe/docs/fhe-computation/tooling/README.md: -------------------------------------------------------------------------------- 1 | # Tooling 2 | -------------------------------------------------------------------------------- /tfhe/docs/fhe-computation/types/README.md: -------------------------------------------------------------------------------- 1 | # Types 2 | -------------------------------------------------------------------------------- /tfhe/docs/fhe-computation/types/integer.md: -------------------------------------------------------------------------------- 1 | # Integer 2 | 3 | This document describes the main integer types of encrypted data in **TFHE-rs** and explains how to specify bit sizes for encryption. 4 | 5 | **TFHE-rs** supports two main types of encrypted data: 6 | 7 | * `FheUint`: homomorphic equivalent of Rust unsigned integers `u8, u16, ...` 8 | * `FheInt`: homomorphic equivalent of Rust signed integers `i8, i16, ...` 9 | 10 | **TFHE-rs** uses integers to encrypt all messages which are larger than 4 bits. 11 | 12 | Similar to Rust integers, you need to specify the bit size of data when declaring a variable: 13 | 14 | ```Rust 15 | // let clear_a: u64 = 7; 16 | let mut a = FheUint64::try_encrypt(clear_a, &keys)?; 17 | 18 | // let clear_b: i8 = 3; 19 | let mut b = FheInt8::try_encrypt(clear_b, &keys)?; 20 | 21 | // let clear_c: u128 = 2; 22 | let mut c = FheUint128::try_encrypt(clear_c, &keys)?; 23 | ``` 24 | -------------------------------------------------------------------------------- /tfhe/docs/getting_started/benchmarks/cpu/README.md: -------------------------------------------------------------------------------- 1 | # Benchmarks over CPU 2 | 3 | This document details the CPU performance benchmarks of homomorphic operations using **TFHE-rs**. 4 | 5 | By their nature, homomorphic operations run slower than their cleartext equivalents. 6 | 7 | {% hint style="info" %} 8 | All CPU benchmarks were launched on an `AWS hpc7a.96xlarge` instance equipped with a 96-core `AMD EPYC 9R14 CPU @ 2.60GHz` and 740GB of RAM. 9 | {% endhint %} 10 | 11 | * [Integer operations](cpu_integer_operations.md) 12 | * [Programmable Bootstrapping](cpu_programmable_bootstrapping.md) 13 | -------------------------------------------------------------------------------- /tfhe/docs/getting_started/benchmarks/gpu/README.md: -------------------------------------------------------------------------------- 1 | # Benchmarks over GPU 2 | 3 | This document details the GPU performance benchmarks of homomorphic operations using **TFHE-rs**. 4 | 5 | By their nature, homomorphic operations run slower than their cleartext equivalents. 6 | 7 | {% hint style="info" %} 8 | All GPU benchmarks were launched on H100 GPUs, and rely on the multithreaded PBS algorithm. 9 | {% endhint %} 10 | 11 | * [Integer operations](gpu_integer_operations.md) 12 | * [Programmable Bootstrapping](gpu_programmable_bootstrapping.md) 13 | -------------------------------------------------------------------------------- /tfhe/docs/getting_started/benchmarks/hpu/README.md: -------------------------------------------------------------------------------- 1 | # Benchmarks over HPU 2 | 3 | This document details the HPU performance benchmarks of homomorphic operations using **TFHE-rs**. 4 | 5 | By their nature, homomorphic operations run slower than their cleartext equivalents. 6 | 7 | {% hint style="info" %} 8 | All HPU benchmarks were launched on AMD Alveo v80 FPGAs. 9 | {% endhint %} 10 | 11 | * [Integer operations](hpu_integer_operations.md) 12 | -------------------------------------------------------------------------------- /tfhe/docs/getting_started/benchmarks/zk_proof_benchmarks.md: -------------------------------------------------------------------------------- 1 | # Zero-knowledge proof benchmarks 2 | 3 | This document details the performance benchmarks of [zero-knowledge proofs](../../fhe-computation/advanced-features/zk-pok.md) for [compact public key encryption](../../fhe-computation/advanced-features/public_key.md) using **TFHE-rs**. 4 | 5 | Benchmarks for the zero-knowledge proofs have been run on a `m6i.4xlarge` with 16 cores to simulate a usual client configuration. The verifications are done on an `hpc7a.96xlarge` AWS instance to mimic a powerful server. 6 | 7 | {% embed url="https://docs.google.com/spreadsheets/d/1x12I7Tkdx63Q6sNllygg6urSd5KC1sj1wj4L9jWiET4/edit?usp=sharing" %} 8 | -------------------------------------------------------------------------------- /tfhe/docs/references/core-crypto-api/README.md: -------------------------------------------------------------------------------- 1 | # Core crypto API 2 | 3 | * [Quick start](presentation.md) 4 | * [Tutorial](tutorial.md) 5 | -------------------------------------------------------------------------------- /tfhe/docs/references/fine-grained-apis/README.md: -------------------------------------------------------------------------------- 1 | # Fine-grained APIs 2 | 3 | * [Quick start](quick\_start.md) 4 | * [Boolean](boolean/) 5 | * [Shortint](shortint/) 6 | * [Integer](integer/) 7 | -------------------------------------------------------------------------------- /tfhe/docs/references/fine-grained-apis/integer/parameters.md: -------------------------------------------------------------------------------- 1 | # Cryptographic Parameters 2 | 3 | `integer` does not come with its own set of parameters. Instead, it relies on parameters from `shortint`. Currently, parameter sets having the same space dedicated to the message and the carry (i.e. `PARAM_MESSAGE_{X}_CARRY_{X}` with `X` in \[1,4]) are recommended. See [here](../shortint/parameters.md) for more details about cryptographic parameters, and [here](operations.md) to see how to properly instantiate integers depending on the chosen representation. 4 | -------------------------------------------------------------------------------- /tfhe/docs/tutorials/see-all-tutorials.md: -------------------------------------------------------------------------------- 1 | # See all tutorials 2 | 3 | ### Start here 4 | 5 | * [Homomorphic parity bit](parity\_bit.md) 6 | * [Homomorphic case changing on Ascii string](ascii\_fhe\_string.md) 7 | * [SHA 256 with Boolean API](sha256\_bool.md) 8 | 9 | ### Go further 10 | 11 | #### Blog tutorials and articles 12 | 13 | * [Dark Market with TFHE-rs](https://www.zama.ai/post/dark-market-tfhe-rs) - July 7, 2023 14 | * [Regular Expression Engine with TFHE-rs](https://www.zama.ai/post/regex-engine-tfhe-rs) - June 30, 2023 15 | 16 | #### Video tutorials 17 | * [Implement GPU acceleration on homomorphic computation using TFHE-rs](https://www.zama.ai/post/video-tutorial-implement-gpu-acceleration-on-homomorphic-computation-using-tfhe-rs) - May 2024 18 | * [Implement signed integers using TFHE-rs](https://www.youtube.com/watch?v=O0aGj\_xUo40) - Nov 8, 2023 19 | -------------------------------------------------------------------------------- /tfhe/examples/pbs_count.rs: -------------------------------------------------------------------------------- 1 | use tfhe::prelude::*; 2 | use tfhe::*; 3 | 4 | pub fn main() { 5 | let config = ConfigBuilder::default().build(); 6 | 7 | let (cks, sks) = generate_keys(config); 8 | 9 | let a = FheUint32::encrypt(42u32, &cks); 10 | let b = FheUint32::encrypt(69u32, &cks); 11 | 12 | set_server_key(sks); 13 | 14 | let c = &a * &b; 15 | let mul_32_count = get_pbs_count(); 16 | 17 | reset_pbs_count(); 18 | let d = &a & &b; 19 | let and_32_count = get_pbs_count(); 20 | 21 | println!("mul_32_count: {mul_32_count}"); 22 | println!("and_32_count: {and_32_count}"); 23 | 24 | let c_dec: u32 = c.decrypt(&cks); 25 | let d_dec: u32 = d.decrypt(&cks); 26 | 27 | assert_eq!(42 * 69, c_dec); 28 | assert_eq!(42 & 69, d_dec); 29 | } 30 | -------------------------------------------------------------------------------- /tfhe/examples/regex_engine/ciphertext.rs: -------------------------------------------------------------------------------- 1 | use tfhe::integer::{gen_keys_radix, RadixCiphertext, RadixClientKey, ServerKey}; 2 | use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS; 3 | 4 | pub type StringCiphertext = Vec; 5 | 6 | pub fn encrypt_str( 7 | client_key: &RadixClientKey, 8 | s: &str, 9 | ) -> Result> { 10 | if !s.is_ascii() { 11 | return Err("content contains non-ascii characters".into()); 12 | } 13 | Ok(s.as_bytes() 14 | .iter() 15 | .map(|byte| client_key.encrypt(*byte as u64)) 16 | .collect()) 17 | } 18 | 19 | pub fn gen_keys() -> (RadixClientKey, ServerKey) { 20 | let num_block = 4; 21 | gen_keys_radix(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_block) 22 | } 23 | -------------------------------------------------------------------------------- /tfhe/examples/regex_engine/main.rs: -------------------------------------------------------------------------------- 1 | mod ciphertext; 2 | mod engine; 3 | mod execution; 4 | mod parser; 5 | 6 | use env_logger::Env; 7 | use std::env; 8 | 9 | fn main() { 10 | let env = Env::default().filter_or("RUST_LOG", "info"); 11 | env_logger::init_from_env(env); 12 | 13 | let args: Vec = env::args().collect(); 14 | let content = &args[1]; 15 | let pattern = &args[2]; 16 | 17 | let (client_key, server_key) = ciphertext::gen_keys(); 18 | let ct_content = ciphertext::encrypt_str(&client_key, content).unwrap(); 19 | 20 | let ct_res = engine::has_match(&server_key, &ct_content, pattern).unwrap(); 21 | let res: u64 = client_key.decrypt(&ct_res); 22 | if res == 0 { 23 | println!("no match"); 24 | } else { 25 | println!("match"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tfhe/js_on_wasm_tests/.prettierignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | node_modules/ 3 | pkg/ 4 | test/benchmark_results/ 5 | -------------------------------------------------------------------------------- /tfhe/js_on_wasm_tests/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: fmt # Format Javascript code 2 | fmt: 3 | npm install 4 | npm run format 5 | 6 | .PHONY: check_fmt # Check Javascript code format 7 | check_fmt: 8 | npm install 9 | npm run check-format 10 | -------------------------------------------------------------------------------- /tfhe/js_on_wasm_tests/index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/js_on_wasm_tests/index.js -------------------------------------------------------------------------------- /tfhe/js_on_wasm_tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js_on_wasm_tests", 3 | "version": "1.0.0", 4 | "description": "JS API tests", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "node --test --test-reporter=tap", 8 | "format": "prettier . --write", 9 | "check-format": "prettier . --check" 10 | }, 11 | "devDependencies": { 12 | "prettier": "^3.3.3" 13 | }, 14 | "author": "", 15 | "license": "BSD-3-Clause-Clear" 16 | } 17 | -------------------------------------------------------------------------------- /tfhe/src/boolean/backward_compatibility/ciphertext.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::boolean::ciphertext::{Ciphertext, CompressedCiphertext}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum CiphertextVersions { 7 | V0(Ciphertext), 8 | } 9 | 10 | #[derive(VersionsDispatch)] 11 | pub enum CompressedCiphertextVersions { 12 | V0(CompressedCiphertext), 13 | } 14 | -------------------------------------------------------------------------------- /tfhe/src/boolean/backward_compatibility/client_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::boolean::client_key::ClientKey; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum ClientKeyVersions { 7 | V0(ClientKey), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/boolean/backward_compatibility/key_switching_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::boolean::key_switching_key::KeySwitchingKey; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum KeySwitchingKeyVersions { 7 | V0(KeySwitchingKey), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/boolean/backward_compatibility/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ciphertext; 2 | pub mod client_key; 3 | pub mod key_switching_key; 4 | pub mod parameters; 5 | pub mod public_key; 6 | pub mod server_key; 7 | -------------------------------------------------------------------------------- /tfhe/src/boolean/backward_compatibility/parameters.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::boolean::parameters::{BooleanKeySwitchingParameters, BooleanParameters}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum BooleanParametersVersions { 7 | V0(BooleanParameters), 8 | } 9 | 10 | #[derive(VersionsDispatch)] 11 | pub enum BooleanKeySwitchingParametersVersions { 12 | V0(BooleanKeySwitchingParameters), 13 | } 14 | -------------------------------------------------------------------------------- /tfhe/src/boolean/backward_compatibility/public_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::boolean::public_key::{CompressedPublicKey, PublicKey}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum PublicKeyVersions { 7 | V0(PublicKey), 8 | } 9 | 10 | #[derive(VersionsDispatch)] 11 | pub enum CompressedPublicKeyVersions { 12 | V0(CompressedPublicKey), 13 | } 14 | -------------------------------------------------------------------------------- /tfhe/src/boolean/backward_compatibility/server_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::boolean::server_key::{CompressedServerKey, ServerKey}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum ServerKeyVersions { 7 | V0(ServerKey), 8 | } 9 | 10 | #[derive(VersionsDispatch)] 11 | pub enum CompressedServerKeyVersions { 12 | V0(CompressedServerKey), 13 | } 14 | -------------------------------------------------------------------------------- /tfhe/src/boolean/prelude.rs: -------------------------------------------------------------------------------- 1 | //! Module with the definition of the prelude. 2 | //! 3 | //! The TFHE-rs preludes include convenient imports. 4 | //! Having `tfhe::boolean::prelude::*;` should be enough to start using the lib. 5 | 6 | pub use super::ciphertext::{Ciphertext, CompressedCiphertext}; 7 | pub use super::client_key::ClientKey; 8 | pub use super::gen_keys; 9 | pub use super::key_switching_key::KeySwitchingKey; 10 | pub use super::parameters::*; 11 | pub use super::public_key::{CompressedPublicKey, PublicKey}; 12 | pub use super::server_key::{BinaryBooleanGates, ServerKey}; 13 | -------------------------------------------------------------------------------- /tfhe/src/boolean/public_key/mod.rs: -------------------------------------------------------------------------------- 1 | mod compressed; 2 | mod standard; 3 | 4 | pub use compressed::CompressedPublicKey; 5 | pub use standard::PublicKey; 6 | -------------------------------------------------------------------------------- /tfhe/src/c_api/high_level_api/i128.rs: -------------------------------------------------------------------------------- 1 | /// w0 and w1 are words in little endian order 2 | /// using two's complement representation 3 | #[repr(C)] 4 | #[derive(Copy, Clone)] 5 | pub struct I128 { 6 | pub w0: u64, 7 | pub w1: u64, 8 | } 9 | 10 | impl From for I128 { 11 | fn from(value: i128) -> Self { 12 | let w0 = (value & (u64::MAX as i128)) as u64; 13 | let w1 = (value >> 64) as u64; 14 | Self { w0, w1 } 15 | } 16 | } 17 | 18 | impl From for i128 { 19 | fn from(value: I128) -> Self { 20 | ((value.w1 as Self) << 64u128) | value.w0 as Self 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tfhe/src/c_api/high_level_api/u128.rs: -------------------------------------------------------------------------------- 1 | #[repr(C)] 2 | #[derive(Copy, Clone)] 3 | pub struct U128 { 4 | pub w0: u64, 5 | pub w1: u64, 6 | } 7 | 8 | impl From for U128 { 9 | fn from(value: u128) -> Self { 10 | let w0 = (value & (u64::MAX as u128)) as u64; 11 | let w1 = (value >> 64) as u64; 12 | Self { w0, w1 } 13 | } 14 | } 15 | 16 | impl From for u128 { 17 | fn from(value: U128) -> Self { 18 | ((value.w1 as Self) << 64u128) | value.w0 as Self 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tfhe/src/c_api/mod.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::missing_safety_doc)] 2 | #[cfg(feature = "boolean-c-api")] 3 | pub mod boolean; 4 | pub mod buffer; 5 | pub mod core_crypto; 6 | pub mod error; 7 | #[cfg(feature = "high-level-c-api")] 8 | pub mod high_level_api; 9 | #[cfg(feature = "shortint-c-api")] 10 | pub mod shortint; 11 | pub(crate) mod utils; 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/algorithms/test/noise_distribution/variance_formula/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod lwe_keyswitch; 2 | pub mod lwe_programmable_bootstrap; 3 | pub mod secure_noise; 4 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/commons/ciphertext_modulus.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::commons::ciphertext_modulus::SerializableCiphertextModulus; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum SerializableCiphertextModulusVersions { 7 | V0(SerializableCiphertextModulus), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/commons/dispersion.rs: -------------------------------------------------------------------------------- 1 | use crate::core_crypto::commons::dispersion::{StandardDev, Variance}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | #[derive(VersionsDispatch)] 5 | pub enum StandardDevVersions { 6 | V0(StandardDev), 7 | } 8 | 9 | #[derive(VersionsDispatch)] 10 | pub enum VarianceVersions { 11 | V0(Variance), 12 | } 13 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/commons/math/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod random; 2 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/commons/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ciphertext_modulus; 2 | pub mod dispersion; 3 | pub mod math; 4 | pub mod parameters; 5 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/cleartext.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Cleartext, Numeric}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum CleartextVersions { 7 | V0(Cleartext), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/compressed_modulus_switched_glwe_ciphertext.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::compressed_modulus_switched_glwe_ciphertext::CompressedModulusSwitchedGlweCiphertext; 4 | use crate::core_crypto::prelude::UnsignedInteger; 5 | 6 | #[derive(VersionsDispatch)] 7 | pub enum CompressedModulusSwitchedGlweCiphertextVersions { 8 | V0(CompressedModulusSwitchedGlweCiphertext), 9 | } 10 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/ggsw_ciphertext.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, GgswCiphertext, UnsignedInteger}; 5 | 6 | impl Deprecable for GgswCiphertext 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "GgswCiphertext"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum GgswCiphertextVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(GgswCiphertext), 21 | } 22 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/ggsw_ciphertext_list.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, GgswCiphertextList, UnsignedInteger}; 5 | 6 | impl Deprecable for GgswCiphertextList 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "GgswCiphertextList"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum GgswCiphertextListVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(GgswCiphertextList), 21 | } 22 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/glwe_ciphertext.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, GlweCiphertext, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum GlweCiphertextVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(GlweCiphertext), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/glwe_ciphertext_list.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, GlweCiphertextList, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum GlweCiphertextListVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(GlweCiphertextList), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/glwe_keyswitch_key.rs: -------------------------------------------------------------------------------- 1 | use crate::core_crypto::prelude::{Container, GlweKeyswitchKey, UnsignedInteger}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | #[derive(VersionsDispatch)] 5 | pub enum GlweKeyswitchKeyVersions 6 | where 7 | C::Element: UnsignedInteger, 8 | { 9 | V0(GlweKeyswitchKey), 10 | } 11 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/glwe_secret_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, GlweSecretKey}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum GlweSecretKeyVersions { 7 | V0(GlweSecretKey), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/gsw_ciphertext.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, GswCiphertext}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum GswCiphertextVersions { 7 | V0(GswCiphertext), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/lwe_bootstrap_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, LweBootstrapKey, UnsignedInteger}; 5 | 6 | impl Deprecable for LweBootstrapKey 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "LweBootstrapKey"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum LweBootstrapKeyVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(LweBootstrapKey), 21 | } 22 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/lwe_bootstrap_key_chunk.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, LweBootstrapKeyChunk, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum LweBootstrapKeyChunkVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(LweBootstrapKeyChunk), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/lwe_ciphertext.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, LweCiphertext, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum LweCiphertextVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(LweCiphertext), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/lwe_ciphertext_list.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, LweCiphertextList, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum LweCiphertextListVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(LweCiphertextList), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/lwe_compact_ciphertext_list.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, LweCompactCiphertextList, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum LweCompactCiphertextListVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(LweCompactCiphertextList), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/lwe_compact_public_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, LweCompactPublicKey, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum LweCompactPublicKeyVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(LweCompactPublicKey), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/lwe_keyswitch_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, LweKeyswitchKey, UnsignedInteger}; 5 | 6 | impl Deprecable for LweKeyswitchKey 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "LweKeyswitchKey"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum LweKeyswitchKeyVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(Deprecated>), 21 | V2(LweKeyswitchKey), 22 | } 23 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/lwe_keyswitch_key_chunk.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, LweKeyswitchKeyChunk, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum LweKeyswitchKeyChunkVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(LweKeyswitchKeyChunk), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/lwe_packing_keyswitch_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, LwePackingKeyswitchKey, UnsignedInteger}; 5 | 6 | impl Deprecable for LwePackingKeyswitchKey 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "LwePackingKeyswitchKey"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum LwePackingKeyswitchKeyVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(Deprecated>), 21 | V2(LwePackingKeyswitchKey), 22 | } 23 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/lwe_private_functional_packing_keyswitch_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{ 5 | Container, LwePrivateFunctionalPackingKeyswitchKey, UnsignedInteger, 6 | }; 7 | 8 | impl Deprecable for LwePrivateFunctionalPackingKeyswitchKey 9 | where 10 | C::Element: UnsignedInteger, 11 | { 12 | const TYPE_NAME: &'static str = "LwePrivateFunctionalPackingKeyswitchKey"; 13 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 14 | } 15 | 16 | #[derive(VersionsDispatch)] 17 | pub enum LwePrivateFunctionalPackingKeyswitchKeyVersions 18 | where 19 | C::Element: UnsignedInteger, 20 | { 21 | V0(Deprecated>), 22 | V1(LwePrivateFunctionalPackingKeyswitchKey), 23 | } 24 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/lwe_public_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, LwePublicKey, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum LwePublicKeyVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(LwePublicKey), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/lwe_secret_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, LweSecretKey}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum LweSecretKeyVersions { 7 | V0(LweSecretKey), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/ntt_ggsw_ciphertext.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, NttGgswCiphertext, UnsignedInteger}; 5 | 6 | impl Deprecable for NttGgswCiphertext 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "NttGgswCiphertext"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum NttGgswCiphertextVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(NttGgswCiphertext), 21 | } 22 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/ntt_ggsw_ciphertext_list.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, NttGgswCiphertextList, UnsignedInteger}; 5 | 6 | impl Deprecable for NttGgswCiphertextList 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "NttGgswCiphertextList"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum NttGgswCiphertextListVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(NttGgswCiphertextList), 21 | } 22 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/ntt_lwe_bootstrap_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, NttLweBootstrapKey, UnsignedInteger}; 5 | 6 | impl Deprecable for NttLweBootstrapKey 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "NttLweBootstrapKey"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum NttLweBootstrapKeyVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(NttLweBootstrapKey), 21 | } 22 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/packed_integers.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::packed_integers::PackedIntegers; 4 | use crate::core_crypto::prelude::UnsignedInteger; 5 | 6 | #[derive(VersionsDispatch)] 7 | pub enum PackedIntegersVersions { 8 | V0(PackedIntegers), 9 | } 10 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/plaintext.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Numeric, Plaintext}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum PlaintextVersions { 7 | V0(Plaintext), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/plaintext_list.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, PlaintextList}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum PlaintextListVersions { 7 | V0(PlaintextList), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/polynomial.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, Polynomial}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum PolynomialVersions { 7 | V0(Polynomial), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/polynomial_list.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, PolynomialList}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum PolynomialListVersions { 7 | V0(PolynomialList), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_ggsw_ciphertext.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, SeededGgswCiphertext, UnsignedInteger}; 5 | 6 | impl Deprecable for SeededGgswCiphertext 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "SeededGgswCiphertext"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum SeededGgswCiphertextVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(SeededGgswCiphertext), 21 | } 22 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_ggsw_ciphertext_list.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, SeededGgswCiphertextList, UnsignedInteger}; 5 | 6 | impl Deprecable for SeededGgswCiphertextList 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "SeededGgswCiphertextList"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum SeededGgswCiphertextListVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(SeededGgswCiphertextList), 21 | } 22 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_glwe_ciphertext.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, SeededGlweCiphertext, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum SeededGlweCiphertextVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(SeededGlweCiphertext), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_glwe_ciphertext_list.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, SeededGlweCiphertextList, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum SeededGlweCiphertextListVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(SeededGlweCiphertextList), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_bootstrap_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, SeededLweBootstrapKey, UnsignedInteger}; 5 | 6 | impl Deprecable for SeededLweBootstrapKey 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "SeededLweBootstrapKey"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum SeededLweBootstrapKeyVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(SeededLweBootstrapKey), 21 | } 22 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_bootstrap_key_chunk.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, SeededLweBootstrapKeyChunk, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum SeededLweBootstrapKeyChunkVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(SeededLweBootstrapKeyChunk), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_ciphertext.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{SeededLweCiphertext, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum SeededLweCiphertextVersions { 7 | V0(SeededLweCiphertext), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_ciphertext_list.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, SeededLweCiphertextList, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum SeededLweCiphertextListVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(SeededLweCiphertextList), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_compact_public_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, SeededLweCompactPublicKey, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum SeededLweCompactPublicKeyVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(SeededLweCompactPublicKey), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_keyswitch_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, SeededLweKeyswitchKey, UnsignedInteger}; 5 | 6 | impl Deprecable for SeededLweKeyswitchKey 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "SeededLweKeyswitchKey"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum SeededLweKeyswitchKeyVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(Deprecated>), 21 | V2(SeededLweKeyswitchKey), 22 | } 23 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_keyswitch_key_chunk.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, SeededLweKeyswitchKeyChunk, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum SeededLweKeyswitchKeyChunkVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(SeededLweKeyswitchKeyChunk), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_multi_bit_bootstrap_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, SeededLweMultiBitBootstrapKey, UnsignedInteger}; 5 | 6 | impl Deprecable for SeededLweMultiBitBootstrapKey 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "SeededLweMultiBitBootstrapKey"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum SeededLweMultiBitBootstrapKeyVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(SeededLweMultiBitBootstrapKey), 21 | } 22 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_packing_keyswitch_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::core_crypto::prelude::{Container, SeededLwePackingKeyswitchKey, UnsignedInteger}; 5 | 6 | impl Deprecable for SeededLwePackingKeyswitchKey 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | const TYPE_NAME: &'static str = "SeededLwePackingKeyswitchKey"; 11 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 12 | } 13 | 14 | #[derive(VersionsDispatch)] 15 | pub enum SeededLwePackingKeyswitchKeyVersions 16 | where 17 | C::Element: UnsignedInteger, 18 | { 19 | V0(Deprecated>), 20 | V1(Deprecated>), 21 | V2(SeededLwePackingKeyswitchKey), 22 | } 23 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/entities/seeded_lwe_public_key.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::{Container, SeededLwePublicKey, UnsignedInteger}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum SeededLwePublicKeyVersions 7 | where 8 | C::Element: UnsignedInteger, 9 | { 10 | V0(SeededLwePublicKey), 11 | } 12 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/backward_compatibility/mod.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::large_enum_variant)] 2 | // Backward compatibility types should not be themselves versioned 3 | #![cfg_attr(dylint_lib = "tfhe_lints", allow(serialize_without_versionize))] 4 | 5 | pub mod commons; 6 | pub mod entities; 7 | pub mod fft_impl; 8 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/commons/generators/mod.rs: -------------------------------------------------------------------------------- 1 | //! Module containing various APIs wrapping `tfhe-csprng` generators for specialized use in 2 | //! [`TFHE-rs`](`crate`). 3 | 4 | mod encryption; 5 | pub use encryption::mask_random_generator::{MaskRandomGenerator, MaskRandomGeneratorForkConfig}; 6 | pub use encryption::noise_random_generator::NoiseRandomGenerator; 7 | pub use encryption::EncryptionRandomGenerator; 8 | pub(crate) use encryption::EncryptionRandomGeneratorForkConfig; 9 | 10 | mod secret; 11 | pub use secret::SecretRandomGenerator; 12 | 13 | mod seeder; 14 | pub use seeder::DeterministicSeeder; 15 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/commons/math/mod.rs: -------------------------------------------------------------------------------- 1 | //! A module containing general mathematical tools. 2 | 3 | pub mod decomposition; 4 | pub mod ntt; 5 | pub mod random; 6 | pub mod torus; 7 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/commons/math/ntt/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ntt64; 2 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/commons/noise_formulas/mod.rs: -------------------------------------------------------------------------------- 1 | // This file was autogenerated, do not modify by hand. 2 | pub mod lwe_keyswitch; 3 | pub mod lwe_multi_bit_programmable_bootstrap; 4 | pub mod lwe_programmable_bootstrap; 5 | pub mod secure_noise; 6 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/commons/traits/encryptable.rs: -------------------------------------------------------------------------------- 1 | use crate::core_crypto::commons::math::random::{Distribution, RandomGenerable}; 2 | use crate::core_crypto::commons::numeric::UnsignedInteger; 3 | 4 | pub trait Encryptable: 5 | UnsignedInteger 6 | + RandomGenerable 7 | + RandomGenerable 8 | { 9 | } 10 | 11 | impl 12 | Encryptable for T 13 | where 14 | T: UnsignedInteger 15 | + RandomGenerable 16 | + RandomGenerable, 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/commons/traits/mod.rs: -------------------------------------------------------------------------------- 1 | //! Module containing common traits used throughout the [`core_crypto 2 | //! module`](`crate::core_crypto`). 3 | 4 | pub mod container; 5 | pub mod contiguous_entity_container; 6 | pub mod create_from; 7 | pub mod encryptable; 8 | 9 | pub use container::*; 10 | pub use contiguous_entity_container::*; 11 | pub use create_from::*; 12 | pub use encryptable::*; 13 | 14 | // Convenience re-exports 15 | pub use super::math::random::{ByteRandomGenerator, ParallelByteRandomGenerator, Seeder}; 16 | pub use super::math::torus::UnsignedTorus; 17 | pub use super::numeric::*; 18 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/experimental/algorithms/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod glwe_fast_keyswitch; 2 | pub mod glwe_partial_sample_extraction; 3 | pub mod lwe_shrinking_keyswitch; 4 | pub mod lwe_shrinking_keyswitch_key_generation; 5 | pub mod partial_glwe_secret_key_generation; 6 | pub mod pseudo_ggsw_conversion; 7 | pub mod pseudo_ggsw_encryption; 8 | pub mod shared_glwe_secret_key_generation; 9 | pub mod shared_lwe_secret_key_generation; 10 | 11 | pub use glwe_fast_keyswitch::*; 12 | pub use glwe_partial_sample_extraction::*; 13 | pub use lwe_shrinking_keyswitch::*; 14 | pub use lwe_shrinking_keyswitch_key_generation::*; 15 | pub use partial_glwe_secret_key_generation::*; 16 | pub use pseudo_ggsw_conversion::*; 17 | pub use pseudo_ggsw_encryption::*; 18 | pub use shared_glwe_secret_key_generation::*; 19 | pub use shared_lwe_secret_key_generation::*; 20 | 21 | #[cfg(test)] 22 | mod test; 23 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/experimental/algorithms/test/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::core_crypto::algorithms::test::*; 2 | use crate::core_crypto::experimental::prelude::*; 3 | 4 | mod lwe_fast_keyswitch; 5 | mod lwe_stair_keyswitch; 6 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/experimental/commons/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parameters; 2 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/experimental/entities/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod fourier_pseudo_ggsw_ciphertext; 2 | pub mod lwe_shrinking_keyswitch_key; 3 | pub mod pseudo_ggsw_ciphertext; 4 | 5 | pub use fourier_pseudo_ggsw_ciphertext::*; 6 | pub use lwe_shrinking_keyswitch_key::*; 7 | pub use pseudo_ggsw_ciphertext::*; 8 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/experimental/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod algorithms; 2 | pub mod commons; 3 | pub mod entities; 4 | pub mod prelude; 5 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/experimental/prelude.rs: -------------------------------------------------------------------------------- 1 | //! Module with the definition of the experimental prelude. 2 | //! 3 | //! The TFHE-rs preludes include convenient imports. 4 | //! Having `tfhe::core_crypto::prelude::*;` should be enough to start using the lib. 5 | 6 | pub use super::algorithms::*; 7 | pub use super::commons::parameters::*; 8 | pub use super::entities::*; 9 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/fft_impl/fft128/crypto/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bootstrap; 2 | pub mod ggsw; 3 | 4 | #[cfg(test)] 5 | pub mod tests; 6 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/fft_impl/fft128/crypto/tests.rs: -------------------------------------------------------------------------------- 1 | use crate::core_crypto::fft_impl::common::tests::test_bootstrap_generic; 2 | use crate::core_crypto::fft_impl::fft128::crypto::bootstrap::Fourier128LweBootstrapKeyOwned; 3 | use crate::core_crypto::prelude::test::{FFT_U128_PARAMS, FFT_U32_PARAMS, FFT_U64_PARAMS}; 4 | 5 | #[test] 6 | fn test_bootstrap_u128() { 7 | test_bootstrap_generic::(FFT_U128_PARAMS); 8 | } 9 | 10 | #[test] 11 | fn test_bootstrap_u64() { 12 | test_bootstrap_generic::(FFT_U64_PARAMS); 13 | } 14 | 15 | #[test] 16 | fn test_bootstrap_u32() { 17 | test_bootstrap_generic::(FFT_U32_PARAMS); 18 | } 19 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/fft_impl/fft128/math/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod fft; 2 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/fft_impl/fft128/mod.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::too_many_arguments)] 2 | 3 | pub mod crypto; 4 | pub mod math; 5 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/fft_impl/fft128_u128/crypto/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bootstrap; 2 | pub mod ggsw; 3 | 4 | #[cfg(test)] 5 | mod tests; 6 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/fft_impl/fft128_u128/math/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod fft; 2 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/fft_impl/fft128_u128/mod.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::too_many_arguments)] 2 | 3 | pub mod crypto; 4 | pub mod math; 5 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/fft_impl/fft64/crypto/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bootstrap; 2 | pub mod ggsw; 3 | pub mod wop_pbs; 4 | 5 | #[cfg(test)] 6 | pub mod tests; 7 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/fft_impl/fft64/crypto/tests.rs: -------------------------------------------------------------------------------- 1 | use crate::core_crypto::fft_impl::common::tests::test_bootstrap_generic; 2 | use crate::core_crypto::fft_impl::fft64::crypto::bootstrap::FourierLweBootstrapKeyOwned; 3 | use crate::core_crypto::prelude::test::{FFT_U32_PARAMS, FFT_U64_PARAMS}; 4 | 5 | #[test] 6 | fn test_bootstrap_u64() { 7 | test_bootstrap_generic::(FFT_U64_PARAMS); 8 | } 9 | 10 | #[test] 11 | fn test_bootstrap_u32() { 12 | test_bootstrap_generic::(FFT_U32_PARAMS); 13 | } 14 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/fft_impl/fft64/math/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod decomposition; 2 | pub mod fft; 3 | pub mod polynomial; 4 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/fft_impl/fft64/mod.rs: -------------------------------------------------------------------------------- 1 | #![doc(hidden)] 2 | pub use aligned_vec::{ABox, AVec}; 3 | pub use tfhe_fft::c64; 4 | 5 | pub mod crypto; 6 | pub mod math; 7 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/fft_impl/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod common; 2 | 3 | // TODO REFACTOR 4 | // For now this module is not refactored, it contains high performance code and will be refactored 5 | // at a later stage. It is self contained, allowing to put it in its own module in the meantime. 6 | pub mod fft64; 7 | 8 | pub mod fft128; 9 | mod fft128_u128; 10 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/gpu/algorithms/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod glwe_linear_algebra; 2 | pub mod glwe_sample_extraction; 3 | pub mod lwe_keyswitch; 4 | pub mod lwe_linear_algebra; 5 | 6 | pub mod lwe_multi_bit_programmable_bootstrapping; 7 | pub mod lwe_packing_keyswitch; 8 | pub mod lwe_programmable_bootstrapping; 9 | 10 | #[cfg(test)] 11 | mod test; 12 | 13 | pub use lwe_keyswitch::*; 14 | pub use lwe_linear_algebra::*; 15 | pub use lwe_multi_bit_programmable_bootstrapping::*; 16 | pub use lwe_packing_keyswitch::*; 17 | pub use lwe_programmable_bootstrapping::*; 18 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/gpu/entities/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod glwe_ciphertext_list; 2 | pub mod lwe_bootstrap_key; 3 | pub mod lwe_ciphertext_list; 4 | pub mod lwe_compact_ciphertext_list; 5 | pub mod lwe_keyswitch_key; 6 | pub mod lwe_multi_bit_bootstrap_key; 7 | pub mod lwe_packing_keyswitch_key; 8 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/hpu/algorithms/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod modswitch; 2 | pub mod order; 3 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/hpu/entities/mod.rs: -------------------------------------------------------------------------------- 1 | use super::algorithms; 2 | 3 | // Export tfhe-hpu-backend type for use external crate 4 | pub use tfhe_hpu_backend::prelude::*; 5 | 6 | pub mod glwe_ciphertext; 7 | pub mod glwe_lookuptable; 8 | pub mod lwe_bootstrap_key; 9 | pub mod lwe_ciphertext; 10 | pub mod lwe_keyswitch_key; 11 | -------------------------------------------------------------------------------- /tfhe/src/core_crypto/hpu/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod algorithms; 2 | pub mod entities; 3 | pub use entities::*; 4 | -------------------------------------------------------------------------------- /tfhe/src/high_level_api/array/dynamic/mod.rs: -------------------------------------------------------------------------------- 1 | //! This module contains the implementations 2 | //! where the location of the values and computations can be changed/selected at runtime 3 | 4 | pub(crate) mod booleans; 5 | mod signed; 6 | mod unsigned; 7 | 8 | #[cfg(test)] 9 | pub use signed::DynIntBackend; 10 | pub use signed::{FheIntArray, FheIntSlice, FheIntSliceMut}; 11 | 12 | #[cfg(test)] 13 | pub use unsigned::DynUintBackend; 14 | pub use unsigned::{FheUintArray, FheUintSlice, FheUintSliceMut}; 15 | 16 | #[cfg(test)] 17 | pub use booleans::DynFheBoolArrayBackend; 18 | pub use booleans::{FheBoolArray, FheBoolSlice, FheBoolSliceMut}; 19 | -------------------------------------------------------------------------------- /tfhe/src/high_level_api/array/gpu/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod booleans; 2 | pub(crate) mod integers; 3 | #[cfg(test)] 4 | pub use booleans::GpuFheBoolArrayBackend; 5 | pub use booleans::{GpuFheBoolArray, GpuFheBoolSlice, GpuFheBoolSliceMut}; 6 | pub use integers::{ 7 | GpuFheIntArray, GpuFheIntSlice, GpuFheIntSliceMut, GpuFheUintArray, GpuFheUintSlice, 8 | GpuFheUintSliceMut, 9 | }; 10 | -------------------------------------------------------------------------------- /tfhe/src/high_level_api/backward_compatibility/config.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::Config; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum ConfigVersions { 7 | V0(Config), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/high_level_api/backward_compatibility/mod.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::large_enum_variant)] 2 | // Backward compatibility types should not be themselves versioned 3 | #![cfg_attr(dylint_lib = "tfhe_lints", allow(serialize_without_versionize))] 4 | 5 | pub mod booleans; 6 | pub mod compact_list; 7 | pub mod compressed_ciphertext_list; 8 | pub mod config; 9 | pub mod integers; 10 | pub mod keys; 11 | #[cfg(feature = "strings")] 12 | pub mod strings; 13 | pub mod tag; 14 | -------------------------------------------------------------------------------- /tfhe/src/high_level_api/backward_compatibility/strings.rs: -------------------------------------------------------------------------------- 1 | use crate::FheAsciiString; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | #[derive(VersionsDispatch)] 5 | pub enum FheAsciiStringVersions { 6 | V0(FheAsciiString), 7 | } 8 | -------------------------------------------------------------------------------- /tfhe/src/high_level_api/backward_compatibility/tag.rs: -------------------------------------------------------------------------------- 1 | use crate::high_level_api::tag::Tag; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | #[derive(VersionsDispatch)] 5 | pub enum TagVersions { 6 | V0(Tag), 7 | } 8 | -------------------------------------------------------------------------------- /tfhe/src/high_level_api/booleans/mod.rs: -------------------------------------------------------------------------------- 1 | pub use base::{FheBool, FheBoolConformanceParams}; 2 | pub use compressed::CompressedFheBool; 3 | pub use squashed_noise::SquashedNoiseFheBool; 4 | 5 | pub(in crate::high_level_api) use compressed::InnerCompressedFheBool; 6 | pub(in crate::high_level_api) use inner::{InnerBoolean, InnerBooleanVersionOwned}; 7 | pub(in crate::high_level_api) use squashed_noise::InnerSquashedNoiseBooleanVersionOwned; 8 | 9 | mod base; 10 | mod compressed; 11 | mod encrypt; 12 | mod inner; 13 | mod oprf; 14 | mod squashed_noise; 15 | #[cfg(test)] 16 | mod tests; 17 | -------------------------------------------------------------------------------- /tfhe/src/high_level_api/details.rs: -------------------------------------------------------------------------------- 1 | use std::ops::Deref; 2 | 3 | /// 'smart-pointer' that holds either a borrowed T, or an owned T. 4 | /// 5 | /// This is essentially like a Cow, except T does not need to be ToOwned 6 | pub enum MaybeCloned<'a, T> { 7 | Borrowed(&'a T), 8 | Cloned(T), 9 | } 10 | 11 | impl MaybeCloned<'_, T> { 12 | pub(crate) fn into_owned(self) -> T 13 | where 14 | T: ToOwned, 15 | { 16 | match self { 17 | Self::Borrowed(b) => b.to_owned(), 18 | Self::Cloned(o) => o, 19 | } 20 | } 21 | } 22 | 23 | impl Deref for MaybeCloned<'_, T> { 24 | type Target = T; 25 | 26 | fn deref(&self) -> &Self::Target { 27 | match self { 28 | Self::Borrowed(b) => b, 29 | Self::Cloned(o) => o, 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tfhe/src/high_level_api/strings/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod ascii; 2 | #[cfg(test)] 3 | mod tests; 4 | pub(in crate::high_level_api) mod traits; 5 | -------------------------------------------------------------------------------- /tfhe/src/high_level_api/strings/tests/cpu.rs: -------------------------------------------------------------------------------- 1 | use crate::high_level_api::tests::setup_default_cpu; 2 | 3 | #[test] 4 | fn test_string_eq_ne() { 5 | let cks = setup_default_cpu(); 6 | super::test_string_eq_ne(&cks); 7 | } 8 | 9 | #[test] 10 | fn test_string_find_rfind() { 11 | let cks = setup_default_cpu(); 12 | super::test_string_find_rfind(&cks); 13 | } 14 | 15 | #[test] 16 | fn test_string_len_is_empty() { 17 | let cks = setup_default_cpu(); 18 | super::test_string_len_is_empty(&cks); 19 | } 20 | 21 | #[test] 22 | fn test_string_lower_upper() { 23 | let cks = setup_default_cpu(); 24 | super::test_string_lower_upper(&cks); 25 | } 26 | 27 | #[test] 28 | fn test_string_trim() { 29 | let cks = setup_default_cpu(); 30 | super::test_string_trim(&cks); 31 | } 32 | 33 | #[test] 34 | fn test_string_strip() { 35 | let cks = setup_default_cpu(); 36 | super::test_string_strip(&cks); 37 | } 38 | -------------------------------------------------------------------------------- /tfhe/src/integer/backward_compatibility/client_key/mod.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::integer::{ClientKey, CrtClientKey, RadixClientKey}; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum ClientKeyVersions { 7 | V0(ClientKey), 8 | } 9 | 10 | #[derive(VersionsDispatch)] 11 | pub enum CrtClientKeyVersions { 12 | V0(CrtClientKey), 13 | } 14 | 15 | #[derive(VersionsDispatch)] 16 | pub enum RadixClientKeyVersions { 17 | V0(RadixClientKey), 18 | } 19 | -------------------------------------------------------------------------------- /tfhe/src/integer/backward_compatibility/mod.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::large_enum_variant)] 2 | 3 | pub mod ciphertext; 4 | pub mod client_key; 5 | pub mod key_switching_key; 6 | pub mod list_compression; 7 | pub mod noise_squashing; 8 | pub mod public_key; 9 | pub mod server_key; 10 | -------------------------------------------------------------------------------- /tfhe/src/integer/backward_compatibility/noise_squashing.rs: -------------------------------------------------------------------------------- 1 | use crate::integer::noise_squashing::{ 2 | CompressedNoiseSquashingKey, NoiseSquashingKey, NoiseSquashingPrivateKey, 3 | }; 4 | use tfhe_versionable::VersionsDispatch; 5 | 6 | #[derive(VersionsDispatch)] 7 | pub enum NoiseSquashingKeyVersions { 8 | V0(NoiseSquashingKey), 9 | } 10 | 11 | #[derive(VersionsDispatch)] 12 | pub enum CompressedNoiseSquashingKeyVersions { 13 | V0(CompressedNoiseSquashingKey), 14 | } 15 | 16 | #[derive(VersionsDispatch)] 17 | pub enum NoiseSquashingPrivateKeyVersions { 18 | V0(NoiseSquashingPrivateKey), 19 | } 20 | -------------------------------------------------------------------------------- /tfhe/src/integer/backward_compatibility/public_key/mod.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::core_crypto::prelude::Container; 4 | use crate::integer::{ 5 | CompactPrivateKey, CompactPublicKey, CompressedCompactPublicKey, CompressedPublicKey, PublicKey, 6 | }; 7 | 8 | #[derive(VersionsDispatch)] 9 | pub enum PublicKeyVersions { 10 | V0(PublicKey), 11 | } 12 | 13 | #[derive(VersionsDispatch)] 14 | pub enum CompactPublicKeyVersions { 15 | V0(CompactPublicKey), 16 | } 17 | 18 | #[derive(VersionsDispatch)] 19 | pub enum CompactPrivateKeyVersions> { 20 | V0(CompactPrivateKey), 21 | } 22 | 23 | #[derive(VersionsDispatch)] 24 | pub enum CompressedPublicKeyVersions { 25 | V0(CompressedPublicKey), 26 | } 27 | 28 | #[derive(VersionsDispatch)] 29 | pub enum CompressedCompactPublicKeyVersions { 30 | V0(CompressedCompactPublicKey), 31 | } 32 | -------------------------------------------------------------------------------- /tfhe/src/integer/backward_compatibility/server_key/mod.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::deprecation::{Deprecable, Deprecated}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | use crate::integer::{CompressedServerKey, ServerKey}; 5 | 6 | impl Deprecable for ServerKey { 7 | const TYPE_NAME: &'static str = "ServerKey"; 8 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 9 | } 10 | 11 | #[derive(VersionsDispatch)] 12 | pub enum ServerKeyVersions { 13 | V0(Deprecated), 14 | V1(ServerKey), 15 | } 16 | 17 | impl Deprecable for CompressedServerKey { 18 | const TYPE_NAME: &'static str = "CompressedServerKey"; 19 | const MIN_SUPPORTED_APP_VERSION: &'static str = "TFHE-rs v0.10"; 20 | } 21 | 22 | #[derive(VersionsDispatch)] 23 | pub enum CompressedServerKeyVersions { 24 | V0(Deprecated), 25 | V1(Deprecated), 26 | V2(CompressedServerKey), 27 | } 28 | -------------------------------------------------------------------------------- /tfhe/src/integer/bigint/i512.rs: -------------------------------------------------------------------------------- 1 | pub type I512 = super::static_signed::StaticSignedBigInt<8>; 2 | 3 | #[cfg(test)] 4 | mod tests { 5 | use super::*; 6 | #[test] 7 | fn test_const() { 8 | assert_eq!(I512::BITS, 512); 9 | assert_eq!(I512::ZERO, I512::from([0, 0, 0, 0, 0, 0, 0, 0])); 10 | assert_eq!(I512::ONE, I512::from([1, 0, 0, 0, 0, 0, 0, 0])); 11 | assert_eq!(I512::TWO, I512::from([2, 0, 0, 0, 0, 0, 0, 0])); 12 | assert_eq!( 13 | I512::MAX, 14 | I512::from([ 15 | u64::MAX, 16 | u64::MAX, 17 | u64::MAX, 18 | u64::MAX, 19 | u64::MAX, 20 | u64::MAX, 21 | u64::MAX, 22 | u64::MAX >> 1 23 | ]) 24 | ); 25 | assert_eq!(I512::MIN, I512::from([0, 0, 0, 0, 0, 0, 0, 1u64 << 63])); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tfhe/src/integer/ciphertext/mod.rs: -------------------------------------------------------------------------------- 1 | mod base; 2 | pub mod boolean_value; 3 | mod compact_list; 4 | mod compressed; 5 | mod compressed_ciphertext_list; 6 | mod compressed_modulus_switched_ciphertext; 7 | mod integer_ciphertext; 8 | mod squashed_noise; 9 | mod utils; 10 | 11 | pub use base::*; 12 | pub use boolean_value::*; 13 | pub use compact_list::*; 14 | pub use compressed::*; 15 | pub use compressed_ciphertext_list::*; 16 | pub use compressed_modulus_switched_ciphertext::*; 17 | pub use integer_ciphertext::*; 18 | pub use squashed_noise::*; 19 | pub use utils::*; 20 | -------------------------------------------------------------------------------- /tfhe/src/integer/client_key/secret_encryption_key.rs: -------------------------------------------------------------------------------- 1 | use crate::shortint::client_key::secret_encryption_key::SecretEncryptionKeyView as ShortintSecretEncryptionKey; 2 | 3 | #[derive(Clone)] 4 | pub struct SecretEncryptionKeyView<'key> { 5 | pub(crate) key: ShortintSecretEncryptionKey<'key>, 6 | } 7 | -------------------------------------------------------------------------------- /tfhe/src/integer/gpu/client_key/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod radix; 2 | -------------------------------------------------------------------------------- /tfhe/src/integer/gpu/list_compression/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod compressed_server_keys; 2 | pub mod server_keys; 3 | -------------------------------------------------------------------------------- /tfhe/src/integer/gpu/server_key/radix/tests_signed/test_div_mod.rs: -------------------------------------------------------------------------------- 1 | use crate::integer::gpu::server_key::radix::tests_unsigned::{ 2 | create_gpu_parameterized_test, GpuFunctionExecutor, 3 | }; 4 | use crate::integer::gpu::CudaServerKey; 5 | use crate::integer::server_key::radix_parallel::tests_signed::test_div_rem::signed_unchecked_div_rem_test; 6 | use crate::shortint::parameters::test_params::*; 7 | use crate::shortint::parameters::*; 8 | 9 | create_gpu_parameterized_test!(integer_signed_unchecked_div_rem); 10 | 11 | fn integer_signed_unchecked_div_rem

(param: P) 12 | where 13 | P: Into, 14 | { 15 | let executor = GpuFunctionExecutor::new(&CudaServerKey::div_rem); 16 | signed_unchecked_div_rem_test(param, executor); 17 | } 18 | -------------------------------------------------------------------------------- /tfhe/src/integer/gpu/server_key/radix/tests_signed/test_scalar_div_mod.rs: -------------------------------------------------------------------------------- 1 | use crate::integer::gpu::server_key::radix::tests_unsigned::{ 2 | create_gpu_parameterized_test, GpuFunctionExecutor, 3 | }; 4 | use crate::integer::gpu::CudaServerKey; 5 | use crate::integer::server_key::radix_parallel::tests_signed::test_scalar_div_mod::signed_unchecked_scalar_div_rem_test; 6 | use crate::shortint::parameters::test_params::*; 7 | use crate::shortint::parameters::*; 8 | 9 | create_gpu_parameterized_test!(integer_signed_unchecked_scalar_div_rem); 10 | 11 | fn integer_signed_unchecked_scalar_div_rem

(param: P) 12 | where 13 | P: Into, 14 | { 15 | let executor = GpuFunctionExecutor::new(&CudaServerKey::signed_scalar_div_rem); 16 | signed_unchecked_scalar_div_rem_test(param, executor); 17 | } 18 | -------------------------------------------------------------------------------- /tfhe/src/integer/gpu/server_key/radix/tests_signed/test_scalar_mul.rs: -------------------------------------------------------------------------------- 1 | use crate::integer::gpu::server_key::radix::tests_unsigned::{ 2 | create_gpu_parameterized_test, GpuFunctionExecutor, 3 | }; 4 | use crate::integer::gpu::CudaServerKey; 5 | use crate::integer::server_key::radix_parallel::tests_signed::test_scalar_mul::signed_unchecked_scalar_mul_test; 6 | use crate::shortint::parameters::test_params::*; 7 | use crate::shortint::parameters::*; 8 | 9 | create_gpu_parameterized_test!(integer_signed_unchecked_scalar_mul); 10 | 11 | fn integer_signed_unchecked_scalar_mul

(param: P) 12 | where 13 | P: Into, 14 | { 15 | let executor = GpuFunctionExecutor::new(&CudaServerKey::unchecked_scalar_mul); 16 | signed_unchecked_scalar_mul_test(param, executor); 17 | } 18 | -------------------------------------------------------------------------------- /tfhe/src/integer/gpu/server_key/radix/tests_unsigned/test_scalar_div_mod.rs: -------------------------------------------------------------------------------- 1 | use crate::integer::gpu::server_key::radix::tests_unsigned::{ 2 | create_gpu_parameterized_test, GpuFunctionExecutor, 3 | }; 4 | use crate::integer::gpu::CudaServerKey; 5 | use crate::integer::server_key::radix_parallel::tests_unsigned::test_scalar_div_mod::default_scalar_div_rem_test; 6 | use crate::shortint::parameters::test_params::*; 7 | use crate::shortint::parameters::*; 8 | 9 | create_gpu_parameterized_test!(integer_scalar_div_rem); 10 | 11 | fn integer_scalar_div_rem

(param: P) 12 | where 13 | P: Into, 14 | { 15 | let executor = GpuFunctionExecutor::new(&CudaServerKey::scalar_div_rem); 16 | default_scalar_div_rem_test(param, executor); 17 | } 18 | -------------------------------------------------------------------------------- /tfhe/src/integer/noise_squashing/mod.rs: -------------------------------------------------------------------------------- 1 | mod keys; 2 | #[cfg(test)] 3 | mod tests; 4 | 5 | pub use keys::*; 6 | -------------------------------------------------------------------------------- /tfhe/src/integer/prelude.rs: -------------------------------------------------------------------------------- 1 | pub use crate::integer::ciphertext::{IntegerCiphertext, IntegerRadixCiphertext}; 2 | pub use crate::integer::server_key::radix_parallel::cmux::ServerKeyDefaultCMux; 3 | -------------------------------------------------------------------------------- /tfhe/src/integer/public_key/mod.rs: -------------------------------------------------------------------------------- 1 | //! Module with the definition of the encryption PublicKey. 2 | 3 | pub mod compact; 4 | pub mod compressed; 5 | pub mod standard; 6 | 7 | pub use compact::{CompactPrivateKey, CompactPublicKey, CompressedCompactPublicKey}; 8 | pub use compressed::CompressedPublicKey; 9 | pub use standard::PublicKey; 10 | 11 | #[cfg(test)] 12 | mod tests; 13 | -------------------------------------------------------------------------------- /tfhe/src/integer/server_key/radix_parallel/tests_long_run/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod test_erc20; 2 | pub(crate) mod test_random_op_sequence; 3 | pub(crate) mod test_signed_erc20; 4 | pub(crate) mod test_signed_random_op_sequence; 5 | pub(crate) const NB_CTXT_LONG_RUN: usize = 32; 6 | pub(crate) const NB_TESTS_LONG_RUN: usize = 20000; 7 | -------------------------------------------------------------------------------- /tfhe/src/js_on_wasm_api/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "shortint-client-js-wasm-api")] 2 | mod shortint; 3 | 4 | #[cfg(feature = "boolean-client-js-wasm-api")] 5 | mod boolean; 6 | 7 | // We need to use the init_thread_pool for it to be publicly visible but it appears unused when 8 | // compiling 9 | #[allow(unused_imports)] 10 | #[cfg(feature = "parallel-wasm-api")] 11 | pub use wasm_bindgen_rayon::init_thread_pool; 12 | 13 | #[cfg(feature = "integer-client-js-wasm-api")] 14 | mod js_high_level_api; 15 | 16 | pub(crate) fn into_js_error(e: E) -> wasm_bindgen::JsError { 17 | wasm_bindgen::JsError::new(format!("{e:?}").as_str()) 18 | } 19 | -------------------------------------------------------------------------------- /tfhe/src/named.rs: -------------------------------------------------------------------------------- 1 | pub trait Named { 2 | /// Default name for the type 3 | const NAME: &'static str; 4 | /// Aliases that should also be accepted for backward compatibility when checking the name of 5 | /// values of this type 6 | const BACKWARD_COMPATIBILITY_ALIASES: &'static [&'static str] = &[]; 7 | } 8 | -------------------------------------------------------------------------------- /tfhe/src/shortint/backward_compatibility/client_key/atomic_pattern.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use crate::shortint::client_key::atomic_pattern::{ 4 | AtomicPatternClientKey, KS32AtomicPatternClientKey, StandardAtomicPatternClientKey, 5 | }; 6 | 7 | #[derive(VersionsDispatch)] 8 | pub enum AtomicPatternClientKeyVersions { 9 | V0(AtomicPatternClientKey), 10 | } 11 | 12 | #[derive(VersionsDispatch)] 13 | pub enum StandardAtomicPatternClientKeyVersions { 14 | V0(StandardAtomicPatternClientKey), 15 | } 16 | 17 | #[derive(VersionsDispatch)] 18 | pub enum KS32AtomicPatternClientKeyVersions { 19 | V0(KS32AtomicPatternClientKey), 20 | } 21 | -------------------------------------------------------------------------------- /tfhe/src/shortint/backward_compatibility/mod.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::large_enum_variant)] 2 | 3 | pub mod atomic_pattern; 4 | pub mod ciphertext; 5 | pub mod client_key; 6 | pub mod key_switching_key; 7 | pub mod list_compression; 8 | pub mod noise_squashing; 9 | pub mod parameters; 10 | pub mod public_key; 11 | pub mod server_key; 12 | -------------------------------------------------------------------------------- /tfhe/src/shortint/backward_compatibility/noise_squashing.rs: -------------------------------------------------------------------------------- 1 | use crate::shortint::noise_squashing::{ 2 | CompressedNoiseSquashingKey, NoiseSquashingKey, NoiseSquashingPrivateKey, 3 | }; 4 | use tfhe_versionable::VersionsDispatch; 5 | 6 | #[derive(VersionsDispatch)] 7 | pub enum NoiseSquashingPrivateKeyVersions { 8 | V0(NoiseSquashingPrivateKey), 9 | } 10 | 11 | #[derive(VersionsDispatch)] 12 | pub enum NoiseSquashingKeyVersions { 13 | V0(NoiseSquashingKey), 14 | } 15 | 16 | #[derive(VersionsDispatch)] 17 | pub enum CompressedNoiseSquashingKeyVersions { 18 | V0(CompressedNoiseSquashingKey), 19 | } 20 | -------------------------------------------------------------------------------- /tfhe/src/shortint/backward_compatibility/parameters/key_switching.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use super::parameters::ShortintKeySwitchingParameters; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum ShortintKeySwitchingParametersVersions { 7 | V0(ShortintKeySwitchingParameters), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/shortint/backward_compatibility/parameters/list_compression.rs: -------------------------------------------------------------------------------- 1 | use tfhe_versionable::VersionsDispatch; 2 | 3 | use super::parameters::list_compression::CompressionParameters; 4 | 5 | #[derive(VersionsDispatch)] 6 | pub enum CompressionParametersVersions { 7 | V0(CompressionParameters), 8 | } 9 | -------------------------------------------------------------------------------- /tfhe/src/shortint/backward_compatibility/parameters/modulus_switch_noise_reduction.rs: -------------------------------------------------------------------------------- 1 | use crate::shortint::parameters::ModulusSwitchNoiseReductionParams; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | #[derive(VersionsDispatch)] 5 | pub enum ModulusSwitchNoiseReductionParamsVersions { 6 | V0(ModulusSwitchNoiseReductionParams), 7 | } 8 | -------------------------------------------------------------------------------- /tfhe/src/shortint/backward_compatibility/parameters/noise_squashing.rs: -------------------------------------------------------------------------------- 1 | use crate::shortint::parameters::noise_squashing::NoiseSquashingParameters; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | #[derive(VersionsDispatch)] 5 | pub enum NoiseSquashingParametersVersions { 6 | V0(NoiseSquashingParameters), 7 | } 8 | -------------------------------------------------------------------------------- /tfhe/src/shortint/ciphertext/mod.rs: -------------------------------------------------------------------------------- 1 | mod common; 2 | mod compact_list; 3 | mod compressed; 4 | mod compressed_ciphertext_list; 5 | mod compressed_modulus_switched_ciphertext; 6 | mod squashed_noise; 7 | mod standard; 8 | #[cfg(feature = "zk-pok")] 9 | mod zk; 10 | 11 | pub use common::*; 12 | pub use compact_list::*; 13 | pub use compressed::*; 14 | pub use compressed_ciphertext_list::*; 15 | pub use compressed_modulus_switched_ciphertext::*; 16 | pub use squashed_noise::*; 17 | pub use standard::*; 18 | #[cfg(feature = "zk-pok")] 19 | pub use zk::*; 20 | -------------------------------------------------------------------------------- /tfhe/src/shortint/client_key/secret_encryption_key.rs: -------------------------------------------------------------------------------- 1 | use crate::core_crypto::entities::LweSecretKey; 2 | use crate::shortint::parameters::{CarryModulus, MessageModulus}; 3 | 4 | #[derive(Clone)] 5 | pub struct SecretEncryptionKeyView<'key> { 6 | pub(crate) lwe_secret_key: LweSecretKey<&'key [u64]>, 7 | pub(crate) message_modulus: MessageModulus, 8 | pub(crate) carry_modulus: CarryModulus, 9 | } 10 | 11 | impl<'key> From<&'key Self> for SecretEncryptionKeyView<'key> { 12 | fn from(value: &'key Self) -> Self { 13 | Self { 14 | lwe_secret_key: value.lwe_secret_key.as_view(), 15 | message_modulus: value.message_modulus, 16 | carry_modulus: value.carry_modulus, 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tfhe/src/shortint/list_compression/mod.rs: -------------------------------------------------------------------------------- 1 | mod compressed_server_keys; 2 | mod compression; 3 | mod private_key; 4 | mod server_keys; 5 | 6 | pub use compressed_server_keys::{CompressedCompressionKey, CompressedDecompressionKey}; 7 | pub use private_key::CompressionPrivateKeys; 8 | pub use server_keys::{CompressionKey, CompressionKeyConformanceParams, DecompressionKey}; 9 | -------------------------------------------------------------------------------- /tfhe/src/shortint/noise_squashing/mod.rs: -------------------------------------------------------------------------------- 1 | mod compressed_server_key; 2 | mod private_key; 3 | mod server_key; 4 | #[cfg(test)] 5 | pub mod tests; 6 | 7 | pub use compressed_server_key::CompressedNoiseSquashingKey; 8 | pub use private_key::NoiseSquashingPrivateKey; 9 | pub use server_key::{NoiseSquashingKey, NoiseSquashingKeyConformanceParams}; 10 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/classic/compact_pk/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_64; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/classic/compact_pk/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/classic/compact_pk/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gaussian; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/classic/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_64; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/classic/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/classic/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod compact_pk; 2 | pub mod gaussian; 3 | pub mod tuniform; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/classic/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_64; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/classic/tuniform/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/compact_public_key_only/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_64; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/compact_public_key_only/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/key_switching/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_64; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/key_switching/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/list_compression.rs: -------------------------------------------------------------------------------- 1 | use crate::shortint::parameters::{ 2 | CiphertextModulusLog, CompressionParameters, DecompositionBaseLog, DecompositionLevelCount, 3 | DynamicDistribution, GlweDimension, LweCiphertextCount, PolynomialSize, 4 | }; 5 | 6 | pub const V0_10_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64: CompressionParameters = 7 | CompressionParameters { 8 | br_level: DecompositionLevelCount(1), 9 | br_base_log: DecompositionBaseLog(23), 10 | packing_ks_level: DecompositionLevelCount(4), 11 | packing_ks_base_log: DecompositionBaseLog(4), 12 | packing_ks_polynomial_size: PolynomialSize(256), 13 | packing_ks_glwe_dimension: GlweDimension(4), 14 | lwe_per_glwe: LweCiphertextCount(256), 15 | storage_log_modulus: CiphertextModulusLog(12), 16 | packing_ks_key_noise_distribution: DynamicDistribution::new_t_uniform(42), 17 | }; 18 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/mod.rs: -------------------------------------------------------------------------------- 1 | //! FHE Parameters as they were defined in TFHE-rs 0.10 and before. 2 | //! 3 | //! These parameters may be used for backward compatibility. 4 | 5 | pub mod classic; 6 | pub mod compact_public_key_only; 7 | pub mod key_switching; 8 | pub mod list_compression; 9 | pub mod multi_bit; 10 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/multi_bit/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | //! #Warning experimental 2 | 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/multi_bit/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/multi_bit/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gaussian; 2 | pub mod tuniform; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/multi_bit/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_64; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_10/multi_bit/tuniform/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs_gpu; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/classic/compact_pk/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_64; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/classic/compact_pk/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/classic/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/classic/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod compact_pk; 2 | pub mod gaussian; 3 | pub mod tuniform; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/classic/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_64; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/classic/tuniform/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/compact_public_key_only/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_64; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/compact_public_key_only/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/key_switching/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_64; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/key_switching/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/mod.rs: -------------------------------------------------------------------------------- 1 | //! FHE Parameters as they were defined in TFHE-rs 0.11 and before. 2 | //! 3 | //! These parameters may be used for backward compatibility. 4 | 5 | pub mod classic; 6 | pub mod compact_public_key_only; 7 | pub mod key_switching; 8 | pub mod list_compression; 9 | pub mod multi_bit; 10 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/multi_bit/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_64; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/multi_bit/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/multi_bit/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gaussian; 2 | pub mod tuniform; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/multi_bit/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_64; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v0_11/multi_bit/tuniform/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs_gpu; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/classic/compact_pk/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_64; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/classic/compact_pk/gaussian/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/classic/compact_pk/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/classic/compact_pk/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gaussian; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/classic/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/classic/gaussian/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/classic/gaussian/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/classic/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/classic/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod compact_pk; 2 | pub mod gaussian; 3 | pub mod tuniform; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/classic/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/classic/tuniform/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/classic/tuniform/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/classic/tuniform/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/compact_public_key_only/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | 3 | pub use p_fail_2_minus_128::ks_pbs::*; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/compact_public_key_only/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/key_switching/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | 3 | pub use p_fail_2_minus_128::ks_pbs::*; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/key_switching/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/list_compression/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_64; 3 | 4 | pub use p_fail_2_minus_128::*; 5 | pub use p_fail_2_minus_64::*; 6 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/multi_bit/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/multi_bit/gaussian/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/multi_bit/gaussian/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/multi_bit/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/multi_bit/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gaussian; 2 | pub mod tuniform; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/multi_bit/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | //! #Warning experimental 2 | pub mod p_fail_2_minus_128; 3 | pub mod p_fail_2_minus_40; 4 | pub mod p_fail_2_minus_64; 5 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/multi_bit/tuniform/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/multi_bit/tuniform/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_0/multi_bit/tuniform/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/classic/compact_pk/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_64; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/classic/compact_pk/gaussian/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/classic/compact_pk/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/classic/compact_pk/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gaussian; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/classic/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/classic/gaussian/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/classic/gaussian/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/classic/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/classic/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod compact_pk; 2 | pub mod gaussian; 3 | pub mod tuniform; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/classic/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/classic/tuniform/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/classic/tuniform/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/classic/tuniform/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/compact_public_key_only/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/compact_public_key_only/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/key_switching/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/key_switching/p_fail_2_minus_128/ks_pbs_gpu.rs: -------------------------------------------------------------------------------- 1 | use crate::shortint::parameters::{ 2 | DecompositionBaseLog, DecompositionLevelCount, ShortintKeySwitchingParameters, 3 | }; 4 | use crate::shortint::EncryptionKeyChoice; 5 | 6 | pub const V1_1_PARAM_MULTI_BIT_GROUP_4_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128: 7 | ShortintKeySwitchingParameters = ShortintKeySwitchingParameters { 8 | ks_level: DecompositionLevelCount(4), 9 | ks_base_log: DecompositionBaseLog(4), 10 | destination_key: EncryptionKeyChoice::Small, 11 | }; 12 | 13 | pub const V1_1_PARAM_MULTI_BIT_GROUP_4_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128: 14 | ShortintKeySwitchingParameters = ShortintKeySwitchingParameters { 15 | ks_level: DecompositionLevelCount(1), 16 | ks_base_log: DecompositionBaseLog(24), 17 | destination_key: EncryptionKeyChoice::Big, 18 | }; 19 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/key_switching/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/list_compression/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_64; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/multi_bit/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/multi_bit/gaussian/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/multi_bit/gaussian/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/multi_bit/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/multi_bit/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gaussian; 2 | pub mod tuniform; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/multi_bit/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/multi_bit/tuniform/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/multi_bit/tuniform/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/multi_bit/tuniform/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_1/noise_squashing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/classic/compact_pk/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_64; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/classic/compact_pk/gaussian/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/classic/compact_pk/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/classic/compact_pk/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gaussian; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/classic/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/classic/gaussian/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/classic/gaussian/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/classic/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/classic/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod compact_pk; 2 | pub mod gaussian; 3 | pub mod tuniform; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/classic/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/classic/tuniform/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/classic/tuniform/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/classic/tuniform/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/compact_public_key_only/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/compact_public_key_only/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/key_switching/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/key_switching/p_fail_2_minus_128/ks_pbs_gpu.rs: -------------------------------------------------------------------------------- 1 | use crate::shortint::parameters::{ 2 | DecompositionBaseLog, DecompositionLevelCount, ShortintKeySwitchingParameters, 3 | }; 4 | use crate::shortint::EncryptionKeyChoice; 5 | 6 | pub const V1_2_PARAM_MULTI_BIT_GROUP_4_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128: 7 | ShortintKeySwitchingParameters = ShortintKeySwitchingParameters { 8 | ks_level: DecompositionLevelCount(4), 9 | ks_base_log: DecompositionBaseLog(4), 10 | destination_key: EncryptionKeyChoice::Small, 11 | }; 12 | 13 | pub const V1_2_PARAM_MULTI_BIT_GROUP_4_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128: 14 | ShortintKeySwitchingParameters = ShortintKeySwitchingParameters { 15 | ks_level: DecompositionLevelCount(1), 16 | ks_base_log: DecompositionBaseLog(24), 17 | destination_key: EncryptionKeyChoice::Big, 18 | }; 19 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/key_switching/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/ks32/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod tuniform; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/ks32/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/ks32/tuniform/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/list_compression/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_64; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/multi_bit/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/multi_bit/gaussian/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/multi_bit/gaussian/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/multi_bit/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/multi_bit/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gaussian; 2 | pub mod tuniform; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/multi_bit/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/multi_bit/tuniform/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/multi_bit/tuniform/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/multi_bit/tuniform/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_2/noise_squashing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/classic/compact_pk/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_64; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/classic/compact_pk/gaussian/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/classic/compact_pk/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/classic/compact_pk/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gaussian; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/classic/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/classic/gaussian/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod pbs_ks; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/classic/gaussian/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/classic/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/classic/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod compact_pk; 2 | pub mod gaussian; 3 | pub mod tuniform; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/classic/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/classic/tuniform/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/classic/tuniform/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/classic/tuniform/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/compact_public_key_only/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/compact_public_key_only/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/key_switching/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/key_switching/p_fail_2_minus_128/ks_pbs_gpu.rs: -------------------------------------------------------------------------------- 1 | use crate::shortint::parameters::{ 2 | DecompositionBaseLog, DecompositionLevelCount, ShortintKeySwitchingParameters, 3 | }; 4 | use crate::shortint::EncryptionKeyChoice; 5 | 6 | pub const V1_3_PARAM_MULTI_BIT_GROUP_4_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128: 7 | ShortintKeySwitchingParameters = ShortintKeySwitchingParameters { 8 | ks_level: DecompositionLevelCount(4), 9 | ks_base_log: DecompositionBaseLog(4), 10 | destination_key: EncryptionKeyChoice::Small, 11 | }; 12 | 13 | pub const V1_3_PARAM_MULTI_BIT_GROUP_4_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128: 14 | ShortintKeySwitchingParameters = ShortintKeySwitchingParameters { 15 | ks_level: DecompositionLevelCount(1), 16 | ks_base_log: DecompositionBaseLog(24), 17 | destination_key: EncryptionKeyChoice::Big, 18 | }; 19 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/key_switching/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/ks32/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod tuniform; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/ks32/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/ks32/tuniform/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/list_compression/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_64; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/multi_bit/gaussian/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/multi_bit/gaussian/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/multi_bit/gaussian/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/multi_bit/gaussian/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/multi_bit/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gaussian; 2 | pub mod tuniform; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/multi_bit/tuniform/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | pub mod p_fail_2_minus_40; 3 | pub mod p_fail_2_minus_64; 4 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/multi_bit/tuniform/p_fail_2_minus_128/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/multi_bit/tuniform/p_fail_2_minus_40/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/multi_bit/tuniform/p_fail_2_minus_64/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ks_pbs; 2 | pub mod ks_pbs_gpu; 3 | -------------------------------------------------------------------------------- /tfhe/src/shortint/parameters/v1_3/noise_squashing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod p_fail_2_minus_128; 2 | -------------------------------------------------------------------------------- /tfhe/src/shortint/public_key/mod.rs: -------------------------------------------------------------------------------- 1 | //! Module with the definition of the encryption PublicKey. 2 | 3 | pub mod compact; 4 | pub mod compressed; 5 | pub mod standard; 6 | 7 | pub use compact::{CompactPrivateKey, CompactPublicKey, CompressedCompactPublicKey}; 8 | pub use compressed::CompressedPublicKey; 9 | pub use standard::PublicKey; 10 | -------------------------------------------------------------------------------- /tfhe/src/strings/backward_compatibility/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::strings::ciphertext::{FheAsciiChar, FheString}; 2 | use tfhe_versionable::VersionsDispatch; 3 | 4 | #[derive(VersionsDispatch)] 5 | pub enum FheAsciiCharVersions { 6 | V0(FheAsciiChar), 7 | } 8 | 9 | #[derive(VersionsDispatch)] 10 | pub enum FheStringVersions { 11 | V0(FheString), 12 | } 13 | -------------------------------------------------------------------------------- /tfhe/src/strings/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ciphertext; 2 | pub mod client_key; 3 | pub mod server_key; 4 | 5 | mod backward_compatibility; 6 | mod char_iter; 7 | #[cfg(test)] 8 | mod test_functions; 9 | 10 | // Used as the const argument for StaticUnsignedBigInt, specifying the max chars length of a 11 | // ClearString 12 | const N: usize = 32; 13 | 14 | pub use client_key::ClientKey; 15 | pub use server_key::{ServerKey, ServerKeyRef}; 16 | -------------------------------------------------------------------------------- /tfhe/src/strings/test_functions/mod.rs: -------------------------------------------------------------------------------- 1 | mod test_common; 2 | mod test_compact; 3 | mod test_compression; 4 | mod test_concat; 5 | mod test_contains; 6 | mod test_find_replace; 7 | mod test_split; 8 | mod test_up_low_case; 9 | mod test_whitespace; 10 | -------------------------------------------------------------------------------- /tfhe/tests/zk_wasm_x86_test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zk_wasm_x86_test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "type": "commonjs", 10 | "author": "", 11 | "license": "BSD-3-Clause-Clear", 12 | "dependencies": { 13 | "node-tfhe": "file:../../pkg" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tfhe/web_wasm_parallel_tests/.gitignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /tfhe/web_wasm_parallel_tests/.prettierignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | node_modules/ 3 | pkg/ 4 | test/benchmark_results/ 5 | -------------------------------------------------------------------------------- /tfhe/web_wasm_parallel_tests/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: run_server # Build and run Node server 2 | run_server: 3 | npm install 4 | npm run build 5 | npm run server 6 | 7 | .PHONY: fmt # Format Javascript code 8 | fmt: 9 | npm install 10 | npm run format 11 | 12 | .PHONY: check_fmt # Check Javascript code format 13 | check_fmt: 14 | npm install 15 | npm run check-format 16 | -------------------------------------------------------------------------------- /tfhe/web_wasm_parallel_tests/babel.config.js: -------------------------------------------------------------------------------- 1 | const presets = [["@babel/preset-env"]]; 2 | 3 | module.exports = { presets }; 4 | -------------------------------------------------------------------------------- /tfhe/web_wasm_parallel_tests/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zama-ai/tfhe-rs/0ba2e5c6fde92cadac3a2826d911ee5cc7b5ac65/tfhe/web_wasm_parallel_tests/favicon.ico -------------------------------------------------------------------------------- /tfhe/web_wasm_parallel_tests/jest.config.js: -------------------------------------------------------------------------------- 1 | const secs = 3600; // 60 Minutes 2 | 3 | const config = { 4 | verbose: true, 5 | testTimeout: secs * 1000, 6 | testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|js?|tsx?|ts?)$", 7 | transform: { 8 | "^.+\\.jsx?$": "babel-jest", 9 | "^.+\\.mjs$": "babel-jest", 10 | }, 11 | testPathIgnorePatterns: ["/build/", "/node_modules/"], 12 | moduleFileExtensions: ["js", "jsx", "mjs"], 13 | }; 14 | 15 | module.exports = config; 16 | -------------------------------------------------------------------------------- /tfhe/web_wasm_parallel_tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tfhe-wasm-par", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "cp -r ../../tfhe/pkg ./ && webpack build ./index.js --mode production -o dist --output-filename index.js && cp index.html dist/ && cp favicon.ico dist/", 8 | "server": "serve --config ../serve.json dist/", 9 | "format": "prettier . --write", 10 | "check-format": "prettier . --check" 11 | }, 12 | "author": "", 13 | "license": "BSD-3-Clause-Clear", 14 | "devDependencies": { 15 | "@babel/preset-env": "^7.25.4", 16 | "prettier": "^3.3.3", 17 | "serve": "^14.2.3", 18 | "webpack": "^5.94.0", 19 | "webpack-cli": "^5.1.4" 20 | }, 21 | "dependencies": { 22 | "comlink": "^4.4.1", 23 | "wasm-feature-detect": "^1.6.2" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tfhe/web_wasm_parallel_tests/serve.json: -------------------------------------------------------------------------------- 1 | { 2 | "headers": [ 3 | { 4 | "source": "**/*.@(js|html)", 5 | "headers": [ 6 | { "key": "Cross-Origin-Embedder-Policy", "value": "require-corp" }, 7 | { "key": "Cross-Origin-Opener-Policy", "value": "same-origin" } 8 | ] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /toolchain.txt: -------------------------------------------------------------------------------- 1 | nightly-2025-04-28 2 | -------------------------------------------------------------------------------- /utils/param_dedup/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "param_dedup" 3 | version = "0.1.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | syn = { version = "2.0.101", features = ["parsing", "full", "extra-traits"] } 9 | semver = "1.0.26" 10 | cargo_toml = "0.22" 11 | walkdir = "2.5.0" 12 | clap = { version = "=4.5.30", features = ["derive"] } 13 | prettyplease = "0.2.32" 14 | rayon = "1" 15 | -------------------------------------------------------------------------------- /utils/tfhe-lints/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | target-dir = "../../target/tfhe-lints" 3 | 4 | [target.'cfg(all())'] 5 | linker = "dylint-link" 6 | -------------------------------------------------------------------------------- /utils/tfhe-lints/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tfhe-lints" 3 | version = "0.1.0" 4 | description = "Project specific lints for TFHE-rs" 5 | edition = "2021" 6 | publish = false 7 | 8 | [lib] 9 | crate-type = ["cdylib"] 10 | 11 | [dependencies] 12 | clippy_utils = { git = "https://github.com/rust-lang/rust-clippy", rev = "238edf273d195c8e472851ebd60571f77f978ac8" } 13 | dylint_linting = "4.0.0" 14 | 15 | [dev-dependencies] 16 | dylint_testing = "4.0.0" 17 | serde = { version = "1.0", features = ["derive"] } 18 | tfhe-versionable = "0.4.0" 19 | 20 | [package.metadata.rust-analyzer] 21 | rustc_private = true 22 | 23 | [[example]] 24 | name = "ui" 25 | path = "ui/main.rs" 26 | -------------------------------------------------------------------------------- /utils/tfhe-lints/README.md: -------------------------------------------------------------------------------- 1 | # Project specific lints for TFHE-rs 2 | This tool is based on [dylint](https://github.com/trailofbits/dylint). 3 | 4 | ## Usage 5 | From TFHE-rs root folder: 6 | ``` 7 | make tfhe_lints 8 | ``` 9 | 10 | ## `serialize_without_versionize` 11 | 12 | ### What it does 13 | For every type that implements `Serialize`, checks that it also implement `Versionize` 14 | 15 | ### Why is this bad? 16 | If a type is serializable but does not implement Versionize, it is likely that the 17 | implementation has been forgotten. 18 | 19 | ### Example 20 | ```rust 21 | #[derive(Serialize)] 22 | pub struct MyStruct {} 23 | ``` 24 | Use instead: 25 | ```rust 26 | #[derive(Serialize, Versionize)] 27 | #[versionize(MyStructVersions)] 28 | pub struct MyStruct {} 29 | ``` 30 | -------------------------------------------------------------------------------- /utils/tfhe-lints/rust-toolchain: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "nightly-2025-02-20" 3 | components = ["llvm-tools-preview", "rustc-dev"] 4 | profile = "default" 5 | -------------------------------------------------------------------------------- /utils/tfhe-lints/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![feature(rustc_private)] 2 | #![feature(let_chains)] 3 | #![warn(unused_extern_crates)] 4 | 5 | extern crate rustc_ast; 6 | extern crate rustc_hir; 7 | extern crate rustc_lint; 8 | extern crate rustc_middle; 9 | extern crate rustc_span; 10 | 11 | mod serialize_without_versionize; 12 | mod utils; 13 | -------------------------------------------------------------------------------- /utils/tfhe-lints/ui/main.rs: -------------------------------------------------------------------------------- 1 | use serde::Serialize; 2 | 3 | #[derive(Serialize)] 4 | struct MyStruct { 5 | value: u64, 6 | } 7 | 8 | fn main() { 9 | let st = MyStruct { value: 42 }; 10 | println!("{}", st.value); 11 | } 12 | -------------------------------------------------------------------------------- /utils/tfhe-lints/ui/main.stderr: -------------------------------------------------------------------------------- 1 | warning: Type MyStruct implements `Serialize` but does not implement `Versionize` 2 | --> $DIR/main.rs:4:1 3 | | 4 | LL | struct MyStruct { 5 | | ^^^^^^^^^^^^^^^ 6 | | 7 | = note: Add `#[derive(Versionize)]` for this type or silence this warning using `#[cfg_attr(dylint_lib = "tfhe_lints", allow(serialize_without_versionize))]` 8 | note: `Serialize` derived here 9 | --> $DIR/main.rs:3:10 10 | | 11 | LL | #[derive(Serialize)] 12 | | ^^^^^^^^^ 13 | = note: `#[warn(serialize_without_versionize)]` on by default 14 | = note: this warning originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info) 15 | 16 | warning: 1 warning emitted 17 | 18 | -------------------------------------------------------------------------------- /utils/tfhe-versionable-derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tfhe-versionable-derive" 3 | version = "0.6.0" 4 | edition = "2021" 5 | keywords = ["versioning", "serialization", "encoding", "proc-macro", "derive"] 6 | homepage = "https://zama.ai/" 7 | documentation = "https://docs.rs/tfhe_versionable_derive" 8 | repository = "https://github.com/zama-ai/tfhe-rs" 9 | license = "BSD-3-Clause-Clear" 10 | description = "tfhe-versionable-derive: A set of proc macro for easier implementation of the tfhe-versionable traits" 11 | 12 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 13 | 14 | [lib] 15 | proc-macro = true 16 | 17 | [dependencies] 18 | syn = { version = "2.0", features = ["full"] } 19 | quote = "1.0" 20 | proc-macro2 = "1.0" 21 | -------------------------------------------------------------------------------- /utils/tfhe-versionable/src/upgrade.rs: -------------------------------------------------------------------------------- 1 | //! How to perform conversion from one version to the next. 2 | 3 | /// This trait should be implemented for each version of the original type that is not the current 4 | /// one. The upgrade method is called in chains until we get to the last version of the type. 5 | pub trait Upgrade { 6 | type Error: std::error::Error + Send + Sync + 'static; 7 | fn upgrade(self) -> Result; 8 | } 9 | -------------------------------------------------------------------------------- /utils/tfhe-versionable/tests/derive_macro.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn tests() { 3 | let t = trybuild::TestCases::new(); 4 | t.pass("tests/testcases/unit.rs"); 5 | t.pass("tests/testcases/struct.rs"); 6 | t.pass("tests/testcases/enum.rs"); 7 | } 8 | -------------------------------------------------------------------------------- /utils/tfhe-versionable/tests/testcases/enum.rs: -------------------------------------------------------------------------------- 1 | use static_assertions::assert_impl_all; 2 | 3 | use serde::{Deserialize, Serialize}; 4 | use tfhe_versionable::{NotVersioned, Version}; 5 | 6 | // Simple contentless enum 7 | #[derive(Version)] 8 | pub enum MyEnum { 9 | Variant0, 10 | Variant1, 11 | } 12 | 13 | #[derive(Serialize, Deserialize, Clone, NotVersioned)] 14 | pub struct MyStruct { 15 | val: u32, 16 | } 17 | 18 | #[derive(Version)] 19 | pub enum MyEnum2 { 20 | Variant1(MyStruct), 21 | Variant2 { val1: u64, val2: u32 }, 22 | Variant3(T), 23 | } 24 | 25 | fn main() { 26 | assert_impl_all!(MyEnum: Version); 27 | 28 | assert_impl_all!(MyEnum2: Version); 29 | } 30 | -------------------------------------------------------------------------------- /utils/tfhe-versionable/tests/testcases/unit.rs: -------------------------------------------------------------------------------- 1 | use static_assertions::assert_impl_all; 2 | 3 | use tfhe_versionable::Version; 4 | 5 | #[derive(Version)] 6 | pub struct MyUnit; 7 | 8 | fn main() { 9 | assert_impl_all!(MyUnit: Version); 10 | } 11 | --------------------------------------------------------------------------------