Files
zeekay 08a45df14c p3q-sha3 + p3q-gpu-sha3: pluggable Sha3Backend for libluxgpu 0.4 FFI
Adds a Sha3Backend trait in p3q-sha3 with CPU + GPU impls. The CPU
backend is the audited FIPS 202 reference (sha3 crate); the GPU
backend (new crate p3q-gpu-sha3) dlopens libluxgpu and dispatches
through lux_gpu_sha3_256_batch / lux_gpu_shake256_batch. Transparent
CPU fallback whenever dlopen fails, GPU context creation fails, or
libluxgpu panics inside FFI (catch_unwind boundary). KAT parity
enforced against FIPS 202 reference vectors.

The verifier opts in via --features gpu-sha3. Per-query Merkle
authentications fan out into one verify_proof_batch per Merkle root
(trace + each FRI layer); the backend gets one call per root rather
than O(num_queries * log N) serial hashes. CpuShake overrides
tuple_hash256_batch with a streaming impl that avoids per-input
payload allocations — the CPU-only build is now 1017 us/iter
(down from 1308 us serial baseline on the toy AIR).

libluxgpu 0.4 exposes SHAKE256 (0x1F domain) but not cSHAKE256 (0x04),
so the audited transcript binding (cSHAKE / TupleHash / KMAC) still
runs on CPU. The wiring is in place: when libluxgpu adds a native
cSHAKE batch the override drops into p3q-gpu-sha3 with zero verifier
change.

Hard constraints honoured:
- p3q-sha3 stays #![forbid(unsafe_code)]; p3q-gpu-sha3 is the
  second `unsafe`-allowed crate (alongside p3q-c-abi), each unsafe
  block paired with catch_unwind
- GpuShake field order is load-bearing: `gpu` drops before `lib` to
  avoid use-after-free on the destroy fn-ptr at shutdown
- transcript bytes UNCHANGED — Sha3Backend contract guarantees
  byte-identical output on every backend
- 101/101 workspace tests pass with and without --features gpu-sha3

Bench (toy AIR, 256-iter avg, three runs each):
  CPU-only:        1015.2 / 1018.6 / 1017.4 us/iter
  --features gpu-sha3: 1010.3 / 1020.0 / 1019.4 us/iter
2026-05-31 01:24:42 -07:00

42 lines
1.5 KiB
TOML

[package]
name = "p3q-verifier"
description = "P3Q strict-PQ STARK+FRI verifier — panic-free, audit-gated."
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
homepage.workspace = true
rust-version.workspace = true
keywords = ["stark", "fri", "verifier", "post-quantum"]
categories = ["cryptography"]
[dependencies]
p3q-core = { workspace = true }
p3q-field = { workspace = true }
p3q-fri = { workspace = true }
p3q-merkle = { workspace = true }
p3q-sha3 = { workspace = true }
p3q-stark = { workspace = true }
p3q-recursion = { workspace = true }
p3q-challenger = { workspace = true }
# Optional GPU SHA3/SHAKE256 backend (libluxgpu 0.4 dlopen). Falls back
# to the CPU reference whenever the dylib isn't present or lacks the
# required symbols. NEVER changes verifier outputs — byte-identical to
# the audited CPU path by `Sha3Backend` contract.
p3q-gpu-sha3 = { workspace = true, optional = true }
[features]
default = []
# Enable the toy prover (used by the in-crate golden vector tests). The
# prover compiles ONLY under `cargo test` or with `--features prover`;
# the audited production verifier path does not pull in any of this code.
prover = []
# Wire libluxgpu's SHA3-256 / SHAKE256 batch primitives into the
# per-query Merkle path verifications. Compile-time opt-in only;
# audited build stays CPU-only.
gpu-sha3 = ["dep:p3q-gpu-sha3"]
[lints]
workspace = true