boredzo

Also @boredzo@mastodon.social.

Breaker of binaries. Sweary but friendly. See also @TheMatrixDotGIF and @boredzo-kitchen-diary.



Is there a known hashing algorithm with the following properties?

  • Preferably 32 or 64 bits
  • Does not need to be a cryptographic hash
  • [Added] … but ideally it should uniformly fill out the whole 32/64 bits for any input or length of input
  • Can concatenate multiple hashes to get the same hash as the concatenated messages

By that last one, I mean: Let's say that I have a message divided into chunks A, B, C, …. I want to hash each chunk, hash(A), hash(B), etc., and be able to combine the hashes in such a way that hash(A) 🤝 hash(B) 🤝 hash(C) … = hash(A + B + C …).

(It's OK for this to be order-dependent. In fact, it would be preferable for the order of the chunks to change the resulting hash.)

One possible (maybe the only possible) mechanism for this would be that the hash function has no state besides the current value of the hash.

Edit: Changed the operator between the hashes to something wholly fictional to clarify that I'm not proposing concatenating the hash values. Hashes are fixed-length values; it never makes sense to concatenate them.


You must log in to comment.

in reply to @boredzo's post:

Thinking about it for a little, I thiiiiiink something like the rolling hash in https://en.m.wikipedia.org/wiki/Universal_hashing#Hashing_strings , plus an output of the hash function being (l mod p, h_a(x)) would work? You need the length mod p to properly scale each successive hash.

Downside is that information is leaked in the length, especially since this also recommends p be large compared to the length of strings hashed. Maybe good enough for the chunking step if u don't expose the length in the digest?

In my case the length of strings hashed is going to be publicly defined to a well-known number, so leaking it isn't a problem.

I'll have to look more at rolling hashes as a solution to this problem when I have a little more time. They look promising. Thank you.

Pinned Tags