binius_hash/
compression.rs

1// Copyright 2024-2025 Irreducible Inc.
2// Copyright (c) 2024 The Plonky3 Authors
3
4//! These interfaces are taken from [p3_symmetric](https://github.com/Plonky3/Plonky3/blob/main/symmetric/src/compression.rs) in [Plonky3].
5//!
6//! [Plonky3]: <https://github.com/plonky3/plonky3>
7
8/// An `N`-to-1 compression function collision-resistant in a hash tree setting.
9///
10/// Unlike `CompressionFunction`, it may not be collision-resistant in general.
11/// Instead it is only collision-resistant in hash-tree like settings where
12/// the preimage of a non-leaf node must consist of compression outputs.
13pub trait PseudoCompressionFunction<T, const N: usize>: Clone {
14	fn compress(&self, input: [T; N]) -> T;
15}
16
17/// An `N`-to-1 compression function.
18pub trait CompressionFunction<T, const N: usize>: PseudoCompressionFunction<T, N> {}