hashsplit / hashsplit-spec

The Unlicense
7 stars 3 forks source link

Fix (?) the cp32 spec #28

Open bobg opened 2 weeks ago

bobg commented 2 weeks ago

The cp32 spec says that the hash of a string X is the xor of rotl(g(xi), |X|-i+1) for each i in 0..|X|-1.

That means that the first g value gets rotl'd by |X|+1 bits, the second gets rotl'd by |X| bits, the third by |X|-1 bits, and so on, until the last g value gets rotl'd by 2 bits.

This seems like it might be a simple typo, and the +1 should perhaps be a -1. Then the first g value gets rotl'd by |X|-1 bits, then |X|-2, and so on until the last g value gets rotl'd by 0 bits.

Was that in fact the intent?

(With the advent of iterators in Go 1.23, I went back to my hashsplit package to update its API. In the process I rediscovered this old PR draft and so decided to take the advice in it and add my own implementation of cp32, which is why I'm looking at this again after all this time.)