-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crypto: Add BLAKE3 hashing algorithm #4366
Conversation
This is a translation of the [official reference implementation][1] with few other changes. The bad news is that the reference implementation is designed for simplicity and not speed, so there's a lot of room for performance improvement. The good news is that, according to the crypto benchmark, the implementation is still fast relative to the other hashing algorithms: ``` md5: 430 MiB/s sha1: 386 MiB/s sha256: 191 MiB/s sha512: 275 MiB/s sha3-256: 233 MiB/s sha3-512: 137 MiB/s blake2s: 464 MiB/s blake2b: 526 MiB/s blake3: 576 MiB/s poly1305: 1479 MiB/s hmac-md5: 653 MiB/s hmac-sha1: 553 MiB/s hmac-sha256: 222 MiB/s x25519: 8685 exchanges/s ``` [1]: https://github.com/BLAKE3-team/BLAKE3
I do not see many cases of constant pointers to arrays in the stdlib. In fact, this makes the code run a little faster, probably because Zig automatically converts to pointers where it makes sense.
Something about my test data is causing Zig to segfault in CI and local non-release builds. The test succeeds if I use a release build from my package manager ( test "BLAKE3 reference test cases" {
for (reference_test.cases) |t| {
_ = t;
}
} |
I've opened #4373 for that problem, you can side-step it by declaring |
Style question: When passing an array into a slice parameter, is it preferable to use |
I've been using |
Nice work! |
I think this algorithm is a great candidate for use in #4311, especially with more potential performance wins. In addition to the simple reference implementation, the BLAKE3 repo also has a super-charged (but more complex) SIMD implementation that could be translated. |
This is a translation of the official reference implementation with few changes. The bad news is that the reference implementation is designed for simplicity and not speed, so there's a lot of room for performance improvement. The good news is that, according to the crypto benchmark, the implementation is still fast relative to the other hashing algorithms: