diff --git a/src/air/public_input.cairo b/src/air/public_input.cairo index 1852e88e7..790a6342a 100644 --- a/src/air/public_input.cairo +++ b/src/air/public_input.cairo @@ -1,10 +1,9 @@ use core::{pedersen::PedersenTrait, hash::{HashStateTrait, HashStateExTrait, Hash}}; use cairo_verifier::{ common::{ - array_extend::ArrayExtend, - flip_endianness::FlipEndiannessTrait, array_append::ArrayAppendTrait, hasher::hash, - math::{pow, Felt252PartialOrd, Felt252Div}, asserts::assert_range_u128_le, - array_print::SpanPrintTrait, hash::hash_felts, + array_extend::ArrayExtend, flip_endianness::FlipEndiannessTrait, + array_append::ArrayAppendTrait, hasher::hash, math::{pow, Felt252PartialOrd, Felt252Div}, + asserts::assert_range_u128_le, array_print::SpanPrintTrait, hash::hash_felts, }, air::{ public_memory::{ diff --git a/src/channel/channel.cairo b/src/channel/channel.cairo index bd3015a33..b2a4a3dca 100644 --- a/src/channel/channel.cairo +++ b/src/channel/channel.cairo @@ -25,32 +25,6 @@ impl ChannelImpl of ChannelTrait { Channel { digest: digest, counter: counter } } - // fn random_uint256_to_prover(ref self: Channel) -> u256 { - // let mut hash_data = ArrayTrait::new(); // u32 for blake, u64 for keccak - // hash_data.append_big_endian(self.digest); - // hash_data.append_big_endian(self.counter); - // self.counter += 1; - // hash(hash_data).flip_endianness() - // } - - // fn random_felt_to_prover(ref self: Channel) -> felt252 { - // let mut res: felt252 = 0; - - // // To ensure a uniform distribution over field elements, if the generated 256-bit number x is in - // // range [0, C * PRIME), take x % PRIME. Otherwise, regenerate. - // // The maximal possible C is 2**256//PRIME = 31. - - // loop { - // let rand = self.random_uint256_to_prover(); - // if (rand < u256 { low: C_PRIME_AS_UINT256_LOW, high: C_PRIME_AS_UINT256_HIGH }) { - // let to_append = (rand % STARK_PRIME).try_into().unwrap(); - // res = to_append * MONTGOMERY_R_INVERSE; - // break; - // } - // }; - // res - // } - fn random_felt_to_prover(ref self: Channel) -> felt252 { let (hash, _, _) = hades_permutation(self.digest, self.counter, 2); self.counter += 1; @@ -69,35 +43,15 @@ impl ChannelImpl of ChannelTrait { }; res } -// not sure what to do with it -// fn read_truncated_hash_from_prover(ref self: Channel, value: felt252) { -// let mut hash_data = ArrayTrait::new(); // u32 for blake, u64 for keccak - -// assert(self.digest.low != BoundedU128::max(), 'digest low is 2^128-1'); -// hash_data.append_big_endian(self.digest + 1); -// hash_data.append_big_endian(value); - -// self.digest = hash(hash_data).flip_endianness(); -// self.counter = 0; -// } - -fn read_felt_from_prover(ref self: Channel, value: felt252) { - let mut hash_data = ArrayTrait::new(); - hash_data.append(self.digest + 1); - hash_data.append(value); - self.digest = poseidon_hash_span(hash_data.span()); - self.counter = 0; -} + fn read_felt_from_prover(ref self: Channel, value: felt252) { + let mut hash_data = ArrayTrait::new(); + hash_data.append(self.digest + 1); + hash_data.append(value); -// fn read_felts_from_prover(ref self: Channel, mut values: Span) { -// loop { -// match values.pop_front() { -// Option::Some(value) => { self.read_felt_from_prover(*value); }, -// Option::None => { break; } -// } -// } -// } + self.digest = poseidon_hash_span(hash_data.span()); + self.counter = 0; + } fn read_felt_vector_from_prover(ref self: Channel, mut values: Span) { let mut hash_data = ArrayTrait::new(); @@ -118,4 +72,4 @@ fn read_felt_from_prover(ref self: Channel, value: felt252) { fn read_uint64_from_prover(ref self: Channel, value: u64) { self.read_felt_from_prover(value.into()) } -} \ No newline at end of file +} diff --git a/src/queries/queries.cairo b/src/queries/queries.cairo index 099add166..53cc6e2d7 100644 --- a/src/queries/queries.cairo +++ b/src/queries/queries.cairo @@ -37,7 +37,7 @@ fn sample_random_queries( } let res = channel.random_felt_to_prover(); - let low128 = Into::::into(res).low; + let low128 = Into::::into(res).low; let (_, sample) = DivRem::div_rem(low128, query_upper_bound_nonzero); result.append(sample.try_into().unwrap());