pub enum DomainTag {
Block,
Transaction,
Merkle,
Nonce,
Rng,
}Expand description
Type-safe domain tag enumeration for ClockinChain use cases
DomainTag provides compile-time type safety for domain separation.
Each variant corresponds to a specific use case and maps to the
appropriate domain tag bytes. This prevents typos and ensures
consistent domain usage across the codebase.
§Examples
Using with typed domains:
use clock_hash::{clockhash256_with_domain, DomainTag};
let block_data = b"block header data";
let tx_data = b"transaction data";
let block_hash = clockhash256_with_domain(DomainTag::Block, block_data);
let tx_hash = clockhash256_with_domain(DomainTag::Transaction, tx_data);
assert_ne!(block_hash, tx_hash); // Guaranteed to be differentConverting to bytes:
let tag = DomainTag::Merkle;
let bytes = tag.as_bytes();
assert_eq!(bytes, b"CLK-MERKLE");Variants§
Block
Block header hashing domain
For hashing complete block headers in the blockchain
Transaction
Transaction identifier domain
For computing unique transaction IDs
Merkle
Merkle tree construction domain
For building Merkle trees and computing merkle roots
Nonce
Signature nonce derivation domain
For deterministic nonce generation in signatures
Rng
Deterministic RNG seeding domain
For seeding cryptographic random number generators
Implementations§
Trait Implementations§
impl Copy for DomainTag
impl Eq for DomainTag
impl StructuralPartialEq for DomainTag
Auto Trait Implementations§
impl Freeze for DomainTag
impl RefUnwindSafe for DomainTag
impl Send for DomainTag
impl Sync for DomainTag
impl Unpin for DomainTag
impl UnwindSafe for DomainTag
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more