refactor: genericize the WHIR-R1CS scheme builder + add provekit-fixtures#459
Open
BornPsych wants to merge 3 commits into
Open
Conversation
|
@BornPsych is attempting to deploy a commit to the World Foundation Team on Vercel. A member of the Team first needs to authorize it. |
shreyas-londhe
requested changes
Jun 25, 2026
shreyas-londhe
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the PR @BornPsych. Clean continuation of the field-generic work. The scheme-builder move keeps bn254 parameter selection identical, splitting the generic constructors from the Mavros adapter is the right line to draw, and the fixtures finally give the spine real frontend-independent coverage with negative tests that actually reject. Left two minor nits inline; neither blocks.
Resolve the conflict in common/whir_r1cs.rs from the base's wasm-gating fix (1f03a22): keep the field-generic scheme-builder imports/constants this branch adds, while moving the on-disk file-format glue (binary_format, Compression/FileFormat/MaybeHashAware) behind the non-wasm cfg gate. Address review feedback: - fixtures harness: derive has_public_inputs from public_inputs instead of hardcoding true, so a no-public-input instance routed through prove() no longer emits a public eval the verifier never reads. - de-duplicate the MIN_WHIR_NUM_VARIABLES floor: export it from common and import it in the r1cs-compiler builder test instead of redeclaring 13.
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.
Summary
Moves WHIR-R1CS scheme construction into the field-generic spine. The scheme parameters (witness commitment domain size, sumcheck rounds, blinding room, zkWHIR config) are now derived generically over the proof field in
provekit-common, instead of living inr1cs-compilerwelded to bn254'sFieldElement. The only genuinely bn254-specific constructor — building a scheme from a Mavros artifact — stays inr1cs-compileras a thin adapter. bn254 parameter selection is unchanged.Also adds a new
provekit-fixturescrate: a field-generic prove→verify harness plus soundness, roundtrip, and proving-time benchmark tests that exercise the spine on synthetic R1CS instances, independently of any frontend.This builds on the field-generic spine (
<P: ProofField>, #458). Since that work is not yet onmain, this PR's commit list includes it; the changes specific to this PR are the final two commits.Why
#458 made the proof types generic over the field, but scheme construction still lived in
r1cs-compilerand tookR1CS<FieldElement>/ returned a bn254WhirZkConfig. A Goldilocks backend has to build a scheme without depending on the Noir/mavros compiler (the goldilocks build excludesr1cs-compilerentirely). So the field-generic half of the builder has to move down into the spine, next to theWhirR1CSScheme<P>type it constructs, leaving only the field-specific Mavros adapter behind.The fixtures crate exists because the generic spine needs coverage that does not route through the bn254 Noir frontend — building R1CS instances with the
R1CSAPI alone lets the same prove→verify path run over anyFieldHashproof field once a second backend lands.What changed
provekit-common:WhirR1CSScheme<P>gains field-generic constructorsnew_for_r1cs/new_from_dimensions/new_whir_zk_config_for_size, derived purely from R1CS dimensions and the committed/extension fields ofP. TheMIN_WHIR_NUM_VARIABLES/MIN_SUMCHECK_NUM_VARIABLESfloors move here too. For bn254 (Identity<Fr>, base == ext) the parameters monomorphize to exactly what shipped before.provekit-r1cs-compiler: trimmed to a bn254-onlyMavrosSchemeBuilderadapter. Mavros artifacts are bn254-specific, so this can't move to the spine; it just forwards the instance's dimensions into the genericnew_from_dimensions. Call sites spell the field explicitly (WhirR1CSScheme::<Bn254Field>::…).provekit-prover: comment cleanup only — the base→ext witness lift is a no-op under anyIdentityembedding (bn254 and pre-v3 goldilocks), not a bn254-specific fact.provekit-fixtures(new): field-generic R1CS builders + a prove→verify harness, pinned toSha256so a roundtrip needs no field-specific hash-engine setup. Tests cover R1CS satisfaction, public-input binding (N=1 and N=2), instance binding, scale boundaries, and a small seed fuzz, plus#[ignore]d proving-time benches.Scope
The fixtures are functional only — they assert that honest proofs verify and that malformed witnesses / public inputs are rejected. They deliberately do not assert bn254 byte-identity; that equivalence is owned by the field-generic spine's regression gate, and the exact
m/m_0/ security-level parameter regression stays in ther1cs-compilerbuilder tests.Verification
cargo build/cargo testgreen overcommon,r1cs-compiler,prover, andfixtures.provekit-fixtures: 6 roundtrip + 4 soundness pass; 2 benches ignored.Commits