Skip to content

Conversation

@markosg04
Copy link
Collaborator

@markosg04 markosg04 commented Sep 30, 2025

adds the initial recursion & snark composition proof machinery. Brings the main dory verification from 1.5B RISC-V cycles down to 330 million:

  • adds a square and multiply sumcheck
  • adds hyrax and related things
  • changes the commitment scheme API to allow for offloading ops
  • adds some new accumulator methods for recursion specific context
  • grumpkin-related support for sumchecks
  • stage 6 DAG for recursion mode

also does some miscellaneous things:

  • srs -> urs
  • aligns all the feature branches back into dev/twist-shout across dory and arkworks
  • probably some other small fixes along the way that I don't quite remember

In general, I am somewhat OK with the flow of the stage 6 for now. My personal main problem is with the recursion helpers being verbose in the opening_proof.rs and some jank casts. I am still thinking for better solutions and so just flagging this during the review. Happy to take suggestions for better approaches. If no one has better ideas in this review then a subsequent PR will address

Next steps:

  • CI needs to test in recursion mode
  • Implement remaining sumchecks for the 330 mil cycles (should bring us to pretty much 0 cycles hopefully).
  • further cleanup as we come up with better solutions for the recursion machinery
  • measure and improve prover perf in stage 6 (for this initial version it is a few seconds in debug mode)
  • Optimize the hyrax scheme by using a giant matrix instead of homomorphism (we have many small polys so currently homomorphic combining is inefficient)

On the last point: we are producing about 50k polys of 4 vars. We should be able to fit everything including all the remaining witnesses from the 330M cycles into a 2^10 x 2^10 matrix, so we have 2^11 Grumpkin G1 (Fr) ops for verifier (2 MSM of 2^10), which should be really fast (few ms) to verify...


fn scale(&self, k: &Self::Scalar) -> Self {
Self(self.0.cyclotomic_exp(k.0.into_bigint()))
Self(self.0.pow(k.0.into_bigint()))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cyclotomic exp is currently not implemented in our bespoke dory snark (though it could be in future, it would reduce the witness size by about half)

Comment on lines +573 to +586
let sz_proof_fq = unsafe {
std::mem::transmute::<
&crate::subprotocols::snark_composition::RecursionProof<
F,
ProofTranscript,
1,
>,
&crate::subprotocols::snark_composition::RecursionProof<
Fq,
ProofTranscript,
1,
>,
>(sz_proof)
};
Copy link
Collaborator Author

@markosg04 markosg04 Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open to suggestions to avoid jank casts (applies prover side too)

Comment on lines +959 to +974
let commitment_coeffs_for_recursion = if cfg!(feature = "recursion")
&& std::any::TypeId::of::<PCS>()
== std::any::TypeId::of::<super::commitment::dory::DoryCommitmentScheme>()
{
Some(
rlc_map
.iter()
.map(|(polynomial, coeff)| {
(commitments.get(polynomial).unwrap().clone(), *coeff)
})
.collect::<Vec<_>>(),
)
} else {
None
};

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also jank, suggestions?

@markosg04 markosg04 marked this pull request as ready for review October 6, 2025 23:46
@markosg04 markosg04 requested a review from sagar-a16z October 7, 2025 00:44
@markosg04 markosg04 changed the title Feat/snark composition feat: snark composition Oct 7, 2025
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.

3 participants