#blake2s #hashing #simd #hash #data #performance #dynamic

no-std blake2s_const

a pure Rust BLAKE2s implementation with dynamic SIMD

2 unstable releases

0.8.0 Jul 5, 2024
0.7.0 Jul 5, 2024

#120 in Profiling

Download history 15191/week @ 2024-07-26 9030/week @ 2024-08-02 8752/week @ 2024-08-09 13897/week @ 2024-08-16 20220/week @ 2024-08-23 22403/week @ 2024-08-30 15718/week @ 2024-09-06 581/week @ 2024-09-13 155/week @ 2024-09-20 158/week @ 2024-09-27 204/week @ 2024-10-04 201/week @ 2024-10-11 445/week @ 2024-10-18 168/week @ 2024-10-25 165/week @ 2024-11-01 135/week @ 2024-11-08

971 downloads per month
Used in bellman_ce

MIT license

150KB
3.5K SLoC

blake2s_simd GitHub crates.io Build Status

An implementation of the BLAKE2s and BLAKE2sp hash functions. See also blake2b_simd.

This crate includes:

  • 100% stable Rust.
  • SIMD implementations based on Samuel Neves' blake2-avx2. These are very fast. For benchmarks, see the Performance section of the README.
  • Portable, safe implementations for other platforms.
  • Dynamic CPU feature detection. Binaries include multiple implementations by default and choose the fastest one the processor supports at runtime.
  • All the features from the the BLAKE2 spec, like adjustable length, keying, and associated data for tree hashing.
  • no_std support. The std Cargo feature is on by default, for CPU feature detection and for implementing std::io::Write.
  • Support for computing multiple BLAKE2s hashes in parallel, matching the efficiency of BLAKE2sp. See the many module.

Example

use blake2s_simd::{blake2s, Params};

let expected = "08d6cad88075de8f192db097573d0e829411cd91eb6ec65e8fc16c017edfdb74";
let hash = blake2s(b"foo");
assert_eq!(expected, &hash.to_hex());

let hash = Params::new()
    .hash_length(16)
    .key(b"Squeamish Ossifrage")
    .personal(b"Shaftoe")
    .to_state()
    .update(b"foo")
    .update(b"bar")
    .update(b"baz")
    .finalize();
assert_eq!("28325512782cbf5019424fa65da9a6c7", &hash.to_hex());

Dependencies

~110KB