Skip to content

Fix (?) the cp32 spec #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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