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

SipHash Constructors #4

Open
daskol opened this issue Nov 15, 2018 · 1 comment
Open

SipHash Constructors #4

daskol opened this issue Nov 15, 2018 · 1 comment

Comments

@daskol
Copy link

daskol commented Nov 15, 2018

Constructors of SipHash (New64() and New128()) are inconsistent with ad hoc routines (Sum64() and Sum128()). Parameter key is specified as either fixed size array or slice. It would be greate use slice in all cases. Moreover, I think that key representation as byte slice is not very convenient. Perhaps two uint64 numbers would be better.

func New64(k0, k1 uint64) {} // instead of
func New64(k []byte) {}
@aead
Copy link
Owner

aead commented Nov 15, 2018

The reason for using an array type for Sum64() / Sum128 is that these functions should not return an error in case of invalid key length. However, I agree that it looks a bit odd from a user perspective.

It would be greate use slice in all cases.

That would force either panic'ing in case of invalid key length or returning an error for all functions.
Neither approach is ideal IMO. Actually a New64(key *[16]byte) hash.Hash { ... } would enforce a well-formed key through the type-system.

Moreover, I think that key representation as byte slice is not very convenient.

Can you explain why this should be inconvenient. Keys are usually passed as bit/byte string. For example: how would k0, k1 correspond to a byte string? - little/big endian, is the MSB in k0 or in k1, ...?!

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

No branches or pull requests

2 participants