Uh oh!
There was an error while loading. Please reload this page.
salsa20: revert sse2 - #346
Conversation
This reverts RustCrypto#328. The changes introduced here generate failure when used in `scrypt`. The `scrypt_block_mix` would generate a different value. I'm not able to figure out why that change breaks scrypt. Reverting until we can figure out why.
baloo
commented
Mar 4, 2024
cc @oxarbitrage Sorry for the set back. I'd love your help on fixing this. |
tarcieri
commented
Mar 4, 2024
Agreed we should remove this for now. Perhaps it would be possible to add proptests between the two implementations to ensure they function equivalently. Turning the inputs/outputs from the linked failures into a regression test would be good as well. |
baloo
commented
Mar 4, 2024
https://github.com/baloo/salsa20-inconsistency |
baloo
commented
Mar 4, 2024
Last commit adds a regression test, the output of it on master: |
oxarbitrage
commented
Mar 4, 2024
Thank you for tagging me and for the regression test to expose the issue, I can take a look in about 24 hours and let you know if i can make a fix. |
oxarbitrage
commented
Mar 5, 2024
I see the reverse was already merged, that gives me some more time. I was not able to find the problem in a quick lookup however i will find out. Ill keep you posted here. |
baloo
commented
Mar 6, 2024
We needed to merge the revert because that was blocking the dependencies. |
oxarbitrage
commented
Mar 6, 2024
Yea, that is fine and understandable, ill figure out whats going on there. Thanks you again. |
oxarbitrage
commented
Mar 12, 2024
It seems that the SSE2 setup i did will only work for salsa20 with 10 double rounds (salsa20/20). The scrypt uses the salsa20/8 version. A quick workaround is to call the software backend when we are in the SSE2 mode and using other than salsa20/20. This call can be around here, something like: if !is_salsa20(&backend){
f.call(&mutcrate::backends::soft::Backend(&mutSalsaCore::<R>{state:*state,rounds:PhantomData,}));}else{
f.call(&mut backend);
state[8] = _mm_cvtsi128_si32(backend.v[2])asu32;}A function to know if we are in salsa20/20 can be coded as: This is far from ideal as we loss SSE2 optimization for salsa20/8. I can try to make that work but it will take more time or, i can push a PR adding back SSE2, the quick fix for versions that are not salsa20/20 and documenting that the SSE2 optimization will only be used in salsa20/20. I am also open to other alternatives, let me know. |
You should be able to do: ifR::USIZE == 10...which should allow the compiler to remove the branch as it can be determined at compile-time. Otherwise I think falling back to the soft implementation for non-Salsa20/20 sounds fine for now. Of course it would be really nice to get it working for Salsa20/8 for scrypt, since it's bottlenecked on that. |
oxarbitrage
commented
Mar 14, 2024
Thanks. Ill do this for now and ill work in a possible implementation of the sse2 optimization for salsa20/8 with some more time. Will push a PR with this soon. |
This reverts commit fea3dd0.
This reverts #328.
The changes introduced here generate failure when used in
scrypt. Thescrypt_block_mixwould generate a different value.I'm not able to figure out why that change breaks scrypt. Reverting until we can figure out why.