File tree Expand file tree Collapse file tree
circuits/halo2_ivc/tests/common/generators
protocol/aggregate_signature Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -173,17 +173,19 @@ pub(crate) fn build_deterministic_params(circuit_degree: u32) -> ParamsKZG<Bls12
173173 ParamsKZG :: < Bls12 > :: unsafe_setup ( circuit_degree, ChaCha20Rng :: seed_from_u64 ( ASSET_SEED ) )
174174}
175175
176- /// Derives circuit-specific commitment parameters from a shared universal SRS.
176+ /// Returns commitment parameters for `circuit_degree`. Reuses `universal_kzg_parameters`
177+ /// directly when it already matches, otherwise generates fresh parameters at `circuit_degree`
178+ /// with the same deterministic seed.
177179pub ( super ) fn derive_commitment_params (
178180 universal_kzg_parameters : & ParamsKZG < Bls12 > ,
179181 shared_srs_degree : u32 ,
180182 circuit_degree : u32 ,
181183) -> ParamsKZG < Bls12 > {
182- let mut commitment_parameters = universal_kzg_parameters. clone ( ) ;
183- if circuit_degree < shared_srs_degree {
184- commitment_parameters. downsize ( circuit_degree) ;
184+ if circuit_degree == shared_srs_degree {
185+ universal_kzg_parameters. clone ( )
186+ } else {
187+ build_deterministic_params ( circuit_degree)
185188 }
186- commitment_parameters
187189}
188190
189191/// Builds the shared verifier-side recursive setup from the deterministic SRS.
Original file line number Diff line number Diff line change @@ -21,8 +21,6 @@ use crate::{
2121use super :: setup:: build_deterministic_params;
2222
2323pub ( crate ) fn golden_recursive_circuit_verification_key_bytes ( ) -> Vec < u8 > {
24- let srs_for_recursive_circuit = build_deterministic_params ( RECURSIVE_CIRCUIT_DEGREE ) ;
25-
2624 let small_parameters = Parameters {
2725 m : 10 ,
2826 k : 1 ,
@@ -32,8 +30,8 @@ pub(crate) fn golden_recursive_circuit_verification_key_bytes() -> Vec<u8> {
3230 let circuit = StmCertificateCircuit :: try_new ( & small_parameters, merkle_tree_depth) . unwrap ( ) ;
3331 let circuit_degree = MidnightCircuit :: from_relation ( & circuit, None ) . k ( ) ;
3432
35- let mut srs_for_non_recursive_circuit = srs_for_recursive_circuit . clone ( ) ;
36- srs_for_non_recursive_circuit . downsize ( circuit_degree ) ;
33+ let srs_for_non_recursive_circuit = build_deterministic_params ( circuit_degree ) ;
34+ let srs_for_recursive_circuit = build_deterministic_params ( RECURSIVE_CIRCUIT_DEGREE ) ;
3735
3836 let circuit_verification_key = NonRecursiveCircuitVerifyingKey :: new (
3937 midnight_zk_stdlib:: setup_vk ( & srs_for_non_recursive_circuit, & circuit) ,
Original file line number Diff line number Diff line change @@ -361,16 +361,12 @@ mod tests {
361361 params : Parameters ,
362362 depth : u32 ,
363363 ) -> ( Arc < IvcSnarkProverSetup > , NonRecursiveCircuitVerifyingKey ) {
364- let srs: Arc < ParamsKZG < Bls12 > > = Arc :: new ( ParamsKZG :: < Bls12 > :: unsafe_setup (
365- 12 ,
366- ChaCha20Rng :: from_seed ( [ 42u8 ; 32 ] ) ,
367- ) ) ;
368364 let circuit = StmCertificateCircuit :: try_new ( & params, depth)
369365 . expect ( "certificate circuit should build" ) ;
370366 let circuit_degree = MidnightCircuit :: from_relation ( & circuit, None ) . k ( ) ;
371367
372- let mut cert_srs = ( * srs ) . clone ( ) ;
373- cert_srs . downsize ( circuit_degree) ;
368+ let cert_srs =
369+ ParamsKZG :: < Bls12 > :: unsafe_setup ( circuit_degree, ChaCha20Rng :: from_seed ( [ 42u8 ; 32 ] ) ) ;
374370
375371 let midnight_vk = zk:: setup_vk ( & cert_srs, & circuit) ;
376372 let midnight_pk = zk:: setup_pk ( & circuit, & midnight_vk) ;
You can’t perform that action at this time.
0 commit comments