pub fn verify_proof(
    proof_params: Vec<Uint256>,
    proof: Vec<Uint256>,
    task_meta_data: Vec<Uint256>,
    cairo_aux_input: Vec<Uint256>,
    cairo_verifier_id: Uint256,
) {

    /* ------------ GPS Statement Verifier ----------- */

    /* Auxiliary inputs check */
    assert!(cairo_aux_input.len() > pub_input::OFFSET_N_PUBLIC_MEMORY_PAGES); //Invalid cairoAuxInput length
    let n_pages = uint256_ops::to_usize( &cairo_aux_input[pub_input::OFFSET_N_PUBLIC_MEMORY_PAGES] );
    assert!(cairo_aux_input.len() == pub_input::get_public_input_length( n_pages ) + 2); //Invalid cairoAuxInput length

    /* Transform cairo_aux_input -> cairoPublic input (- z, alpha) */
    // The values z and alpha are used only for the fact registration of the main page.
    // They are not needed in the auxiliary input of CpuVerifier as they are computed there.
    // Create a copy of cairo_aux_input without z and alpha.
    let mut cairo_pub_input: Vec<Uint256> = vec![ uint256_ops::get_uint256("0"); cairo_aux_input.len()-2 ];
    for i in 0..cairo_aux_input.len()-2 {
        cairo_pub_input[i] = cairo_aux_input[i].clone();
    }

    // Process public memory and store facts of registered pages in hashmap
    let mut memory_page_fact_reg: HashMap<Uint256, bool> = HashMap::new();
    let (pub_mem_len, mem_hash, prod) = memory_fact_registry::register_public_memory_main_page(
        &task_meta_data, &cairo_aux_input, &mut memory_page_fact_reg
    );

    // Make sure the first page is valid.
    // If the size or the hash are invalid, it may indicate that there is a mismatch between the
    // bootloader program contract and the program in the proof
    assert!( uint256_ops::to_usize(&cairo_aux_input[pub_input::get_offset_page_size(0)]) == pub_mem_len ); //Invalid size for memory page 0
    assert!( cairo_aux_input[pub_input::get_offset_page_hash(0)] == mem_hash ); //Invalid hash for memory page 0
    assert!( cairo_aux_input[pub_input::get_offset_page_prod(0, n_pages)] == prod ); //Invalid cumulative product for memory page 0


    /* --------- StarkVerifier.verifyProof --------- */

    let mut verifier_state: Vec<Uint256> = vec![uint256_ops::get_uint256("0"); map::MM_CONTEXT_SIZE];//Blank init size MM_CONTEXT_SIZE
    init_verifier_params(&cairo_pub_input, &proof_params, & mut verifier_state);

    let channel_idx = map::MM_CHANNEL;

    //Append the proof to the end of the verifier state and store a pointer there
    let proof_idx = verifier_state.len(); //TODO: Include len?
    for i in 0..proof.len() {
        verifier_state.push( proof[i].clone() );
    }

    //Init the channel
    verifier_channel::init_channel( channel_idx, proof_idx, pub_input::get_public_input_hash(&cairo_pub_input), &mut verifier_state );

    //Read trace commitment
    verifier_state[map::MM_TRACE_COMMITMENT] = verifier_channel::read_hash(channel_idx, true, &mut verifier_state);

    println!("verifier_state[map::MM_TRACE_COMMITMENT]: {}", verifier_state[map::MM_TRACE_COMMITMENT]);


     if stark_params::N_COLUMNS_IN_TRACE1 > 0 { //true - has (simulated) interaction w/ prover
        // Send interaction elements
        verifier_channel::send_field_elements(channel_idx, stark_params::N_INTERACTION_ELEMENTS, map::MM_INTERACTION_ELEMENTS, & mut verifier_state);

        // Read second trace commitment
        verifier_state[map::MM_TRACE_COMMITMENT + 1] = verifier_channel::read_hash(channel_idx, true, &mut verifier_state);
        println!("verifier_state[map::MM_TRACE_COMMITMENT + 1]: {}", verifier_state[map::MM_TRACE_COMMITMENT + 1]);
     }


    verifier_channel::send_field_elements(channel_idx, stark_params::N_COEFFICIENTS, map::MM_COEFFICIENTS, & mut verifier_state);

    verifier_state[map::MM_OODS_COMMITMENT] = verifier_channel::read_hash(channel_idx, true, &mut verifier_state);
    

    //Send out domain sampling point
    verifier_channel::send_field_elements(channel_idx, 1, map::MM_OODS_POINT, & mut verifier_state);


    //Read the answers to the Out of Domain Sampling
    let lmm_oods_vals: usize = map::MM_OODS_VALUES;
    for i in lmm_oods_vals..(lmm_oods_vals + stark_params::N_OODS_VALUES) {
        verifier_state[i] = verifier_channel::read_field_elements(channel_idx, true, &mut verifier_state);
    }

    // println!("ctx prior to stuff that remix can't handle: ");
    // for i in 0..verifier_state.len() {
    //     println!("ctx[{}] = {}", i, verifier_state[i]);
    // }

    oods_consistency_check(&mut verifier_state, &memory_page_fact_reg);


    verifier_channel::send_field_elements(channel_idx, stark_params::N_OODS_COEFFICIENTS, map::MM_OODS_COEFFICIENTS, & mut verifier_state);
    verifier_state[map::MM_FRI_COMMITMENTS] = verifier_channel::read_hash(channel_idx, true, &mut verifier_state);


    let n_fri_steps = fri::get_fri_steps(&mut verifier_state).len();
    for i in 1..(n_fri_steps-1) { //TODO: probably wrong bounds
        verifier_channel::send_field_elements(channel_idx, 1, map::MM_FRI_EVAL_POINTS + i, & mut verifier_state);
        verifier_state[ map::MM_FRI_COMMITMENTS + i ] = verifier_channel::read_hash(channel_idx, true, &mut verifier_state);
    }


    // Send last random FRI evaluation point.
    verifier_channel::send_field_elements(channel_idx, 1, map::MM_FRI_EVAL_POINTS + n_fri_steps - 1, & mut verifier_state);


    // Read FRI last layer commitment.
    read_last_fri_layer(&mut verifier_state);


     // Generate queries.
    verifier_channel::verify_pow( channel_idx, uint256_ops::to_usize(&verifier_state[map::MM_PROOF_OF_WORK_BITS]), &mut verifier_state, map::QUARTER_READ_NUM );
    
    verifier_state[map::MM_N_UNIQUE_QUERIES] = verifier_channel::send_random_queries(
        channel_idx, uint256_ops::to_usize(&verifier_state[map::MM_N_UNIQUE_QUERIES]), verifier_state[map::MM_EVAL_DOMAIN_SIZE].clone()-uint256_ops::get_uint256("1"), map::MM_FRI_QUEUE, 3, &mut verifier_state
    );


    compute_first_fri_layer(&mut verifier_state);


    fri::fri_verify_layers(&mut verifier_state);


    /* --------- End of StarkVerifier.verifyProof --------- */

    //TODO: registerGpsFact? and somwhow ensure the program_hash was encoded in the proof data
    //Maybe get the program hashes from register_public_memory_main_page and iterate through tasks

}
/*
    Interace for Verifying Proof:
        - Checks arithmetization
        - Checks low-degreeness using FRI protocol
*/
Interace for Verifying Proof:
Checks arithmetization
Checks low-degreeness using FRI protocol
Interace for Verifying Proof : Checks arithmetization Checks low - degreeness using FRI protocol
pub fn verify_proof(
    proof_params: Vec<Uint256>,
    proof: Vec<Uint256>,
    task_meta_data: Vec<Uint256>,
    cairo_aux_input: Vec<Uint256>,
    cairo_verifier_id: Uint256,
) {
    /* ------------ GPS Statement Verifier ----------- */
    /* Auxiliary inputs check */
    assert!(cairo_aux_input.len() > pub_input::OFFSET_N_PUBLIC_MEMORY_PAGES); //Invalid cairoAuxInput length
    let n_pages = uint256_ops::to_usize( &cairo_aux_input[pub_input::OFFSET_N_PUBLIC_MEMORY_PAGES] );
    assert!(cairo_aux_input.len() == pub_input::get_public_input_length( n_pages ) + 2); //Invalid cairoAuxInput length
    /* Transform cairo_aux_input -> cairoPublic input (- z, alpha) */
    // The values z and alpha are used only for the fact registration of the main page.
    // They are not needed in the auxiliary input of CpuVerifier as they are computed there.
    // Create a copy of cairo_aux_input without z and alpha.
    let mut cairo_pub_input: Vec<Uint256> = vec![ uint256_ops::get_uint256("0"); cairo_aux_input.len()-2 ];
    for i in 0..cairo_aux_input.len()-2 {
        cairo_pub_input[i] = cairo_aux_input[i].clone();
    }
    // Process public memory and store facts of registered pages in hashmap
    let mut memory_page_fact_reg: HashMap<Uint256, bool> = HashMap::new();
    let (pub_mem_len, mem_hash, prod) = memory_fact_registry::register_public_memory_main_page(
        &task_meta_data, &cairo_aux_input, &mut memory_page_fact_reg
    );
    // Make sure the first page is valid.
    // If the size or the hash are invalid, it may indicate that there is a mismatch between the
    // bootloader program contract and the program in the proof
    assert!( uint256_ops::to_usize(&cairo_aux_input[pub_input::get_offset_page_size(0)]) == pub_mem_len ); //Invalid size for memory page 0
    assert!( cairo_aux_input[pub_input::get_offset_page_hash(0)] == mem_hash ); //Invalid hash for memory page 0
    assert!( cairo_aux_input[pub_input::get_offset_page_prod(0, n_pages)] == prod ); //Invalid cumulative product for memory page 0
    /* --------- StarkVerifier.verifyProof --------- */
    let mut verifier_state: Vec<Uint256> = vec![uint256_ops::get_uint256("0"); map::MM_CONTEXT_SIZE];//Blank init size MM_CONTEXT_SIZE
    init_verifier_params(&cairo_pub_input, &proof_params, & mut verifier_state);
    let channel_idx = map::MM_CHANNEL;
    //Append the proof to the end of the verifier state and store a pointer there
    let proof_idx = verifier_state.len(); //TODO: Include len?
    for i in 0..proof.len() {
        verifier_state.push( proof[i].clone() );
    }
    //Init the channel
    verifier_channel::init_channel( channel_idx, proof_idx, pub_input::get_public_input_hash(&cairo_pub_input), &mut verifier_state );
    //Read trace commitment
    verifier_state[map::MM_TRACE_COMMITMENT] = verifier_channel::read_hash(channel_idx, true, &mut verifier_state);
    println!("verifier_state[map::MM_TRACE_COMMITMENT]: {}", verifier_state[map::MM_TRACE_COMMITMENT]);
     if stark_params::N_COLUMNS_IN_TRACE1 > 0 { //true - has (simulated) interaction w/ prover
        // Send interaction elements
        verifier_channel::send_field_elements(channel_idx, stark_params::N_INTERACTION_ELEMENTS, map::MM_INTERACTION_ELEMENTS, & mut verifier_state);
        // Read second trace commitment
        verifier_state[map::MM_TRACE_COMMITMENT + 1] = verifier_channel::read_hash(channel_idx, true, &mut verifier_state);
        println!("verifier_state[map::MM_TRACE_COMMITMENT + 1]: {}", verifier_state[map::MM_TRACE_COMMITMENT + 1]);
     }
    verifier_channel::send_field_elements(channel_idx, stark_params::N_COEFFICIENTS, map::MM_COEFFICIENTS, & mut verifier_state);
    verifier_state[map::MM_OODS_COMMITMENT] = verifier_channel::read_hash(channel_idx, true, &mut verifier_state);
    //Send out domain sampling point
    verifier_channel::send_field_elements(channel_idx, 1, map::MM_OODS_POINT, & mut verifier_state);
    //Read the answers to the Out of Domain Sampling
    let lmm_oods_vals: usize = map::MM_OODS_VALUES;
    for i in lmm_oods_vals..(lmm_oods_vals + stark_params::N_OODS_VALUES) {
        verifier_state[i] = verifier_channel::read_field_elements(channel_idx, true, &mut verifier_state);
    }
    // println!("ctx prior to stuff that remix can't handle: ");
    // for i in 0..verifier_state.len() {
    //     println!("ctx[{}] = {}", i, verifier_state[i]);
    // }
    oods_consistency_check(&mut verifier_state, &memory_page_fact_reg);
    verifier_channel::send_field_elements(channel_idx, stark_params::N_OODS_COEFFICIENTS, map::MM_OODS_COEFFICIENTS, & mut verifier_state);
    verifier_state[map::MM_FRI_COMMITMENTS] = verifier_channel::read_hash(channel_idx, true, &mut verifier_state);
    let n_fri_steps = fri::get_fri_steps(&mut verifier_state).len();
    for i in 1..(n_fri_steps-1) { //TODO: probably wrong bounds
        verifier_channel::send_field_elements(channel_idx, 1, map::MM_FRI_EVAL_POINTS + i, & mut verifier_state);
        verifier_state[ map::MM_FRI_COMMITMENTS + i ] = verifier_channel::read_hash(channel_idx, true, &mut verifier_state);
    }
    // Send last random FRI evaluation point.
    verifier_channel::send_field_elements(channel_idx, 1, map::MM_FRI_EVAL_POINTS + n_fri_steps - 1, & mut verifier_state);
    // Read FRI last layer commitment.
    read_last_fri_layer(&mut verifier_state);
     // Generate queries.
    verifier_channel::verify_pow( channel_idx, uint256_ops::to_usize(&verifier_state[map::MM_PROOF_OF_WORK_BITS]), &mut verifier_state, map::QUARTER_READ_NUM );
    verifier_state[map::MM_N_UNIQUE_QUERIES] = verifier_channel::send_random_queries(
        channel_idx, uint256_ops::to_usize(&verifier_state[map::MM_N_UNIQUE_QUERIES]), verifier_state[map::MM_EVAL_DOMAIN_SIZE].clone()-uint256_ops::get_uint256("1"), map::MM_FRI_QUEUE, 3, &mut verifier_state
    );
    compute_first_fri_layer(&mut verifier_state);
    fri::fri_verify_layers(&mut verifier_state);
    /* --------- End of StarkVerifier.verifyProof --------- */
    //TODO: registerGpsFact? and somwhow ensure the program_hash was encoded in the proof data
    //Maybe get the program hashes from register_public_memory_main_page and iterate through tasks
}
pub fn verify_proof ( proof_params : Vec < Uint256 > , proof : Vec < Uint256 > , task_meta_data : Vec < Uint256 > , cairo_aux_input : Vec < Uint256 > , cairo_verifier_id : Uint256 , ) { /* ------------ GPS Statement Verifier ----------- */ /* Auxiliary inputs check */ assert ! ( cairo_aux_input len ( ) pub_input OFFSET_N_PUBLIC_MEMORY_PAGES ) ; //Invalid cairoAuxInput length let n_pages = uint256_ops :: to_usize ( & cairo_aux_input [ pub_input :: OFFSET_N_PUBLIC_MEMORY_PAGES ] ) ; assert ! ( cairo_aux_input len ( ) pub_input get_public_input_length ( n_pages ) 2 ) ; //Invalid cairoAuxInput length /* Transform cairo_aux_input -> cairoPublic input (- z, alpha) */ // The values z and alpha are used only for the fact registration of the main page. // They are not needed in the auxiliary input of CpuVerifier as they are computed there. // Create a copy of cairo_aux_input without z and alpha. let mut cairo_pub_input : Vec < Uint256 > = vec ! [ uint256_ops get_uint256 ( " " ) cairo_aux_input len ( ) 2 ] ; for i in 0 .. cairo_aux_input . len ( ) - 2 { cairo_pub_input [ i ] = cairo_aux_input [ i ] . clone ( ) ; } // Process public memory and store facts of registered pages in hashmap let mut memory_page_fact_reg : HashMap < Uint256 , bool > = HashMap :: new ( ) ; let ( pub_mem_len , mem_hash , prod ) = memory_fact_registry :: register_public_memory_main_page ( & task_meta_data , & cairo_aux_input , & mut memory_page_fact_reg ) ; // Make sure the first page is valid. // If the size or the hash are invalid, it may indicate that there is a mismatch between the // bootloader program contract and the program in the proof assert ! ( uint256_ops to_usize ( cairo_aux_input [ pub_input get_offset_page_size ( 0 ) ] ) pub_mem_len ) ; //Invalid size for memory page 0 assert ! ( cairo_aux_input [ pub_input get_offset_page_hash ( 0 ) ] mem_hash ) ; //Invalid hash for memory page 0 assert ! ( cairo_aux_input [ pub_input get_offset_page_prod ( 0 n_pages ) ] prod ) ; //Invalid cumulative product for memory page 0 /* --------- StarkVerifier.verifyProof --------- */ let mut verifier_state : Vec < Uint256 > = vec ! [ uint256_ops get_uint256 ( " " ) map MM_CONTEXT_SIZE ] ; //Blank init size MM_CONTEXT_SIZE init_verifier_params ( & cairo_pub_input , & proof_params , & mut verifier_state ) ; let channel_idx = map :: MM_CHANNEL ; //Append the proof to the end of the verifier state and store a pointer there let proof_idx = verifier_state . len ( ) ; //TODO: Include len? for i in 0 .. proof . len ( ) { verifier_state . push ( proof [ i ] . clone ( ) ) ; } //Init the channel verifier_channel :: init_channel ( channel_idx , proof_idx , pub_input :: get_public_input_hash ( & cairo_pub_input ) , & mut verifier_state ) ; //Read trace commitment verifier_state [ map :: MM_TRACE_COMMITMENT ] = verifier_channel :: read_hash ( channel_idx , true , & mut verifier_state ) ; println ! ( " " verifier_state [ map MM_TRACE_COMMITMENT ] ) ; if stark_params :: N_COLUMNS_IN_TRACE1 > 0 { //true - has (simulated) interaction w/ prover // Send interaction elements verifier_channel :: send_field_elements ( channel_idx , stark_params :: N_INTERACTION_ELEMENTS , map :: MM_INTERACTION_ELEMENTS , & mut verifier_state ) ; // Read second trace commitment verifier_state [ map :: MM_TRACE_COMMITMENT + 1 ] = verifier_channel :: read_hash ( channel_idx , true , & mut verifier_state ) ; println ! ( " " verifier_state [ map MM_TRACE_COMMITMENT 1 ] ) ; } verifier_channel :: send_field_elements ( channel_idx , stark_params :: N_COEFFICIENTS , map :: MM_COEFFICIENTS , & mut verifier_state ) ; verifier_state [ map :: MM_OODS_COMMITMENT ] = verifier_channel :: read_hash ( channel_idx , true , & mut verifier_state ) ; //Send out domain sampling point verifier_channel :: send_field_elements ( channel_idx , 1 , map :: MM_OODS_POINT , & mut verifier_state ) ; //Read the answers to the Out of Domain Sampling let lmm_oods_vals : usize = map :: MM_OODS_VALUES ; for i in lmm_oods_vals .. ( lmm_oods_vals + stark_params :: N_OODS_VALUES ) { verifier_state [ i ] = verifier_channel :: read_field_elements ( channel_idx , true , & mut verifier_state ) ; } // println!("ctx prior to stuff that remix can't handle: "); // for i in 0..verifier_state.len() { //     println!("ctx[{}] = {}", i, verifier_state[i]); // } oods_consistency_check ( & mut verifier_state , & memory_page_fact_reg ) ; verifier_channel :: send_field_elements ( channel_idx , stark_params :: N_OODS_COEFFICIENTS , map :: MM_OODS_COEFFICIENTS , & mut verifier_state ) ; verifier_state [ map :: MM_FRI_COMMITMENTS ] = verifier_channel :: read_hash ( channel_idx , true , & mut verifier_state ) ; let n_fri_steps = fri :: get_fri_steps ( & mut verifier_state ) . len ( ) ; for i in 1 .. ( n_fri_steps - 1 ) { //TODO: probably wrong bounds verifier_channel :: send_field_elements ( channel_idx , 1 , map :: MM_FRI_EVAL_POINTS + i , & mut verifier_state ) ; verifier_state [ map :: MM_FRI_COMMITMENTS + i ] = verifier_channel :: read_hash ( channel_idx , true , & mut verifier_state ) ; } // Send last random FRI evaluation point. verifier_channel :: send_field_elements ( channel_idx , 1 , map :: MM_FRI_EVAL_POINTS + n_fri_steps - 1 , & mut verifier_state ) ; // Read FRI last layer commitment. read_last_fri_layer ( & mut verifier_state ) ; // Generate queries. verifier_channel :: verify_pow ( channel_idx , uint256_ops :: to_usize ( & verifier_state [ map :: MM_PROOF_OF_WORK_BITS ] ) , & mut verifier_state , map :: QUARTER_READ_NUM ) ; verifier_state [ map :: MM_N_UNIQUE_QUERIES ] = verifier_channel :: send_random_queries ( channel_idx , uint256_ops :: to_usize ( & verifier_state [ map :: MM_N_UNIQUE_QUERIES ] ) , verifier_state [ map :: MM_EVAL_DOMAIN_SIZE ] . clone ( ) - uint256_ops :: get_uint256 ( " " ) , map :: MM_FRI_QUEUE , 3 , & mut verifier_state ) ; compute_first_fri_layer ( & mut verifier_state ) ; fri :: fri_verify_layers ( & mut verifier_state ) ; /* --------- End of StarkVerifier.verifyProof --------- */ //TODO: registerGpsFact? and somwhow ensure the program_hash was encoded in the proof data //Maybe get the program hashes from register_public_memory_main_page and iterate through tasks }
Interace for Verifying Proof:
 Checks arithmetization
 Checks low-degreeness using FRI protocol
Interace for Verifying Proof : Checks arithmetization Checks low - degreeness using FRI protocol
proof_params
Vec<Uint256>
proof
Vec<Uint256>
task_meta_data
Vec<Uint256>
cairo_aux_input
Vec<Uint256>
cairo_verifier_id
Uint256
proof_params
Vec<Uint256>
proof
Vec<Uint256>
task_meta_data
Vec<Uint256>
cairo_aux_input
Vec<Uint256>
cairo_verifier_id
Uint256