1+ use circuit_definitions:: circuit_definitions:: aux_layer:: compression_modes:: {
2+ CompressionMode1 , CompressionMode1ForWrapper , CompressionMode2 , CompressionMode3 ,
3+ CompressionMode4 , CompressionMode5ForWrapper ,
4+ } ;
5+
16use super :: * ;
27
38pub enum SnarkWrapper {
@@ -9,6 +14,12 @@ pub enum SnarkWrapperProof {
914 FFfonk ( FflonkSnarkVerifierCircuitProof ) ,
1015}
1116
17+ pub type SchedulerProof = franklin_crypto:: boojum:: cs:: implementations:: proof:: Proof <
18+ GoldilocksField ,
19+ circuit_definitions:: circuit_definitions:: recursion_layer:: RecursiveProofsTreeHasher ,
20+ GoldilocksExt2 ,
21+ > ;
22+
1223pub fn run_proof_chain < BS > (
1324 input_proof : SchedulerProof ,
1425 snark_wrapper : SnarkWrapper ,
2940 }
3041}
3142
32- pub ( crate ) fn run_proof_chain_with_fflonk < BS > (
43+ pub fn run_proof_chain_with_fflonk < BS > (
3344 input_proof : SchedulerProof ,
3445 blob_storage : & BS ,
3546) -> FflonkSnarkVerifierCircuitProof
3849{
3950 let context_manager = SimpleContextManager :: new ( ) ;
4051 let start = std:: time:: Instant :: now ( ) ;
41- let snark_context_config =
42- context_manager. initialize_snark_context_config :: < FflonkSnarkWrapper > ( ) ;
52+ let compact_raw_crs =
53+ <FflonkSnarkWrapper as SnarkWrapperStep >:: load_compact_raw_crs ( blob_storage) ;
54+ let fflonk_precomputation = FflonkSnarkWrapper :: get_precomputation ( blob_storage) ;
55+
4356 let next_proof =
4457 CompressionMode1 :: prove_compression_step ( input_proof, blob_storage, & context_manager) ;
4558 let next_proof = CompressionMode2 :: prove_compression_step :: < _ , SimpleContextManager > (
6780 start. elapsed( ) . as_secs( )
6881 ) ;
6982 let final_proof = FflonkSnarkWrapper :: prove_snark_wrapper_step :: < _ , SimpleContextManager > (
70- snark_context_config,
83+ compact_raw_crs,
84+ fflonk_precomputation,
7185 next_proof,
7286 blob_storage,
7387 & context_manager,
@@ -79,13 +93,14 @@ where
7993 final_proof
8094}
8195
82- pub ( crate ) fn precompute_proof_chain_with_fflonk < BS > ( blob_storage : & BS )
96+ pub fn precompute_proof_chain_with_fflonk < BS > ( blob_storage : & BS )
8397where
8498 BS : BlobStorageExt ,
8599{
86100 let context_manager = SimpleContextManager :: new ( ) ;
87- let snark_context_config =
88- context_manager. initialize_snark_context_config :: < FflonkSnarkWrapper > ( ) ;
101+ let compact_raw_crs =
102+ <FflonkSnarkWrapper as SnarkWrapperStep >:: load_compact_raw_crs ( blob_storage) ;
103+
89104 let start = std:: time:: Instant :: now ( ) ;
90105 CompressionMode1 :: precomputae_and_store_compression_circuits ( blob_storage, & context_manager) ;
91106 CompressionMode2 :: precomputae_and_store_compression_circuits ( blob_storage, & context_manager) ;
@@ -100,61 +115,68 @@ where
100115 start. elapsed( ) . as_secs( )
101116 ) ;
102117 FflonkSnarkWrapper :: precompute_and_store_snark_wrapper_circuit (
103- snark_context_config ,
118+ compact_raw_crs ,
104119 blob_storage,
105120 & context_manager,
106121 ) ;
107122 println ! (
108- "Precomputation of entire chain took {}s" ,
123+ "Precomputation of entire chain with fflonk took {}s" ,
109124 start. elapsed( ) . as_secs( )
110125 ) ;
111126}
112127
113- pub ( crate ) fn run_proof_chain_with_plonk < BS > (
128+ pub fn run_proof_chain_with_plonk < BS > (
114129 input_proof : SchedulerProof ,
115130 blob_storage : & BS ,
116131) -> PlonkSnarkVerifierCircuitProof
117132where
118133 BS : BlobStorage ,
119134{
120135 let context_manager = SimpleContextManager :: new ( ) ;
121- let snark_context_config =
122- context_manager. initialize_snark_context_config :: < PlonkSnarkWrapper > ( ) ;
123136 let start = std:: time:: Instant :: now ( ) ;
137+ let compact_raw_crs =
138+ <PlonkSnarkWrapper as SnarkWrapperStep >:: load_compact_raw_crs ( blob_storage) ;
139+ let plonk_precomputation = PlonkSnarkWrapper :: get_precomputation ( blob_storage) ;
140+
124141 let next_proof = CompressionMode1ForWrapper :: prove_compression_step (
125142 input_proof,
126143 blob_storage,
127144 & context_manager,
128145 ) ;
129146
130147 let final_proof = PlonkSnarkWrapper :: prove_snark_wrapper_step (
131- snark_context_config,
148+ compact_raw_crs,
149+ plonk_precomputation,
132150 next_proof,
133151 blob_storage,
134152 & context_manager,
135153 ) ;
136154 println ! (
137- "Entire compression chain took {}s" ,
155+ "Entire compression chain with plonk took {}s" ,
138156 start. elapsed( ) . as_secs( )
139157 ) ;
140158 final_proof
141159}
142160
143- pub ( crate ) fn precompute_proof_chain_with_plonk < BS > ( blob_storage : & BS )
161+ pub fn precompute_proof_chain_with_plonk < BS > ( blob_storage : & BS )
144162where
145163 BS : BlobStorageExt ,
146164{
147165 let context_manager = SimpleContextManager :: new ( ) ;
148- let snark_context_config =
149- context_manager. initialize_snark_context_config :: < PlonkSnarkWrapper > ( ) ;
166+ let start = std:: time:: Instant :: now ( ) ;
167+ let compact_raw_crs =
168+ <PlonkSnarkWrapper as SnarkWrapperStep >:: load_compact_raw_crs ( blob_storage) ;
150169 CompressionMode1ForWrapper :: precomputae_and_store_compression_circuits (
151170 blob_storage,
152171 & context_manager,
153172 ) ;
154173 PlonkSnarkWrapper :: precompute_and_store_snark_wrapper_circuit (
155- snark_context_config ,
174+ compact_raw_crs ,
156175 blob_storage,
157176 & context_manager,
158177 ) ;
159- println ! ( "All steps in this approach precomputed and saved into blob storage" ) ;
178+ println ! (
179+ "Precomputation of entire chain with fflonk took {}s" ,
180+ start. elapsed( ) . as_secs( )
181+ ) ;
160182}
0 commit comments