<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: BuildCoreWorks</title>
    <description>The latest articles on Forem by BuildCoreWorks (@buildcoreworks).</description>
    <link>https://forem.com/buildcoreworks</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3563080%2F1c4034f8-1c35-4365-a955-7ad0072489e6.png</url>
      <title>Forem: BuildCoreWorks</title>
      <link>https://forem.com/buildcoreworks</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/buildcoreworks"/>
    <language>en</language>
    <item>
      <title>Unleashing Native‑Speed Crypto in PHP: Introducing php‑secp256k1 &amp; php‑keccak256</title>
      <dc:creator>BuildCoreWorks</dc:creator>
      <pubDate>Sun, 19 Oct 2025 11:07:29 +0000</pubDate>
      <link>https://forem.com/buildcoreworks/unleashing-native-speed-crypto-in-php-introducing-php-secp256k1-php-keccak256-61</link>
      <guid>https://forem.com/buildcoreworks/unleashing-native-speed-crypto-in-php-introducing-php-secp256k1-php-keccak256-61</guid>
      <description>&lt;p&gt;Have you ever tried to build a blockchain wallet or an NFT marketplace in PHP and felt like you were wearing lead boots? You’re not alone. PHP remains widely used in production and by a large share of working developers, but cryptographic workloads have traditionally been its kryptonite. Pure-PHP libraries for signing and hashing do the job, but when you need to sign or verify thousands of transactions per second, 100 milliseconds per call is the difference between “Hello, world!” and “Sorry, network timeout.” (&lt;a href="https://blog.jetbrains.com/team/2024/12/11/the-state-of-developer-ecosystem-2024-unveiling-current-developer-trends-the-unstoppable-rise-of-ai-adoption-leading-languages-and-impact-on-developer-experience/?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;The JetBrains Blog&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  Why pure-PHP crypto hurts
&lt;/h2&gt;

&lt;p&gt;Let’s quantify the pain. A widely used pure-PHP ECDSA (secp256k1) implementation benchmarks at &lt;strong&gt;~90–136 ms&lt;/strong&gt; per signature and &lt;strong&gt;~100–135 ms&lt;/strong&gt; per verification. At that rate, a node processing &lt;strong&gt;1,000 TPS&lt;/strong&gt; would spend &lt;strong&gt;~2–4 minutes&lt;/strong&gt; computing signatures/verifications for just one second’s workload—nowhere near real-time. &lt;/p&gt;

&lt;h2&gt;
  
  
  Enter &lt;code&gt;php-secp256k1&lt;/code&gt;: native-speed ECDSA
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Secp256k1&lt;/strong&gt; is the elliptic curve chosen by Bitcoin and Ethereum for digital signatures. Thanks to its structure, a tuned implementation can be &lt;strong&gt;~30% faster&lt;/strong&gt; than many other curves. Our &lt;code&gt;php-secp256k1&lt;/code&gt; wraps &lt;strong&gt;Bitcoin Core’s&lt;/strong&gt; battle-tested &lt;strong&gt;&lt;code&gt;libsecp256k1&lt;/code&gt;&lt;/strong&gt; C library as a PHP extension, so you get the same engine—just callable from PHP. In benchmarks, the extension delivers &lt;strong&gt;~0.03–0.06 ms&lt;/strong&gt; per signature and &lt;strong&gt;~0.04–0.06 ms&lt;/strong&gt; per verification. On an &lt;strong&gt;AMD Ryzen 7 3700X&lt;/strong&gt;, that’s &lt;strong&gt;0.030 ms/sign&lt;/strong&gt; vs &lt;strong&gt;89.6 ms&lt;/strong&gt; in pure PHP, turning &lt;strong&gt;100,000 signatures&lt;/strong&gt; from &lt;strong&gt;hours&lt;/strong&gt; into &lt;strong&gt;~3–5 seconds&lt;/strong&gt;. (&lt;a href="https://en.bitcoin.it/wiki/Secp256k1?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Bitcoin Wiki&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="c1"&gt;// Sign a 32-byte message hash with a private key (64-char hex)&lt;/span&gt;
&lt;span class="nv"&gt;$signature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;secp256k1_sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$hash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$privateKey&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Verify a signature with the message hash and public key&lt;/span&gt;
&lt;span class="nv"&gt;$isValid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;secp256k1_verify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$hash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$signature&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$publicKey&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Recover the public key (Ethereum-style) from a signature and message hash&lt;/span&gt;
&lt;span class="nv"&gt;$publicKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;secp256k1_recover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$hash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$signature&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under the hood, the extension &lt;strong&gt;randomises context&lt;/strong&gt;, &lt;strong&gt;zeroes sensitive memory&lt;/strong&gt;, and exposes &lt;strong&gt;sign/verify/recover&lt;/strong&gt; (Ethereum-style) in a thread-safe package—production-ready for FPM/CLI/frameworks. (&lt;a href="https://dev.to/buildcoreworks/building-high-performance-secp256k1-ecdsa-for-php-2987x-faster-2jl3"&gt;DEV Community&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  Enter &lt;code&gt;php-keccak256&lt;/code&gt;: lightning-fast hashing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Keccak-256&lt;/strong&gt; (often called &lt;strong&gt;SHA-3&lt;/strong&gt;) underpins Ethereum: address derivation, transaction hashing, event topics—the works. Ethereum externally owned account (EOA) addresses are &lt;strong&gt;the last 20 bytes of the Keccak-256 hash of the uncompressed public key&lt;/strong&gt;. Pure PHP clocks &lt;strong&gt;~0.28–0.44 ms per hash&lt;/strong&gt;; the native extension cuts this to &lt;strong&gt;~0.018–0.032 ms&lt;/strong&gt;—about &lt;strong&gt;15× faster&lt;/strong&gt;. A million hashes drop from &lt;strong&gt;minutes&lt;/strong&gt; to &lt;strong&gt;under half a minute&lt;/strong&gt;. (&lt;a href="https://ethereum.stackexchange.com/questions/3542/how-are-ethereum-addresses-generated?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Ethereum Stack Exchange&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="c1"&gt;// Hash any string and return hex output by default (or raw binary if $raw = true)&lt;/span&gt;
&lt;span class="nv"&gt;$hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;keccak_hash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Putting it together: an end-to-end Ethereum workflow in PHP
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="c1"&gt;// 1) Prepare transaction data and compute its Keccak-256 hash&lt;/span&gt;
&lt;span class="nv"&gt;$messageHash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;keccak_hash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$transactionData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// 2) Sign the hash with a secp256k1 private key&lt;/span&gt;
&lt;span class="nv"&gt;$signature&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;secp256k1_sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$messageHash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$privateKey&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// 3) Recover the public key (useful for smart-contract signatures)&lt;/span&gt;
&lt;span class="nv"&gt;$publicKey&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;secp256k1_recover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$messageHash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$signature&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// 4) Derive Ethereum address: last 20 bytes of Keccak(pubkey)&lt;/span&gt;
&lt;span class="nv"&gt;$address&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'0x'&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;substr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;keccak_hash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;hex2bin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$publicKey&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That one PHP snippet signs transactions, recovers the signer, and derives an address—&lt;strong&gt;no external process or second language&lt;/strong&gt; required. And because signing and hashing now run in &lt;strong&gt;microseconds&lt;/strong&gt;, you can build dApps, payment gateways, or nodes that chew through &lt;strong&gt;tens of thousands of ops per second&lt;/strong&gt; on commodity hardware. (&lt;a href="https://dev.to/buildcoreworks/building-high-performance-secp256k1-ecdsa-for-php-2987x-faster-2jl3"&gt;DEV Community&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Dependencies&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; libsecp256k1-dev libssl-dev php-dev build-essential

&lt;span class="c"&gt;# php-secp256k1&lt;/span&gt;
git clone https://github.com/BuildCoreWorks/php-secp256k1.git
&lt;span class="nb"&gt;cd &lt;/span&gt;php-secp256k1 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; phpize &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ./configure &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; make &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;make &lt;span class="nb"&gt;install
echo&lt;/span&gt; &lt;span class="s2"&gt;"extension=secp256k1.so"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/php/8.1/mods-available/secp256k1.ini
&lt;span class="nb"&gt;sudo &lt;/span&gt;phpenmod secp256k1

&lt;span class="c"&gt;# php-keccak256&lt;/span&gt;
git clone https://github.com/BuildCoreWorks/php-keccak256.git
&lt;span class="nb"&gt;cd &lt;/span&gt;php-keccak256 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; phpize &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ./configure &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; make &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;make &lt;span class="nb"&gt;install
echo&lt;/span&gt; &lt;span class="s2"&gt;"extension=keccak.so"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/php/8.1/mods-available/keccak.ini
&lt;span class="nb"&gt;sudo &lt;/span&gt;phpenmod keccak
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both extensions are open source; see the GitHub READMEs for full docs and benchmarks. (&lt;a href="https://github.com/BuildCoreWorks/php-secp256k1" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  Why secp256k1 &amp;amp; Keccak-256 (quick context)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;secp256k1&lt;/strong&gt; was selected for Bitcoin/Ethereum and, when well-optimised, can outperform other common curves thanks to its structure. (&lt;a href="https://en.bitcoin.it/wiki/Secp256k1?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Bitcoin Wiki&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keccak-256&lt;/strong&gt; (Ethereum’s hashing workhorse) is used for &lt;strong&gt;address derivation&lt;/strong&gt;, transaction hashing, and more. (&lt;a href="https://ethereum.stackexchange.com/questions/3542/how-are-ethereum-addresses-generated?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Ethereum Stack Exchange&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Ready to build?
&lt;/h2&gt;

&lt;p&gt;Performance shouldn’t be a blocker for innovation. With &lt;code&gt;php-secp256k1&lt;/code&gt; and &lt;code&gt;php-keccak256&lt;/code&gt;, PHP developers can compete with Go and Rust &lt;strong&gt;without leaving PHP&lt;/strong&gt;. Whether you’re building a high-frequency exchange, an NFT marketplace, or an Ethereum login service, these extensions open new possibilities. Try them, benchmark your workloads, and tell us what you build.&lt;/p&gt;




&lt;h3&gt;
  
  
  References &amp;amp; further reading
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;BuildCoreWorks — &lt;strong&gt;High-performance secp256k1 for PHP&lt;/strong&gt; (benchmarks, install, code) (&lt;a href="https://dev.to/buildcoreworks/building-high-performance-secp256k1-ecdsa-for-php-2987x-faster-2jl3"&gt;DEV Community&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;BuildCoreWorks — &lt;strong&gt;High-performance Keccak-256 for PHP&lt;/strong&gt; (benchmarks, install, code) (&lt;a href="https://dev.to/buildcoreworks/building-a-high-performance-keccak-256-extension-for-php-14-16-faster-57il"&gt;DEV Community&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Bitcoin Wiki — &lt;strong&gt;Why secp256k1 is fast/efficient&lt;/strong&gt; (&lt;a href="https://en.bitcoin.it/wiki/Secp256k1?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Bitcoin Wiki&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Ethereum Stack Exchange — &lt;strong&gt;How addresses are derived (last 20 bytes of Keccak-256(pubkey))&lt;/strong&gt; (&lt;a href="https://ethereum.stackexchange.com/questions/3542/how-are-ethereum-addresses-generated?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Ethereum Stack Exchange&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;JetBrains Developer Ecosystem / Accesto — &lt;strong&gt;PHP remains broadly used in production&lt;/strong&gt; (&lt;a href="https://blog.jetbrains.com/team/2024/12/11/the-state-of-developer-ecosystem-2024-unveiling-current-developer-trends-the-unstoppable-rise-of-ai-adoption-leading-languages-and-impact-on-developer-experience/?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;The JetBrains Blog&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Written By AI&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>blockchain</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Building High-Performance Secp256k1 ECDSA for PHP: 2,987 Faster</title>
      <dc:creator>BuildCoreWorks</dc:creator>
      <pubDate>Wed, 15 Oct 2025 13:28:57 +0000</pubDate>
      <link>https://forem.com/buildcoreworks/building-high-performance-secp256k1-ecdsa-for-php-2987x-faster-2jl3</link>
      <guid>https://forem.com/buildcoreworks/building-high-performance-secp256k1-ecdsa-for-php-2987x-faster-2jl3</guid>
      <description>&lt;h2&gt;
  
  
  Making PHP Viable for Blockchain Development
&lt;/h2&gt;

&lt;p&gt;PHP is rarely used for blockchain applications, and for good reason: pure PHP implementations of secp256k1 ECDSA operations are prohibitively slow. Signing a single transaction can take 90-136 milliseconds—far too slow for production cryptocurrency wallets or blockchain nodes.&lt;/p&gt;

&lt;p&gt;But what if we could make PHP 2,500-3,000× faster at cryptography?&lt;/p&gt;

&lt;h2&gt;
  
  
  The Challenge
&lt;/h2&gt;

&lt;p&gt;Secp256k1 is the elliptic curve used by Bitcoin and Ethereum for signing transactions. It requires complex mathematical operations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Point multiplication on an elliptic curve&lt;/li&gt;
&lt;li&gt;Modular arithmetic with 256-bit integers&lt;/li&gt;
&lt;li&gt;Secure random number generation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PHP, being an interpreted language, struggles with these operations. The best pure PHP implementation (&lt;code&gt;kornrunner/secp256k1&lt;/code&gt;) takes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;90-136ms&lt;/strong&gt; per signature&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;100-135ms&lt;/strong&gt; per verification&lt;/li&gt;
&lt;li&gt;No support for public key recovery&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For context, a blockchain node processing 1,000 transactions per second would need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Signing: 90-136 &lt;strong&gt;seconds&lt;/strong&gt; in pure PHP&lt;/li&gt;
&lt;li&gt;Verification: 100-135 &lt;strong&gt;seconds&lt;/strong&gt; in pure PHP&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's 2-4 minutes per second of transactions. Clearly impractical.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution: C Extension
&lt;/h2&gt;

&lt;p&gt;By wrapping the official &lt;code&gt;libsecp256k1&lt;/code&gt; library (used by Bitcoin Core) in a PHP extension, we achieve:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;0.03-0.06ms&lt;/strong&gt; per signature&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;0.04-0.06ms&lt;/strong&gt; per verification&lt;/li&gt;
&lt;li&gt;Full support for public key recovery (Ethereum-style)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's &lt;strong&gt;2,400-3,000× faster&lt;/strong&gt; than pure PHP.&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance Benchmarks
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Hardware&lt;/th&gt;
&lt;th&gt;Operation&lt;/th&gt;
&lt;th&gt;C Extension&lt;/th&gt;
&lt;th&gt;Pure PHP&lt;/th&gt;
&lt;th&gt;Speedup&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Intel i3-2130 (2011)&lt;/td&gt;
&lt;td&gt;Sign&lt;/td&gt;
&lt;td&gt;0.045 ms&lt;/td&gt;
&lt;td&gt;112.9 ms&lt;/td&gt;
&lt;td&gt;2,509×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AMD Ryzen 7 3700X&lt;/td&gt;
&lt;td&gt;Sign&lt;/td&gt;
&lt;td&gt;0.030 ms&lt;/td&gt;
&lt;td&gt;89.6 ms&lt;/td&gt;
&lt;td&gt;2,987×&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Real-world impact:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;100,000 signatures: 3-5 seconds (C) vs 2.5-3 hours (PHP)&lt;/li&gt;
&lt;li&gt;1,000,000 signatures: 30-45 seconds (C) vs 25-31 hours (PHP)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Implementation Details
&lt;/h2&gt;

&lt;p&gt;The extension provides three functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Sign a message hash&lt;/span&gt;
&lt;span class="nv"&gt;$signature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;secp256k1_sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$messageHash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$privateKey&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Returns: r (64 hex) + s (64 hex) + v (2 hex) = 130 characters&lt;/span&gt;

&lt;span class="c1"&gt;// Verify a signature&lt;/span&gt;
&lt;span class="nv"&gt;$isValid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;secp256k1_verify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$messageHash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$signature&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$publicKey&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Returns: true or false&lt;/span&gt;

&lt;span class="c1"&gt;// Recover public key (Ethereum-style)&lt;/span&gt;
&lt;span class="nv"&gt;$publicKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;secp256k1_recover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$messageHash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$signature&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Returns: 128-character hex (X + Y coordinates)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ethereum Address Derivation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Complete Ethereum workflow&lt;/span&gt;
&lt;span class="nv"&gt;$messageHash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;keccak_hash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$transactionData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$signature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;secp256k1_sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$messageHash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$privateKey&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$publicKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;secp256k1_recover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$messageHash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$signature&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'0x'&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;substr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;keccak_hash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;hex2bin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$publicKey&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Security Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Thread-safe: Uses pthread mutex for ZTS compatibility&lt;/li&gt;
&lt;li&gt;Context randomization: Uses OpenSSL's CSPRNG on initialization&lt;/li&gt;
&lt;li&gt;Secure memory: All private keys and hashes are zeroed after use&lt;/li&gt;
&lt;li&gt;Battle-tested: Wraps libsecp256k1 from Bitcoin Core (production since 2015)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Real-World Applications
&lt;/h2&gt;

&lt;p&gt;With this performance, PHP becomes viable for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cryptocurrency wallets: Sign transactions in real-time&lt;/li&gt;
&lt;li&gt;Blockchain nodes: Process thousands of TPS per node&lt;/li&gt;
&lt;li&gt;dApp backends: Server-side transaction signing&lt;/li&gt;
&lt;li&gt;Payment APIs: High-throughput Bitcoin/Ethereum processing&lt;/li&gt;
&lt;li&gt;Authentication systems: ECDSA-based login&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Blockchain Node Performance
&lt;/h2&gt;

&lt;p&gt;With this extension, a single PHP process can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sign ~33,000 transactions per second&lt;/li&gt;
&lt;li&gt;Verify ~18,000 signatures per second&lt;/li&gt;
&lt;li&gt;Combined throughput: ~16,600 TPS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes real-time blockchain implementations in PHP feasible, including gaming blockchains with sub-100ms block times.&lt;/p&gt;

&lt;p&gt;Installation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install dependencies&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;libsecp256k1-dev libssl-dev php-dev

&lt;span class="c"&gt;# Build extension&lt;/span&gt;
git clone https://github.com/BuildCoreWorks/php-secp256k1.git
&lt;span class="nb"&gt;cd &lt;/span&gt;php-secp256k1
phpize &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ./configure &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; make &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;make &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# Enable extension&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"extension=secp256k1.so"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/php/8.1/mods-available/secp256k1.ini
&lt;span class="nb"&gt;sudo &lt;/span&gt;phpenmod secp256k1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Try It Yourself
&lt;/h2&gt;

&lt;p&gt;Full benchmarks, documentation, and code examples are available on GitHub:&lt;br&gt;
&lt;a href="https://github.com/BuildCoreWorks/php-secp256k1" rel="noopener noreferrer"&gt;https://github.com/BuildCoreWorks/php-secp256k1&lt;/a&gt;&lt;br&gt;
Combined with our php-keccak256 extension, PHP developers now have complete, production-grade cryptography tools for Bitcoin and Ethereum development.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By leveraging C extensions for cryptographic operations, PHP transforms from "too slow for blockchain" to a viable platform for production cryptocurrency applications. The 2,500-3,000× performance improvement isn't incremental—it's the difference between impossible and practical.&lt;/p&gt;

&lt;p&gt;This opens new possibilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building blockchain nodes in a language millions of developers know&lt;/li&gt;
&lt;li&gt;Rapid prototyping of cryptocurrency applications&lt;/li&gt;
&lt;li&gt;Enterprise blockchain solutions using existing PHP infrastructure&lt;/li&gt;
&lt;li&gt;Educational blockchain projects with accessible technology&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The extension is open source (MIT licensed) and production-ready. We're using it for a PHP blockchain implementation capable of real-time transaction processing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try it out and let me know what you build with it!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/BuildCoreWorks/php-secp256k1" rel="noopener noreferrer"&gt;https://github.com/BuildCoreWorks/php-secp256k1&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>opensource</category>
      <category>php</category>
    </item>
    <item>
      <title>Building a High-Performance Keccak-256 Extension for PHP: 14-16 Faster</title>
      <dc:creator>BuildCoreWorks</dc:creator>
      <pubDate>Tue, 14 Oct 2025 08:27:11 +0000</pubDate>
      <link>https://forem.com/buildcoreworks/building-a-high-performance-keccak-256-extension-for-php-14-16-faster-57il</link>
      <guid>https://forem.com/buildcoreworks/building-a-high-performance-keccak-256-extension-for-php-14-16-faster-57il</guid>
      <description>&lt;p&gt;&lt;strong&gt;The Problem:&lt;/strong&gt;&lt;br&gt;
Pure PHP Keccak hashing: 0.28-0.44ms per hash&lt;br&gt;
At scale, this makes Ethereum development impractical&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Solution:&lt;/strong&gt;&lt;br&gt;
C extension using direct memory operations&lt;br&gt;
Benchmarked results: 0.018-0.032ms per hash&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Performance:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Intel i3-2130 (2011): 0.032ms vs 0.443ms = 14× faster&lt;/li&gt;
&lt;li&gt;AMD Ryzen 7 3700X: 0.018ms vs 0.280ms = 16× faster&lt;/li&gt;
&lt;li&gt;Works in Docker and bare metal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Real-world impact:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1M hashes: 18-32 seconds (native) vs 4.6-7.4 minutes (pure PHP)&lt;/li&gt;
&lt;li&gt;10M hashes: 3-5 minutes (native) vs 46-74 minutes (pure PHP)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use Cases:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ethereum address derivation&lt;/li&gt;
&lt;li&gt;Transaction hashing
&lt;/li&gt;
&lt;li&gt;dApp backends&lt;/li&gt;
&lt;li&gt;Any high-throughput crypto work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Installation:&lt;/strong&gt;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
git clone https://github.com/BuildCoreWorks/php-keccak256.git
cd php-keccak256
phpize &amp;amp;&amp;amp; ./configure &amp;amp;&amp;amp; make &amp;amp;&amp;amp; sudo make install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>ethereum</category>
      <category>php</category>
      <category>c</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
