Download the PHP package bmilleare/drand-php without Composer
On this page you can find all versions of the php package bmilleare/drand-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bmilleare/drand-php
More information about bmilleare/drand-php
Files in bmilleare/drand-php
Package drand-php
Short Description A PHP client for the drand distributed randomness beacon network with BLS12-381 signature verification.
License MIT
Homepage https://github.com/bmilleare/drand-php
Informations about the package drand-php
drand-php
A PHP client for the drand distributed randomness beacon network (the League of Entropy), 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.
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 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
- PHP 8.2+
ext-json,ext-curl(for the bundled HTTP client)- A verification backend (at least one):
ext-ffi+ alibblstshared library, orext-gmp(pure-PHP backend)
Installation
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:
(or build 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
Quick start
A specific round
Verify a beacon you already have
Round / time math
Beacons and schemes
The League of Entropy mainnet runs these chains:
| Beacon | Scheme | Period | Signature | Public key | Message |
|---|---|---|---|---|---|
quicknet |
bls-unchained-g1-rfc9380 |
3s | G1 (48 B) | G2 (96 B) | sha256(round) |
default |
pedersen-bls-chained |
30s | G2 (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
- Fail-closed by design. The client never returns an unverified beacon. A
verification failure raises
InvalidSignatureException; an environment with no backend raisesVerifierUnavailableException. - 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
Cryptographic correctness is pinned by tests that verify genuine captured beacons (positive vectors) and reject tampered ones (negative vectors).
License
MIT — see LICENSE.
All versions of drand-php with dependencies
ext-json Version *
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0