Skip to main content

binius_circuits/blake2b/
mod.rs

1// Copyright 2025 Irreducible Inc.
2pub mod circuit;
3pub mod constants;
4pub mod reference;
5
6#[cfg(test)]
7mod tests;
8
9pub use circuit::Blake2bCircuit;
10pub use constants::*;
11pub use reference::blake2b;
12
13/// Shared test utilities for BLAKE2b testing
14#[cfg(test)]
15pub mod test_constants {
16	use blake2::{Blake2b512, Digest};
17
18	/// Generate ground truth hash using the standard blake2 crate
19	pub fn ground_truth_blake2b(input: &[u8]) -> [u8; 64] {
20		let mut hasher = Blake2b512::new();
21		hasher.update(input);
22		hasher.finalize().into()
23	}
24
25	/// Convert bytes to hex string
26	pub fn hex_string(bytes: &[u8]) -> String {
27		bytes
28			.iter()
29			.map(|b| format!("{:02x}", b))
30			.collect::<String>()
31	}
32}