Overview
Blake3Hasher is the built-in hash function for RotorTree, providing a high-performance implementation of the BLAKE3 cryptographic hash algorithm.
BLAKE3 is:
- Fast - Faster than MD5, SHA-1, SHA-2, and SHA-3
- Secure - Cryptographically strong with 256-bit security
- Parallelizable - Leverages SIMD instructions
- Standardized - Based on the BLAKE family of hash functions
Type Definition
Construction
new
Create a new BLAKE3 hasher instance.A new BLAKE3 hasher
default
Alternatively, use theDefault trait:
Hasher Implementation
Blake3Hasher implements the Hasher trait:
Associated Type
Uses the
blake3 crate’s streaming hasher as the state typeHashState Implementation
Theblake3::Hasher type implements HashState:
Usage Examples
Basic Hashing
Streaming Data
With TreeHasher
In a Tree
Performance Characteristics
BLAKE3 provides:- Throughput: Up to 10+ GB/s on modern CPUs
- SIMD: Uses AVX-512, AVX2, or SSE4.1 when available
- Small inputs: Optimized for both small and large data
- Zero-copy: Minimal allocations
Security Properties
- Collision resistance: 256-bit security
- Preimage resistance: 256-bit security
- Second preimage resistance: 256-bit security
- Length extension safe: Not vulnerable to length extension attacks
Trait Implementations
Blake3Hasher implements:
Clone- Zero-cost copyCopy- Can be copied implicitlyDebug- Debug formattingDefault- Default constructionHasher- Core hash traitSend- Thread-safe to sendSync- Thread-safe to share
Comparison with Other Hashers
SHA-256
Slower but more widely standardized. BLAKE3 is ~3-4x faster.
SHA-3
Similar security, but BLAKE3 is significantly faster.
xxHash
Faster but non-cryptographic. Use BLAKE3 when security matters.
MD5/SHA-1
Broken and insecure. Never use for new applications.
When to Use BLAKE3
UseBlake3Hasher when you need:
- Cryptographic security guarantees
- High performance
- Merkle tree integrity
- Content addressing
- Digital signatures
Implementing Custom Hashers
If BLAKE3 doesn’t meet your needs, you can implement a custom hasher:Related Types
Hasher
Core hash trait interface
TreeHasher
Domain-separated wrapper for trees
Dependencies
BLAKE3 support requires theblake3 crate:
