Live data from Hacker News

Kangaroo Twelve Implementation in Go

github.com

11–20 of 30 posts

Re: Kangaroo Twelve Implementation in Go

#11
post #8

K12 is not a "faster SHA-3". K12 is K12, M14 is M14. K12 is related to SHA-3, but if you're throwing standards out the door (and I think you should), you can use any of the hash core algorithms, whether or not they're related to Keccak. The best all-purpose cryptographic hash is probably truncated SHA-2 512, and the hipster modern hash is probably still Blake2.

> The best all-purpose cryptographic hash is probably truncated SHA-2 512 Could you elaborate on that please? Why would you consider it as the "best all-purpose cryptographic hash"?

On 64-bit processors SHA-512 truncated to 256 bits is faster than SHA-256, and has the advantage of being safe against length-extension attacks (which are a major gotcha of SHA-512 and the rest of SHA2).

Out of SHA3, K12, SHA2 and Blake, SHA-512 is one of the fastest (some variants of Blake2 are faster), and it's the one with the longest track record, while the Blake-family and SHA3 are fairly new. It's also widely supported nearly everywhere. All that makes truncated SHA-512 a sane default.

Re: Kangaroo Twelve Implementation in Go

#12

Earlier quoted context omitted.

> The best all-purpose cryptographic hash is probably truncated SHA-2 512 Could you elaborate on that please? Why would you consider it as the "best all-purpose cryptographic hash"?

On 64-bit processors SHA-512 truncated to 256 bits is faster than SHA-256, and has the advantage of being safe against length-extension attacks (which are a major gotcha of SHA-512 and the rest of SHA2). Out of SHA3, K12, SHA2 and Blake, SHA-512 is one of the fastest (some variants of Blake2 are faster), and it's the one with the longest track record, while the Blake-family and SHA3 are fairly new. It's also widely s…

> Out of SHA3, K12, SHA2 and Blake, SHA-512 is one of the fastest (some variants of Blake2 are faster)

https://twitter.com/KeccakTeam/status/834789451708628995

> It's also widely supported nearly everywhere

This is true for the non-truncated variants, but I am not aware of any protocol that uses the truncated ones.

I will agree with the "longest track record" however, this is an important part.

Re: Kangaroo Twelve Implementation in Go

#13
post #3

Isn't this SHA-3 less safe, too? Why not just go with BLAKE2?

BLAKE2 is less safe than BLAKE as well. >Isn't this SHA-3 less safe, too? Yes, both K12 and M14 are less safe than SHA3. Instead of 12 + 2ℓ rounds (where ℓ is 25 * 2^ℓ = r + c [where r + c = 1600 in both sha-3 and K12]) it uses just 12 rounds (14 for M14). It also uses half the c (c = 512 in sha3-256, c = 256 in K12, where c is the sponge capacity). It provides the same amount of bits of security against collision at…

For what it's worth, BLAKE2 has the original number of rounds of BLAKE: 12 and 10. It was increased to 16 and 14 before the 3rd round of the competition, because BLAKE was fast enough that increasing the round numbers like this would still make it sufficient fast---and, indeed, the faster function in the 3rd round still---and the most conservative function of the bunch.

Keccak began with 18 rounds. It increased to 24 rounds on the 2nd round after some largely irrelevant distinguishers were found. You can see that K12 is cutting it really close, as the 256-bit variant adds two rounds for added safety, in addition to the reduced control over the state with the larger capacity.

I can imagine ~12-round Keccak being "broken" in my lifetime, as well as ~8-round BLAKE2. I cannot imagine the full version of either being ever broken.

Re: Kangaroo Twelve Implementation in Go

#14
post #8

K12 is not a "faster SHA-3". K12 is K12, M14 is M14. K12 is related to SHA-3, but if you're throwing standards out the door (and I think you should), you can use any of the hash core algorithms, whether or not they're related to Keccak. The best all-purpose cryptographic hash is probably truncated SHA-2 512, and the hipster modern hash is probably still Blake2.

Thanks, we've removed “A Faster SHA-3” from the submission title which isn't purported on the linked page.

Re: Kangaroo Twelve Implementation in Go

#15

Earlier quoted context omitted.

On 64-bit processors SHA-512 truncated to 256 bits is faster than SHA-256, and has the advantage of being safe against length-extension attacks (which are a major gotcha of SHA-512 and the rest of SHA2). Out of SHA3, K12, SHA2 and Blake, SHA-512 is one of the fastest (some variants of Blake2 are faster), and it's the one with the longest track record, while the Blake-family and SHA3 are fairly new. It's also widely s…

> Out of SHA3, K12, SHA2 and Blake, SHA-512 is one of the fastest (some variants of Blake2 are faster) https://twitter.com/KeccakTeam/status/834789451708628995 > It's also widely supported nearly everywhere This is true for the non-truncated variants, but I am not aware of any protocol that uses the truncated ones. I will agree with the "longest track record" however, this is an important part.

If you are free to choose a hash function, you are free to truncate SHA-512. Truncated SHA-512 is secure, there is no need to wait to see it used in a standardized protocol to increase confidence in its security.

Creating a truncate(SHA-512, 256) out of regular SHA-512 is trivial, so it true that it is widely supported nearly everywhere.

Re: Kangaroo Twelve Implementation in Go

#16

Earlier quoted context omitted.

> Out of SHA3, K12, SHA2 and Blake, SHA-512 is one of the fastest (some variants of Blake2 are faster) https://twitter.com/KeccakTeam/status/834789451708628995 > It's also widely supported nearly everywhere This is true for the non-truncated variants, but I am not aware of any protocol that uses the truncated ones. I will agree with the "longest track record" however, this is an important part.

If you are free to choose a hash function, you are free to truncate SHA-512. Truncated SHA-512 is secure, there is no need to wait to see it used in a standardized protocol to increase confidence in its security. Creating a truncate(SHA-512, 256) out of regular SHA-512 is trivial, so it true that it is widely supported nearly everywhere.

This is wrong, SHA-512/256 is not the same as calculating the output of SHA-512 and then taking the first 256 bits of it, there are some differences between them such as different IVs that would make the outputs also different.

Re: Kangaroo Twelve Implementation in Go

#17

Earlier quoted context omitted.

If you are free to choose a hash function, you are free to truncate SHA-512. Truncated SHA-512 is secure, there is no need to wait to see it used in a standardized protocol to increase confidence in its security. Creating a truncate(SHA-512, 256) out of regular SHA-512 is trivial, so it true that it is widely supported nearly everywhere.

This is wrong, SHA-512/256 is not the same as calculating the output of SHA-512 and then taking the first 256 bits of it, there are some differences between them such as different IVs that would make the outputs also different.

Yes, sorry. You need to overwrite the initial value (H0) too, in the constructor. You can do that if you can touch the equivalent of the private member variables.

    SHA-512/256 may be used to hash a message, M, having a length of 𝓁 bits, where 128 0 ≤ 𝓁 
(from §6.7 in http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4....)

EDIT: I trust 'tptacek (in sibling comment) that if there is no chance of protocol confusion, there is no advantage to the different initial value.

Re: Kangaroo Twelve Implementation in Go

#18

Earlier quoted context omitted.

If you are free to choose a hash function, you are free to truncate SHA-512. Truncated SHA-512 is secure, there is no need to wait to see it used in a standardized protocol to increase confidence in its security. Creating a truncate(SHA-512, 256) out of regular SHA-512 is trivial, so it true that it is widely supported nearly everywhere.

This is wrong, SHA-512/256 is not the same as calculating the output of SHA-512 and then taking the first 256 bits of it, there are some differences between them such as different IVs that would make the outputs also different.

This only matters if there's an existing protocol that uses truncated SHA-2 you need to interoperate with (and your premise is there is not).

There is no functional advantage to having a different IV for SHA-2 5-2/256.

Re: Kangaroo Twelve Implementation in Go

#19
post #7

Earlier quoted context omitted.

BLAKE2 is less safe than BLAKE as well. >Isn't this SHA-3 less safe, too? Yes, both K12 and M14 are less safe than SHA3. Instead of 12 + 2ℓ rounds (where ℓ is 25 * 2^ℓ = r + c [where r + c = 1600 in both sha-3 and K12]) it uses just 12 rounds (14 for M14). It also uses half the c (c = 512 in sha3-256, c = 256 in K12, where c is the sponge capacity). It provides the same amount of bits of security against collision at…

The word "safe" isn't doing us any favors here. What we're really talking about is the "security margin" of the different hashes. Every hash we're talking about on this thread has a margin far beyond any plausible or foreseeable attacks. None are unsafe.

This is a serious issue, and I think it's a problem of cryptography education.

On the one hand, we (rightly, in my opinion) teach people who haven't studied cryptography that they shouldn't try to implement it on their own. This is good, because cryptography is mostly applied math (hard) and careful software implementation (also hard), and mixing these two hard things without shooting yourself in the foot is very hard.

On the other hand, developers who follow this advice don't have a clear way to find the answer to questions like, "Which of these great algorithms do I want?" It's easy to find sound recommendations for which algorithms are well-studied and essentially safe; it's less easy to find guides that compare and contrast algorithms along nuanced axes like computational cost, interoperability, security margin or adaptability.

This leads developers to come to their own conclusions based on imperfect understanding of the metrics they can quantify:

"I need to encrypt something - Serpent has a much higher security margin than AES (Rijndael), I should probably go with that."

"I need to hash something - Keccak won the SHA-3 contest, so I should use that instead of BLAKE."

"I need to authenticate something - if I choose two strong algorithms it will be better than one, so I'll use AES-CTR and HMAC-SHA, instead of an AEAD."

"More bits means higher security, so I'll use AES256 and SHA-512."

I'm noticing this more and more in online discussion, where people seem to be talking past each other about things like the "safety" of algorithms without discriminating between other metrics like speed. In my opinion, it would be better for people to consider "safety" as a mostly binary property if they haven't done enough due diligence to know why one algorithm has a higher or lower security margin than another one, because the other metrics are so much more important.

There probably needs to be better cryptography education as well, something that is a bit higher than "do this, don't do this" and which provides some elaboration about the whys inherent to different security margins.

Re: Kangaroo Twelve Implementation in Go

#20
post #18

Earlier quoted context omitted.

This is wrong, SHA-512/256 is not the same as calculating the output of SHA-512 and then taking the first 256 bits of it, there are some differences between them such as different IVs that would make the outputs also different.

This only matters if there's an existing protocol that uses truncated SHA-2 you need to interoperate with (and your premise is there is not). There is no functional advantage to having a different IV for SHA-2 5-2/256.

Yup, this looks like it's a cross-domain protection.
Post reply on HN