fn gather_coset_inputs(
	channel_idx: usize, fri_ctx: usize, fri_queue_head_input: usize, coset_size: usize, ctx: & mut Vec<Uint256>
) -> (usize, Uint256, Uint256) {

	let mut evals_on_coset_idx = fri_ctx + FRI_CTX_TO_COSET_EVALUATIONS_OFFSET;
	let fri_group_idx = fri_ctx + FRI_CTX_TO_FRI_GROUP_OFFSET;
	let mut fri_queue_head = fri_queue_head_input; //mutable copy of input

	let mut queue_item_idx = ctx[fri_queue_head].clone();

	// The coset index is represented by the most significant bits of the queue item index.
	let negated: Uint256 = uint256_ops::bitwise_not( uint256_ops::from_usize(coset_size-1)  );
	let coset_idx = uint256_ops::bitwise_and( &queue_item_idx.clone(), &negated );
	let next_coset_idx = coset_idx.clone() + uint256_ops::from_usize(coset_size);
	

	// Get the algebraic coset offset:
	// I.e. given c*g^(-k) compute c, where
	//      g is the generator of the coset group.
	//      k is bitReverse(offsetWithinCoset, log2(cosetSize)).
	//
	// To do this we multiply the algebraic coset offset at the top of the queue (c*g^(-k))
	// by the group element that corresponds to the index inside the coset (g^k)
	let coset_offset = prime_field::fmul(
		ctx[fri_queue_head + 2].clone(),
		ctx[fri_group_idx + uint256_ops::to_usize( &(queue_item_idx.clone() - coset_idx.clone()) ) ].clone()
	);

	let mut proof_idx = uint256_ops::to_usize(&ctx[channel_idx]);

	let mut index = coset_idx.clone();
	while index < next_coset_idx {
		// Inline channel operation:
		// Assume we are going to read the next element from the proof.
		// If this is not the case proof_idx += 1 will be reverted
		let mut field_elem_idx = proof_idx;
		proof_idx += 1;

		// Load the next index from the queue and check if it is our sibling.
		if index == queue_item_idx {
			// Take element from the queue rather than from the proof
            // and convert it back to Montgomery form for Merkle verification.
			field_elem_idx = fri_queue_head + 1;

			// Revert the read from proof.
			proof_idx -= 1;

			// Reading the next index here is safe due to the
			// delimiter after the queries
			fri_queue_head = fri_queue_head + 3;
			queue_item_idx = ctx[fri_queue_head].clone();
		}

		// Note that we apply the modulo operation to convert the field elements we read
		// from the proof to canonical representation (in the range [0, PRIME - 1])
		ctx[evals_on_coset_idx] = prime_field::mod_prime( ctx[field_elem_idx].clone() ); //mod (val, PRIME)
		evals_on_coset_idx += 1;

		index += uint256_ops::get_uint256("1");
	} 

	//Update proof pointer to reflect proof's data read
	ctx[channel_idx] = uint256_ops::from_usize(proof_idx);

	return (fri_queue_head, coset_idx, coset_offset);

}
/*
	Gathers the "cosetSize" elements that belong to the same coset
	as the item at the top of the FRI queue and stores them in ctx[MM_FRI_STEP_VALUES:].
	Returns
		friQueueHead - friQueueHead + 3 * (# elements that were taken from the queue).
		cosetIdx - the start index of the coset that was gathered.
		cosetOffset - the xInv field element that corresponds to cosetIdx.
*/
Gathers the "cosetSize" elements that belong to the same coset
as the item at the top of the FRI queue and stores them in ctx[MM_FRI_STEP_VALUES:].
Returns
friQueueHead - friQueueHead + 3 * (# elements that were taken from the queue).
cosetIdx - the start index of the coset that was gathered.
cosetOffset - the xInv field element that corresponds to cosetIdx.
Gathers the " cosetSize " elements that belong to the same coset as the item at the top of the FRI queue and stores them in ctx [ MM_FRI_STEP_VALUES : ] . Returns friQueueHead - friQueueHead + 3 * ( # elements that were taken from the queue ) . cosetIdx - the start index of the coset that was gathered . cosetOffset - the xInv field element that corresponds to cosetIdx .
fn gather_coset_inputs(
	channel_idx: usize, fri_ctx: usize, fri_queue_head_input: usize, coset_size: usize, ctx: & mut Vec<Uint256>
) -> (usize, Uint256, Uint256) {
	let mut evals_on_coset_idx = fri_ctx + FRI_CTX_TO_COSET_EVALUATIONS_OFFSET;
	let fri_group_idx = fri_ctx + FRI_CTX_TO_FRI_GROUP_OFFSET;
	let mut fri_queue_head = fri_queue_head_input; //mutable copy of input
	let mut queue_item_idx = ctx[fri_queue_head].clone();
	// The coset index is represented by the most significant bits of the queue item index.
	let negated: Uint256 = uint256_ops::bitwise_not( uint256_ops::from_usize(coset_size-1)  );
	let coset_idx = uint256_ops::bitwise_and( &queue_item_idx.clone(), &negated );
	let next_coset_idx = coset_idx.clone() + uint256_ops::from_usize(coset_size);
	// Get the algebraic coset offset:
	// I.e. given c*g^(-k) compute c, where
	//      g is the generator of the coset group.
	//      k is bitReverse(offsetWithinCoset, log2(cosetSize)).
	//
	// To do this we multiply the algebraic coset offset at the top of the queue (c*g^(-k))
	// by the group element that corresponds to the index inside the coset (g^k)
	let coset_offset = prime_field::fmul(
		ctx[fri_queue_head + 2].clone(),
		ctx[fri_group_idx + uint256_ops::to_usize( &(queue_item_idx.clone() - coset_idx.clone()) ) ].clone()
	);
	let mut proof_idx = uint256_ops::to_usize(&ctx[channel_idx]);
	let mut index = coset_idx.clone();
	while index < next_coset_idx {
		// Inline channel operation:
		// Assume we are going to read the next element from the proof.
		// If this is not the case proof_idx += 1 will be reverted
		let mut field_elem_idx = proof_idx;
		proof_idx += 1;
		// Load the next index from the queue and check if it is our sibling.
		if index == queue_item_idx {
			// Take element from the queue rather than from the proof
            // and convert it back to Montgomery form for Merkle verification.
			field_elem_idx = fri_queue_head + 1;
			// Revert the read from proof.
			proof_idx -= 1;
			// Reading the next index here is safe due to the
			// delimiter after the queries
			fri_queue_head = fri_queue_head + 3;
			queue_item_idx = ctx[fri_queue_head].clone();
		}
		// Note that we apply the modulo operation to convert the field elements we read
		// from the proof to canonical representation (in the range [0, PRIME - 1])
		ctx[evals_on_coset_idx] = prime_field::mod_prime( ctx[field_elem_idx].clone() ); //mod (val, PRIME)
		evals_on_coset_idx += 1;
		index += uint256_ops::get_uint256("1");
	} 
	//Update proof pointer to reflect proof's data read
	ctx[channel_idx] = uint256_ops::from_usize(proof_idx);
	return (fri_queue_head, coset_idx, coset_offset);
}
fn gather_coset_inputs ( channel_idx : usize , fri_ctx : usize , fri_queue_head_input : usize , coset_size : usize , ctx : & mut Vec < Uint256 > ) -> ( usize , Uint256 , Uint256 ) { let mut evals_on_coset_idx = fri_ctx + FRI_CTX_TO_COSET_EVALUATIONS_OFFSET ; let fri_group_idx = fri_ctx + FRI_CTX_TO_FRI_GROUP_OFFSET ; let mut fri_queue_head = fri_queue_head_input ; //mutable copy of input let mut queue_item_idx = ctx [ fri_queue_head ] . clone ( ) ; // The coset index is represented by the most significant bits of the queue item index. let negated : Uint256 = uint256_ops :: bitwise_not ( uint256_ops :: from_usize ( coset_size - 1 ) ) ; let coset_idx = uint256_ops :: bitwise_and ( & queue_item_idx . clone ( ) , & negated ) ; let next_coset_idx = coset_idx . clone ( ) + uint256_ops :: from_usize ( coset_size ) ; // Get the algebraic coset offset: // I.e. given c*g^(-k) compute c, where //      g is the generator of the coset group. //      k is bitReverse(offsetWithinCoset, log2(cosetSize)). // // To do this we multiply the algebraic coset offset at the top of the queue (c*g^(-k)) // by the group element that corresponds to the index inside the coset (g^k) let coset_offset = prime_field :: fmul ( ctx [ fri_queue_head + 2 ] . clone ( ) , ctx [ fri_group_idx + uint256_ops :: to_usize ( & ( queue_item_idx . clone ( ) - coset_idx . clone ( ) ) ) ] . clone ( ) ) ; let mut proof_idx = uint256_ops :: to_usize ( & ctx [ channel_idx ] ) ; let mut index = coset_idx . clone ( ) ; while index < next_coset_idx { // Inline channel operation: // Assume we are going to read the next element from the proof. // If this is not the case proof_idx += 1 will be reverted let mut field_elem_idx = proof_idx ; proof_idx += 1 ; // Load the next index from the queue and check if it is our sibling. if index == queue_item_idx { // Take element from the queue rather than from the proof // and convert it back to Montgomery form for Merkle verification. field_elem_idx = fri_queue_head + 1 ; // Revert the read from proof. proof_idx -= 1 ; // Reading the next index here is safe due to the // delimiter after the queries fri_queue_head = fri_queue_head + 3 ; queue_item_idx = ctx [ fri_queue_head ] . clone ( ) ; } // Note that we apply the modulo operation to convert the field elements we read // from the proof to canonical representation (in the range [0, PRIME - 1]) ctx [ evals_on_coset_idx ] = prime_field :: mod_prime ( ctx [ field_elem_idx ] . clone ( ) ) ; //mod (val, PRIME) evals_on_coset_idx += 1 ; index += uint256_ops :: get_uint256 ( " " ) ; } //Update proof pointer to reflect proof's data read ctx [ channel_idx ] = uint256_ops :: from_usize ( proof_idx ) ; return ( fri_queue_head , coset_idx , coset_offset ) ; }
Gathers the "cosetSize" elements that belong to the same coset
as the item at the top of the FRI queue and stores them in ctx[MM_FRI_STEP_VALUES:].
Gathers the " cosetSize " elements that belong to the same coset as the item at the top of the FRI queue and stores them in ctx [ MM_FRI_STEP_VALUES : ] .
channel_idx
usize
fri_ctx
usize
fri_queue_head_input
usize
coset_size
usize
ctx
& mut Vec<Uint256>
channel_idx
usize
fri_ctx
usize
fri_queue_head_input
usize
coset_size
usize
ctx
& mut Vec<Uint256>