You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement a Spartan-style R1CS PIOP over F_q that reduces relation
satisfaction to an Eq-shaped linear claim consumable by F2Z.
This issue owns:
Projection of the SHA relation into F_q.
The R1CS assignment, padding, and MLE layout.
Prover and verifier orchestration for the cubic outer sumcheck.
The terminal Az/Bz/Cz evaluations and fresh batching challenge.
Prover-side row binding and verifier-side sparse matrix-MLE evaluation.
Prover and verifier orchestration for the quadratic inner sumcheck.
Reduction of the inner terminal claim to EqShapedVirtualClaim<Q>.
Transcript binding, proof types, and positive and negative tests.
The completed protocol must reduce
(AZ) ∘ (BZ) = CZ
to a verifier-derived claim
kappa * H~(r_H) = target
that is subsequently authenticated by F2Z.
To avoid collision with the SHA relation's existing notation z = M_mix f, this issue uses Z for the complete padded R1CS assignment
and H for the private binary oracle authenticated by F2Z.
The Spartan verifier is a reduction verifier. It MUST NOT report final
acceptance after the inner sumcheck. Overall acceptance requires successful
F2Z verification of the returned Eq-shaped claim.
Spartan2 as an algorithmic reference for the R1CS reduction
the repository's shared polynomial, transcript, and sumcheck abstractions
The local F2Z specification is normative. Spartan2 is an implementation
reference; its field, PCS, transcript, assignment ordering, and MLE variable
ordering must not be copied without adapting them to this repository.
Relation and field profile
The PIOP proves the R1CS relation
(AZ) ∘ (BZ) = CZ
over the configured prime field
F_q, q = 2^100 - 15.
For the initial SHA integration, lower each exact-integer linear row
L(H) = 0
as the degenerate R1CS constraint
L(H) * 1 = 0.
The generic outer sumcheck must accept individual degree at most three. The
linear SHA instance may degenerate to degree two and must not be rejected for
having degree below the maximum.
Projection of signed integer coefficients into F_q must be checked and must
preserve #17's no-modular-aliasing bound. Do not reinterpret signed
coefficients using unchecked integer casts.
Every coordinate ultimately authenticated by F2Z must be binary. Supporting
general R1CS witnesses containing arbitrary F_q values is out of scope unless
those values are explicitly bit-encoded and linked to the binary assignment.
1. Assignment layout and padding
Define one canonical layout for the R1CS assignment and its row and column
domains.
The layout must pin:
fixed-one, public-input, and private-witness coordinate ordering
live and padded row and column dimensions
deterministic zero padding
MLE variable and index-bit ordering
multi-compression ordering
All R1CS matrices, prover tables, sparse verifier evaluations, and F2Z
reductions must use the same layout metadata. Bind that metadata into the
public statement and add golden tests for representative indices and padded
coordinates.
2. Spartan prover-verifier protocol
The Spartan PIOP consists of:
A degree-at-most-three outer sumcheck.
Three terminal MLE evaluations and a fresh batching challenge.
A degree-at-most-two inner sumcheck.
An Eq-shaped reduction to F2Z.
All verifier challenges are derived through Fiat-Shamir from the shared
transcript.
2.1 Outer sumcheck
Let the padded constraint-row domain have size 2^m_x. The verifier samples
tau <- F_q^m_x
from the transcript.
Define
G(x) =
eq(tau, x)
(Az~(x) Bz~(x) - Cz~(x)).
For a satisfying assignment,
sum_{x in {0,1}^m_x} G(x) = 0.
The prover and verifier run a degree-at-most-three sumcheck for this claim.
In each round:
The prover sends the current univariate round polynomial g_i(X).
The verifier checks
g_i(0) + g_i(1) = current_claim.
The verifier absorbs the round message.
The verifier samples the next challenge r_x[i].
Both parties update
current_claim = g_i(r_x[i]).
After m_x rounds, the protocol has a transcript-derived point r_x and
terminal value
sigma_outer = G(r_x).
The prover then sends
a = Az~(r_x)
b = Bz~(r_x)
c = Cz~(r_x).
The verifier checks
sigma_outer
= eq(tau, r_x) (a b - c).
The values (a, b, c) are then absorbed into the transcript.
2.2 Batched MLE claim and row binding
After absorbing (a, b, c), the verifier samples a fresh challenge
This table is prover-local and is not included in the proof.
The verifier does not construct D[j] at this stage. It retains r_x, rho, and v. After the inner sumcheck produces r_y, the verifier evaluates D~(r_y) directly from the public sparse matrices.
The fresh rho must be sampled after all three values (a, b, c) have been
absorbed.
2.3 Inner sumcheck
The prover and verifier run a degree-at-most-two sumcheck for
v = sum_{y in {0,1}^m_y} D(y) Z[y].
In each round:
The prover sends the quadratic round polynomial.
The verifier checks
g_i(0) + g_i(1) = current_claim.
The verifier absorbs the round message.
The verifier samples the next challenge r_y[i].
Both parties update the running claim.
After m_y rounds, the protocol derives a point r_y and terminal value
sigma_inner = D~(r_y) Z~(r_y).
The verifier evaluates the public sparse matrices at (r_x, r_y):
The matrix evaluations and lambda are verifier-derived. They are not prover
messages.
2.4 Assignment split and F2Z handoff
For the terminal reduction, interpret the canonical assignment as
Z = H || P,
where H is the private binary oracle authenticated by F2Z and P is
verifier-known.
Split the inner point as
r_y = (r_H, s)
according to the pinned MLE ordering. With contiguous halves under the
repository's little-endian convention, s is the high-bit selector and is
folded last.
The correctness-first implementation may evaluate A, B, and C
separately. The optimized implementation should fuse the three CSR traversals
to reuse row and column weights.
Verifier work must be linear in
nnz(A) + nnz(B) + nnz(C)
plus construction of the two Eq tables. Production code must not materialize
a dense bivariate matrix MLE.
4. Proof and API shape
The Spartan proof should contain only prover messages:
Use a return type or naming convention that makes it impossible to mistake
successful Spartan reduction for final proof acceptance.
5. Transcript order and statement binding
Pin the following transcript order:
Domain separator and protocol version.
Field and R1CS profile.
R1CS matrix and shape digest.
Public input.
Assignment and padding metadata.
Virtual-map digest.
F2Z parameters and commitment root.
Outer point tau.
Outer sumcheck rounds.
Outer evaluations (a, b, c).
Batching challenge rho.
Inner sumcheck rounds.
Spartan-to-F2Z handoff.
F2Z proof.
Add an audit mode or golden transcript test recording every absorb and squeeze.
Prover and verifier logs must match byte for byte.
6. Expected prover and verifier cost
For padded row dimension 2^m_x and assignment dimension 2^m_y, the
Spartan verifier performs:
m_x degree-3 sumcheck rounds
m_y degree-2 sumcheck rounds
two Eq-table constructions
one fused sparse evaluation of A, B, and C
one public-table MLE evaluation
one Eq-shaped reduction
one F2Z verification
The issue must document the concrete SHA profile after the assignment layout
is frozen, including:
S2 - Spartan PIOP: outer sumcheck, inner sumcheck, and F2Z handoff
Implement a Spartan-style R1CS PIOP over
F_qthat reduces relationsatisfaction to an Eq-shaped linear claim consumable by F2Z.
This issue owns:
F_q.Az/Bz/Czevaluations and fresh batching challenge.EqShapedVirtualClaim<Q>.The completed protocol must reduce
to a verifier-derived claim
that is subsequently authenticated by F2Z.
To avoid collision with the SHA relation's existing notation
z = M_mix f, this issue usesZfor the complete padded R1CS assignmentand
Hfor the private binary oracle authenticated by F2Z.The Spartan verifier is a reduction verifier. It MUST NOT report final
acceptance after the inner sumcheck. Overall acceptance requires successful
F2Z verification of the returned Eq-shaped claim.
Source of truth
Use:
The local F2Z specification is normative. Spartan2 is an implementation
reference; its field, PCS, transcript, assignment ordering, and MLE variable
ordering must not be copied without adapting them to this repository.
Relation and field profile
The PIOP proves the R1CS relation
over the configured prime field
For the initial SHA integration, lower each exact-integer linear row
as the degenerate R1CS constraint
The generic outer sumcheck must accept individual degree at most three. The
linear SHA instance may degenerate to degree two and must not be rejected for
having degree below the maximum.
Projection of signed integer coefficients into
F_qmust be checked and mustpreserve #17's no-modular-aliasing bound. Do not reinterpret signed
coefficients using unchecked integer casts.
Every coordinate ultimately authenticated by F2Z must be binary. Supporting
general R1CS witnesses containing arbitrary
F_qvalues is out of scope unlessthose values are explicitly bit-encoded and linked to the binary assignment.
1. Assignment layout and padding
Define one canonical layout for the R1CS assignment and its row and column
domains.
The layout must pin:
All R1CS matrices, prover tables, sparse verifier evaluations, and F2Z
reductions must use the same layout metadata. Bind that metadata into the
public statement and add golden tests for representative indices and padded
coordinates.
2. Spartan prover-verifier protocol
The Spartan PIOP consists of:
All verifier challenges are derived through Fiat-Shamir from the shared
transcript.
2.1 Outer sumcheck
Let the padded constraint-row domain have size
2^m_x. The verifier samplesfrom the transcript.
Define
For a satisfying assignment,
The prover and verifier run a degree-at-most-three sumcheck for this claim.
In each round:
The prover sends the current univariate round polynomial
g_i(X).The verifier checks
The verifier absorbs the round message.
The verifier samples the next challenge
r_x[i].Both parties update
After
m_xrounds, the protocol has a transcript-derived pointr_xandterminal value
The prover then sends
The verifier checks
The values
(a, b, c)are then absorbed into the transcript.2.2 Batched MLE claim and row binding
After absorbing
(a, b, c), the verifier samples a fresh challengeThe parties derive
For each assignment coordinate
y, defineThe three terminal MLE claims are thereby reduced to the single claim
The prover constructs the row-bound table
This table is prover-local and is not included in the proof.
The verifier does not construct
D[j]at this stage. It retainsr_x,rho, andv. After the inner sumcheck producesr_y, the verifier evaluatesD~(r_y)directly from the public sparse matrices.The fresh
rhomust be sampled after all three values(a, b, c)have beenabsorbed.
2.3 Inner sumcheck
The prover and verifier run a degree-at-most-two sumcheck for
In each round:
The prover sends the quadratic round polynomial.
The verifier checks
The verifier absorbs the round message.
The verifier samples the next challenge
r_y[i].Both parties update the running claim.
After
m_yrounds, the protocol derives a pointr_yand terminal valueThe verifier evaluates the public sparse matrices at
(r_x, r_y):It then computes
By construction,
so the remaining terminal claim is
The matrix evaluations and
lambdaare verifier-derived. They are not provermessages.
2.4 Assignment split and F2Z handoff
For the terminal reduction, interpret the canonical assignment as
where
His the private binary oracle authenticated by F2Z andPisverifier-known.
Split the inner point as
according to the pinned MLE ordering. With contiguous halves under the
repository's little-endian convention,
sis the high-bit selector and isfolded last.
Then
The verifier computes
and derives, without division,
This yields the Eq-shaped claim
The claim is returned as
and subsequently verified by F2Z.
Do not divide by
lambdaor1 - s.A zero
kappais not an automatic success. The resulting relation stillrequires
target = 0, which must be enforced by F2Z.3. Verifier algorithm
Inputs
The verifier receives:
the public R1CS statement
(A, B, C)public inputs and assignment-layout metadata
the F2Z commitment
the Spartan proof:
the F2Z proof
the shared transcript
The verifier does not receive:
taur_xsigma_outerrhovr_ysigma_innerlambdaThese values are all derived locally.
Algorithm
Validate:
Bind to the transcript:
Sample
Verify the degree-at-most-three outer sumcheck with initial claim zero,
obtaining
Read
(a, b, c)from the proof and reject unlessAbsorb
(a, b, c)in canonical order and sampleDerive
Verify the degree-at-most-two inner sumcheck with initial claim
v,obtaining
Construct
Evaluate the public sparse matrices:
Compute
Split
r_y = (r_H, s)according to the pinned assignment and MLEordering.
Compute
Construct
Bind the Spartan-to-F2Z handoff:
r_HkappatargetInvoke the F2Z verifier on
claim.Accept if and only if:
Otherwise reject.
Shared sumcheck verification requirements
For both sumchecks, the verifier must:
g_i(0) + g_i(1) = current_claimIf the proof encodes each round as
the verifier reconstructs
This guarantees
Sparse matrix-MLE evaluation
Given
evaluate each sparse matrix as
Expose the equivalent of:
The correctness-first implementation may evaluate
A,B, andCseparately. The optimized implementation should fuse the three CSR traversals
to reuse row and column weights.
Verifier work must be linear in
plus construction of the two Eq tables. Production code must not materialize
a dense bivariate matrix MLE.
4. Proof and API shape
The Spartan proof should contain only prover messages:
Challenges, running claims, terminal points, matrix evaluations, and the
Eq-shaped claim must not be independently serialized.
Expose a reduction API equivalent to:
The composed proof should have the equivalent shape:
The top-level verifier performs:
and accepts only if both calls succeed.
Use a return type or naming convention that makes it impossible to mistake
successful Spartan reduction for final proof acceptance.
5. Transcript order and statement binding
Pin the following transcript order:
tau.(a, b, c).rho.Add an audit mode or golden transcript test recording every absorb and squeeze.
Prover and verifier logs must match byte for byte.
6. Expected prover and verifier cost
For padded row dimension
2^m_xand assignment dimension2^m_y, theSpartan verifier performs:
The issue must document the concrete SHA profile after the assignment layout
is frozen, including:
Out of scope
M_mix/A_xconstruction from SHA-256 relation: witness synthesis and sparse M/A construction #17The optimized native Eq-shaped F2Z wire profile should be tracked separately.
This issue owns the stable Eq-shaped reduction boundary.
Validation
Done when all of the following hold:
Tiny hand-built satisfiable R1CS instances prove and verify.
Unsatisfied R1CS instances are rejected.
The SHA linear relation is correctly lowered to degenerate R1CS.
Signed coefficients project into
F_qwithout modular aliasing.Outer verification rejects incorrect round counts and degrees.
Outer verification rejects mutations to
a,b, orc.The batching challenge is sampled only after
(a, b, c)are absorbed.Inner verification rejects incorrect round counts and degrees.
Sparse
A/B/Cevaluations match an independent dense reference.Fused and separate matrix evaluators return identical values.
The verifier never consumes a prover-supplied matrix evaluation.
The derived
lambdamatches direct evaluation of the row-boundDtable.The final Eq-shaped claim matches direct witness-MLE evaluation.
Edge tests cover
lambda = 0,kappa = 0, and selector values zero and one.A zero-scale claim with nonzero target is rejected.
Mutating the public table changes or invalidates the handoff claim.
Mutating the R1CS digest, layout, padding, public input, commitment root, or
virtual map causes rejection.
Golden tests pin assignment order and MLE variable order.
Golden transcript tests pin every absorb and squeeze.
The composed verifier cannot accept without successful F2Z verification.
Production code does not allocate a dense bivariate matrix MLE.
The workspace passes:
Dependencies
Effort L.