-
-
Notifications
You must be signed in to change notification settings - Fork 180
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
Add interfaces to popular Rust hash libraries #276
base: master
Are you sure you want to change the base?
Conversation
Looks great, but I'll need a few days to integrate and test these. Still at home with covid for a few more days |
Thanks for the update, sounds good. Hope you feel better soon. |
411993e
to
a479f0b
Compare
I think I got it all linked up, the tests run now. Few things I wasn't sure about:
I plan to expose Rust's HashMap API so that can be tested directly rather than going via Non GHA CI probably does not work yet, may need some help there. |
uppercase vars, fixed types fixed a typo
See the branch tgross35-add-rust with my cmake cleanups. /usr/lib64/ccache/g++ -std=c++11 -march=native -DRUST_ENABLED -DLTO -O3 -DNDEBUG -flto=auto -fno-fat-lto-objects CMakeFiles/SMHasher.dir/main.cpp.o -o SMHasher libSMHasherSupport.a -lhighwayhash -lahash_c /home/rurban/Software/smhasher/rust-hashes/target/release/librust_hashes.a |
I"ll do this manually. verification can be tested via
So far we went with 32bit seeds only, as 64bit seeds are too hard to test.
I adjusted some test values for these overly slow crypto hashes, or disable them completely when they bring nothing to the table. in our case Rust vs C++ would be interesting though, esp. when parallized.
Not yet, but should be done somewhen. I've only added asan, ubsan. I don't expect them to fail msan/cfi, but who knows. Quality was surprisingly mixed. |
Thanks for the fixes, I just enabled LTO and fixed RUSTFLAGS since I it seemed like that was not getting set properly (diff). Are you able to disable the ahash_c interface and see if that works? I think there are probably some Rust symbol conflicts between that staticlib and this one since they're currently getting linked at the same time |
Yes it clashes only with the ahash_c. Maybe just add ahash to librust_hashes |
Thanks for these detailed responses, I just saw them
This makes it sound like there are tests that need to sweep the entire seed space? I am not too familiar with the test algorithms. All the hashes that take a u64 or larger seed currently use the provided seed and zero-extend it to the needed size, but I can change them to just ignore the seed if that is preferred.
I suspect the C++ implementations will win out much of the time :) Many of these Rust implementations come from the Rust code does tend to optimize a bit better than C when neither have handwrittern instructions (near-ideal
Rust also has an interpreter
It is there currently, under the symbol |
Add ntdll to link list
The old ahash has much better seeds. The new one has tons of bad seeds. So either remove it, or match it. |
Ad rust restrict: rust depends on llvm, and this still has a broken restrict implementation with small inlinable loops. |
zero-extension is fine. no seed makes them almost unusable for us. |
I adjusted this implementation to use the same invocation as the current ahash. Is repeating the seed preferred to zero extending? I don't understand the exact vector. Seems to be some linking errors on Windows. 64 bit github CI can't find some |
Have a look at the results in the tgross35-add-rust branch. |
Great to have results, thank you for the update. What does the "invalid hash bit width" failure mean? Is this the failure you were referring to, or did you mean algorithmic failures? I wonder if I could have hooked something up wrong, or if some of this would be different if I repeated the keys rather than zero-extending. Also, that branch does not have the recent change to |
The blake hashes also take some optional input variables, I just used defaults since I was not entirely sure how to use them. I can update the usage if you have suggestions |
This is just the 123 typo. Will be tested in the next round. Testing is extremely slow on my home laptop.
Yes, that's missing. Should be the same as the standalone ahash. |
I've tested the new ahash_rs, it"s even worse than the old. |
That is weird, it should be doing the exact same thing. Do you know what version of the library it was testing against before? I can run some of these on my home computer which should be faster, just haven't gotten the chance. |
Hello! Any progress on this? I have this PR pending for adding gxhash but I think it might be better to simply add it as a rust dependency as I've put a lot more effort into this rust version, and is available on crates.io |
Hey @ogxd, I haven't yet taken another look at this so no, there are no updates. I am happy to add gxhash to this list before it gets closer to being mergeable, but I don't think you need to hold off on adding the C implementation as well. |
Fixes #69, #94
This adds bindings to Rust implementations of the following algorithms:
C interfaces are in
rust-hashes/rust_hashes.h
. You can buildlibrust_hashes.a
withcargo run --release
(output is intarget/release
). I assumed here that*out
is at least 512 bits,keccak256full_rstest
is a special case that needs 1600 bits if run.I am not sure how to tie these in to the rest of the system. If you could do that it would be great, or just tell me how.