|
myl7/fss 2.0.0
Function secret sharing (FSS) primitives including distributed point/comparison function (DPF/DCF)
|
Function secret sharing (FSS) primitives including:
Features:
Multi-party computation (MPC) is a subfield of cryptography that aims to enable a group of parties (e.g., servers) to jointly compute a function over their inputs while keeping the inputs private.
Secret sharing is a method that distributes a secret among a group of parties, such that no individual party holds any information about the secret. For example, a number \(x\) can be secret-shared into \(x_0, x_1\) via \(x = x_0 + x_1\).
FSS is a scheme to secret-share a function into a group of function shares. Each function share, called a key, can be individually evaluated by a party. The outputs of the keys are the shares of the original function output. FSS consists of 2 methods: Gen for generating function shares as keys and Eval for evaluating a key to get an output share. FSS's workflow is shown below:
DPF and DCF are FSS for point/comparison functions. Two-party DPF and DCF can have \(O(\log N)\) key size, where \(N\) is the input domain size. Meanwhile, 3-or-more-party DPF/DCF and general FSS have \(O(\sqrt{N})\) key size. See the API documentation for Dpf and Dcf for their definitions and input requirements.
If you are upgrading from an earlier release, see the migration guide.
Clone the repository:
Install via CMake and use find_package:
Then in your project's CMakeLists.txt:
When configuring your project, point CMake to the install prefix:
To use the headers without installing, define a target in your CMakeLists.txt:
Link the target in your project:
To enable parallel CPU evaluation, follow the sample CMake configuration.
This example uses DPF and DCF on the CPU with the AES-128 MMO PRG. This PRG requires OpenSSL.
Include the headers and set up type aliases:
Create the PRG with AES keys and instantiate DPF/DCF:
Run Gen to generate correction words and control bits from the secret inputs:
Run Eval on each party and reconstruct using the group:
Free the AES contexts when done:
DCF follows the same pattern with DcfPrg (mul=4, needs 4 AES keys) and Dcf. Allocate both cws and vws arrays of Dcf::kCwCount elements, and pass both spans before tr to Gen and Eval. Each party receives its own initial seed and the shared corrections. The reconstructed output equals beta when x < alpha and 0 otherwise.
Link with OpenSSL in your CMakeLists.txt:
If you defined the header-only target above, link fss instead of fss::fss. See the complete CPU example.
This example uses DPF and DCF on the GPU with the ChaCha PRG.
Include the headers and set up type aliases:
Write a Gen kernel. Use the same ChaCha nonce for generation and evaluation:
Prepare host data, copy to device, and launch the Gen kernel:
Write and launch an Eval kernel for each party, then copy results back:
Reconstruct on the host using the group, same as the CPU case:
DCF follows the same pattern with DcfPrg (mul=4) and Dcf, adding a vws array to the device storage. Check every CUDA API return value, kernel launch, and execution result before using the outputs. Keep device buffers alive until queued work completes, and free them afterwards. ChaCha and software AES support host and device execution. OpenSSL and AES-NI backends are host-only.
See the complete CUDA example.
samples/ holds a standalone program per scheme. They form their own CMake project:
| Sample | Scheme | Shows |
|---|---|---|
| dpf_dcf_cpu.cu | DPF, DCF | Host Gen/Eval with AES-128 MMO PRG |
| dpf_dcf_gpu.cu | DPF, DCF | Gen/Eval inside CUDA kernels with ChaCha PRG |
| half_tree_dpf_cpu.cu | Half-Tree DPF | Gen/Eval/EvalAll with a CCR hash and an explicit instance seed |
| packed_half_tree_dpf_cpu.cu | Packed Half-Tree DPF (experimental) | Sub-128-bit packed outputs: Gen/Eval/EvalAll/Extract over packed blocks |
| grotto_dcf_cpu.cu | Grotto DCF | Gen/Preprocess/Eval over a parity segment tree, plus EvalAll |
| vdpf_cpu.cu | VDPF | Gen/Eval/EvalAll plus the Prove/Verify check |
| vdmpf_cpu.cu | VDMPF | Gen/BatchEval over cuckoo-hash packed points |
| dmpf_cpu.cu | DMPF | Gen/BatchEval over cuckoo-hash packed points, without verification |
The samples project requires OpenSSL. EvalAll uses OpenMP when available.
Use Python 3.11 or newer and a CUDA-enabled PyTorch 2.6 or newer. Choose a PyTorch build whose CUDA major version matches your local CUDA toolkit, even for CPU execution. Then install the package from this checkout:
The Python samples show CUDA execution and the other schemes.
FSS curves show v2.0.0. CPU runs use an AMD EPYC 9115, and GPU runs use an NVIDIA RTX A6000 with CUDA 12.6. The comparison lists the library versions and configurations for the third-party curves.
CPU Gen and point Eval report time per key and per query. EvalAll produces the full domain for one key. VDPF evaluation includes proof generation, with verification outside timing.
GPU point timings divide the measured batch time by its key or query count. Full-domain curves report time per key after batch normalization. These throughput measurements are not single-key launch latencies.
The interactive comparison has exact values and selectable methods. See the measurement methodology for output types, proof protocols, timing boundaries, and supplementary figures.
Build and run a selection with Google Benchmark:
Choose an idle GPU with CUDA_VISIBLE_DEVICES before running CUDA benchmarks. For pinned CPU runs, sampling profiles, full-domain workloads, and third-party adapters, see the benchmark runner guide.
Generate a CPU flamegraph with perf and FlameGraph:
make flamegraph configures a RelWithDebInfo build and runs the profiling commands. Set FLAMEGRAPH_DIR to the FlameGraph checkout and FLAMEGRAPH_BENCH to the benchmark filter:
Open build/flamegraph.svg in a browser. The graph is interactive: click a frame to zoom in.
Apache License, Version 2.0
Copyright (C) 2026 Yulong Ming i@myl.nosp@m.7.or.nosp@m.g