Skip to main content

Crate stark_pca

Crate stark_pca 

Source
Expand description

§stark-pca — a transparent STARK of the PCA release gate

A genuine, verifiable zk-STARK (Winterfell, hash-based, no trusted setup, post-quantum) proving the core release gate of Proof-Carrying Authority.

§What the AIR proves

Given PUBLIC inputs — the risk weights (α,β,γ,δ,ε,ζ), the tier-1 threshold θ₁, the cost scale κ, the budget ceiling bMax, the fixed-point scale S = 1e6, and two opaque commitments (policy_commitment, action_commitment) — and PRIVATE witnesses — the six risk-magnitude inputs (d, rev, bl, taint, conf, age), the trust budget B, a predicate-match bit pm, and a caveats-satisfied bit co — the prover demonstrates knowledge of a witness such that

  r_raw = α·d + β·(1−rev) + γ·bl + δ·taint + ε·(1−conf) + ζ·age           (fixed-point, scale S²)
  allow = (tier==1) ∧ (B ≥ κ·r) ∧ pm ∧ co   and   allow == 1

where r = r_raw / S² is computed by the same fixed-point risk functional as the @atlasauth/pca reference risk model (weights clamped ≥0, inputs in [0,1] at scale S, reversibility and confidence entering as 1−x), tier==1 ⟺ r ≤ θ₁ (requiredThreshold’s t=1 band), and B ≥ κ·r is the budget-admission cost gate (admit / cost).

allow is derived in-trace as the product of the four conjuncts and asserted == 1: a deny witness (r > θ₁, B < κ·r, pm == 0, or co == 0) makes the system unsatisfiable, so you cannot forge an allow proof. The two inequalities are enforced by in-AIR bit-decomposition range gadgets (θ₁·S² − r_raw ≥ 0 and B·S − κ·r_raw ≥ 0), which are real algebraic STARK constraints — not a trusted bit.

§Witness ↔ commitment binding (the in-AIR hash)

The private witness is now bound in-AIR to a public commitment. A genuine in-AIR algebraic hash (NUM_LANES=10-wide cube-S-box SPN: a_k = (Hₖ + 2^row + RCₖ)³, diffusion H'ⱼ = Σₖ aₖ + aⱼ, one round per trace row) absorbs the nine quantized witness quantities (d, rev, bl, taint, conf, age, B, pm, co) on row 0 (lanes 0..8) + a capacity IV (lane 9), runs TRACE_LEN−1 rounds, and the first COMMIT_LIMBS=4 state lanes at the final row are asserted equal to a public input witness_commitment (the resource server’s algebraic commitment to the quantized action). The same witness columns drive both the risk gate and the hash, so a proof exists only for a witness whose quantized form hashes to the committed value — you cannot prove the gate for a witness that does not match the committed action. See compute_witness_commitment.

See README.md for the precise honest gaps versus the Groth16 Policy-VM circuit (the @atlasauth/pca Groth16 circuit). The binding above is over the quantized preimage via the AIR’s native algebraic hash — it is not a recomputation of the SHA-256-of-canonical- JSON action_commitment in-AIR (still infeasible in this field); the two are linked off-circuit by the resource server deriving both from one action. Remaining gaps: predicates/caveats are reduced to booleans, the threshold ladder beyond t=1 and the attenuation chain are not encoded.

Structs§

PolicyParams
Public policy parameters (the verifier’s view). All risk quantities are integers at scale S; kappa is a non-negative integer cost scale (see README gap note).
PublicInputs
Public inputs as field elements. Order here defines the Fiat–Shamir transcript binding.
ReleaseAir
Witness
Private witness.

Constants§

COMMIT_LIMBS
Number of squeezed output limbs forming the public witness_commitment.
HEX_COMMITMENT_DIGITS
Required length of an opaque commitment: 64 hex digits (a SHA-256 digest).
HEX_LIMBS
Number of 64-bit limbs each opaque 256-bit hex commitment is split into (big-endian: limb 0 = hex digits 0..16 … limb 3 = hex digits 48..64). 64-bit limbs are always < p in f128, so the split is injective: all 256 bits are bound, with no modular reduction.
MIN_SECURITY_BITS
Minimum security level the verifier will accept.
NUM_LANES
Hash-state lanes: lanes 0..8 absorb the 9 quantized witness quantities, lane 9 = capacity.
NUM_RC
Number of in-AIR range checks (bit-decomposition gadgets).
S
Fixed-point scale (parts-per-million). Matches the reference risk model and Groth16 circuit (S = 1e6).
TRACE_LEN
Execution-trace length (power of two; ≥ 63 so the range gadgets cover bits 0..=62).
WIDTH
Total trace width.

Functions§

build_trace
Build the execution trace for (witness, policy).
compute_witness_commitment
The algebraic commitment to the quantized witness preimage: the first COMMIT_LIMBS hash-state lanes at the final trace row. The resource server computes the same value over the quantized action and publishes it as PolicyParams::witness_commitment.
hex256_limbs
Parse exactly 64 lowercase hex digits into four big-endian 64-bit limbs (all 256 bits, injective).
proof_from_bytes
Decode a serialized proof from UNTRUSTED bytes, failing closed.
proof_options
Winterfell proof options: 37 queries, blowup 8, no field extension → 111-bit query security, 110 bits conjectured (min(min(128, 111) - 1, 128)).
prove_release
Generate a STARK proof that witness satisfies the release gate under policy.
risk_raw
r_raw = Σ wᵢ·termᵢ where termᵢ = xᵢ or (S − xᵢ) for inverted inputs. Scale S². This is the integer image of riskScore in the reference model; dividing by S² recovers r∈[0,1].
verify_release
Verify a release-gate STARK proof against the public policy. Ok(()) ⟺ the gate holds (allow == 1) for some witness, under exactly these public inputs.
verify_release_bytes
Decode (fail-closed) and verify a serialized proof in one step.