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

proposal: x/crypto/blake2b: support arbitrary length digests #22751

Closed
xyziemba opened this issue Nov 15, 2017 · 7 comments
Closed

proposal: x/crypto/blake2b: support arbitrary length digests #22751

xyziemba opened this issue Nov 15, 2017 · 7 comments

Comments

@xyziemba
Copy link

Blake2b supports digests between 1-64 bytes, but the blake2b library only exposes three of the standard digest sizes. Ideally, the library would support an arbitrary digest size between 1 and 64.

It looks like the logic is already there in the newDigest function. It's just a matter of exposing it.

@gopherbot gopherbot added this to the Proposal milestone Nov 15, 2017
@aead
Copy link
Contributor

aead commented Dec 7, 2017

The problem is that users may use too short hash values. The package tries to achieve a security level of at least 128 bit. See also RFC 7693

However I'm currently working on #19896 which requires arbitrary digest sizes.
In general I would recommend the XOF (blake2x) construction if arbitrary digest sizes are required.

@xyziemba
Copy link
Author

xyziemba commented Dec 7, 2017

The package tries to achieve a security level of at least 128 bit. See also RFC 7693

Ah! That's why you didn't include id-blake2b160.

In general I would recommend the XOF (blake2x) construction if arbitrary digest sizes are required.

Agreed. For a little context here: I was writing a golang implementation of libsodium's sealed box. It's the same as NaCl's sealed box except it specifies the creation of the nonce as 24-byte-blake2b-mac(pubkey1 CONCAT pubkey2).

@aead
Copy link
Contributor

aead commented Dec 7, 2017

Ah! That's why you didn't include id-blake2b160.

Correct -However it's still available here.

Agreed. For a little context here: I was writing a golang implementation of libsodium's sealed box. It's the same as NaCl's sealed box except it specifies the creation of the nonce as 24-byte-blake2b-mac(pubkey1 CONCAT pubkey2).

That sounds like a use case for a XOF like BLAKE2x, SHA3 / SHAKE or Kangaroo 12.

@sporkmonger
Copy link

Too-short hash values may have legitimate use-cases, like birthday paradox proof-of-work where hash collisions are what you're trying to find, e.g. equihash. If you're aiming for a very short proof-of-work period, you need a very short hash. The XOF doc says "Note that an ℓ smaller or equal than 64 is acceptable, there’s just no reason to use it since BLAKE2b already provides hashes of 64 bytes or less". From that comment, it seems to me that arbitrary length BLAKE2b was intended.

@aead
Copy link
Contributor

aead commented Dec 16, 2017

@sporkmonger
I'm not saying there are no use cases for short hash values - like 64 bit. There are many applications for example preventing hash-flooding attacks. However a collision based proof-of-work could be implemented by truncating a larger hash or just considering only a specific number of bits - that would make the difficulty adjustable...

The XOF doc says "Note that an ℓ smaller or equal than 64 is acceptable, there’s just no reason to use it since BLAKE2b already provides hashes of 64 bytes or less". From that comment, it seems to me that arbitrary length BLAKE2b was intended.

Sure, the problem is that users may use a too short hash to achieve collision resistance. However the BLAKE2b package will support arbitrary hash sizes because of Argon2.

@aead
Copy link
Contributor

aead commented Dec 18, 2017

Fixed by #19896 - Can be closed.

@xyziemba
Copy link
Author

Thanks!

xyziemba added a commit to xyziemba/sodiumbox that referenced this issue Jan 17, 2018
Upstream blake2b has been updated to allow arbitrary digest sizes. My
private copy is no longer needed.

See golang/go#22751 for more info.
@golang golang locked and limited conversation to collaborators Dec 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants