Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement personalisation for Blake2 #111

Open
dannywillems opened this issue May 7, 2021 · 3 comments
Open

Implement personalisation for Blake2 #111

dannywillems opened this issue May 7, 2021 · 3 comments

Comments

@dannywillems
Copy link

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.

@dinosaure
Copy link
Member

Which parameters you want to personalize in BLAKE2? The interface currently allows to personalize the length of the hash:

digestif/src/digestif.mli

Lines 232 to 238 in 8919076

module Make_BLAKE2B (D : sig
val digest_size : int
end) : S
module Make_BLAKE2S (D : sig
val digest_size : int
end) : S

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:

digestif/src/digestif.mli

Lines 218 to 228 in 8919076

module BLAKE2B : sig
include S
module Keyed : MAC with type t = t
end
module BLAKE2S : sig
include S
module Keyed : MAC with type t = t
end

@dannywillems
Copy link
Author

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

@dinosaure
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants