@@ -10,7 +10,7 @@ use sp1_aggregator::{
1010 AlignedSP1VerificationError , SP1AggregationError , SP1ProofWithPubValuesAndElf ,
1111} ;
1212
13- const AGG_PROOF_CHUNKS : usize = 512 ;
13+ const MAX_PROOFS_PER_AGGREGATION : usize = 512 ;
1414
1515#[ derive( Clone , Debug ) ]
1616pub enum ZKVMEngine {
@@ -55,6 +55,15 @@ impl ZKVMEngine {
5555 ///
5656 /// This function performs proof aggregation and ensures the resulting Merkle root
5757 /// can be independently verified by external systems.
58+ ///
59+ /// If the number of proofs exceeds [`MAX_PROOFS_PER_AGGREGATION`], it first aggregates
60+ /// them in chunks of [`MAX_PROOFS_PER_AGGREGATION`], and then aggregates those intermediate results into
61+ /// the final proof.
62+ ///
63+ /// Note: Intermediate proof commitments are not computed using the Keccak hash of the
64+ /// verification key and public inputs. Instead, the raw bytes of the public input—
65+ /// which represent the chunk's merkle root are used directly. This is to ensure
66+ /// the final Merkle root matches the leaf hashes published on the blob.
5867 pub fn aggregate_proofs (
5968 & self ,
6069 proofs : Vec < AlignedProof > ,
@@ -69,8 +78,8 @@ impl ZKVMEngine {
6978 } )
7079 . collect ( ) ;
7180
72- let mut agg_proof = if proofs. len ( ) > AGG_PROOF_CHUNKS {
73- let chunks = proofs. chunks ( AGG_PROOF_CHUNKS ) ;
81+ let mut agg_proof = if proofs. len ( ) > MAX_PROOFS_PER_AGGREGATION {
82+ let chunks = proofs. chunks ( MAX_PROOFS_PER_AGGREGATION ) ;
7483 let mut agg_proofs: Vec < SP1ProofWithPubValuesAndElf > = vec ! [ ] ;
7584 for chunk in chunks {
7685 let agg_proof = sp1_aggregator:: aggregate_proofs ( chunk, false , false )
@@ -102,8 +111,8 @@ impl ZKVMEngine {
102111 } )
103112 . collect ( ) ;
104113
105- let agg_proof = if proofs. len ( ) > AGG_PROOF_CHUNKS {
106- let chunks = proofs. chunks ( AGG_PROOF_CHUNKS ) ;
114+ let agg_proof = if proofs. len ( ) > MAX_PROOFS_PER_AGGREGATION {
115+ let chunks = proofs. chunks ( MAX_PROOFS_PER_AGGREGATION ) ;
107116 let mut agg_proofs: Vec < Risc0ProofReceiptAndImageId > = vec ! [ ] ;
108117 for chunk in chunks {
109118 let agg_proof = risc0_aggregator:: aggregate_proofs ( chunk, false , false )
0 commit comments