Skip to main content

Module utils

Module utils 

Source
Expand description

§Utility Modules

Supporting utilities for cryptography, compression, logging, and timing.

This module provides reusable utilities used throughout the protocol implementation.

§Components

  • Crypto: ChaCha20-Poly1305 AEAD encryption
  • Compression: LZ4 and Zstd with size limits and adaptive entropy-based selection
  • Logging: Structured logging configuration
  • Time: Timestamp utilities for timeout and expiry checks
  • Timeout: Async timeout wrappers
  • Replay Cache: TTL-based nonce deduplication for replay attack prevention
  • Metrics: Thread-safe observability counters
  • Buffer Pool: Object pooling for small buffer allocations (<4KB)

§Security

  • Cryptographically secure RNG (getrandom)
  • Decompression bomb protection (16MB limit)
  • Memory zeroing for sensitive data (zeroize crate)

§Performance

  • Buffer pooling reduces allocation overhead by 3-5%
  • Adaptive compression reduces CPU usage by 10-15% for mixed workloads

Re-exports§

pub use buffer_pool::BufferPool;
pub use replay_cache::CacheKey;
pub use replay_cache::ReplayCache;

Modules§

buffer_pool
Buffer Pool
compression
crypto
logging
metrics
Observability and Metrics
replay_cache
Replay Cache for Enhanced Replay Attack Protection
time
timeout