fn compute_fact_hash(
	memory_pairs: &Vec<Uint256>, z: Uint256, alpha: Uint256, prime: Uint256
) -> (Uint256, Uint256, Uint256) {
	let mem_size = memory_pairs.len() / 2;

	let mut prod = uint256_ops::get_uint256("1");

	// Each value of memoryPairs is a pair: (address, value)
	let last_idx = memory_pairs.len()-1;

	let mut idx = 0;
	while idx < last_idx {
		// Compute address + alpha * value
		let addr_val_linear_comb = prime_field::fadd(
			memory_pairs[idx].clone(), prime_field::fmul(
				memory_pairs[idx+1].clone(), alpha.clone()
			)
		);
		prod = prime_field::fmul(
			prod.clone(), z.clone() + prime.clone() - addr_val_linear_comb.clone()
		);
		idx += 2;
	}

	let mut combined_data1: Vec<u8> = vec![0; 32*memory_pairs.len()];
    for i in 0..memory_pairs.len() {
        let bytes = uint256_ops::to_fixed_bytes( &memory_pairs[i] );
        for j in 0..bytes.len() {
            combined_data1[ 32*i + j] = bytes[j];
        }
    }
    let mem_hash = uint256_ops::keccak_256(&combined_data1);


	let mut combined_data2: Vec<u8> = vec![0; 32*8];
	let mut hashing_vals: Vec<Uint256> = vec![ uint256_ops::from_usize(REGULAR_PAGE), prime.clone(), uint256_ops::from_usize(mem_size), z.clone(), alpha.clone(), prod.clone(), mem_hash.clone(), uint256_ops::get_uint256("0") ];
    for i in 0..hashing_vals.len() {
        let bytes = uint256_ops::to_fixed_bytes( &hashing_vals[i] );
        for j in 0..bytes.len() {
            combined_data2[ 32*i + j] = bytes[j];
        }
    }
    let fact_hash = uint256_ops::keccak_256(&combined_data2);

	return (fact_hash, mem_hash, prod);

}
/* Registers a fact based of the given memory (address, value) pairs (REGULAR_PAGE) */
Registers a fact based of the given memory (address, value) pairs (REGULAR_PAGE)
Registers a fact based of the given memory ( address value ) pairs ( REGULAR_PAGE )
fn compute_fact_hash(
	memory_pairs: &Vec<Uint256>, z: Uint256, alpha: Uint256, prime: Uint256
) -> (Uint256, Uint256, Uint256) {
	let mem_size = memory_pairs.len() / 2;
	let mut prod = uint256_ops::get_uint256("1");
	// Each value of memoryPairs is a pair: (address, value)
	let last_idx = memory_pairs.len()-1;
	let mut idx = 0;
	while idx < last_idx {
		// Compute address + alpha * value
		let addr_val_linear_comb = prime_field::fadd(
			memory_pairs[idx].clone(), prime_field::fmul(
				memory_pairs[idx+1].clone(), alpha.clone()
			)
		);
		prod = prime_field::fmul(
			prod.clone(), z.clone() + prime.clone() - addr_val_linear_comb.clone()
		);
		idx += 2;
	}
	let mut combined_data1: Vec<u8> = vec![0; 32*memory_pairs.len()];
    for i in 0..memory_pairs.len() {
        let bytes = uint256_ops::to_fixed_bytes( &memory_pairs[i] );
        for j in 0..bytes.len() {
            combined_data1[ 32*i + j] = bytes[j];
        }
    }
    let mem_hash = uint256_ops::keccak_256(&combined_data1);
	let mut combined_data2: Vec<u8> = vec![0; 32*8];
	let mut hashing_vals: Vec<Uint256> = vec![ uint256_ops::from_usize(REGULAR_PAGE), prime.clone(), uint256_ops::from_usize(mem_size), z.clone(), alpha.clone(), prod.clone(), mem_hash.clone(), uint256_ops::get_uint256("0") ];
    for i in 0..hashing_vals.len() {
        let bytes = uint256_ops::to_fixed_bytes( &hashing_vals[i] );
        for j in 0..bytes.len() {
            combined_data2[ 32*i + j] = bytes[j];
        }
    }
    let fact_hash = uint256_ops::keccak_256(&combined_data2);
	return (fact_hash, mem_hash, prod);
}
fn compute_fact_hash ( memory_pairs : & Vec < Uint256 > , z : Uint256 , alpha : Uint256 , prime : Uint256 ) -> ( Uint256 , Uint256 , Uint256 ) { let mem_size = memory_pairs . len ( ) / 2 ; let mut prod = uint256_ops :: get_uint256 ( " " ) ; // Each value of memoryPairs is a pair: (address, value) let last_idx = memory_pairs . len ( ) - 1 ; let mut idx = 0 ; while idx < last_idx { // Compute address + alpha * value let addr_val_linear_comb = prime_field :: fadd ( memory_pairs [ idx ] . clone ( ) , prime_field :: fmul ( memory_pairs [ idx + 1 ] . clone ( ) , alpha . clone ( ) ) ) ; prod = prime_field :: fmul ( prod . clone ( ) , z . clone ( ) + prime . clone ( ) - addr_val_linear_comb . clone ( ) ) ; idx += 2 ; } let mut combined_data1 : Vec < u8 > = vec ! [ 0 32 memory_pairs len ( ) ] ; for i in 0 .. memory_pairs . len ( ) { let bytes = uint256_ops :: to_fixed_bytes ( & memory_pairs [ i ] ) ; for j in 0 .. bytes . len ( ) { combined_data1 [ 32 * i + j ] = bytes [ j ] ; } } let mem_hash = uint256_ops :: keccak_256 ( & combined_data1 ) ; let mut combined_data2 : Vec < u8 > = vec ! [ 0 32 8 ] ; let mut hashing_vals : Vec < Uint256 > = vec ! [ uint256_ops from_usize ( REGULAR_PAGE ) prime clone ( ) uint256_ops from_usize ( mem_size ) z clone ( ) alpha clone ( ) prod clone ( ) mem_hash clone ( ) uint256_ops get_uint256 ( " " ) ] ; for i in 0 .. hashing_vals . len ( ) { let bytes = uint256_ops :: to_fixed_bytes ( & hashing_vals [ i ] ) ; for j in 0 .. bytes . len ( ) { combined_data2 [ 32 * i + j ] = bytes [ j ] ; } } let fact_hash = uint256_ops :: keccak_256 ( & combined_data2 ) ; return ( fact_hash , mem_hash , prod ) ; }
Registers a fact based of the given memory (address, value) pairs (REGULAR_PAGE)
Registers a fact based of the given memory ( address value ) pairs ( REGULAR_PAGE )
memory_pairs
&Vec<Uint256>
z
Uint256
alpha
Uint256
prime
Uint256
memory_pairs
&Vec<Uint256>
z
Uint256
alpha
Uint256
prime
Uint256