bmw-hash 0.1.0

Pure Rust implementation of Blue Midnight Wish (BMW-512) hash function
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 25.53 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.35 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • bshuler/bmw-hash
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • bshuler

bmw-hash

Crates.io Documentation License: MIT Build Status

Pure Rust implementation of the Blue Midnight Wish (BMW-512) cryptographic hash function.

BMW-512 is one of the six hash functions in the Quark hash chain used by Divi and other cryptocurrencies. This crate fills the gap as the only Quark component without a pure Rust implementation on crates.io — the other five (BLAKE, Groestl, JH, Keccak, Skein) are all available from RustCrypto.

Features

  • Pure Rust — no C dependencies, no FFI, no unsafe code
  • no_std compatible — works in embedded and WASM environments
  • RustCrypto ecosystem — implements the digest::Digest trait (v0.10)
  • Verified — 13 test vectors validated against the sphlib C reference implementation

Usage

Add to your Cargo.toml:

[dependencies]
bmw-hash = "0.1"

One-shot hashing

use bmw_hash::{Bmw512, Digest};

let hash = Bmw512::digest(b"Hello, World!");
println!("{:x}", hash);

Incremental hashing

use bmw_hash::{Bmw512, Digest};

let mut hasher = Bmw512::new();
hasher.update(b"Hello, ");
hasher.update(b"World!");
let hash = hasher.finalize();

In a Quark hash chain

use bmw_hash::{Bmw512, Digest};
use blake::Blake512;    // from RustCrypto
use groestl::Groestl512;
use jh::Jh512;
use sha3::Keccak512;
use skein::Skein512;

fn quark_hash(data: &[u8]) -> Vec<u8> {
    let h = Blake512::digest(data);
    let h = Bmw512::digest(&h);
    let h = Groestl512::digest(&h);
    let h = Jh512::digest(&h);
    let h = Keccak512::digest(&h);
    let h = Skein512::digest(&h);
    // ... (full Quark chain has 9 rounds with interleaving)
    h.to_vec()
}

Algorithm

BMW (Blue Midnight Wish) was a candidate in the NIST SHA-3 competition. The 512-bit variant operates on 64-bit words with a 128-byte block size and uses the Merkle-Damgard construction with a unique double-compression finalization step.

This implementation is a direct port of the compress_big function from sphlib (MIT license, Thomas Pornin / Projet RNRT SAPHIR).

Reference

License

MIT