Skip to content
Three beacons' pulses, each verified against its pinned anchor, then mixed into the generator, which reseeds. A drawing of the flow, not a trace of a real process.

Secrets nobody can predict. Draws anyone can check.

ISecureRandom makes keys, tokens and values with an SP 800-90A generator seeded by the operating system and reseeded with every verified pulse from CURBy, NIST and drand. A draw from one pulse can be recomputed by anyone, and every sample on this site is a test.

A beacon's bytes never become a secret on their own, and no random value waits on the network.

Terminal window
dotnet add package NCode.Randomness
dotnet add package NCode.Randomness.Curby
dotnet add package NCode.Randomness.Nist
dotnet add package NCode.Randomness.Drand

NuGet version NuGet downloads CI Target framework OpenSSF Scorecard OpenSSF Best Practices License

One registration adds the generator and three beacons, and one ISecureRandom makes a secret.

var builder = Host.CreateApplicationBuilder(args);
var configuration = builder.Configuration;
var randomness = configuration.GetSection(RandomnessOptions.SectionName);
var curby = configuration.GetSection(CurbyBeaconOptions.SectionName);
var nist = configuration.GetSection(NistBeaconOptions.SectionName);
var drand = configuration.GetSection(DrandBeaconOptions.SectionName);
builder
.Services.AddRandomness(randomness)
.AddCurbyBeacon(curby)
.AddNistBeacon(nist)
.AddDrandBeacon(drand);
builder.Services.AddHealthChecks().AddRandomnessBeacons("ready");

The drawing above is this flow: each beacon’s pulse is verified and mixed into the generator in the background, and the secret you make never waits on any of them.

It does

  • Run an SP 800-90A HMAC_DRBG per processor, seeded from the operating system.
  • Mix each verified pulse into that generator and never use a pulse alone for a secret. ADR-1000
  • Verify every pulse against a pinned anchor before any byte is used.
  • Fetch pulses in the background, so no random value waits on the network.
  • Draw unbiased values of every integer type.
  • Make draws that anyone can reproduce from one pulse, by the algorithm ncode-randomness-draw/1.

It does not

  • Use a beacon’s bytes alone for a secret. Everyone who reads the beacon sees the same bytes.
  • Stop the application when a beacon is down. Outages
  • Verify CURBy-Q’s Bell test or its extraction in process. ADR-1007
  • Keep a key safe in the array GetBytes returns. Make a secret
  • Make a draw secret. Anyone can recompute it from the pulse.

Each guide is one situation, its code and its pitfalls.

Not sure which API you need? Which API? asks a few questions and names one.

  • Four packages: NCode.Randomness, with the generator and the draws, and NCode.Randomness.Curby, NCode.Randomness.Nist and NCode.Randomness.Drand, one adapter for each beacon.
  • The target framework is net10.0, which the badge shows and nuget.org lists.
  • Every C# sample on this site is a test the pull request build compiles and runs.
  • The reasons behind the design are on record in docs/decisions.
  • Apache License 2.0, copyright NCode Group. A vulnerability is reported privately, as the security policy says.