Skip to content

Conversation

@daxpedda
Copy link

@daxpedda daxpedda commented Nov 5, 2021

Hi!

I'm currently working on an implementation of the Balloon hashing algorithm for the RustCrypto organization: RustCrypto/password-hashes#232. In an effort to make this viable, I am seeking to provide compatibility between different implementations.

Only two changes are required to provide compatibility:

  • Change encoding of values to little-endian as is done in the prototype implementation
  • The ints_to_block function was interpreted as hashing these values and produce a "block" of bytes; the prototype implementation uses some sort of encryption here, I merely replaced it with the hash already used

Any input is welcome! I added test-vectors to assure compatibility. I am willing to contribute a CI setup, just say the word!
I have never programmed in Go before!

Another library I provided compatibility for: nachonavarro/balloon-hashing#2

Addresses #1.

balloon.go Outdated
Comment on lines 129 to 131
for left, right := 0, len(otherBytes)-1; left < right; left, right = left+1, right-1 {
otherBytes[left], otherBytes[right] = otherBytes[right], otherBytes[left]
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

math/big only takes big-endian, I copied this reverse slice implementation from here:
https://github.com/golang/go/wiki/SliceTricks#reversing

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was messing around with this project and found out that there exists a function in math/big that takes little-endian.

I've submitted a pull request on your fork a while ago, but sadly I think this original repo has gotten stale. If there's more interest, I might spend some time to optimize the implementation.

khonsulabs#1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw your comment here, sorry for the delay!
@nogoegst has to look at this PR, I really don't feel comfortable reviewing unsafe Go code.

@darenliang personally I have no stake in this library, I was only trying to help multiple Balloon implementations be compatible with each other, specifically the Rust library I contributed to. So if you are more interested in using Balloon with Go and want to have common compatibility, feel free to contact me.

@unkaktus
Copy link
Owner

Hi!
Thanks for your pull request, looks good to me!
I will only replace the slice inversion via more straightforward function - there should be one in math.big.

@daxpedda
Copy link
Author

I did try to replace the slice inversion. What I did was basically make a new slice with the math.big.Word type, copied over the bytes, then used math.big.Int.SetBits to convert it. This involved a bit of trickery and didn't really improve the code, I'm open to suggestions!

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.

3 participants