Skip to content

tkmct/fhe-snark

Repository files navigation

FHE-SNARK

This repository experiments with packed FHE operations and constant‑depth NTTs, with Criterion benchmarks to evaluate performance.

Prerequisites

  • Rust nightly (see rust-toolchain.toml)
  • A recent C++17 toolchain and CMake (required by openfhe-rs)
  • Optional: gnuplot for Criterion plots (Plotters backend is used if not installed)

Run The NTT Benchmarks

1) Witness‑Driven NTT (this work)

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, or witness.
  • 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 i64 and satisfy encryption validation (absolute value < plaintext modulus; see src/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).

2) Other NTT Bench Groups

  • 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

Tuning Benchmark Runtime

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.)

Where To Look

  • 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

License

See repository terms; contributions should follow the existing project license and guidelines.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages