You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fun bit is that the 1 line of code in rotateLeft is basically exactly the same in the C code in libscrypt.
Has anyone an idea what's causing this slowdown? It's actually so slow that even the JS implementation is faster. Something is up with it but I don't know what it is. Right now it's not usable in production.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I benchmarked CryptoSwift scrypt vs this library: https://github.com/greymass/swift-scrypt which is a C binding to libscrypt.
libscrypt scrypt seems to be 4 times faster than CryptoSwift scrypt.
Both have been release compiled with optimizations.
After time profiling I found out which code segments are the issue:
This function takes up about 90% of the total time:
https://github.com/krzyzanowskim/CryptoSwift/blob/main/Sources/CryptoSwift/Scrypt.swift#L206
More specifically, this
rotateLeft
uses up again more than 90% of thesalsa20_8_typed
function:https://github.com/krzyzanowskim/CryptoSwift/blob/main/Sources/CryptoSwift/Utils.swift#L18
The fun bit is that the 1 line of code in
rotateLeft
is basically exactly the same in the C code in libscrypt.Has anyone an idea what's causing this slowdown? It's actually so slow that even the JS implementation is faster. Something is up with it but I don't know what it is. Right now it's not usable in production.
Beta Was this translation helpful? Give feedback.
All reactions