p3_baby_bear/aarch64_neon/
poseidon2.rs#[cfg(test)]
mod tests {
use p3_field::FieldAlgebra;
use p3_symmetric::Permutation;
use rand::Rng;
use crate::{BabyBear, PackedBabyBearNeon, Poseidon2BabyBear};
type F = BabyBear;
type Perm16 = Poseidon2BabyBear<16>;
type Perm24 = Poseidon2BabyBear<24>;
#[test]
fn test_neon_poseidon2_width_16() {
let mut rng = rand::thread_rng();
let poseidon2 = Perm16::new_from_rng_128(&mut rng);
let input: [F; 16] = rng.gen();
let mut expected = input;
poseidon2.permute_mut(&mut expected);
let mut neon_input = input.map(PackedBabyBearNeon::from_f);
poseidon2.permute_mut(&mut neon_input);
let neon_output = neon_input.map(|x| x.0[0]);
assert_eq!(neon_output, expected);
}
#[test]
fn test_neon_poseidon2_width_24() {
let mut rng = rand::thread_rng();
let poseidon2 = Perm24::new_from_rng_128(&mut rng);
let input: [F; 24] = rng.gen();
let mut expected = input;
poseidon2.permute_mut(&mut expected);
let mut neon_input = input.map(PackedBabyBearNeon::from_f);
poseidon2.permute_mut(&mut neon_input);
let neon_output = neon_input.map(|x| x.0[0]);
assert_eq!(neon_output, expected);
}
}