multihash icon indicating copy to clipboard operation
multihash copied to clipboard

Supporting KangarooTwelve

Open DonaldTsang opened this issue 6 years ago • 7 comments

I would like KangarooTwelve and MarsupilamiFourteen to be added to Multiformats as K12 is faster than SHA1, and M14 is expected to be as about as fast as SHA1 and twice as fast as SHA256. Statistics: https://bench.cr.yp.to/results-hash.html#oki M12 is 2.21 cpb, M14 is assumed to be 2.21*(14/12)*(168/136)=3.185 Cycles per byte For comparison, SHA1 is 3.06 cpb, MD5 is 4.33 cpb, and SHA256 is 6.65 cpb

DonaldTsang avatar Dec 04 '18 17:12 DonaldTsang

Do they provide any benefit over blake2b?

Stebalien avatar Dec 04 '18 19:12 Stebalien

@Stebalien According to the benchmark KangarooTwelve is 2.92/2.21=1.32x faster than BLAKE2b, since kangarooTwelve is engineered by Team Keccak to be an ultra-fast version of SHAKE arbitrary length hash (see https://keccak.team/kangarootwelve.html for more info)

DonaldTsang avatar Dec 04 '18 19:12 DonaldTsang

For future reference this will come in handy https://github.com/multiformats/multicodec/pull/56

DonaldTsang avatar Dec 04 '18 19:12 DonaldTsang

I see, I was looking at a different benchmark. It appears to really depend on the CPU.

I'm not really against these but I'd like to carefully consider which ones are likely to be used for identifying content (needs a single byte code).

Do you know of any existing users of these hash functions?

Stebalien avatar Dec 04 '18 22:12 Stebalien

@Stebalien If I were to be in charge of Multihash, I would treat the multihash ID as book indexing, where each code can have up to 4 bytes, so that many different types of hashes are included. My hash selection criteria is as follows:

  • [ ] High priority: MD-hash, SHA-1/2, (SHA3, SHAKE, K12), BLAKE2, Skein (all are useful and/or common)
  • [ ] Mid priority: SHA competition finalists and round 3 candidates whose speed are faster than SHA256, bcrypt, scrypt, Argon2 and other PHC "special recognition"
  • [ ] Low priority: Other SHA competition finalists and round 3 candidates, other PHC finalists

DonaldTsang avatar Dec 19 '18 13:12 DonaldTsang

I just don't want to regret any decisions later. Either regret choosing a short code because we never use it or regret choosing a long code because we find it really useful.

However, I agree with your analysis. This seems useful to include as either a 2 or 3 byte code.

Stebalien avatar Jan 10 '19 02:01 Stebalien

Since BLAKE3 exists as a replacement for BLAKE2, it might be a good idea to reconsider K12.

DonaldTsang avatar Mar 11 '20 17:03 DonaldTsang