BLAKE3 in PHP
Marcos Marcolin • January 26, 2024 • 2 min read
php opensource phprfcOn 01/19, a Pull Request (PR) was submitted to the PHP project aiming to add support for the BLAKE3 hashing function. 🐘🔑
Until then, I didn't know about this function. However, after doing some research, I found it to be a remarkably fast function (as shown in the image), while also being secure compared to MD5 and SHA1, for example.
Hash functions are commonly used to validate files, ensure message authenticity, generate keys, among other applications. Eventually including this feature would certainly bring significant benefits to the language.
This PR will likely lead to an RFC and further discussion.
The PR is on php-src: #13194.
It also made it onto the PHP mailing list, you can follow it at BLAKE3 hash.
BLAKE3
The official implementation is written in Rust and C, check it out in the official BLAKE3 repository.
The repository above states the following:
- Much faster than MD5, SHA-1, SHA-2, SHA-3, and BLAKE2.
- Secure, unlike MD5 and SHA-1. And secure against length-extension attacks, unlike SHA-2.
- Highly parallelizable across any number of threads and SIMD lanes, because it's a Merkle tree internally.
- Capable of verified streaming and incremental updates, again thanks to its Merkle tree nature.
- Works as a Pseudorandom Function (PRF), Message Authentication Code (MAC), Key Derivation Function (KDF), and Extendable Output Function (XOF), in addition to being a regular hash.
- A single algorithm with no variants, optimized for x86-64 and also efficient on smaller architectures.