lblake3
The BLAKE3 hash function in pure Rust: no C, no assembly files and no inline asm in the build, and no dependency that has any.
lblake3 is the blake3 crate, version 1.8.7, with its C and assembly parts taken out. The public API is the same, so a caller switches with one line:
[dependencies]
blake3 = { package = "lblake3", version = "0.3.0" }
What differs from blake3 1.8.7
| blake3 1.8.7 (default build) | lblake3 | |
| x86 SSE2, SSE4.1, AVX2 | assembly (c/*.S) |
Rust intrinsics (blake3's own rust_*.rs) |
| x86_64 AVX-512 | assembly, or C intrinsics | Rust intrinsics (src/rust_avx512.rs) |
| AArch64 NEON | C intrinsics (c/blake3_neon.c) |
Rust intrinsics (src/rust_neon.rs) |
| x86 feature detection | cpufeatures crate |
CPUID/XGETBV through core::arch, in platform.rs |
constant-time Hash equality |
constant_time_eq (has inline asm) |
subtle |
rayon feature |
yes | left out; feature gatling (off by default) hashes on N threads instead |
| build dependency | cc |
none |
The features pure and prefer_intrinsics are accepted and change nothing. On 32-bit ARM the neon feature is accepted, but the build stays portable, since Rust's 32-bit ARM NEON intrinsics are not stable. Rust 1.89 or newer is needed (AVX-512 intrinsics).
Tests
src/test.rs from blake3 checks every SIMD path against the portable code and the reference implementation; the AVX-512 and NEON paths are part of it. tests/test_vectors.rs runs the official test vectors.
Credit and license
All of the algorithm work is BLAKE3's, by Jack O'Connor, Samuel Neves, Jean-Philippe Aumasson and Zooko, and the Rust implementation is the BLAKE3 team's blake3 crate. The AVX-512 module starts from the open BLAKE3 pull request #566, "Add Rust AVX-512 intrinsics implementation", by Nazar Mokrynskyi. The NEON module is a translation of BLAKE3's c/blake3_neon.c. src/reference_impl.rs and tests/test_vectors.json are BLAKE3's.
Licensed like BLAKE3, under any of CC0-1.0, Apache-2.0, or Apache-2.0 WITH LLVM-exception (LICENSE_CC0, LICENSE_A2, LICENSE_A2LLVM).