PHP bindings for https://github.com/bitcoin-core/secp256k1
This project seeks to reboot Bit-Wasp's secp256k1-php to make this binding available again for PHP 8.2 and above, as well as exposing the newer secp256k1 APIs of more recent versions.
It is not a fork of the old binding, rather a new implementation built from scratch starting from the official extension skeleton given by PHP 8.5.
The easiest way to install the extension is with PIE:
$ pie check-build-tools
$ sudo apt install libsecp256k1-dev
$ sudo pie install uma/secp256k1-phpThis should take care of building and enabling the extension in PHP on your behalf.
Verify with the --ri flag:
$ php --ri secp256k1
secp256k1
secp256k1 support => enabled
binding version => 0.1.2
libsecp256k1 version => 0.8.0
ecdh module => On
recovery module => On
extrakeys module => On
schnorrsig module => On
ellswift module => On
musig module => Not supported
silentpayments module => Not supportedTODO
TODO (new sections)
Yes. Simply use Composer to install uma/secp256k1-php as a development dependency of your project:
$ composer require --dev uma/secp256k1-phpNOTICE: This isn't a substitute for the real installation described above.
This will just make the secp256k1.stub.php file visible to your IDE so that it's aware of the extension functions.
But this does not install the extension, which is really the secp256k1.so binary shared library.
TODO
How does this extension compare to secp256k1-php?
TODO
Claude Opus 4.6 has written 95% to 99% of the codebase, but my way of using AI involves planning the work in human-digestible chunks and not let it go on until I fully approve and understand each chunk. Each chunk of work usually involves asking questions about the secp256k1 APIs, about the Zend Engine, about cryptography, finding bugs in the logic, finding gaps in the test suite, discussing potential refactors, etc.
This forces the agent to work much slower than it could, but on the other hand I end up building exactly what I want while I catch a lot of errors and learn new things along the way.
I feel confident enough about my understanding of this binding to claim full ownership of the code as if I had written it myself.
The APIs of these modules are remarkably complex and I don't fully understand them at the same level as the others.
I decided to put off the implementation for later releases, since the base module plus extrakeys+schnorrsig is probably what 99% of users will care about.
If you have a use case for the musig or silentpayments APIs let me know in a GitHub issue.
All the other secp256k1 modules are supported, but only if they were enabled in libsecp256k1 when it was built or packaged for your distro.
Does secp256k1 follow semantic versioning?
Only once the binding reaches v1.0.0, if it ever does.
Pre v1.0.0 versions must be considered alpha releases and could break backwards compatibility.
No, sorry Ballmer.
Can secp256k1 be installed with PECL?
No, PECL is deprecated and no effort will be made to add this extension there.
0 comments
log in to comment.