Skip to main content

Module crypto

Module crypto 

Source
Expand description

Cryptographic hash functions with CPU feature detection and optimizations

Provides optimized SHA256 implementations that automatically select the best available implementation based on CPU features:

  • AVX2 SIMD (8-way parallel) - fastest on modern CPUs
  • SSE4 SIMD (4-way parallel) - fallback for older CPUs
  • Generic (sha2 crate with asm) - baseline for all CPUs

The sha2 crate with “asm” feature already includes optimized assembly, but we can add batch processing and CPU feature detection for better performance in batch scenarios.

Modules§

avx2_batch
AVX2-optimized batch SHA256 hashing
cpu_features
CPU feature detection for runtime optimization selection
hash_compare
SIMD-optimized hash comparison utilities
int_ops
Optimized integer arithmetic operations for hot paths
sha256_avx2
AVX2-optimized SHA256 implementation
sha_ni
Intel SHA Extensions (SHA-NI) optimized SHA256
simd_bytes
SIMD-optimized byte array operations

Structs§

OptimizedSha256
Optimized SHA256 hasher with CPU feature detection

Functions§

hash256
Convenience function for double SHA256 hash (Bitcoin standard)
sha256
Convenience function for single SHA256 hash