pub fn init_verifier_params(public_input: & Vec<Uint256>, proof_params: & Vec<Uint256>, ctx: & mut Vec<Uint256>) {
    assert!(proof_params.len() > PROOF_PARAMS_FRI_STEPS_OFFSET); //Invalid proof_params
    assert!(proof_params.len() == PROOF_PARAMS_FRI_STEPS_OFFSET + uint256_ops::to_usize(&proof_params[PROOF_PARAMS_N_FRI_STEPS_OFFSET])); //Invalid proof_params

    let log_blowup_factor = proof_params[PROOF_PARAMS_LOG_BLOWUP_FACTOR_OFFSET].clone();
    assert!(log_blowup_factor <= uint256_ops::get_uint256("10")); //log_blowup_factor must be at most 16
    assert!(log_blowup_factor >= uint256_ops::get_uint256("1")); //log_blowup_factor must be at least 1

    let pow_bits = proof_params[PROOF_PARAMS_PROOF_OF_WORK_BITS_OFFSET].clone();
    assert!(pow_bits <= uint256_ops::get_uint256("32")); //pow_bits must be at most 50
    assert!( uint256_ops::to_usize(&pow_bits) >= MIN_PROOF_OF_WORK_BITS ); //MIN_PROOF_OF_WORK_BITS
    assert!( uint256_ops::to_usize(&pow_bits) < NUM_SECURITY_BITS ); //Proofs may not be purely based on PoW

     let log_fri_last_layer_deg_bound = proof_params[PROOF_PARAMS_FRI_LAST_LAYER_DEG_BOUND_OFFSET].clone();
     assert!(log_fri_last_layer_deg_bound <= uint256_ops::get_uint256("A")); //log_fri_last_layer_deg_bound must be at most 10

     let n_fri_steps = uint256_ops::to_usize(&proof_params[PROOF_PARAMS_N_FRI_STEPS_OFFSET]);
     assert!(n_fri_steps <= 10); //Too many fri steps
     assert!(n_fri_steps > 1); //Not enough fri steps

     let mut fri_steps: Vec<Uint256> = Vec::new(); //TODO: PROOF_PARAMS_FRI_STEPS_OFFSET is being weird, its one ahead
     for i in 0..n_fri_steps {
        fri_steps.push( proof_params[PROOF_PARAMS_FRI_STEPS_OFFSET + i].clone() );
     }

     let log_trace_length = air_specific_init(public_input, ctx);

     fri::validate_params(&mut fri_steps, log_trace_length.clone(), log_fri_last_layer_deg_bound.clone());

    /* Storing the fri steps at the end of verifier context/state */
    ctx[map::MM_FRI_STEPS_PTR] = uint256_ops::from_usize( ctx.len() );
    ctx.push( uint256_ops::from_usize(n_fri_steps) );
    for step_idx in 0..n_fri_steps {
        ctx.push( fri_steps[step_idx].clone() );
    }

    
     let n_queries = uint256_ops::to_usize(&proof_params[PROOF_PARAMS_N_QUERIES_OFFSET]);
     assert!(n_queries > 0); //Number of queries must be at least one
     assert!(n_queries <= map::MAX_N_QUERIES); //Too many queries
     assert!( uint256_ops::from_usize(n_queries) * log_blowup_factor.clone() + pow_bits.clone() >= uint256_ops::from_usize(NUM_SECURITY_BITS) ); //Proof params do not satisfy security requirements


     ctx[map::MM_FRI_LAST_LAYER_DEG_BOUND] = prime_field::fpow(&uint256_ops::get_uint256("2"), &log_fri_last_layer_deg_bound); //2^log_fri_last_layer_deg_bound Note: no overflow for PRIME, we can use prime_field
     ctx[map::MM_TRACE_LENGTH] = prime_field::fpow(&uint256_ops::get_uint256("2"), &log_trace_length); //2^log_trace_length
     ctx[map::MM_BLOW_UP_FACTOR] = prime_field::fpow(&uint256_ops::get_uint256("2"), &log_blowup_factor); //2^log_blowup_factor
     ctx[map::MM_PROOF_OF_WORK_BITS] = pow_bits.clone();
     ctx[map::MM_N_UNIQUE_QUERIES] = uint256_ops::from_usize(n_queries);
     // We start with log_evalDomainSize = logTraceSize and update it here.
     ctx[map::MM_LOG_EVAL_DOMAIN_SIZE] = log_trace_length.clone() + log_blowup_factor.clone();
     ctx[map::MM_EVAL_DOMAIN_SIZE] = prime_field::fpow(&uint256_ops::get_uint256("2"), &ctx[map::MM_LOG_EVAL_DOMAIN_SIZE]);//2^ctx[MM_LOG_EVAL_DOMAIN_SIZE]
     ctx[map::MM_EVAL_DOMAIN_GENERATOR] = prime_field::fpow( 
         &prime_field::get_generator_val(), 
         &( ( prime_field::get_k_modulus()-uint256_ops::get_uint256("1") ) / ctx[map::MM_EVAL_DOMAIN_SIZE].clone() ) 
    );
     ctx[map::MM_TRACE_GENERATOR] = prime_field::fpow( &ctx[map::MM_EVAL_DOMAIN_GENERATOR], &ctx[map::MM_BLOW_UP_FACTOR] );
}
/*
    Checks that the proof parameters are valid and initializes the verifier state
*/
Checks that the proof parameters are valid and initializes the verifier state
Checks that the proof parameters are valid and initializes the verifier state
pub fn init_verifier_params(public_input: & Vec<Uint256>, proof_params: & Vec<Uint256>, ctx: & mut Vec<Uint256>) {
    assert!(proof_params.len() > PROOF_PARAMS_FRI_STEPS_OFFSET); //Invalid proof_params
    assert!(proof_params.len() == PROOF_PARAMS_FRI_STEPS_OFFSET + uint256_ops::to_usize(&proof_params[PROOF_PARAMS_N_FRI_STEPS_OFFSET])); //Invalid proof_params
    let log_blowup_factor = proof_params[PROOF_PARAMS_LOG_BLOWUP_FACTOR_OFFSET].clone();
    assert!(log_blowup_factor <= uint256_ops::get_uint256("10")); //log_blowup_factor must be at most 16
    assert!(log_blowup_factor >= uint256_ops::get_uint256("1")); //log_blowup_factor must be at least 1
    let pow_bits = proof_params[PROOF_PARAMS_PROOF_OF_WORK_BITS_OFFSET].clone();
    assert!(pow_bits <= uint256_ops::get_uint256("32")); //pow_bits must be at most 50
    assert!( uint256_ops::to_usize(&pow_bits) >= MIN_PROOF_OF_WORK_BITS ); //MIN_PROOF_OF_WORK_BITS
    assert!( uint256_ops::to_usize(&pow_bits) < NUM_SECURITY_BITS ); //Proofs may not be purely based on PoW
     let log_fri_last_layer_deg_bound = proof_params[PROOF_PARAMS_FRI_LAST_LAYER_DEG_BOUND_OFFSET].clone();
     assert!(log_fri_last_layer_deg_bound <= uint256_ops::get_uint256("A")); //log_fri_last_layer_deg_bound must be at most 10
     let n_fri_steps = uint256_ops::to_usize(&proof_params[PROOF_PARAMS_N_FRI_STEPS_OFFSET]);
     assert!(n_fri_steps <= 10); //Too many fri steps
     assert!(n_fri_steps > 1); //Not enough fri steps
     let mut fri_steps: Vec<Uint256> = Vec::new(); //TODO: PROOF_PARAMS_FRI_STEPS_OFFSET is being weird, its one ahead
     for i in 0..n_fri_steps {
        fri_steps.push( proof_params[PROOF_PARAMS_FRI_STEPS_OFFSET + i].clone() );
     }
     let log_trace_length = air_specific_init(public_input, ctx);
     fri::validate_params(&mut fri_steps, log_trace_length.clone(), log_fri_last_layer_deg_bound.clone());
    /* Storing the fri steps at the end of verifier context/state */
    ctx[map::MM_FRI_STEPS_PTR] = uint256_ops::from_usize( ctx.len() );
    ctx.push( uint256_ops::from_usize(n_fri_steps) );
    for step_idx in 0..n_fri_steps {
        ctx.push( fri_steps[step_idx].clone() );
    }
     let n_queries = uint256_ops::to_usize(&proof_params[PROOF_PARAMS_N_QUERIES_OFFSET]);
     assert!(n_queries > 0); //Number of queries must be at least one
     assert!(n_queries <= map::MAX_N_QUERIES); //Too many queries
     assert!( uint256_ops::from_usize(n_queries) * log_blowup_factor.clone() + pow_bits.clone() >= uint256_ops::from_usize(NUM_SECURITY_BITS) ); //Proof params do not satisfy security requirements
     ctx[map::MM_FRI_LAST_LAYER_DEG_BOUND] = prime_field::fpow(&uint256_ops::get_uint256("2"), &log_fri_last_layer_deg_bound); //2^log_fri_last_layer_deg_bound Note: no overflow for PRIME, we can use prime_field
     ctx[map::MM_TRACE_LENGTH] = prime_field::fpow(&uint256_ops::get_uint256("2"), &log_trace_length); //2^log_trace_length
     ctx[map::MM_BLOW_UP_FACTOR] = prime_field::fpow(&uint256_ops::get_uint256("2"), &log_blowup_factor); //2^log_blowup_factor
     ctx[map::MM_PROOF_OF_WORK_BITS] = pow_bits.clone();
     ctx[map::MM_N_UNIQUE_QUERIES] = uint256_ops::from_usize(n_queries);
     // We start with log_evalDomainSize = logTraceSize and update it here.
     ctx[map::MM_LOG_EVAL_DOMAIN_SIZE] = log_trace_length.clone() + log_blowup_factor.clone();
     ctx[map::MM_EVAL_DOMAIN_SIZE] = prime_field::fpow(&uint256_ops::get_uint256("2"), &ctx[map::MM_LOG_EVAL_DOMAIN_SIZE]);//2^ctx[MM_LOG_EVAL_DOMAIN_SIZE]
     ctx[map::MM_EVAL_DOMAIN_GENERATOR] = prime_field::fpow( 
         &prime_field::get_generator_val(), 
         &( ( prime_field::get_k_modulus()-uint256_ops::get_uint256("1") ) / ctx[map::MM_EVAL_DOMAIN_SIZE].clone() ) 
    );
     ctx[map::MM_TRACE_GENERATOR] = prime_field::fpow( &ctx[map::MM_EVAL_DOMAIN_GENERATOR], &ctx[map::MM_BLOW_UP_FACTOR] );
}
pub fn init_verifier_params ( public_input : & Vec < Uint256 > , proof_params : & Vec < Uint256 > , ctx : & mut Vec < Uint256 > ) { assert ! ( proof_params len ( ) PROOF_PARAMS_FRI_STEPS_OFFSET ) ; //Invalid proof_params assert ! ( proof_params len ( ) PROOF_PARAMS_FRI_STEPS_OFFSET uint256_ops to_usize ( proof_params [ PROOF_PARAMS_N_FRI_STEPS_OFFSET ] ) ) ; //Invalid proof_params let log_blowup_factor = proof_params [ PROOF_PARAMS_LOG_BLOWUP_FACTOR_OFFSET ] . clone ( ) ; assert ! ( log_blowup_factor uint256_ops get_uint256 ( " " ) ) ; //log_blowup_factor must be at most 16 assert ! ( log_blowup_factor uint256_ops get_uint256 ( " " ) ) ; //log_blowup_factor must be at least 1 let pow_bits = proof_params [ PROOF_PARAMS_PROOF_OF_WORK_BITS_OFFSET ] . clone ( ) ; assert ! ( pow_bits uint256_ops get_uint256 ( " " ) ) ; //pow_bits must be at most 50 assert ! ( uint256_ops to_usize ( pow_bits ) MIN_PROOF_OF_WORK_BITS ) ; //MIN_PROOF_OF_WORK_BITS assert ! ( uint256_ops to_usize ( pow_bits ) NUM_SECURITY_BITS ) ; //Proofs may not be purely based on PoW let log_fri_last_layer_deg_bound = proof_params [ PROOF_PARAMS_FRI_LAST_LAYER_DEG_BOUND_OFFSET ] . clone ( ) ; assert ! ( log_fri_last_layer_deg_bound uint256_ops get_uint256 ( " " ) ) ; //log_fri_last_layer_deg_bound must be at most 10 let n_fri_steps = uint256_ops :: to_usize ( & proof_params [ PROOF_PARAMS_N_FRI_STEPS_OFFSET ] ) ; assert ! ( n_fri_steps 10 ) ; //Too many fri steps assert ! ( n_fri_steps 1 ) ; //Not enough fri steps let mut fri_steps : Vec < Uint256 > = Vec :: new ( ) ; //TODO: PROOF_PARAMS_FRI_STEPS_OFFSET is being weird, its one ahead for i in 0 .. n_fri_steps { fri_steps . push ( proof_params [ PROOF_PARAMS_FRI_STEPS_OFFSET + i ] . clone ( ) ) ; } let log_trace_length = air_specific_init ( public_input , ctx ) ; fri :: validate_params ( & mut fri_steps , log_trace_length . clone ( ) , log_fri_last_layer_deg_bound . clone ( ) ) ; /* Storing the fri steps at the end of verifier context/state */ ctx [ map :: MM_FRI_STEPS_PTR ] = uint256_ops :: from_usize ( ctx . len ( ) ) ; ctx . push ( uint256_ops :: from_usize ( n_fri_steps ) ) ; for step_idx in 0 .. n_fri_steps { ctx . push ( fri_steps [ step_idx ] . clone ( ) ) ; } let n_queries = uint256_ops :: to_usize ( & proof_params [ PROOF_PARAMS_N_QUERIES_OFFSET ] ) ; assert ! ( n_queries 0 ) ; //Number of queries must be at least one assert ! ( n_queries map MAX_N_QUERIES ) ; //Too many queries assert ! ( uint256_ops from_usize ( n_queries ) log_blowup_factor clone ( ) pow_bits clone ( ) uint256_ops from_usize ( NUM_SECURITY_BITS ) ) ; //Proof params do not satisfy security requirements ctx [ map :: MM_FRI_LAST_LAYER_DEG_BOUND ] = prime_field :: fpow ( & uint256_ops :: get_uint256 ( " " ) , & log_fri_last_layer_deg_bound ) ; //2^log_fri_last_layer_deg_bound Note: no overflow for PRIME, we can use prime_field ctx [ map :: MM_TRACE_LENGTH ] = prime_field :: fpow ( & uint256_ops :: get_uint256 ( " " ) , & log_trace_length ) ; //2^log_trace_length ctx [ map :: MM_BLOW_UP_FACTOR ] = prime_field :: fpow ( & uint256_ops :: get_uint256 ( " " ) , & log_blowup_factor ) ; //2^log_blowup_factor ctx [ map :: MM_PROOF_OF_WORK_BITS ] = pow_bits . clone ( ) ; ctx [ map :: MM_N_UNIQUE_QUERIES ] = uint256_ops :: from_usize ( n_queries ) ; // We start with log_evalDomainSize = logTraceSize and update it here. ctx [ map :: MM_LOG_EVAL_DOMAIN_SIZE ] = log_trace_length . clone ( ) + log_blowup_factor . clone ( ) ; ctx [ map :: MM_EVAL_DOMAIN_SIZE ] = prime_field :: fpow ( & uint256_ops :: get_uint256 ( " " ) , & ctx [ map :: MM_LOG_EVAL_DOMAIN_SIZE ] ) ; //2^ctx[MM_LOG_EVAL_DOMAIN_SIZE] ctx [ map :: MM_EVAL_DOMAIN_GENERATOR ] = prime_field :: fpow ( & prime_field :: get_generator_val ( ) , & ( ( prime_field :: get_k_modulus ( ) - uint256_ops :: get_uint256 ( " " ) ) / ctx [ map :: MM_EVAL_DOMAIN_SIZE ] . clone ( ) ) ) ; ctx [ map :: MM_TRACE_GENERATOR ] = prime_field :: fpow ( & ctx [ map :: MM_EVAL_DOMAIN_GENERATOR ] , & ctx [ map :: MM_BLOW_UP_FACTOR ] ) ; }
Checks that the proof parameters are valid and initializes the verifier state
Checks that the proof parameters are valid and initializes the verifier state
public_input
& Vec<Uint256>
proof_params
& Vec<Uint256>
ctx
& mut Vec<Uint256>
public_input
& Vec<Uint256>
proof_params
& Vec<Uint256>
ctx
& mut Vec<Uint256>