binius_hash/groestl/
compress.rs

1// Copyright 2024-2025 Irreducible Inc.
2
3use digest::{Digest, Output};
4use groestl_crypto::Groestl256;
5
6use crate::PseudoCompressionFunction;
7
8/// One-way compression function that compresses two 32-byte strings into a single 32-byte string.
9#[derive(Debug, Default, Clone)]
10pub struct Groestl256ByteCompression;
11
12impl PseudoCompressionFunction<Output<Groestl256>, 2> for Groestl256ByteCompression {
13	// TODO: Implement this using just the truncation phase of the P permutation
14	fn compress(&self, input: [Output<Groestl256>; 2]) -> Output<Groestl256> {
15		Groestl256::new()
16			.chain_update(input[0].as_slice())
17			.chain_update(input[1].as_slice())
18			.finalize()
19	}
20}