Draft
Conversation
- Reduce 16 ZK tests to 5 comprehensive API tests - Extract shared prove_helper_evaluations/verify_helper_evaluations - Extract prepare_helper_polynomials utility - Move build_helper_config to ZkParams method - Extract separate_by_arity helper in api.rs - Remove ~240 lines of duplicated code from prefold.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ZK-WHIR Prefolding Protocol (Mixed Arity)
This document describes the full prefolding protocol used to reduce over-sized polynomials to the target arity before entering the main ZK-WHIR flow, while preserving zero-knowledge and soundness.
Phase 0 — Commitment
Each polynomial (native and over-sized) is committed independently at its original arity.
For a polynomial
the prover samples ZK preprocessing data.
All helper polynomials are$\ell$ -variate, with $\ell < L$ .
The prover commits to the masked polynomial
using Interleaved Reed–Solomon (IRS):
Helper polynomials
are batch-committed via a separate helper-WHIR configuration.
The IRS interleaving depth is
where
Each Merkle opening reveals a coset of$k$ evaluations, which is exactly what is required for folding in Phase 2.
Phase 1 — ZK Blinding Setup
This phase is shared across all groups (native and prefold) and establishes the Fiat–Shamir challenges that bind the protocol.
Sample
from the transcript.
Blinding Polynomial
For each polynomial, construct
The prover sends
for each constraint point$a_i$ .
Blinded Polynomial
Sample mixing scalar
Define
Since$g$ is uniform over $\mathbb{F}^{2^L}$ , $P$ is a perfect one-time pad on $\rho \cdot f$ .
Modified evaluations are computed as
Both prover and verifier can compute these values.
Phase 2 — Prefold
This phase is executed for each group with arity$L > n_{\min}$ , starting from the highest arity.
Step 2.1 — Random Linear Combination (RLC)
For polynomials$P_1,\ldots,P_N$ in the group, combine
Combine constraints
Compute the claimed sum
Step 2.2 — Partial Sumcheck
Prove
Run only
rounds of sumcheck.
For each round:
and samples randomness$r_t$ .
After$d$ rounds:
If the group has no constraints,$r$ is sampled directly from Fiat–Shamir.
Step 2.3 — Fold
Define the folded polynomial
Each coefficient of$P'$ is the multilinear evaluation of a block of $2^d$ coefficients of $P_{\mathrm{comb}}$ .
Step 2.4 — Reveal Folded Polynomial
The prover sends all coefficients of$P'$ into the transcript.
Since
and$\mathrm{fold}(g,r)$ is uniformly random, this perfectly hides
while binding the prover to$P'$ .
Step 2.5 — Binding Equation Check
Split each evaluation point
where
Using
the verifier checks
Any incorrect evaluation causes this check to fail.
Step 2.6 — STIR Consistency Check
This step ensures$P'$ is the fold of the committed polynomial.
The verifier opens$\hat f$ at $q$ random IRS query points.
Each query reveals a coset
The prover provides helper evaluations, allowing the verifier to compute
and
By construction,$L(\gamma) = P(\gamma)$ on the evaluation domain.
The verifier:
A mismatch at any query implies cheating with overwhelming probability (Schwartz–Zippel).
Phase 3 — Main ZK-WHIR
After all prefold groups are verified, the remaining native-arity polynomials enter the standard ZK-WHIR protocol at arity$n_{\min}$ .
This includes the full sumcheck, STIR folding, and final coefficient checks.
Unified API
The low-level prefold API requires the caller to manually create configs, sample preprocessings, commit, and wire up group inputs. The new batch_prove_zk / batch_verify_zk API abstracts all of this — the caller just provides polynomials, weights, and evaluations grouped by arity:
The library automatically identifies the native group, creates prefold configs for higher arities, samples ZK preprocessing, commits, and routes to the appropriate prove/verify path (falling back to plain prove_zk when all groups share the same arity).
--
Summary
This achieves sound, ZK-secure batching across mixed arities.