libsodium-bindings icon indicating copy to clipboard operation
libsodium-bindings copied to clipboard

Better UX for constant output function for Sel.Hashing

Open Kleidukos opened this issue 2 years ago • 5 comments

Sel.Hashing uses a Maybe HashKey parameter to hashByteString. However this is not fantastic in terms of readability.

I'd like to avoid Maybe-blindness by having a sum type like data KeyParma = Key <hashkey> | NoKey (or Constant).

Kleidukos avatar Aug 31 '23 17:08 Kleidukos

@divarvel @kozross @a-02 your input would be appreciated. :)

Kleidukos avatar Aug 31 '23 17:08 Kleidukos

I'm OK either way: I don't really feel this is confusing or less readable.

kozross avatar Aug 31 '23 21:08 kozross

Key / NoKey does not improve readability compared to Maybe Key imo. Is there a canonical name for when the operation is ran without a key? (eg deterministic or something). Using this name in a sum type could make things clearer.

Also, if the presence/ absence of key changes semantics too much, then maybe two functions would work better by not conflating different operations.

That being said:

  • I haven't use these operations so I might be off the mark
  • I think Maybe is okay anyway, I understand it's a matter of making things better, but the existing state of things is not horrible either.

divarvel avatar Sep 03 '23 21:09 divarvel

@divarvel Well, the change of semantics is "same input gives same output", which makes sense when one has been diving into this kind of API for a while. Not sure about outsiders though.

Kleidukos avatar Sep 03 '23 21:09 Kleidukos

It appears that the Blake2 paper uses "Keyed"

Kleidukos avatar Sep 03 '23 22:09 Kleidukos