Expand description
§inspiring — InspiRING.Pack ring-packing crate
A standalone Rust implementation of Algorithm 1 (InspiRING.Pack)
from the InsPIRe paper (eprint 2025/1352, Mahdavi–Patel–Seo–Yeo, 2025).
The crate exposes a single primitive:
pub fn pack(lwe_b: LweBatch, pre: &PackPreprocessed) -> RlweCiphertextwhich compresses d LWE ciphertexts (each of LWE dimension d) into a
single RLWE ciphertext of degree d, using exactly two key-switching
matrices K_g and K_h. See SPEC.md for the mathematical contract
and docs/spiral-rs-mapping.md for the spiral-rs primitive audit.
§Locked-in scope
- Algorithm 1 only. No
PartialPack, no PIR layers. - Built on Valar’s
spiral-rsfork pinned torev = 6f5b66c6a5a639827c6486c59d31c7ec2d4399a8. - Production posture: offline/online split (CRS model), full unit and integration tests and empirical decryption-margin checks, benchmarks reproducing paper Table 5, CI, rustdoc.
§Crate map
| Module | Concept (paper §) | Phase |
|---|---|---|
params | RlweParams, GadgetParams, validators | Phase 4 |
lwe | LweCiphertext, batch type, embedding (Eq. 1) | Phase 4 / 5 |
automorph | τ_g, τ_h, τ_g^j (§2 + Lemma 1) | Phase 4 / 5 |
intermediate | IRCtx, Stage 1 transform, Stage 2 aggregate | Phase 5 / 6 |
collapse | collapse_one, collapse_half, collapse (Stage 3) | Phase 7 |
key_switching | KS.Setup, KS.Switch, automorphic images | Phase 7 |
preprocess | PackPreprocessed (CRS-model offline cache) | Phase 8 |
pack | top-level pack (Algorithm 1) | Phase 8 |
error | InspiringError | Phase 4 |
§Public API invariants
These are also asserted by tests (tests/inspiring_vs_cdks_recursion.rs):
PackPreprocessed::buildaccepts exactly two key-switching matrices,kgandkh.- A single call to
pack::packinvokesKS.Switchexactlyd − 1times. pack::packis a deterministic function of(lwe_b, pre)— no fresh randomness is sampled in the online path.
§Toolchain & platform
Valar’s fork removes the old #![feature(stdarch_x86_avx512)] dependency
and fixes the scalar multiply_add_modular accumulator bug for
crt_count == 1, so inspiring no longer gates correctness on AVX-512.
CI still runs on x86_64-unknown-linux-gnu; other targets depend on the
upstream fork’s portability.
See docs/spiral-rs-mapping.md for the full audit of inherited
constraints.
Re-exports§
pub use error::InspiringError;pub use lwe::LweBatch;pub use lwe::LweCiphertext;pub use pack::pack;pub use pack::RlweCiphertext;pub use params::GadgetParams;pub use params::RlweParams;pub use preprocess::reference_mask_coeffs;pub use preprocess::PackPreprocessed;pub use preprocess::PackPublicPreprocessed;pub use preprocess::PackingKeys;pub use preprocess::QueryPackPreprocessed;pub use preprocess::TopKeyImages;pub use preprocess::REFERENCE_V_SEED;pub use preprocess::REFERENCE_W_SEED;
Modules§
- automorph
- Galois automorphisms
τ_g,τ_h, and iteratedτ_g^j. - collapse
- Stage 3 of
InspiRING.Pack: the collapse fromIRCtx(a wide(d+1)-element ciphertext) down to a 2-element RLWE ciphertext under the base secrets̃. - error
- Crate error type.
- gaussian
- Discrete-Gaussian sampler with a frozen default CDF.
- intermediate
- The intermediate ciphertext
IRCtx = (â, b̃)and the algorithms that produce it. - key_
switching - Key-switching primitives
KS.SetupandKS.Switch, plus helpers to compute automorphic imagesτ_g^{k-1}(K_g)of a base matrix locally (without extra key material). See SPEC.md §6 (Stage 3) and §9.b (the structural reason InspiRING needs only two base KS matrices vs. CDKS’slg d). - lwe
- LWE ciphertext type and the LWE→RLWE embedding.
- pack
- Top-level
packentry point — Algorithm 1 of eprint 2025/1352. - params
- Parameter sets for
inspiring. - prepared
- Versioned public packing state. Callers must authenticate the complete file digest and bind it to their published session before serving with this state. Shapes come from trusted parameters, never allocation lengths in the stream.
- preprocess
PackPreprocessed: the CRS-model offline cache.