pub fn clockhash256_domain(domain: &[u8], data: &[u8]) -> [u8; 32]Expand description
Compute ClockHash-256 with custom domain separation.
This function provides domain separation by prepending the domain identifier followed by a null byte separator before hashing the actual data. This ensures that identical data produces different hashes when used in different domains, preventing cross-domain collision attacks.
§Arguments
domain- Custom domain identifier bytes (must be consistent for the same domain)data- The data to hash
§Returns
A 32-byte array containing the domain-separated ClockHash-256 hash
§Examples
Using custom domain tags:
let data = b"some data";
let domain1 = b"MY-APP-V1";
let domain2 = b"MY-APP-V2";
let hash1 = clockhash256_domain(domain1, data);
let hash2 = clockhash256_domain(domain2, data);
assert_ne!(hash1, hash2); // Different domains = different hashesCustom domain vs no domain:
let data = b"test";
let custom_hash = clockhash256_domain(b"CUSTOM", data);
let plain_hash = clockhash256(data);
assert_ne!(custom_hash, plain_hash); // Domain separation works§Security Notes
- Domain identifiers should be unique and consistent within your application
- Never use the same domain for different purposes
- Domain separation is critical for maintaining hash function security properties