NCode.Randomness.Drand 1.0.0

Prefix Reserved
dotnet add package NCode.Randomness.Drand --version 1.0.0
                    
NuGet\Install-Package NCode.Randomness.Drand -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NCode.Randomness.Drand" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NCode.Randomness.Drand" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="NCode.Randomness.Drand" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NCode.Randomness.Drand --version 1.0.0
                    
#r "nuget: NCode.Randomness.Drand, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NCode.Randomness.Drand@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NCode.Randomness.Drand&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=NCode.Randomness.Drand&version=1.0.0
                    
Install as a Cake Tool

NCode.Randomness.Drand

CI Target framework Documentation License

The drand adapter for NCode.Randomness. drand is a distributed randomness beacon run by the League of Entropy, a group of independent organizations that jointly sign each round with a BLS12-381 threshold signature. This package fetches rounds of the quicknet chain, which publishes a round every 3 seconds, registered as the beacon drand, and verifies each one before any byte is used:

  • every document's text is well-formed Unicode before any member is read;
  • the round's signature is a point of the BLS12-381 group G1, other than the identity;
  • the signature verifies against the quicknet group public key pinned in DrandDefaults.PublicKey, so no server or mirror can substitute another key: the pairing e(signature, g2) must equal e(H(message), key), where the message is the SHA-256 hash of the round number as 8 big-endian bytes and H is the hash to curve of RFC 9380, BLS12381G1_XMD:SHA-256_SSWU_RO_, with the domain separation tag BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_;
  • when the response carries a randomness member, it is the SHA-256 hash of the signature;
  • the response answers the round that was asked for.

Only the quicknet chain is supported: its chain hash, group public key, genesis time and period are constants in DrandDefaults, and no chain info document is fetched. Other members of a round that the chain does not sign are ignored.

The randomness is the 32-byte SHA-256 hash of the round's signature. The beacon's pulse carries the quicknet chain hash as its chain, the round number as its round, the signature in lowercase hex as its identifier, and the time the round is due: the genesis time plus 3 seconds for each round before it. Rounds start at 1, so a round below 1 is reported as not found.

Installation

dotnet add package NCode.Randomness.Drand

The package depends on NCode.Randomness, so adding it brings the generator too. It targets net10.0.

Registration

AddDrandBeacon() registers the drand beacon:

var configuration = builder.Configuration;
var randomness = configuration.GetSection(RandomnessOptions.SectionName);
var drand = configuration.GetSection(DrandBeaconOptions.SectionName);
builder.Services.AddRandomness(randomness).AddDrandBeacon(drand);

Settings bind from RandomnessBeacons:Drand: BaseAddress (default https://api.drand.sh/) and MaxResponseBytes (default 16 KiB; a round is about 200 bytes). The same chain is served by other relays, such as https://api2.drand.sh/, https://api3.drand.sh/ and https://drand.cloudflare.com/. Because every round is verified against the pinned group public key, a mirror can withhold rounds but never forge one. Requests use a named HttpClient, DrandDefaults.HttpClientName, with retries, attempt and total timeouts and a circuit breaker; add a proxy or other handlers to it with services.AddHttpClient(DrandDefaults.HttpClientName).

Verifying saved documents

DrandRoundVerifier makes the same checks without the network, on a round a caller supplies as the UTF-8 JSON the API serves at <chain hash>/public/<round>. It pins the quicknet chain, as the beacon does, so the round is the only document it needs, and returns the pulse the beacon returns for that round, or throws a BeaconException with InvalidPulse. Pass the pulse to VerifiableRandom.Create to recompute a published draw, as docs/draws.md describes:

var pulse = new DrandRoundVerifier().Verify(roundJson);
using var draw = VerifiableRandom.Create(pulse, "example-raffle-2026-11-25");

BLS12-381

The pairing arithmetic comes from the managed Neo.Cryptography.BLS12_381 library, so the package has no native dependency and runs wherever .NET does. That library does not hash to the curve, so the adapter implements the RFC 9380 hash to G1 itself, and its tests pin the result to the RFC's test vectors. Verifying one round takes about 0.15 seconds. ADR-1010 records the choice.

Learn more

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 51 11/26/2026
0.5.3 53 11/26/2026
0.5.2 48 11/26/2026
0.5.1 41 11/25/2026
0.5.0 41 11/25/2026
0.4.1 46 11/25/2026
0.4.0 54 11/25/2026
0.3.0 46 11/25/2026