digestif
digestif copied to clipboard
Implement personalisation for Blake2
I forked the Blake2 OCaml implementation to add the personalisation, with some tests from Zcash, see https://gitlab.com/dannywillems/ocaml-ec/-/merge_requests/18, directory src/digestif. I am happy to make an MR, but a discussion for the interface is necessary. The fork in ocaml-ec changes it slightly and only uses blake2.
Which parameters you want to personalize in BLAKE2? The interface currently allows to personalize the length of the hash: https://github.com/mirage/digestif/blob/891907675ead09b5e1c5de28c24246a0e411a546/src/digestif.mli#L232-L238
I'm aware about some others parameters but I need to know which one you want to change. digestif
shares the same interface for the C implementation and the OCaml implementation, we must implement what you want for both. This is the first constraint, the second constraint is the common interface module type S
for any hashes implementations.
From what I see, you want to add a new argument for the init
function. I would like to say that the best is to provide a special new function init_with_iv
or something like that and provide it here:
https://github.com/mirage/digestif/blob/891907675ead09b5e1c5de28c24246a0e411a546/src/digestif.mli#L218-L228
The personalisation I implemented is the parameter personal
, see https://github.com/mirage/digestif/blob/master/src-ocaml/baijiu_blake2s.ml#L88. It might be better to allow also adding a salt (see https://github.com/mirage/digestif/blob/master/src-ocaml/baijiu_blake2s.ml#L87).
I have just finished splitting the fork of Digestif I used. The commit you might be interested in is https://gitlab.com/dannywillems/ocaml-ec/-/merge_requests/18/diffs?commit_id=389f457d567de58fccbea738a5259d164ebcf80f.
(it might be a bit ugly, but as it is not going to be exposed in the library ocaml-ec, that's fine).
As I said, an other init
function with personalization should be fine for me 👍 . So if you want to propose something like that, I will happy to review and merge.