Function smix() in the scrypt implementation currently does something like that:
Initialize X
Copy X to V[0]
Mix X to Y
Copy Y to V[1]
Mix Y to X
Copy X to V[2]
...
If you look closely, the copy operations are unnecessary. Instead, one can do the following:
Initialize V[0]
Mix V[0] to V[1]
Mix V[1] to V[2]
...
Only the very last mix operation is slightly problematic because there is no space in V for the result any more and it needs to go into X. This issue can be avoided by allocating X and Y at the end of the V array. That's what I have done now, improves performance by around 10% for me (in both Firefox and Chrome).
Function
smix()
in the scrypt implementation currently does something like that:If you look closely, the copy operations are unnecessary. Instead, one can do the following:
Only the very last mix operation is slightly problematic because there is no space in V for the result any more and it needs to go into X. This issue can be avoided by allocating X and Y at the end of the V array. That's what I have done now, improves performance by around 10% for me (in both Firefox and Chrome).