#hash #digest #bitcoin #sha-256 #cryptography #crypto

no-std chf

Cryptographic hash functions used by rust-bitcoin

5 unstable releases

0.3.1 Sep 4, 2024
0.3.0 May 14, 2024
0.2.1 May 14, 2024
0.2.0 May 14, 2024
0.1.0 May 2, 2024

#77 in #sha-256

CC0 license

190KB
4K SLoC

This was an exploratory crate that turned out not to be useful, the repository is being archived and this crate should not be used

If you would like to use the crate name, reach out to me.

Rust Cryptographic Hash Functions.

This is a simple, minimal-dependency library which implements the bunch of crypotographic hash functions. At the moment this includes:

  • SHA-1
  • SHA-2
    • SHA-256
    • SHA-384
    • SHA-512
    • SHA-512/256
  • RIPEMD-160
  • SipHash-2-4
  • HMAC-x (where x is any of the hash functions above).
  • Domain separation using tagged SHA-256.

Relation to bitcoin_hashes

This crate was extracted out of bitcoin_hashes. As shown in the initial commit:

commit 05a2955470864919172b66feb7b70ebb81d5ec51
Author: Tobin C. Harding <me@tobin.cc>
Date:   Mon Apr 29 04:52:27 2024 +1000

    Import hashes from rust-bitcoin

    Copy the `hashes` directory directly from
    `github.com/rust-bitcoin/rust-bitcoin/hashes` at the tip of the 0.32.0
    tagged release: commit `a3f766715eabf008e0d7f2bfdf2ce7a86e9d2f9b`.

    No other changes.

In the manifest the original author was left as is and no additional authors were added made because I mealy took the code and removed stuff.

Minimum Supported Rust Version (MSRV)

This library should always compile with any combination of features on Rust 1.56.1.

Contributions

Contributions are welcome, including additional hash function implementations.

Githooks

To assist devs in catching errors before running CI we provide some githooks. If you do not already have locally configured githooks you can use the ones in this repository by running, in the root directory of the repository:

git config --local core.hooksPath githooks/

Alternatively add symlinks in your .git/hooks directory to any of the githooks we provide.

Running Benchmarks

We use a custom Rust compiler configuration conditional to guard the bench mark code. To run the bench marks use: RUSTFLAGS='--cfg=bench' cargo +nightly bench.

Dependencies

~145–490KB
~10K SLoC