Overview
The BLAKE3 inline provides an optimized implementation of the BLAKE3 hash function with 256-bit output. BLAKE3 is significantly faster than BLAKE2, SHA-1, SHA-2, and SHA-3 while maintaining security. The current implementation is optimized for inputs up to 64 bytes (single block).API Reference
Blake3
Main hasher struct supporting both streaming and one-shot hashing.
Methods
new() -> Self
Creates a new BLAKE3 hasher.
update(&mut self, input: &[u8])
Writes data to the hasher incrementally. Panics if total input exceeds 64 bytes.
finalize(self) -> [u8; 32]
Finalizes the hash and returns the 32-byte digest.
digest(input: &[u8]) -> [u8; 32]
Computes BLAKE3 hash in one call. Input must be ≤64 bytes.
AlignedHash32
8-byte aligned 32-byte hash/key type for efficient operations.
Methods
blake3_keyed64()
BLAKE3 keyed hash for 64-byte inputs (Merkle tree optimization).
blake3::keyed_hash(key, left || right) but optimized for when left and right are in separate memory locations.
Usage Examples
Basic Hashing (≤64 bytes)
Merkle Tree Parent Node
Streaming API (≤64 bytes total)
Implementation Details
Compression Function
BLAKE3 uses a ChaCha-like compression function:- State: 8 × 32-bit words (256 bits)
- Message block: 16 × 32-bit words (512 bits)
- Counter: 2 × 32-bit words (64 bits)
- Flags: 1 × 32-bit word (32 bits)
- Rounds: 7 rounds
Custom Instructions
BLAKE3_COMPRESS(funct3=0x00, funct7=0x03): Standard compressionBLAKE3_KEYED64(funct3=0x01, funct7=0x03): Keyed 64-byte hash for Merkle trees
BLAKE3 Flags
Initialization Vector
Message Scheduling
Constants
Input Size Limitation
The current implementation only supports inputs up to 64 bytes (single block):- Merkle tree nodes (2 × 32-byte hashes)
- Small messages
- Hash-based signatures
Performance Characteristics
- Block size: 64 bytes per compression
- Output size: 32 bytes (256 bits)
- Speed: Fastest among all hash inlines
- Optimization: Specialized
blake3_keyed64()for Merkle trees
Alignment Requirements
TheAlignedHash32 type ensures 8-byte alignment for efficient 64-bit load/store operations:
Feature Flags
host: Enables reference implementation for host-side execution- Guest code: Compile WITHOUT this feature
- Prover code: Compile WITH this feature
Comparison with Standard Implementation
When compared to the officialblake3 crate:
- Cycle count: ~10-50x reduction for single-block inputs
- Proving time: Proportionally faster proof generation
- Compatibility: Identical output to
blake3::hash()
Source Code Location
See Also
- BLAKE2 - Previous generation BLAKE hash
- SHA-256 - SHA-2 hash function
- Keccak-256 - SHA-3 hash function
- Inlines Overview - General information about cryptographic inlines