Skip to content

Evolve CommitmentScheme trait for PCS-generic batch opening#1300

Open
quangvdao wants to merge 7 commits intoa16z:mainfrom
quangvdao:quang/evolve-commitment-scheme-trait
Open

Evolve CommitmentScheme trait for PCS-generic batch opening#1300
quangvdao wants to merge 7 commits intoa16z:mainfrom
quangvdao:quang/evolve-commitment-scheme-trait

Conversation

@quangvdao
Copy link
Copy Markdown
Contributor

Summary

  • Refactor CommitmentScheme trait to abstract away Dory-specific homomorphic batching (combine_commitments/combine_hints) and introduce PCS-generic batch_prove/batch_verify methods
  • Add BatchPolynomialSource<F> trait + StreamingBatchSource struct to preserve Dory's zero-witness-regeneration streaming RLC path with no performance regression
  • Refactor Stage 8 prover/verifier to use the new PCS::batch_prove/PCS::batch_verify interface, removing DoryOpeningState and compute_joint_commitment

This is preparation for integrating a non-homomorphic PCS (Hachi) alongside Dory. The trait changes are designed so that:

  • Dory continues using its streaming RLC polynomial + homomorphic hint/commitment combination (identical perf path)
  • Hachi (future PR) will ignore the BatchPolynomialSource and instead use its own ring-coefficient-based batch opening

Files changed

File Change
commitment_scheme.rs Add batch_prove/batch_verify, add commitment param to prove(), remove combine_commitments/combine_hints
opening_proof.rs Add BatchPolynomialSource trait + StreamingBatchSource; remove DoryOpeningState
dory/commitment_scheme.rs Implement batch_prove/batch_verify; move combine methods to pub(crate)
hyperkzg.rs Implement batch_prove/batch_verify
mock.rs Implement batch_prove/batch_verify
prover.rs Refactor prove_stage8 to use StreamingBatchSource + PCS::batch_prove
verifier.rs Refactor verify_stage8 to use PCS::batch_verify; remove compute_joint_commitment
proof_serialization.rs joint_opening_proof: PCS::ProofPCS::BatchedProof

Test plan

  • cargo clippy with zero warnings
  • muldiv e2e test passes
  • All 31 Dory tests pass (including e2e: sha2, sha3, fib, btreemap, advice, address major, etc.)

Made with Cursor

Refactor the CommitmentScheme trait to abstract away Dory-specific
assumptions (homomorphic batching via combine_commitments/combine_hints)
and prepare a clean PCS-generic Stage 8 batch opening interface.

Key changes:
- Add BatchPolynomialSource<F> trait for lazy polynomial access
- Add StreamingBatchSource that wraps existing RLCPolynomial::new_streaming
- Add batch_prove/batch_verify to CommitmentScheme trait
- Add commitment param to prove() (needed by non-homomorphic PCS)
- Remove combine_commitments/combine_hints from trait (moved to private
  Dory methods)
- Refactor prove_stage8/verify_stage8 to use PCS::batch_prove/batch_verify
- Remove DoryOpeningState (replaced by StreamingBatchSource)
- Update JoltProof to store BatchedProof for joint opening

Zero performance regression on Dory/BN254 path: the streaming RLC
polynomial construction is preserved identically via StreamingBatchSource.

Made-with: Cursor
…roof/config

Convert all crypto methods (commit, batch_commit, prove, verify,
batch_prove, batch_verify) and StreamingCommitmentScheme methods
from static to instance methods (&self). Add opaque Config associated
type, from_proof() for reconstructing PCS from proof, and config()
accessor. Require Default on CommitmentScheme for ergonomic instance
creation at call sites.

DoryCommitmentScheme now carries a layout field and wraps its batched
proof in DoryBatchedProof (proof + layout). Methods still read
DoryGlobals internally; the instance state will replace globals in
a follow-up.

Made-with: Cursor
…l computation

Extract balanced_sigma_nu as a standalone function. Replace
DoryGlobals::get_num_columns/get_max_num_rows reads in commit, prove,
process_chunk, process_chunk_onehot, aggregate_chunks, and
combine_hints_internal with values derived from polynomial/chunk sizes.
Thread layout through reorder_opening_point_for_layout via self.layout.

Made-with: Cursor
…int cleanup

Add missing match arms for OneHot and RLC variants in len()/original_len()
which were panicking at runtime. Fix test_dory_one_hot_address_major to use
AddressMajor layout on the DoryCommitmentScheme instance. Hoist FQ paths,
remove commented-out code, move mid-function imports to top.

Made-with: Cursor
Move DoryGlobals reads (layout, sigma, nu) from commit()/prove() into
Default::default() and from_proof(), so the operational methods use
self.sigma/self.nu/self.layout instead. Fixes AddressMajor Stage 8
verification failure caused by derive(Default) always using CycleMajor.

Made-with: Cursor
…it evolution branch

Reconcile the CommitmentScheme trait evolution (self-methods, Config,
from_proof, batch_prove/batch_verify) with main's BlindFold ZK protocol,
WASM verifier, JoltCurve type parameter, and tracing spans.

Key decisions:
- prove() takes &self + commitment param (branch) and returns
  (Proof, Option<Field>) for ZK y_blinding (main)
- BatchedProof associated type removed; batch_prove/batch_verify use Proof
- combine_commitments/combine_hints stay as Dory inherent methods
- DoryBatchedProof removed (layout already in JoltProof::dory_layout)
- ZK verifier uses batch_verify with zero claims (committed eval)
- Non-ZK verifier uses batch_verify with actual claims

Made-with: Cursor
@moodlezoup moodlezoup requested a review from markosg04 March 6, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant