PHPackages                             bmilleare/drand-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. bmilleare/drand-php

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

bmilleare/drand-php
===================

A PHP client for the drand distributed randomness beacon network with BLS12-381 signature verification.

v0.1.0(1mo ago)00MITPHPPHP &gt;=8.2CI passing

Since May 30Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/bmilleare/drand-php)[ Packagist](https://packagist.org/packages/bmilleare/drand-php)[ Docs](https://github.com/bmilleare/drand-php)[ RSS](/packages/bmilleare-drand-php/feed)WikiDiscussions master Synced 1w ago

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

drand-php
=========

[](#drand-php)

[![CI](https://github.com/bmilleare/drand-php/actions/workflows/ci.yml/badge.svg)](https://github.com/bmilleare/drand-php/actions/workflows/ci.yml)[![Packagist](https://camo.githubusercontent.com/89370267b3849ccdbda9ed298e16a69896292a9d21412d0c8e5c3bd85c589f82/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626d696c6c656172652f6472616e642d7068702e737667)](https://packagist.org/packages/bmilleare/drand-php)[![PHP Version](https://camo.githubusercontent.com/7f7b312c2423f423b82c6c473cbcc9575ad9d48239025829bc591a2b83cec7df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f626d696c6c656172652f6472616e642d7068702e737667)](https://packagist.org/packages/bmilleare/drand-php)[![License](https://camo.githubusercontent.com/8198350062a8983d40fc21ee6829e5babda1f50566c52207ab9afa7a5c392a95/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f626d696c6c656172652f6472616e642d7068702e737667)](LICENSE)

A PHP client for the [drand](https://drand.love) distributed randomness beacon network (the [League of Entropy](https://www.cloudflare.com/leagueofentropy/)), with **cryptographic verification** of the BLS12-381 threshold signatures.

drand-php is **fail-closed**: `latest()` and `round()` return a beacon only when its signature verifies against the chain's distributed public key — otherwise they throw. You never get unverified randomness by accident.

```
use Bmilleare\Drand\DrandClient;

$client = DrandClient::create($httpClient, $httpFactory, beaconId: 'quicknet');

$beacon = $client->latest();           // fetched AND verified
echo $beacon->round, PHP_EOL;          // e.g. 29110875
echo $beacon->randomnessHex(), PHP_EOL; // 32-byte verifiable random value
```

Features
--------

[](#features)

- Fetch randomness from any drand relay over the v2 (and v1) HTTP API.
- Verify BLS12-381 signatures for all three League-of-Entropy schemes.
- Two interchangeable verification backends behind one interface:
    - **blst** — the audited [supranational/blst](https://github.com/supranational/blst)C library via FFI (fast).
    - **pure-PHP** — a dependency-free backend using `ext-gmp` (portable).
- PSR-18 / PSR-17 transport: bring your own HTTP client (Guzzle, Symfony, ...) or use the bundled cURL client.
- Round/time helpers: compute the round at any timestamp and vice-versa.

Requirements
------------

[](#requirements)

- PHP 8.2+
- `ext-json`, `ext-curl` (for the bundled HTTP client)
- A verification backend (at least one):
    - `ext-ffi` + a `libblst` shared library, **or**
    - `ext-gmp` (pure-PHP backend)

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

[](#installation)

```
composer require bmilleare/drand-php
```

### Verification backend

[](#verification-backend)

The client refuses to run without a working verification backend (it throws `VerifierUnavailableException`). Enable one:

**Option A — blst (fast):** enable `ext-ffi` and provide a `libblst` shared library. Build it once:

```
php vendor/bmilleare/drand-php/bin/install-blst.php
# builds resources/lib/libblst.
```

(or build [blst](https://github.com/supranational/blst) yourself with `./build.sh -shared` and point `BlstVerifier` at the resulting library).

**Option B — pure-PHP (portable):** install `ext-gmp`. No native library needed.

`VerifierFactory::auto()` prefers blst when available and falls back to pure-PHP.

Usage
-----

[](#usage)

### Quick start

[](#quick-start)

```
use Bmilleare\Drand\DrandClient;
use Bmilleare\Drand\Http\CurlHttpClient;
use GuzzleHttp\Psr7\HttpFactory; // any PSR-17 factory

$factory = new HttpFactory();
$http    = new CurlHttpClient($factory, $factory);

$client = DrandClient::create($http, $factory, beaconId: 'quicknet');

$beacon = $client->latest();
printf("round %d: %s\n", $beacon->round, $beacon->randomnessHex());
```

### A specific round

[](#a-specific-round)

```
$beacon = $client->round(29110875);   // verified, or throws InvalidSignatureException
```

### Verify a beacon you already have

[](#verify-a-beacon-you-already-have)

```
if ($client->verify($beacon)) {
    // signature is valid
}
```

### Round / time math

[](#round--time-math)

```
$info = $client->chainInfo();
$round = $info->roundAt(time());      // current round number
$emittedAt = $info->timeOfRound($round);
```

Beacons and schemes
-------------------

[](#beacons-and-schemes)

The League of Entropy mainnet runs these chains:

BeaconSchemePeriodSignaturePublic keyMessage`quicknet``bls-unchained-g1-rfc9380`3sG1 (48 B)G2 (96 B)`sha256(round)``default``pedersen-bls-chained`30sG2 (96 B)G1 (48 B)`sha256(prev‖round)``quicknet` is recommended for new applications: it is unchained (statelessly verifiable) and has smaller, faster signatures. The randomness for every scheme is `sha256(signature)`.

Security
--------

[](#security)

- **Fail-closed by design.** The client never returns an unverified beacon. A verification failure raises `InvalidSignatureException`; an environment with no backend raises `VerifierUnavailableException`.
- **Pin the chain hash / public key** you expect for production use, and fetch chain info over a trusted channel — a malicious relay could otherwise serve a self-consistent fake chain.
- The blst backend uses an audited C library. The pure-PHP backend is a from-scratch implementation provided for portability; prefer blst where you can.

Testing
-------

[](#testing)

```
composer install
vendor/bin/phpunit                      # all tests (network tests skip if offline)
vendor/bin/phpunit --testsuite unit     # offline only
```

Cryptographic correctness is pinned by tests that verify **genuine** captured beacons (positive vectors) and reject tampered ones (negative vectors).

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance89

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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

55d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed907bcb4cec221659478dc44dd9f88cd31b5d27546530002d85a40c72081b52?d=identicon)[bmilleare](/maintainers/bmilleare)

---

Top Contributors

[![bmilleare](https://avatars.githubusercontent.com/u/21267?v=4)](https://github.com/bmilleare "bmilleare (20 commits)")

---

Tags

beaconblsrandomnessdrandbls12-381league-of-entropyverifiable-randomnessvrf

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bmilleare-drand-php/health.svg)

```
[![Health](https://phpackages.com/badges/bmilleare-drand-php/health.svg)](https://phpackages.com/packages/bmilleare-drand-php)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k16](/packages/tempest-framework)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[cakephp/cakephp

The CakePHP framework

8.8k19.5M1.8k](/packages/cakephp-cakephp)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

36789.4k2](/packages/telnyx-telnyx-php)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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