[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

And this new release integrate:

  • 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.


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: