Repository navigation
Conversation
The solver runs a level with enough instructions in parallel, so the BSB22 hints of two independent commitments can run at the same time. Both hints Write/Sum/Reset the same hash-to-field instance, the calls interleave and the commitment wire gets a wrong value, which makes the proof fail verification from time to time. Guard the hash with a mutex in the groth16, plonk and icicle groth16 provers.
Bugbot needs on-demand usage enabledBugbot uses usage-based billing for this team and requires on-demand usage to be enabled. A team admin can enable on-demand usage in the Cursor dashboard. |
|
Oh, thanks -- I haven't checked deeply yet, but skimmed quickly through and you're right. Perhaps it would make sense to have independent hasher instances instead, in which case we don't synchronize the parallel computation? Would it require significant refactor? |
|
Thanks! A per-hint instance would be nice, but |
Thanks! Yeah, indeed that we provide instance of the hasher instead of the index, so its difficult to copy. The API compatibility is a bit of a mess (I think at some point we used to overcome the issue by hashing a known value and checking what the digest is to predict the used hash, but its an ugly solution and I'd not have it elsewhere). Also -- mostly we use only up to a single commitment, so this doesn't really show up, but we should fix for You can keep the PR as is for now -- I'll have a look with fresh head soon. |
|
Hi @ivokub, friendly ping on this one and on my two other small fixes when you have a moment:
All three are still mergeable on current master. Happy to adjust anything. |
Please don't spam on all the opened PRs with different alt-accounts. We review and merge when we have time to do so. |
Description
When a circuit has two BSB22 commitments that don't depend on each other, groth16 and plonk proofs sometimes fail to verify (
proof rejected/algebraic relation does not hold).The solver computes a level in parallel once it has enough instructions, so both commitment hints can run at the same time. Each hint does
Write/Sum/Reseton the same hash-to-field instance (opt.HashToFieldFnin groth16,s.htfFuncin plonk). When the calls interleave, one commitment value is hashed together with the other one, the commitment wire gets a wrong value, and the verifier's recomputation doesn't match.go test -racereports the race onwrappedHashToField.Write/Resetfromgroth16/bn254.Prove.func1andplonk/bn254.(*instance).bsb22Hint.The fix puts the hash calls behind a mutex. It's done in the groth16 and plonk prover templates and in the icicle groth16 template, then regenerated.
Type of change
How has this been tested?
Added
TestIndependentCommitmentstobackend/groth16andbackend/plonk. The circuit has two independent commitments surrounded by ~400 constraints so both hints land in the same parallel level, and it proves 20 times.go test -race -run TestIndependentCommitments ./backend/groth16/ ./backend/plonk/: 8 data races on master, clean with the fix. Without-racemaster fails too but not on every run (e.g. plonk at proof 18).go test -short ./backend/...I couldn't build the icicle package locally (no icicle library), the change there is the same few lines as in groth16.
Checklist:
Note
Medium Risk
Touches core proving paths for BSB22 commitments across groth16/plonk; incorrect locking could still break proofs, but the change is narrowly scoped to shared hasher access and is covered by new concurrency tests.
Overview
Fixes intermittent proof verification failures when a circuit has multiple independent BSB22 commitments: the constraint solver can run commitment hints in parallel, but each hint was sharing one hash-to-field instance (
opt.HashToFieldFnin groth16,s.htfFuncin plonk) without synchronization, so interleavedWrite/Sum/Resetcould corrupt commitment wire values.The PR serializes hash-to-field use with a mutex around those calls in the BSB22 commitment hint paths for groth16, plonk, and icicle groth16 (via prover templates plus regenerated curve-specific code). Plonk stores
htfLockon the proverinstance; groth16/icicle use a localhtfLockin the hint closure.Adds
TestIndependentCommitmentsinbackend/groth16andbackend/plonk: a circuit with two parallelizable commitments, proved 20 times to stress concurrent hints.Reviewed by Cursor Bugbot for commit c73d789. Bugbot is set up for automated code reviews on this repo. Configure here.