mirror of
https://github.com/luxfi/p3q.git
synced 2026-10-30 15:22:47 +00:00
10 crates wired in dependency order, all building under cargo build
--workspace --all-targets and 43 unit tests passing.
p3q-core protocol types, error model, profile dispatch
p3q-field Field trait + Goldilocks (p = 2^64 - 2^32 + 1)
p3q-sha3 FIPS 202 / SP 800-185: cSHAKE256, KMAC256, TupleHash256
p3q-merkle cSHAKE256-based binary Merkle tree + path verifier
p3q-challenger cSHAKE256 Fiat-Shamir transcript
p3q-fri FRI low-degree-test trait surface
p3q-stark AIR trait + StarkProof envelope
p3q-recursion STARK-native recursion trait (no curve wrappers)
p3q-verifier panic-free verifier dispatch (typed errors only)
p3q-zchain HIP-0078 epoch circuits (register / rotate / revoke /
committee / DKG / epoch commitment)
Strict-PQ profile enforced by scripts/lint_forbidden.sh + CI:
no bn254, kzg, groth16, plonk_kzg, halo, blake3, poseidon,
monolith, rescue in imports or dependency tables.
Signed-off-by: Lux Industries Inc <[email protected]>
86 lines
2.5 KiB
Bash
Executable File
86 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# P3Q strict-PQ lint gate.
|
|
#
|
|
# Refuses any *.rs or Cargo.toml in the workspace that **imports** a
|
|
# forbidden hash family or proof-system primitive. The list is the
|
|
# canonical strict-PQ exclusion set from CONTRIBUTING.md.
|
|
#
|
|
# Documentation prose is allowed to mention forbidden primitives by
|
|
# name — the lint inspects only actual code-level references:
|
|
#
|
|
# * Cargo.toml dependency keys (e.g. `bn254 = "..."`,
|
|
# `[dependencies.bn254]`, `[*-dependencies.bn254]`)
|
|
# * Rust `use` / `extern crate` / `mod` statements
|
|
#
|
|
# Exits non-zero on the first match.
|
|
|
|
set -uo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
patterns=(
|
|
"bn254"
|
|
"kzg"
|
|
"groth16"
|
|
"plonk_kzg"
|
|
"halo"
|
|
"blake3"
|
|
"poseidon"
|
|
"monolith"
|
|
"rescue"
|
|
)
|
|
|
|
# Collect candidate files. macOS bash 3.2 has no `mapfile`, so we
|
|
# materialise the list in a tempfile and iterate via line-read.
|
|
tmp=$(mktemp)
|
|
trap 'rm -f "$tmp"' EXIT
|
|
|
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
|
git ls-files '*.rs' 'Cargo.toml' '**/Cargo.toml' > "$tmp" 2>/dev/null || true
|
|
else
|
|
find . -type f \( -name '*.rs' -o -name 'Cargo.toml' \) \
|
|
-not -path './target/*' \
|
|
-not -path './scripts/*' \
|
|
-not -name 'README.md' \
|
|
-not -name 'CONTRIBUTING.md' > "$tmp"
|
|
fi
|
|
|
|
found_any=0
|
|
|
|
for pattern in "${patterns[@]}"; do
|
|
while IFS= read -r f; do
|
|
[ -f "$f" ] || continue
|
|
case "$f" in
|
|
*.rs)
|
|
# Rust imports: `use X`, `extern crate X`, `mod X` where X is or
|
|
# ends with the forbidden token. Attribute prefixes (e.g.
|
|
# `#[allow(unused)]`) on the same line are allowed.
|
|
if grep -nEi "\b(use|extern[[:space:]]+crate|mod)[[:space:]]+([a-z0-9_]+::)*${pattern}([:;{[:space:]]|$)" "$f"; then
|
|
echo "FORBIDDEN(rust import) ${pattern} in $f" >&2
|
|
found_any=1
|
|
fi
|
|
;;
|
|
Cargo.toml|*/Cargo.toml)
|
|
# Cargo dep keys: `<name> = ...` or `[<...>dependencies.<name>]`.
|
|
if grep -nEi "^[[:space:]]*${pattern}[[:space:]]*=" "$f"; then
|
|
echo "FORBIDDEN(cargo dep key) ${pattern} in $f" >&2
|
|
found_any=1
|
|
fi
|
|
if grep -nEi "^[[:space:]]*\[[a-z0-9_.-]*dependencies\.[a-z0-9_-]*${pattern}[a-z0-9_-]*\][[:space:]]*$" "$f"; then
|
|
echo "FORBIDDEN(cargo dep table) ${pattern} in $f" >&2
|
|
found_any=1
|
|
fi
|
|
;;
|
|
esac
|
|
done < "$tmp"
|
|
done
|
|
|
|
if [ "$found_any" -ne 0 ]; then
|
|
echo
|
|
echo "P3Q strict-PQ profile forbids: BN254, KZG, Groth16, PLONK/KZG," >&2
|
|
echo "Halo, BLAKE3, Poseidon, Monolith, Rescue. See CONTRIBUTING.md." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "lint_forbidden.sh: clean."
|