YPIR
This is a fork of the YPIR implementation of the YPIR scheme for single-server private information retrieval, introduced in "YPIR: High-Throughput Single-Server PIR with Silent Preprocessing".
This fork has been audited by Zellic. The audit report is available in audits/zellic-audit-report.pdf.
Client-side code is considered frozen in this repository. Server-side code remains open to changes. This is because these changes can only affect performance, they cannot break client privacy. A server-side change could break integrity, as could a malicious server. However, all authentication of data retrieved is not done at the cryptographic layer in YPIR, but instead is an application-layer concern. In our usages within voting and spendability, authentication is explicitly addressed (via merkle path authentication checks against a trusted merkle root, or recursive proofs post-Tachyon).
Running
To build and run this code:
- Ensure you are running on Ubuntu (at least 22.04), and that AVX-512 is available on the CPU (you can run
lscpuand look for theavx512fflag). Our benchmarks were collected using the AWSr6i.16xlargeinstance type, which has all necessary CPU features. - Run
sudo apt-get update && sudo apt-get install -y build-essential libssl-dev pkg-config. - Install Rust using rustup using
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh.
- Select
1) Proceed with installation (default)when prompted - After installation, configure the current shell as instructed by running
source "$HOME/.cargo/env"
- Run
git clone https://github.com/valargroup/ypir.gitandcd ypir. - Run
cargo run --release -- 1073741824to run YPIR on a random database consisting of 1073741824 bits (~134 MB). The first time you run this command, Cargo will download and install the necessary libraries to build the code (~2 minutes); later calls will not take as long. Stability warnings can be safely ignored. See below for details on how to interpret the measurements.
We have tested the above steps on a fresh AWS r6i.16xlarge Ubuntu 22.04 instance and confirmed they work.
Options
To pass arguments, make sure to run cargo run --release -- <ARGS> (the -- is important).
Passing --verbose or setting the environment variable RUST_LOG=debug
will enable detailed logging. All PIR results are checked for correctness.
The full command-line parameters are as follows:
Usage: cargo run --release -- [OPTIONS] <NUM_ITEMS> [ITEM_SIZE_BITS] [NUM_CLIENTS] [TRIALS] [OUT_REPORT_JSON]
Arguments:
<NUM_ITEMS> Number of items in the database
[ITEM_SIZE_BITS] Size of each item in bits (optional, default 1), values over 8 are unsupported
[NUM_CLIENTS] Number of clients (optional, default 1) to perform cross-client batching over
[TRIALS] Number of trials (optional, default 5) to run the YPIR scheme
and average performance measurements over (with one additional warmup trial excluded)
[OUT_REPORT_JSON] Output report file (optional) where results will be written in JSON
Options:
-v, --verbose Verbose mode (optional) if set, the program will print debug logs to stderr
-h, --help Print help
-V, --version Print version
YPIR-SP ring dimension
YPIR-SP defaults to the audited 2048-degree parameter set. The experimental
4096-degree set can be selected with --poly-len 4096 on the run, client,
and server binaries. Clients and servers must select the same degree.
Library callers can select it explicitly:
use ;
let client = from_db_sz_simplepir_with_config;
Why four gadget digits
The gadget base is derived from the digit count, not chosen independently
(⌊56/t⌋ + 1 bits), so t_exp_left is the only dial. Doubling the ring degree
makes the packing term ~8x noisier while the decoding window (set by p and
q'_1) does not move, so the audited t = 3 misses by a wide margin at 4096 —
a modelled failure probability around 2^-14. Four digits shrink each digit
from 19 to 15 bits, cutting that term ~192x, which over-pays the 8x. Five
digits would buy nothing: the packing term is then already below the
modulus-switch floor, and each extra digit costs ~25% more packing-key upload.
Only (2048, 3) and (4096, 4) are accepted. YPIRSPConfig's fields are
private so no other pair is constructible, and assert_valid_ypir_sp_params
re-checks the pair wherever a bare &Params enters the YPIR-SP path, since
Params exposes poly_len and t_exp_left publicly.
Inspecting the noise bound
ypir_sp_noise_report models the YPIR-SP path term by term: the two
modulus-switch contributions, the SimplePIR first dimension (the only
db_rows-dependent term), and automorphism packing. It carries an explicit
PACKING_TERM_SLACK, because composing the per-automorphism bound across
log2(poly_len) levels is a heuristic that measurement puts ~2.3x low.
noise_bound_dominates_measurement in scheme.rs runs the real pipeline over
a range of shapes, verifies every decoded coefficient against the requested
database row, and fails if measured noise crosses the model. This provides
randomized regression evidence that the slack has not gone stale; it does not
turn the heuristic packing composition or its modeled failure probabilities
into a mathematical bound.
For 16,384 rows of 131,072-bit items, the model reports both the estimated tail
probability for one coefficient and a response-wide estimate obtained by
union-bounding over
poly_len * instances decoded coefficients. The response-wide value is the
one compared with the 2^-40 correctness target:
| set | modeled per-coefficient failure | modeled response failure | worst sampled coefficient |
|---|---|---|---|
| 2048, t=3 | 2^-46.03 |
2^-32.71 |
20–30% of window |
| 4096, t=4 | 2^-532.75 |
2^-519.16 |
8–10% of window |
With measurement-calibrated packing slack, the 2048 set no longer meets
response-wide 2^-40 for this (or even single-ciphertext) shape: packing
dominates the modulus-switch term ~37:1 and sits well above the switch floor.
The 4096 set is switch-limited and therefore close to the floor the wire format
allows, which is why it retains a large margin.
Separately, aligning the model with the production gadget base (2^19 for
three digits) changes the 2048-degree YPIR-double model from approximately
2^-41.75 to 2^-26.74 total failure probability (2^-96.70 for the
SimplePIR stage and 2^-26.74 for the double-PIR stage). That is below the
previous 2^-40 target and is tracked by a characterization test. It does not
affect the YPIR-SP bounds, and the double path is unreachable from the shipped
binaries, which require --is-simplepir.
Interpreting measurements
This is an annotated version of the output
of running RUST_LOG=debug cargo run --profile release-with-debug --bin server 8589934592 1
(testing on a 1 GB database),
detailing what each measurement means:
Server & Client
You can run YPIR as a standalone HTTP server using a command like:
Acknowledgements
YPIR is based on DoublePIR, and this implementation uses matrix-vector multiplication routines based on the ones in ahenzinger/simplepir. We also use a fork of spiral-rs for Spiral to handle RLWE ciphertexts.
Citing
Please cite the original work as:
@inproceedings{MW24,
author = {Samir Jordan Menon and David J. Wu},
title = {{YPIR}: High-Throughput Single-Server {PIR} with Silent Preprocessing},
booktitle = {{USENIX} Security Symposium},
year = {2024}
}
This fork is maintained by valargroup.