furqansiddiqui/blockchain-core-php
Composer 安装命令:
composer require furqansiddiqui/blockchain-core-php
包简介
Shared cryptographic primitives and chain identity abstractions for blockchain libraries.
README 文档
README
A lightweight PHP library providing cryptographic primitives and elliptic curve abstractions specifically tailored for blockchain development.
Features
- Elliptic Curves Support:
secp256k1(Bitcoin, Ethereum)secp256r1(NIST P-256)brainpoolP256r1
- ECDSA (Elliptic Curve Digital Signature Algorithm):
- High-performance pure-PHP implementation using
ext-gmp. - Deterministic nonce generation via RFC 6979.
- Canonical signature enforcement (BIP 66).
- Public key recovery from signatures.
- Support for compressed and uncompressed public keys.
- High-performance pure-PHP implementation using
- EdDSA Support:
- Abstractions for Edwards-curve Digital Signature Algorithm (e.g., Ed25519).
- Security Focused:
- Uses PHP 8.3
#[\SensitiveParameter]attribute to protect private keys in backtraces. - Implements Low-S normalization for ECDSA signatures.
- Uses PHP 8.3
⚠️ Disclaimer
This library exposes low-level cryptographic functionality. Use at your own risk. No warranties are provided. Perform an independent security review before production use.
Requirements
- PHP 8.3 or higher.
ext-gmpextension.
Installation
You can install the package via composer:
composer require furqansiddiqui/blockchain-core-php
Usage
Secp256k1 Key Generation and Signing
use FurqanSiddiqui\Blockchain\Core\Crypto\Curves\Secp256k1; use Charcoal\Buffers\Types\Bytes32; $secp256k1 = new Secp256k1(); // 1. Generate a public key from a private key $privateKey = new Bytes32(hex2bin("...32_byte_hex_private_key...")); $publicKey = $secp256k1->generatePublicKey($privateKey); echo "Public Key (X): " . bin2hex($publicKey->x->bytes()) . PHP_EOL; echo "Public Key (Y): " . bin2hex($publicKey->y->bytes()) . PHP_EOL; // 2. Sign a message hash (must be 32 bytes for secp256k1) $msgHash = new Bytes32(hash("sha256", "Hello Blockchain", true)); $signature = $secp256k1->sign($privateKey, $msgHash); echo "Signature R: " . bin2hex($signature->r->bytes()) . PHP_EOL; echo "Signature S: " . bin2hex($signature->s->bytes()) . PHP_EOL; // 3. Verify the signature $isValid = $secp256k1->verify($publicKey, $signature, $msgHash); var_dump($isValid); // bool(true)
Working with DER Signatures (BIP 66)
use FurqanSiddiqui\Blockchain\Core\Codecs\EcdsaDerCodec; // Encode signature to DER $der = $signature->toDER(); echo "DER: " . bin2hex($der) . PHP_EOL; // Decode DER signature // (Requires specifying expected scalar bit length) use FurqanSiddiqui\Blockchain\Core\Enums\ScalarBitLength; [$r, $s] = EcdsaDerCodec::decode(ScalarBitLength::Bits256, $der);
Testing
The library is thoroughly tested with vectors from libsecp256k1, RFC 6979, and standard NIST vectors.
To run the tests:
php phpunit.phar
License
This project is licensed under the MIT License - see the LICENSE file for details.
furqansiddiqui/blockchain-core-php 适用场景与选型建议
furqansiddiqui/blockchain-core-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 115 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 02 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 furqansiddiqui/blockchain-core-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 furqansiddiqui/blockchain-core-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 115
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 34
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-10