[ANN] Digestif 0.4

Hi all,

I’m happy to announce a new release of digestif.0.4, available for installation via OPAM.

Digestif is a library which contains some hashes algorithms like:

  • MD5
  • SHA1
  • SHA224
  • SHA256
  • SHA384
  • SHA512
  • BLAKE2B

And this new release integrate:

  • BLAKE2S
  • RIPEMD160

As the previous release, this library provides 2 implementations. One in C and one in OCaml. You need to link your program/library with digestif.c to get the first one or digestif.ocaml to get the second one (and compile with js_of_ocaml).

This release is well-tested on the advise of @cfcs and we did a little benchmark with core_bench.

For the C implementation:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Name                       β”‚ Time/Run β”‚ mWd/Run β”‚ Percentage β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ sha1 (bigstring:1024)      β”‚   5.39us β”‚  22.00w β”‚     32.49% β”‚
β”‚ sha1 (bytes:1024)          β”‚   5.46us β”‚  17.00w β”‚     32.94% β”‚
β”‚ sha256 (bigstring:1024)    β”‚   8.75us β”‚  22.00w β”‚     52.72% β”‚
β”‚ sha256 (bytes:1024)        β”‚  10.39us β”‚  19.00w β”‚     62.64% β”‚
β”‚ sha512 (bigstring:1024)    β”‚   7.48us β”‚  22.00w β”‚     45.10% β”‚
β”‚ sha512 (bytes:1024)        β”‚   7.11us β”‚  23.00w β”‚     42.87% β”‚
β”‚ ripemd160 (bigstring:1024) β”‚  13.60us β”‚  22.00w β”‚     82.00% β”‚
β”‚ ripemd160 (bytes:1024)     β”‚  16.59us β”‚  17.00w β”‚    100.00% β”‚
β”‚ blake2b (bigstring:1024)   β”‚   4.59us β”‚  22.00w β”‚     27.68% β”‚
β”‚ blake2b (bytes:1024)       β”‚   4.47us β”‚  23.00w β”‚     26.93% β”‚
β”‚ blake2s (bigstring:1024)   β”‚   5.51us β”‚  22.00w β”‚     33.19% β”‚
β”‚ blake2s (bytes:1024)       β”‚   5.60us β”‚  19.00w β”‚     33.75% β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

And the OCaml implementation:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Name                       β”‚ Time/Run β”‚ mWd/Run β”‚ mjWd/Run β”‚ Prom/Run β”‚ Percentage β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ sha1 (bigstring:1024)      β”‚  85.62us β”‚ 17.21kw β”‚   12.82w β”‚   12.82w β”‚     52.31% β”‚
β”‚ sha1 (bytes:1024)          β”‚  86.27us β”‚ 17.16kw β”‚   12.91w β”‚   12.91w β”‚     52.70% β”‚
β”‚ sha256 (bigstring:1024)    β”‚ 163.68us β”‚ 29.84kw β”‚   43.93w β”‚   43.93w β”‚    100.00% β”‚
β”‚ sha256 (bytes:1024)        β”‚ 138.79us β”‚ 29.80kw β”‚   45.09w β”‚   45.09w β”‚     84.79% β”‚
β”‚ sha512 (bigstring:1024)    β”‚  71.31us β”‚ 19.89kw β”‚   33.58w β”‚   33.58w β”‚     43.57% β”‚
β”‚ sha512 (bytes:1024)        β”‚  72.74us β”‚ 19.86kw β”‚   31.70w β”‚   31.70w β”‚     44.44% β”‚
β”‚ ripemd160 (bigstring:1024) β”‚ 121.48us β”‚ 26.25kw β”‚   18.14w β”‚   18.14w β”‚     74.22% β”‚
β”‚ ripemd160 (bytes:1024)     β”‚ 118.38us β”‚ 26.22kw β”‚   18.55w β”‚   18.55w β”‚     72.32% β”‚
β”‚ blake2b (bigstring:1024)   β”‚  77.51us β”‚ 19.72kw β”‚   20.17w β”‚   20.17w β”‚     47.35% β”‚
β”‚ blake2b (bytes:1024)       β”‚  68.31us β”‚ 19.69kw β”‚   21.23w β”‚   21.23w β”‚     41.73% β”‚
β”‚ blake2s (bigstring:1024)   β”‚ 145.73us β”‚ 33.06kw β”‚   34.12w β”‚   34.12w β”‚     89.03% β”‚
β”‚ blake2s (bytes:1024)       β”‚ 150.63us β”‚ 33.01kw β”‚   34.48w β”‚   34.48w β”‚     92.03% β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

As my previous announcement, if you want a specific hash algorithm, you can ask to the issue tracker.

9 Likes

This is great, thanks for doing some performance statistics. They would be more informative if you would compare them to other implementations – OpenSSL, (ocaml-)sha, nocrypto and cryptokit come to mind.

About nocrypto and ocaml-sha, because digestif comes from these implementations (exactly the same code), the result should be the same :slight_smile: ! However, it could be interesting to compare with cryptokit and openssl indeed.

But the functorized memory layout could make a difference - I think it would still be interesting to see what effects that has on performance :slight_smile: