Skip to content

Conversation

bobg
Copy link
Contributor

@bobg bobg commented Sep 30, 2024

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant