This repository experiments with packed FHE operations and constant‑depth NTTs, with Criterion benchmarks to evaluate performance.
- Rust nightly (see
rust-toolchain.toml) - A recent C++17 toolchain and CMake (required by
openfhe-rs) - Optional:
gnuplotfor Criterion plots (Plotters backend is used if not installed)
Runs ntt_const_depth_packed over ciphertexts made from a JSON witness. The benchmark sweeps depth from 1..=log2(n_cts).
-
Prepare a witness file. Accepted formats:
- Top‑level array of numbers or numeric strings:
[1, "2", 3, ...] - Object containing one array field named
input,inputs, orwitness.
- Top‑level array of numbers or numeric strings:
-
Default path (
./witness.json):cargo bench --bench ntt_benchmarks -- ntt_const_depth_packed_witness
-
Custom path (example:
witness_short.json):WITNESS_JSON=witness_short.json cargo bench --bench ntt_benchmarks -- ntt_const_depth_packed_witness
Notes
- Values must fit in
i64and satisfy encryption validation (absolute value < plaintext modulus; seesrc/constants.rs). - Values are packed 4‑per‑ciphertext; the ciphertext count is padded to the next power of two with encrypted zeros.
- Results appear under
target/criterion/ntt_const_depth_packed_witness/*and include an HTML report (report/index.html).
- Constant‑depth NTT with RS expansion factors:
cargo bench --bench ntt_benchmarks -- ntt_const_depth_packed_with_rs
- Vary expansion factors:
cargo bench --bench ntt_benchmarks -- ntt_expansion_factors
- Vary depth on synthetic inputs:
cargo bench --bench ntt_benchmarks -- ntt_depths
- Specific large case (1024, depth 3):
cargo bench --bench ntt_benchmarks -- ntt_specific_cases
Criterion options can reduce run time, e.g. samples or measurement time. Example:
cargo bench --bench ntt_benchmarks -- ntt_const_depth_packed_witness -- --sample-size 10 --warm-up-time 2 --measurement-time 5
(Flags after -- are passed to the benchmark binary and parsed by Criterion.)
- Bench file:
benches/ntt_benchmarks.rs - NTT implementation:
src/ntt/packed_ntt.rs - Context and ciphertext wrappers:
src/fhe/context.rs,src/fhe/ciphertext.rs
See repository terms; contributions should follow the existing project license and guidelines.