Skip to content
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

Go port of this excellent project #1

Closed
rainrambler opened this issue Nov 19, 2024 · 3 comments
Closed

Go port of this excellent project #1

rainrambler opened this issue Nov 19, 2024 · 3 comments

Comments

@rainrambler
Copy link

This project has been incredibly inspiring and useful in my own projects.

I recently created a Go port of ChibiHash, and I would be thrilled if you could take a look at it. ==> https://github.com/rainrambler/ChibiHashGo

Please consider adding a link to my project in your readme file, as I believe it could be beneficial to others in the community who are interested in using Go.

Thank you once again for your amazing work.

@N-R-K
Copy link
Owner

N-R-K commented Nov 19, 2024

Hello,

Thanks for the port. I have some concerns however. I do not read/understand Go code well, but from what I can tell, you're using a kpos index variable to keep track of the string position.

But in some places it's reading from k[0], shouldn't that read from k[kpos] instead?

I have run the C version on a couple inputs and collected the results. Can you verify the Go port matches these results?

// chibihash64(string, len, seed)
chibihash64("", 0, 0) => 0x9EA80F3B18E26CFB
chibihash64("", 0, 55555) => 0x2EED9399FC4AC7E5
chibihash64("hi", 2, 0) => 0xAF98F3924F5C80D6
chibihash64("123", 3, 0) => 0x893A5CCA05B0A883
chibihash64("abcdefgh", 8, 0) => 0x8F922660063E3E75
chibihash64("Hello, world!", 13, 0) => 0x5AF920D8C0EBFE9F
chibihash64("qwertyuiopasdfghjklzxcvbnm123456", 32, 0) => 0x2EF296DB634F6551
chibihash64("qwertyuiopasdfghjklzxcvbnm123456789", 35, 0) => 0x0F56CF3735FFA943

I also see that there is some length checks inside the latter two loops, but they should be unnecessary because those loops will run for 3 iterations max.

@thevilledev thevilledev mentioned this issue Nov 19, 2024
@rainrambler
Copy link
Author

Hello,

Thanks for the port. I have some concerns however. I do not read/understand Go code well, but from what I can tell, you're using a kpos index variable to keep track of the string position.

But in some places it's reading from k[0], shouldn't that read from k[kpos] instead?

I have run the C version on a couple inputs and collected the results. Can you verify the Go port matches these results?

// chibihash64(string, len, seed)
chibihash64("", 0, 0) => 0x9EA80F3B18E26CFB
chibihash64("", 0, 55555) => 0x2EED9399FC4AC7E5
chibihash64("hi", 2, 0) => 0xAF98F3924F5C80D6
chibihash64("123", 3, 0) => 0x893A5CCA05B0A883
chibihash64("abcdefgh", 8, 0) => 0x8F922660063E3E75
chibihash64("Hello, world!", 13, 0) => 0x5AF920D8C0EBFE9F
chibihash64("qwertyuiopasdfghjklzxcvbnm123456", 32, 0) => 0x2EF296DB634F6551
chibihash64("qwertyuiopasdfghjklzxcvbnm123456789", 35, 0) => 0x0F56CF3735FFA943

I also see that there is some length checks inside the latter two loops, but they should be unnecessary because those loops will run for 3 iterations max.

Hi, I've fixed several bugs in Go code, this is the unit tests (passed): https://github.com/rainrambler/ChibiHashGo/blob/master/chibihash64_test.go

@N-R-K
Copy link
Owner

N-R-K commented Nov 28, 2024

Added to the list #4

@N-R-K N-R-K closed this as completed Nov 28, 2024
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

No branches or pull requests

2 participants