Files
p3q/Cargo.toml
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

67 lines
2.3 KiB
TOML

[workspace]
resolver = "2"
members = [
"crates/p3q-core",
"crates/p3q-field",
"crates/p3q-fri",
"crates/p3q-merkle",
"crates/p3q-stark",
"crates/p3q-recursion",
"crates/p3q-challenger",
"crates/p3q-verifier",
"crates/p3q-sha3",
"crates/p3q-gpu-sha3",
"crates/p3q-zchain",
"crates/p3q-c-abi",
]
[workspace.package]
version = "0.0.1"
authors = ["Lux Industries Inc <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/luxfi/p3q"
homepage = "https://github.com/luxfi/p3q"
description = "P3Q — post-quantum-only profile and fork of Plonky3 for Lux Z-Chain (HIP-0078). Strict STARK/FRI/SHA-3 only; no KZG, no BN254, no Groth16, no PLONK, no pairings."
keywords = ["zk", "stark", "fri", "post-quantum", "plonky3"]
categories = ["cryptography"]
rust-version = "1.79"
[workspace.dependencies]
# Internal crates — pinned to workspace version.
p3q-core = { version = "0.0.1", path = "crates/p3q-core" }
p3q-field = { version = "0.0.1", path = "crates/p3q-field" }
p3q-fri = { version = "0.0.1", path = "crates/p3q-fri" }
p3q-merkle = { version = "0.0.1", path = "crates/p3q-merkle" }
p3q-stark = { version = "0.0.1", path = "crates/p3q-stark" }
p3q-recursion = { version = "0.0.1", path = "crates/p3q-recursion" }
p3q-challenger = { version = "0.0.1", path = "crates/p3q-challenger" }
p3q-verifier = { version = "0.0.1", path = "crates/p3q-verifier" }
p3q-sha3 = { version = "0.0.1", path = "crates/p3q-sha3" }
p3q-gpu-sha3 = { version = "0.0.1", path = "crates/p3q-gpu-sha3" }
p3q-zchain = { version = "0.0.1", path = "crates/p3q-zchain" }
p3q-c-abi = { version = "0.0.1", path = "crates/p3q-c-abi" }
# External — only PQ-safe primitives.
sha3 = "0.10" # FIPS 202: SHA-3, SHAKE128/256, cSHAKE
hex = "0.4"
thiserror = "1.0"
[workspace.lints.rust]
unsafe_code = "deny" # P3Q code MUST NOT use `unsafe`. Audited subset.
[profile.release]
opt-level = 3
lto = "thin"
codegen-units = 1
debug = false
panic = "abort"
[profile.bench]
opt-level = 3
lto = "thin"
debug = true # benches need symbols for flamegraphs
[profile.test]
opt-level = 1 # fast test compile; correctness > speed in dev