binius_hash/groestl/
compression.rs1use digest::Output;
4
5use super::digest::Groestl256;
6use crate::{
7 groestl::{GroestlShortImpl, GroestlShortInternal},
8 PseudoCompressionFunction,
9};
10
11#[derive(Debug, Default, Clone)]
21pub struct Groestl256ByteCompression;
22
23impl PseudoCompressionFunction<Output<Groestl256>, 2> for Groestl256ByteCompression {
24 fn compress(&self, input: [Output<Groestl256>; 2]) -> Output<Groestl256> {
25 let mut state_bytes = [0u8; 64];
26 let (half0, half1) = state_bytes.split_at_mut(32);
27 half0.copy_from_slice(&input[0]);
28 half1.copy_from_slice(&input[1]);
29 let input = GroestlShortImpl::state_from_bytes(&state_bytes);
30 let mut state = input;
31 GroestlShortImpl::p_perm(&mut state);
32 GroestlShortImpl::xor_state(&mut state, &input);
33 state_bytes = GroestlShortImpl::state_to_bytes(&state);
34 *<Output<Groestl256>>::from_slice(&state_bytes[32..])
35 }
36}