11use crate :: machine_type:: MachineType ;
22use prover:: definitions:: OPTIMAL_FOLDING_PROPERTIES ;
3+ use prover:: prover_stages:: ProofSecurityConfig ;
34use setups:: {
45 add_sub_lui_auipc_mop, bigint_with_control, blake2_with_compression, inits_and_teardowns,
56 jump_branch_slt, keccak_special5, load_store_subword_only, load_store_word_only, mul_div,
@@ -75,6 +76,13 @@ impl CircuitType {
7576 // Self::Unrolled(unrolled_type) => unrolled_type.get_tree_cap_size(),
7677 // }
7778 }
79+
80+ pub fn get_security_config ( & self ) -> ProofSecurityConfig {
81+ match self {
82+ Self :: Delegation ( delegation_type) => delegation_type. get_security_config ( ) ,
83+ Self :: Unrolled ( unrolled_type) => unrolled_type. get_security_config ( ) ,
84+ }
85+ }
7886}
7987
8088#[ repr( u32 ) ]
@@ -155,6 +163,18 @@ impl DelegationCircuitType {
155163 MachineType :: Reduced => & [ DelegationCircuitType :: Blake2WithCompression ] ,
156164 }
157165 }
166+
167+ pub fn get_security_config ( & self ) -> ProofSecurityConfig {
168+ match self {
169+ Self :: BigIntWithControl => {
170+ get_security_config :: < { bigint_with_control:: DOMAIN_SIZE } > ( )
171+ }
172+ Self :: Blake2WithCompression => {
173+ get_security_config :: < { blake2_with_compression:: DOMAIN_SIZE } > ( )
174+ }
175+ Self :: KeccakSpecial5 => get_security_config :: < { keccak_special5:: DOMAIN_SIZE } > ( ) ,
176+ }
177+ }
158178}
159179
160180impl From < u16 > for DelegationCircuitType {
@@ -272,6 +292,17 @@ impl UnrolledCircuitType {
272292 . iter ( )
273293 . map ( |id| DelegationCircuitType :: from ( * id as u16 ) )
274294 }
295+
296+ pub fn get_security_config ( & self ) -> ProofSecurityConfig {
297+ match self {
298+ Self :: InitsAndTeardowns => {
299+ get_security_config :: < { inits_and_teardowns:: DOMAIN_SIZE } > ( )
300+ }
301+ Self :: Memory ( circuit_type) => circuit_type. get_security_config ( ) ,
302+ Self :: NonMemory ( circuit_type) => circuit_type. get_security_config ( ) ,
303+ Self :: Unified => get_security_config :: < { unified_reduced_machine:: DOMAIN_SIZE } > ( ) ,
304+ }
305+ }
275306}
276307
277308#[ repr( u32 ) ]
@@ -361,6 +392,17 @@ impl UnrolledMemoryCircuitType {
361392 } ,
362393 }
363394 }
395+
396+ pub fn get_security_config ( & self ) -> ProofSecurityConfig {
397+ match self {
398+ Self :: LoadStoreSubwordOnly => {
399+ get_security_config :: < { load_store_subword_only:: DOMAIN_SIZE } > ( )
400+ }
401+ Self :: LoadStoreWordOnly => {
402+ get_security_config :: < { load_store_word_only:: DOMAIN_SIZE } > ( )
403+ }
404+ }
405+ }
364406}
365407
366408#[ repr( u32 ) ]
@@ -516,6 +558,18 @@ impl UnrolledNonMemoryCircuitType {
516558 Self :: ShiftBinaryCsr => 4 ,
517559 }
518560 }
561+
562+ pub fn get_security_config ( & self ) -> ProofSecurityConfig {
563+ match self {
564+ Self :: AddSubLuiAuipcMop => {
565+ get_security_config :: < { add_sub_lui_auipc_mop:: DOMAIN_SIZE } > ( )
566+ }
567+ Self :: JumpBranchSlt => get_security_config :: < { jump_branch_slt:: DOMAIN_SIZE } > ( ) ,
568+ Self :: MulDiv => get_security_config :: < { mul_div:: DOMAIN_SIZE } > ( ) ,
569+ Self :: MulDivUnsigned => get_security_config :: < { mul_div_unsigned:: DOMAIN_SIZE } > ( ) ,
570+ Self :: ShiftBinaryCsr => get_security_config :: < { shift_binary_csr:: DOMAIN_SIZE } > ( ) ,
571+ }
572+ }
519573}
520574
521575#[ inline( always) ]
@@ -534,3 +588,21 @@ pub const fn get_tree_cap_size_for_log_domain_size(log_domain_size: u32) -> usiz
534588pub const fn get_log_tree_cap_size_for_log_domain_size ( log_domain_size : u32 ) -> usize {
535589 OPTIMAL_FOLDING_PROPERTIES [ log_domain_size as usize ] . total_caps_size_log2
536590}
591+
592+ const fn get_num_foldings < const DOMAIN_SIZE : usize > ( ) -> usize {
593+ assert ! ( DOMAIN_SIZE . is_power_of_two( ) ) ;
594+ OPTIMAL_FOLDING_PROPERTIES [ DOMAIN_SIZE . trailing_zeros ( ) as usize ]
595+ . folding_sequence
596+ . len ( )
597+ }
598+
599+ fn get_security_config < const DOMAIN_SIZE : usize > ( ) -> ProofSecurityConfig
600+ where
601+ [ ( ) ; get_num_foldings :: < DOMAIN_SIZE > ( ) ] : ,
602+ {
603+ assert ! ( DOMAIN_SIZE . is_power_of_two( ) ) ;
604+ let config = verifier_common:: SizedProofSecurityConfig :: < {
605+ get_num_foldings :: < DOMAIN_SIZE > ( )
606+ } > :: worst_case_config ( ) ;
607+ config. for_prover ( )
608+ }
0 commit comments