diff --git a/src/air/public_input.cairo b/src/air/public_input.cairo index 185498ac0..644db2df9 100644 --- a/src/air/public_input.cairo +++ b/src/air/public_input.cairo @@ -244,8 +244,9 @@ fn verify_cairo1_public_input(public_input: @PublicInput) -> (felt252, felt252) (program_hash, output_hash) } + +#[cfg(feature: 'stone5')] #[cfg(feature: 'recursive')] -#[cfg(feature: 'keccak')] #[cfg(test)] mod tests { use super::get_public_input_hash; @@ -254,9 +255,9 @@ mod tests { #[available_gas(9999999999)] fn test_get_public_input_hash() { let public_input = get(); - let hash = get_public_input_hash(@public_input); + let hash = get_public_input_hash(@public_input, 0); assert( - hash == 0xaf91f2c71f4a594b1575d258ce82464475c82d8fb244142d0db450491c1b52, 'Hash invalid' + hash == 0x1c3097c2a1665c78d69edc47ff35a3f3c9c0678e3daaa74d2b68331a5757a37, 'Hash invalid' ) } } diff --git a/src/common/hasher.cairo b/src/common/hasher.cairo index 69dd0c668..7c2acb2df 100644 --- a/src/common/hasher.cairo +++ b/src/common/hasher.cairo @@ -13,7 +13,7 @@ fn hash_n_bytes(mut data: Array, n: u8, hash_len: bool) -> u256 { #[cfg(feature: 'blake2s_160_lsb')] fn hash_truncated(data: Array) -> felt252 { (blake2s(data).flip_endianness() - & 0x0000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) + & 0x000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) .try_into() .unwrap() } diff --git a/src/common/tests/test_blake2s.cairo b/src/common/tests/test_blake2s.cairo index 18f9cbac6..2eeb0c769 100644 --- a/src/common/tests/test_blake2s.cairo +++ b/src/common/tests/test_blake2s.cairo @@ -1,5 +1,5 @@ use cairo_verifier::common::{ - array_append::ArrayAppendTrait, blake2s::{blake2s, truncated_blake2s}, blake2s_u8::load32, + array_append::ArrayAppendTrait, blake2s::blake2s, hasher::hash_truncated, blake2s_u8::load32, }; fn get_arr_v1(n: u32) -> Array { @@ -84,14 +84,24 @@ fn test_blake2s_v2() { ); } +#[cfg(feature: 'blake2s_160_lsb')] #[test] #[available_gas(9999999999)] -fn test_truncated_blake2s() { +fn test_blake2s_160_lsb() { let mut data = ArrayTrait::::new(); - data.append_big_endian(1157029198022238202306346125123666191662554108005_u256); - data.append_big_endian(129252051435949032402481343903845417193011527432_u256); assert( - truncated_blake2s(data) == 642191007116032514313255519742888271333651019057, - 'invalid truncated_blake2s' + hash_truncated(data) == 0x00000000000000000000000042354a7c1f55b6482ca1a51e1b250dfd1ed0eef9, + 'invalid value' ); } + +#[cfg(feature: 'blake2s_248_lsb')] +#[test] +#[available_gas(9999999999)] +fn test_blake2s_248_lsb() { + let mut data = ArrayTrait::::new(); + assert( + hash_truncated(data) == 0x00217a3079908094e11121d042354a7c1f55b6482ca1a51e1b250dfd1ed0eef9, + 'invalid value' + ); +} \ No newline at end of file