PHPackages                             furqansiddiqui/blockchain-core-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. furqansiddiqui/blockchain-core-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

furqansiddiqui/blockchain-core-php
==================================

Shared cryptographic primitives and chain identity abstractions for blockchain libraries.

0.1.0(3mo ago)1871MITPHPPHP ^8.5CI passing

Since Feb 14Pushed 3mo agoCompare

[ Source](https://github.com/furqansiddiqui/blockchain-core-php)[ Packagist](https://packagist.org/packages/furqansiddiqui/blockchain-core-php)[ Docs](https://github.com/furqansiddiqui/blockchain-core-php)[ RSS](/packages/furqansiddiqui-blockchain-core-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (1)

Blockchain Core PHP
===================

[](#blockchain-core-php)

[![Tests Passing](https://github.com/furqansiddiqui/blockchain-core-php/actions/workflows/tests.yml/badge.svg)](https://github.com/furqansiddiqui/blockchain-core-php/actions)[![MIT License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

A lightweight PHP library providing cryptographic primitives and elliptic curve abstractions specifically tailored for blockchain development.

Features
--------

[](#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.
- **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.

⚠️ Disclaimer
-------------

[](#️-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
------------

[](#requirements)

- PHP 8.3 or higher.
- `ext-gmp` extension.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require furqansiddiqui/blockchain-core-php
```

Usage
-----

[](#usage)

### Secp256k1 Key Generation and Signing

[](#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)

[](#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
-------

[](#testing)

The library is thoroughly tested with vectors from `libsecp256k1`, RFC 6979, and standard NIST vectors.

To run the tests:

```
php phpunit.phar
```

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance82

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

93d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11485189?v=4)[M. Furqan Siddiqui](/maintainers/furqansiddiqui)[@furqansiddiqui](https://github.com/furqansiddiqui)

---

Top Contributors

[![furqansiddiqui](https://avatars.githubusercontent.com/u/11485189?v=4)](https://github.com/furqansiddiqui "furqansiddiqui (40 commits)")

### Embed Badge

![Health badge](/badges/furqansiddiqui-blockchain-core-php/health.svg)

```
[![Health](https://phpackages.com/badges/furqansiddiqui-blockchain-core-php/health.svg)](https://phpackages.com/packages/furqansiddiqui-blockchain-core-php)
```

###  Alternatives

[optimistdigital/nova-multiselect-field

A multiple select field for Laravel Nova.

3403.5M7](/packages/optimistdigital-nova-multiselect-field)[symfony/semaphore

Symfony Semaphore Component

373.9M6](/packages/symfony-semaphore)[furqansiddiqui/bip39-mnemonic-php

BIP39 Mnemonics implementation in PHP

56176.9k18](/packages/furqansiddiqui-bip39-mnemonic-php)[crell/fp

Functional utilities for PHP 8 and later

91429.8k11](/packages/crell-fp)[php-stubs/wordpress-globals

Global variables and global constants from WordPress core.

13799.0k17](/packages/php-stubs-wordpress-globals)[instaclick/symfony2-coding-standard

A code standard to check against the Symfony coding standards.

1048.5k13](/packages/instaclick-symfony2-coding-standard)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
