Hi
(Hans, apologies for the duplicate copy, I accidentally did not send the
first reply to the list)
Am 2025-01-24 20:39, schrieb Hans Henrik Bergan:
Can we add the BLAKE3 hash?
Created a PR here: https://github.com/php/php-src/pull/13194
Created a RFC draft here: https://wiki.php.net/rfc/blake3
BLAKE3 is a cryptographic hash function based on the SHA3-finalist
BLAKE, offering SHA3-256-like security at much higher speed.
Benchmarks from /ext/hash/bench.php highlight BLAKE3's performance: it
is over four times faster than SHA3-256 on AMD Ryzen 9 7950x:
https://wiki.php.net/_detail/rfc/output_5_.png
Thank you for your RFC. I'm a little confused by the benchmark results.
According to
https://www.amd.com/de/products/processors/desktops/ryzen/7000-series/amd-ryzen-9-7950x.html,
the Ryzen 9 7950x should support SHA-NI, which should make SHA-256 much
faster than SHA-1. On my i7-1365U I get SHA-256 results that are
competitive with BLAKE3 and with SHA-256 being a well-established
algorithm, the benefit of having BLAKE3 becomes much smaller when also
considering that will likely remain under much less scrunity of the
cryptographic community.
crc32b 0.001059
crc32 0.001060
crc32c 0.001068
xxh3 0.001888
xxh128 0.001915
xxh64 0.002003
murmur3f 0.003031
xxh32 0.003147
murmur3c 0.003590
murmur3a 0.006133
adler32 0.007285
blake3 0.010877
sha224 0.013217
sha256 0.013227
md4 0.017892
fnv164 0.021882
fnv132 0.021941
fnv1a32 0.021953
fnv1a64 0.021960
sha1 0.026227
joaat 0.027386
tiger128,3 0.028267
tiger160,3 0.028301
tiger192,3 0.028335
md5 0.028426
tiger128,4 0.037212
tiger160,4 0.037262
tiger192,4 0.037312
ripemd128 0.037685
ripemd256 0.037950
sha3-224 0.048985
sha384 0.050335
sha512/256 0.050597
sha512 0.050732
sha512/224 0.050744
sha3-256 0.052112
haval160,3 0.059909
haval128,3 0.059922
haval224,3 0.059940
haval256,3 0.060034
haval192,3 0.060077
ripemd320 0.062434
ripemd160 0.062976
sha3-384 0.064828
haval128,4 0.082339
haval192,4 0.082374
haval160,4 0.082414
haval224,4 0.082511
haval256,4 0.082513
sha3-512 0.093178
haval128,5 0.104438
haval160,5 0.104576
haval256,5 0.104610
haval192,5 0.104631
haval224,5 0.104929
whirlpool 0.108009
gost 0.243599
gost-crypto 0.243799
snefru 0.595979
snefru256 0.596615
md2 1.752960
Is your benchmark perhaps not reflecting the latest changes with PHP
8.4? SHA-NI support was added in
https://github.com/php/php-src/pull/15152.
As for the RFC itself: I suggest to already add the (closed) voting
doodle to the proposed voting choices section. The way the section is
currently worded doesn't make sense, because it implies two distinct
votes.
Other than the above, I don't have a strong opinion either about the
RFC. I don't see much benefit of having it, but also not much against.
Best regards
Tim Düsterhus