fn do_fri_steps(
	fri_ctx: usize, fri_queue_tail: usize,  coset_offset_input: Uint256, fri_eval_point: Uint256,
	fri_coset_size: usize, index: Uint256, merkle_queue_idx: usize, ctx: & mut Vec<Uint256>
) {

	let evals_on_coset_idx = fri_ctx + FRI_CTX_TO_COSET_EVALUATIONS_OFFSET;
	let fri_half_inv_group_idx = fri_ctx + FRI_CTX_TO_FRI_HALF_INV_GROUP_OFFSET;

	let mut fri_val = uint256_ops::get_uint256("0");
	let mut coset_offset = coset_offset_input;


	// Compare to expected FRI step sizes in order of likelihood, step size 3 being most common.
	if fri_coset_size == 8 {
		let (fri_val_tmp, coset_offset_tmp) = do_3_fri_steps( fri_half_inv_group_idx, evals_on_coset_idx, coset_offset, fri_eval_point, ctx );
		fri_val = fri_val_tmp;
		coset_offset = coset_offset_tmp;
	}else if fri_coset_size == 4 {
		let (fri_val_tmp, coset_offset_tmp) = do_2_fri_steps( fri_half_inv_group_idx, evals_on_coset_idx, coset_offset, fri_eval_point, ctx );
		fri_val = fri_val_tmp;
		coset_offset = coset_offset_tmp;
	}else if fri_coset_size == 16  {
		let (fri_val_tmp, coset_offset_tmp) = do_4_fri_steps( fri_half_inv_group_idx, evals_on_coset_idx, coset_offset, fri_eval_point, ctx );
		fri_val = fri_val_tmp;
		coset_offset = coset_offset_tmp;
	}else {
		assert!(false); // Only step sizes of 2, 3 or 4 are supported
	} 

	let idx_in_nxt_step = index / uint256_ops::from_usize(fri_coset_size);
	ctx[merkle_queue_idx] = idx_in_nxt_step.clone();

	let mut hash_data: Vec<u8> = vec![];
	for i in 0..fri_coset_size {
		let data_bytes = uint256_ops::to_fixed_bytes( &ctx[evals_on_coset_idx + i] );
		for j in 0..data_bytes.len() {
			hash_data.push( data_bytes[j] );
		}
	}

	ctx[merkle_queue_idx + 1] = uint256_ops::bitwise_and( 
		&get_hash_mask(), &uint256_ops::keccak_256(&hash_data)
	);
	ctx[fri_queue_tail] = idx_in_nxt_step.clone();
	ctx[fri_queue_tail + 1] = fri_val;
	ctx[fri_queue_tail + 2] = coset_offset;
}
/*
	Operates on the coset of size friFoldedCosetSize that start at index.
	It produces 3 outputs:
	  1. The field elements that result from doing FRI reductions on the coset.
	  2. The pointInv elements for the location that corresponds to the first output.
	  3. The root of a Merkle tree for the input layer.
	The input is read either from the queue or from the proof depending on data availability.
	Since the function reads from the queue it returns an updated head pointer.
*/
Operates on the coset of size friFoldedCosetSize that start at index.
It produces 3 outputs:
1. The field elements that result from doing FRI reductions on the coset.
2. The pointInv elements for the location that corresponds to the first output.
3. The root of a Merkle tree for the input layer.
The input is read either from the queue or from the proof depending on data availability.
Since the function reads from the queue it returns an updated head pointer.
Operates on the coset of size friFoldedCosetSize that start at index . It produces 3 outputs : 1 . The field elements that result from doing FRI reductions on the coset . 2 . The pointInv elements for the location that corresponds to the first output . 3 . The root of a Merkle tree for the input layer . The input is read either from the queue or from the proof depending on data availability . Since the function reads from the queue it returns an updated head pointer .
fn do_fri_steps(
	fri_ctx: usize, fri_queue_tail: usize,  coset_offset_input: Uint256, fri_eval_point: Uint256,
	fri_coset_size: usize, index: Uint256, merkle_queue_idx: usize, ctx: & mut Vec<Uint256>
) {
	let evals_on_coset_idx = fri_ctx + FRI_CTX_TO_COSET_EVALUATIONS_OFFSET;
	let fri_half_inv_group_idx = fri_ctx + FRI_CTX_TO_FRI_HALF_INV_GROUP_OFFSET;
	let mut fri_val = uint256_ops::get_uint256("0");
	let mut coset_offset = coset_offset_input;
	// Compare to expected FRI step sizes in order of likelihood, step size 3 being most common.
	if fri_coset_size == 8 {
		let (fri_val_tmp, coset_offset_tmp) = do_3_fri_steps( fri_half_inv_group_idx, evals_on_coset_idx, coset_offset, fri_eval_point, ctx );
		fri_val = fri_val_tmp;
		coset_offset = coset_offset_tmp;
	}else if fri_coset_size == 4 {
		let (fri_val_tmp, coset_offset_tmp) = do_2_fri_steps( fri_half_inv_group_idx, evals_on_coset_idx, coset_offset, fri_eval_point, ctx );
		fri_val = fri_val_tmp;
		coset_offset = coset_offset_tmp;
	}else if fri_coset_size == 16  {
		let (fri_val_tmp, coset_offset_tmp) = do_4_fri_steps( fri_half_inv_group_idx, evals_on_coset_idx, coset_offset, fri_eval_point, ctx );
		fri_val = fri_val_tmp;
		coset_offset = coset_offset_tmp;
	}else {
		assert!(false); // Only step sizes of 2, 3 or 4 are supported
	} 
	let idx_in_nxt_step = index / uint256_ops::from_usize(fri_coset_size);
	ctx[merkle_queue_idx] = idx_in_nxt_step.clone();
	let mut hash_data: Vec<u8> = vec![];
	for i in 0..fri_coset_size {
		let data_bytes = uint256_ops::to_fixed_bytes( &ctx[evals_on_coset_idx + i] );
		for j in 0..data_bytes.len() {
			hash_data.push( data_bytes[j] );
		}
	}
	ctx[merkle_queue_idx + 1] = uint256_ops::bitwise_and( 
		&get_hash_mask(), &uint256_ops::keccak_256(&hash_data)
	);
	ctx[fri_queue_tail] = idx_in_nxt_step.clone();
	ctx[fri_queue_tail + 1] = fri_val;
	ctx[fri_queue_tail + 2] = coset_offset;
}
fn do_fri_steps ( fri_ctx : usize , fri_queue_tail : usize , coset_offset_input : Uint256 , fri_eval_point : Uint256 , fri_coset_size : usize , index : Uint256 , merkle_queue_idx : usize , ctx : & mut Vec < Uint256 > ) { let evals_on_coset_idx = fri_ctx + FRI_CTX_TO_COSET_EVALUATIONS_OFFSET ; let fri_half_inv_group_idx = fri_ctx + FRI_CTX_TO_FRI_HALF_INV_GROUP_OFFSET ; let mut fri_val = uint256_ops :: get_uint256 ( " " ) ; let mut coset_offset = coset_offset_input ; // Compare to expected FRI step sizes in order of likelihood, step size 3 being most common. if fri_coset_size == 8 { let ( fri_val_tmp , coset_offset_tmp ) = do_3_fri_steps ( fri_half_inv_group_idx , evals_on_coset_idx , coset_offset , fri_eval_point , ctx ) ; fri_val = fri_val_tmp ; coset_offset = coset_offset_tmp ; } else if fri_coset_size == 4 { let ( fri_val_tmp , coset_offset_tmp ) = do_2_fri_steps ( fri_half_inv_group_idx , evals_on_coset_idx , coset_offset , fri_eval_point , ctx ) ; fri_val = fri_val_tmp ; coset_offset = coset_offset_tmp ; } else if fri_coset_size == 16 { let ( fri_val_tmp , coset_offset_tmp ) = do_4_fri_steps ( fri_half_inv_group_idx , evals_on_coset_idx , coset_offset , fri_eval_point , ctx ) ; fri_val = fri_val_tmp ; coset_offset = coset_offset_tmp ; } else { assert ! ( false ) ; // Only step sizes of 2, 3 or 4 are supported } let idx_in_nxt_step = index / uint256_ops :: from_usize ( fri_coset_size ) ; ctx [ merkle_queue_idx ] = idx_in_nxt_step . clone ( ) ; let mut hash_data : Vec < u8 > = vec ! [ ] ; for i in 0 .. fri_coset_size { let data_bytes = uint256_ops :: to_fixed_bytes ( & ctx [ evals_on_coset_idx + i ] ) ; for j in 0 .. data_bytes . len ( ) { hash_data . push ( data_bytes [ j ] ) ; } } ctx [ merkle_queue_idx + 1 ] = uint256_ops :: bitwise_and ( & get_hash_mask ( ) , & uint256_ops :: keccak_256 ( & hash_data ) ) ; ctx [ fri_queue_tail ] = idx_in_nxt_step . clone ( ) ; ctx [ fri_queue_tail + 1 ] = fri_val ; ctx [ fri_queue_tail + 2 ] = coset_offset ; }
Operates on the coset of size friFoldedCosetSize that start at index.
Operates on the coset of size friFoldedCosetSize that start at index .
fri_ctx
usize
fri_queue_tail
usize
coset_offset_input
Uint256
fri_eval_point
Uint256
fri_coset_size
usize
index
Uint256
merkle_queue_idx
usize
ctx
& mut Vec<Uint256>
fri_ctx
usize
fri_queue_tail
usize
coset_offset_input
Uint256
fri_eval_point
Uint256
fri_coset_size
usize
index
Uint256
merkle_queue_idx
usize
ctx
& mut Vec<Uint256>