Skip to main content

Crate inspiring

Crate inspiring 

Source
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) -> RlweCiphertext

which 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-rs fork pinned to rev = 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

ModuleConcept (paper §)Phase
paramsRlweParams, GadgetParams, validatorsPhase 4
lweLweCiphertext, batch type, embedding (Eq. 1)Phase 4 / 5
automorphτ_g, τ_h, τ_g^j (§2 + Lemma 1)Phase 4 / 5
intermediateIRCtx, Stage 1 transform, Stage 2 aggregatePhase 5 / 6
collapsecollapse_one, collapse_half, collapse (Stage 3)Phase 7
key_switchingKS.Setup, KS.Switch, automorphic imagesPhase 7
preprocessPackPreprocessed (CRS-model offline cache)Phase 8
packtop-level pack (Algorithm 1)Phase 8
errorInspiringErrorPhase 4

§Public API invariants

These are also asserted by tests (tests/inspiring_vs_cdks_recursion.rs):

  1. PackPreprocessed::build accepts exactly two key-switching matrices, kg and kh.
  2. A single call to pack::pack invokes KS.Switch exactly d − 1 times.
  3. pack::pack is 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 from IRCtx (a wide (d+1)-element ciphertext) down to a 2-element RLWE ciphertext under the base secret s̃.
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.Setup and KS.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’s lg d).
lwe
LWE ciphertext type and the LWE→RLWE embedding.
pack
Top-level pack entry 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.