tycho_common/
lib.rs

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