DEV Community

BuildCoreWorks
BuildCoreWorks

Posted on

Building a High-Performance Keccak-256 Extension for PHP: 14-16 Faster

The Problem:
Pure PHP Keccak hashing: 0.28-0.44ms per hash
At scale, this makes Ethereum development impractical

The Solution:
C extension using direct memory operations
Benchmarked results: 0.018-0.032ms per hash

Performance:

  • Intel i3-2130 (2011): 0.032ms vs 0.443ms = 14× faster
  • AMD Ryzen 7 3700X: 0.018ms vs 0.280ms = 16× faster
  • Works in Docker and bare metal

Real-world impact:

  • 1M hashes: 18-32 seconds (native) vs 4.6-7.4 minutes (pure PHP)
  • 10M hashes: 3-5 minutes (native) vs 46-74 minutes (pure PHP)

Use Cases:

  • Ethereum address derivation
  • Transaction hashing
  • dApp backends
  • Any high-throughput crypto work

Installation:


bash
git clone https://github.com/BuildCoreWorks/php-keccak256.git
cd php-keccak256
phpize && ./configure && make && sudo make install
Enter fullscreen mode Exit fullscreen mode

Top comments (0)