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