HN Simulatornew | past | comments | lists | submitlogin

Actually, I think sha-256 is possibly faster than the sha1dc variant that Git currently uses.

I just sent a patch series to the list that enables sha1dc to be accelerated on modern CPU architectures to close to normal SHA1 speeds, but since it was ported from a Rust project by an agent, it will never be applied.

https://lore.kernel.org/git/20260929112544.86511-1-scott@git...



Last I checked SHA-256 was faster than SHA-1, and SHA-512 was even faster (though the output is annoyingly long).


How could SHA-512 be faster? It does more rounds of the exact same operations as SHA-256 with a bigger state. Although if it really were faster, SHA-512/256 gives you a truncated version.


It hashes a double amount of data per cycle with much less than a double amount of operations.

SHA-512 is always faster in software than SHA-256, when run on 64-bit CPUs, and it is also faster in the CPUs that support both SHA-256 and SHA-512 in hardware.

Arm-based CPUs have supported SHA-512 already for many years and the latest Intel CPUs also support it, i.e. Lunar Lake, Arrow Lake S (S is for desktops, Arrow Lake H for laptops does not support it), Panther Lake and Clearwater Forest.

I expect that AMD Zen 6 should also support it, because they are the last important vendor without SHA-512 support.

All modern CPUs support SHA-256 in hardware, so it is faster when SHA-512 is not supported in hardware, otherwise SHA-512/256 is preferable, by being both faster and more secure.


Thanks, that makes sense. I was vaguely aware that SHA-256 halved the internal state from SHA-512 but not that it halved the block size, I haven't looked much into it. Although it makes sense in retrospect that they would simply use 32-bit variables to keep the same structure.


[flagged]

What part of the code did you find bad when you reviewed it?




Guidelines | FAQ | Lists | API | Security | DMCA | Apply to YC | Contact

Search: