tycho_common/
lib.rs

1pub mod display;
2pub mod dto;
3pub mod hex_bytes;
4pub mod models;
5pub mod serde_primitives;
6pub mod simulation;
7pub mod storage;
8pub mod traits;
9
10#[cfg(test)]
11#[macro_use]
12extern crate pretty_assertions;
13
14pub use hex_bytes::Bytes;
15use tiny_keccak::{Hasher, Keccak};
16
17/// Compute the Keccak-256 hash of input bytes.
18///
19/// Note that strings are interpreted as UTF-8 bytes,
20pub fn keccak256<T: AsRef<[u8]>>(bytes: T) -> [u8; 32] {
21    let mut output = [0u8; 32];
22
23    let mut hasher = Keccak::v256();
24    hasher.update(bytes.as_ref());
25    hasher.finalize(&mut output);
26
27    output
28}