macula_blake3_nif (macula v1.4.24)
View SourceBLAKE3 hashing with NIF acceleration and Erlang fallback.
This module provides BLAKE3 cryptographic hashing with automatic fallback to a pure Erlang implementation when NIFs are not available.
BLAKE3 is the primary hash algorithm for Macula content-addressed storage due to its speed (faster than SHA-256) and security.
Performance
The NIF implementation (via Rust blake3 crate) is approximately 10-20x faster than the pure Erlang fallback, especially for large inputs.
Usage
%% Hash binary data
Hash = macula_blake3_nif:hash(Data).
%% Hash multiple chunks (streaming)
Hash = macula_blake3_nif:hash_streaming([Chunk1, Chunk2, Chunk3]).
%% Verify a hash
true = macula_blake3_nif:verify(Data, ExpectedHash).
%% Get hex-encoded hash
HexHash = macula_blake3_nif:hash_hex(Data).
Summary
Functions
Hash binary data using BLAKE3. Returns a 32-byte hash.
Hash binary data and return hex-encoded string.
Hash multiple chunks using BLAKE3. Streaming hash - processes chunks without concatenating them.
Check if NIF is loaded.
Verify that data matches an expected BLAKE3 hash.
Functions
Hash binary data using BLAKE3. Returns a 32-byte hash.
Hash binary data and return hex-encoded string.
Hash multiple chunks using BLAKE3. Streaming hash - processes chunks without concatenating them.
-spec is_nif_loaded() -> boolean().
Check if NIF is loaded.
Verify that data matches an expected BLAKE3 hash.