[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: