fn do_3_fri_steps(
	fri_half_inv_group_idx: usize, evals_on_coset_idx: usize, coset_offset_input: Uint256, fri_eval_point: Uint256, ctx: & mut Vec<Uint256>
) -> (Uint256, Uint256) {
	let prime = prime_field::get_k_modulus();
	let m_prime = uint256_ops::get_uint256("8000000000000110000000000000000000000000000000000000000000000010");
	let mut f0 = ctx[evals_on_coset_idx].clone();
	
	let fri_eval_point_divbyx = prime_field::fmul( fri_eval_point.clone(), coset_offset_input.clone() );
	let fri_eval_point_divbyx_squared = prime_field::fmul( fri_eval_point_divbyx.clone(), fri_eval_point_divbyx.clone() );
	let imaginary_unit = ctx[fri_half_inv_group_idx + 1].clone();

	let f1 = ctx[evals_on_coset_idx + 1].clone();
	// f0 < 3P ( = 1 + 1 + 1).
	f0 = (f0.clone() + f1.clone()) + prime_field::fmul( fri_eval_point_divbyx.clone(), f0.clone() + (prime.clone() - f1.clone()) );

	let mut f2 = ctx[evals_on_coset_idx + 2].clone();
	let f3 = ctx[evals_on_coset_idx + 3].clone();
	f2 = (f2.clone() + f3.clone()) + 
		prime_field::fmul(
			f2.clone() + (prime.clone() - f3.clone()), 
			prime_field::fmul(
				fri_eval_point_divbyx.clone(), imaginary_unit.clone()
			)
		);
	
	// f0 < 7P ( = 3 + 3 + 1).
	f0 = (f0.clone() + f2.clone()) + 
		prime_field::fmul(
			fri_eval_point_divbyx_squared.clone(), f0.clone() + (m_prime.clone() - f2.clone())
		);


	let mut f4 = ctx[evals_on_coset_idx + 4].clone();
	let fri_eval_point_div_by_x2 = prime_field::fmul( fri_eval_point_divbyx.clone(), ctx[fri_half_inv_group_idx + 4].clone() );

	let f5 = ctx[evals_on_coset_idx + 5].clone();
	f4 = (f4.clone() + f5.clone()) + prime_field::fmul(
			fri_eval_point_div_by_x2.clone(), f4.clone() + (prime.clone() - f5.clone())
		);

	let mut f6 = ctx[evals_on_coset_idx + 6].clone();
	let f7 = ctx[evals_on_coset_idx + 7].clone();

	 // f6 < 3P ( = 1 + 1 + 1).
	 f6 = (f6.clone() + f7.clone()) + prime_field::fmul(
			f6.clone() + (prime.clone() - f7.clone()), 
			// friEvalPointDivByX2 * imaginaryUnit ==
			// friEvalPointDivByX * ctx[friHalfInvGroupPtr + 3]
			prime_field::fmul(
				fri_eval_point_divbyx.clone(), imaginary_unit.clone()
			)

	 	);

	// f4 < 7P ( = 3 + 3 + 1)
	f4 = (f4.clone() + f6.clone()) + prime_field::fmul(
			prime_field::fmul(
				fri_eval_point_divbyx.clone(), fri_eval_point_divbyx.clone()
			), 
			f4.clone() + (m_prime.clone() - f6.clone())
		);



	
	// f0, f4 < 7P -> f0 + f4 < 14P && 9P < f0 + (MPRIME - f4) < 23P.
	let next_layer_value = prime_field::fadd(
		f0.clone() + f4.clone(), 
		prime_field::fmul(
			prime_field::fmul(
				fri_eval_point_divbyx_squared.clone(), fri_eval_point_divbyx_squared.clone()
			),
			f0.clone() + (m_prime.clone() - f4.clone())
		)
	);
	

	let x_inv_2 = prime_field::fmul( coset_offset_input.clone(), coset_offset_input.clone() );
	let x_inv_4 = prime_field::fmul( x_inv_2.clone(), x_inv_2 );
	let new_x_inv = prime_field::fmul( x_inv_4.clone(), x_inv_4 );

	return (next_layer_value, new_x_inv);

}
/*
	Reads 8 elements, and applies 4 + 2 + 1 FRI transformation to obtain a single element.
	See do_2_fri_steps for more detailed explanation.
*/
Reads 8 elements, and applies 4 + 2 + 1 FRI transformation to obtain a single element.
See do_2_fri_steps for more detailed explanation.
Reads 8 elements and applies 4 + 2 + 1 FRI transformation to obtain a single element . See do_2_fri_steps for more detailed explanation .
fn do_3_fri_steps(
	fri_half_inv_group_idx: usize, evals_on_coset_idx: usize, coset_offset_input: Uint256, fri_eval_point: Uint256, ctx: & mut Vec<Uint256>
) -> (Uint256, Uint256) {
	let prime = prime_field::get_k_modulus();
	let m_prime = uint256_ops::get_uint256("8000000000000110000000000000000000000000000000000000000000000010");
	let mut f0 = ctx[evals_on_coset_idx].clone();
	let fri_eval_point_divbyx = prime_field::fmul( fri_eval_point.clone(), coset_offset_input.clone() );
	let fri_eval_point_divbyx_squared = prime_field::fmul( fri_eval_point_divbyx.clone(), fri_eval_point_divbyx.clone() );
	let imaginary_unit = ctx[fri_half_inv_group_idx + 1].clone();
	let f1 = ctx[evals_on_coset_idx + 1].clone();
	// f0 < 3P ( = 1 + 1 + 1).
	f0 = (f0.clone() + f1.clone()) + prime_field::fmul( fri_eval_point_divbyx.clone(), f0.clone() + (prime.clone() - f1.clone()) );
	let mut f2 = ctx[evals_on_coset_idx + 2].clone();
	let f3 = ctx[evals_on_coset_idx + 3].clone();
	f2 = (f2.clone() + f3.clone()) + 
		prime_field::fmul(
			f2.clone() + (prime.clone() - f3.clone()), 
			prime_field::fmul(
				fri_eval_point_divbyx.clone(), imaginary_unit.clone()
			)
		);
	// f0 < 7P ( = 3 + 3 + 1).
	f0 = (f0.clone() + f2.clone()) + 
		prime_field::fmul(
			fri_eval_point_divbyx_squared.clone(), f0.clone() + (m_prime.clone() - f2.clone())
		);
	let mut f4 = ctx[evals_on_coset_idx + 4].clone();
	let fri_eval_point_div_by_x2 = prime_field::fmul( fri_eval_point_divbyx.clone(), ctx[fri_half_inv_group_idx + 4].clone() );
	let f5 = ctx[evals_on_coset_idx + 5].clone();
	f4 = (f4.clone() + f5.clone()) + prime_field::fmul(
			fri_eval_point_div_by_x2.clone(), f4.clone() + (prime.clone() - f5.clone())
		);
	let mut f6 = ctx[evals_on_coset_idx + 6].clone();
	let f7 = ctx[evals_on_coset_idx + 7].clone();
	 // f6 < 3P ( = 1 + 1 + 1).
	 f6 = (f6.clone() + f7.clone()) + prime_field::fmul(
			f6.clone() + (prime.clone() - f7.clone()), 
			// friEvalPointDivByX2 * imaginaryUnit ==
			// friEvalPointDivByX * ctx[friHalfInvGroupPtr + 3]
			prime_field::fmul(
				fri_eval_point_divbyx.clone(), imaginary_unit.clone()
			)
	 	);
	// f4 < 7P ( = 3 + 3 + 1)
	f4 = (f4.clone() + f6.clone()) + prime_field::fmul(
			prime_field::fmul(
				fri_eval_point_divbyx.clone(), fri_eval_point_divbyx.clone()
			), 
			f4.clone() + (m_prime.clone() - f6.clone())
		);
	// f0, f4 < 7P -> f0 + f4 < 14P && 9P < f0 + (MPRIME - f4) < 23P.
	let next_layer_value = prime_field::fadd(
		f0.clone() + f4.clone(), 
		prime_field::fmul(
			prime_field::fmul(
				fri_eval_point_divbyx_squared.clone(), fri_eval_point_divbyx_squared.clone()
			),
			f0.clone() + (m_prime.clone() - f4.clone())
		)
	);
	let x_inv_2 = prime_field::fmul( coset_offset_input.clone(), coset_offset_input.clone() );
	let x_inv_4 = prime_field::fmul( x_inv_2.clone(), x_inv_2 );
	let new_x_inv = prime_field::fmul( x_inv_4.clone(), x_inv_4 );
	return (next_layer_value, new_x_inv);
}
fn do_3_fri_steps ( fri_half_inv_group_idx : usize , evals_on_coset_idx : usize , coset_offset_input : Uint256 , fri_eval_point : Uint256 , ctx : & mut Vec < Uint256 > ) -> ( Uint256 , Uint256 ) { let prime = prime_field :: get_k_modulus ( ) ; let m_prime = uint256_ops :: get_uint256 ( " " ) ; let mut f0 = ctx [ evals_on_coset_idx ] . clone ( ) ; let fri_eval_point_divbyx = prime_field :: fmul ( fri_eval_point . clone ( ) , coset_offset_input . clone ( ) ) ; let fri_eval_point_divbyx_squared = prime_field :: fmul ( fri_eval_point_divbyx . clone ( ) , fri_eval_point_divbyx . clone ( ) ) ; let imaginary_unit = ctx [ fri_half_inv_group_idx + 1 ] . clone ( ) ; let f1 = ctx [ evals_on_coset_idx + 1 ] . clone ( ) ; // f0 < 3P ( = 1 + 1 + 1). f0 = ( f0 . clone ( ) + f1 . clone ( ) ) + prime_field :: fmul ( fri_eval_point_divbyx . clone ( ) , f0 . clone ( ) + ( prime . clone ( ) - f1 . clone ( ) ) ) ; let mut f2 = ctx [ evals_on_coset_idx + 2 ] . clone ( ) ; let f3 = ctx [ evals_on_coset_idx + 3 ] . clone ( ) ; f2 = ( f2 . clone ( ) + f3 . clone ( ) ) + prime_field :: fmul ( f2 . clone ( ) + ( prime . clone ( ) - f3 . clone ( ) ) , prime_field :: fmul ( fri_eval_point_divbyx . clone ( ) , imaginary_unit . clone ( ) ) ) ; // f0 < 7P ( = 3 + 3 + 1). f0 = ( f0 . clone ( ) + f2 . clone ( ) ) + prime_field :: fmul ( fri_eval_point_divbyx_squared . clone ( ) , f0 . clone ( ) + ( m_prime . clone ( ) - f2 . clone ( ) ) ) ; let mut f4 = ctx [ evals_on_coset_idx + 4 ] . clone ( ) ; let fri_eval_point_div_by_x2 = prime_field :: fmul ( fri_eval_point_divbyx . clone ( ) , ctx [ fri_half_inv_group_idx + 4 ] . clone ( ) ) ; let f5 = ctx [ evals_on_coset_idx + 5 ] . clone ( ) ; f4 = ( f4 . clone ( ) + f5 . clone ( ) ) + prime_field :: fmul ( fri_eval_point_div_by_x2 . clone ( ) , f4 . clone ( ) + ( prime . clone ( ) - f5 . clone ( ) ) ) ; let mut f6 = ctx [ evals_on_coset_idx + 6 ] . clone ( ) ; let f7 = ctx [ evals_on_coset_idx + 7 ] . clone ( ) ; // f6 < 3P ( = 1 + 1 + 1). f6 = ( f6 . clone ( ) + f7 . clone ( ) ) + prime_field :: fmul ( f6 . clone ( ) + ( prime . clone ( ) - f7 . clone ( ) ) , // friEvalPointDivByX2 * imaginaryUnit == // friEvalPointDivByX * ctx[friHalfInvGroupPtr + 3] prime_field :: fmul ( fri_eval_point_divbyx . clone ( ) , imaginary_unit . clone ( ) ) ) ; // f4 < 7P ( = 3 + 3 + 1) f4 = ( f4 . clone ( ) + f6 . clone ( ) ) + prime_field :: fmul ( prime_field :: fmul ( fri_eval_point_divbyx . clone ( ) , fri_eval_point_divbyx . clone ( ) ) , f4 . clone ( ) + ( m_prime . clone ( ) - f6 . clone ( ) ) ) ; // f0, f4 < 7P -> f0 + f4 < 14P && 9P < f0 + (MPRIME - f4) < 23P. let next_layer_value = prime_field :: fadd ( f0 . clone ( ) + f4 . clone ( ) , prime_field :: fmul ( prime_field :: fmul ( fri_eval_point_divbyx_squared . clone ( ) , fri_eval_point_divbyx_squared . clone ( ) ) , f0 . clone ( ) + ( m_prime . clone ( ) - f4 . clone ( ) ) ) ) ; let x_inv_2 = prime_field :: fmul ( coset_offset_input . clone ( ) , coset_offset_input . clone ( ) ) ; let x_inv_4 = prime_field :: fmul ( x_inv_2 . clone ( ) , x_inv_2 ) ; let new_x_inv = prime_field :: fmul ( x_inv_4 . clone ( ) , x_inv_4 ) ; return ( next_layer_value , new_x_inv ) ; }
Reads 8 elements, and applies 4 + 2 + 1 FRI transformation to obtain a single element.
Reads 8 elements and applies 4 + 2 + 1 FRI transformation to obtain a single element .
fri_half_inv_group_idx
usize
evals_on_coset_idx
usize
coset_offset_input
Uint256
fri_eval_point
Uint256
ctx
& mut Vec<Uint256>
fri_half_inv_group_idx
usize
evals_on_coset_idx
usize
coset_offset_input
Uint256
fri_eval_point
Uint256
ctx
& mut Vec<Uint256>