mirage / digestif

Simple hash algorithms in OCaml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Better GADT

dinosaure opened this issue · comments

Currently, the GADT defined by digestif is not quite so good when it's not possible to write something like:

val decode : 'hash Digestif.t -> ... -> 'hash t

The definition of the GADT should be:

type _ hash =
  | SHA1 : SHA1.t hash
  | BLAKE2B : BLAKE2B.t hash
  | ...

instead to rely on a polymorphic variant (eg. [ SHA1 | BLAKE2B | ... ]). The old design comes from the special case about BLAKE2{B,S} where the length of the hash can be a parameter. So a BLAKE2B 64 should be different to a BLAKE2B 128 for example. I think it's better to reduce (and be less expressive) possibilities about BLAKE2{B,S} (and stay on default values) over our GADT - then, if someone wants to configure length of the hash, he can but outside the use of the GADT.

This issue should remove this old code.