NCode.Randomness 0.4.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package NCode.Randomness --version 0.4.0
                    
NuGet\Install-Package NCode.Randomness -Version 0.4.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" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NCode.Randomness" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="NCode.Randomness" />
                    
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 --version 0.4.0
                    
#r "nuget: NCode.Randomness, 0.4.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@0.4.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&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=NCode.Randomness&version=0.4.0
                    
Install as a Cake Tool

NCode.Randomness

Cryptographically secure random numbers for .NET, strengthened by public randomness beacons such as CURBy, and reproducible draws that anyone can check against a beacon pulse.

  • ISecureRandom: an NIST SP 800-90A HMAC_DRBG (HMAC-SHA-512) per processor, seeded and reseeded from the operating system's CSPRNG, with every verified beacon pulse mixed in as additional input. Its output is at least as strong as the operating system's generator whatever a beacon publishes, and a call never waits on the network.
  • Typed values over any source: unbiased integers in any range for every integer type from byte to UInt128, doubles, singles, booleans, version 4 GUIDs, shuffles, choices, strings from an alphabet, and a System.Random adapter.
  • Beacons in the background: one loop per registered beacon, with timeouts, back-off and jitter; Continuous, InitializeOnly (start online, then run offline) and Offline modes; rollback, equivocation and staleness checks; a health check that reports an outage as Degraded; metrics through IMeterFactory.
  • Reproducible draws: IVerifiableRandomFactory derives a deterministic stream, ncode-randomness-draw/1, from one verified pulse and a context label, for raffles, audits and sortition. It is deliberately not an ISecureRandom.
  • RandomnessHost: the same generator and beacons without dependency injection, for console tools and libraries: build it with RandomnessHost.CreateBuilder() and BuildAsync, and dispose it to stop the beacons.
  • SystemRandomSource.Instance: the operating system's generator behind the same API, with no beacon and nothing to dispose.
builder.Services
    .AddRandomness(builder.Configuration.GetSection(RandomnessOptions.SectionName))
    .AddCurbyBeacon(); // from NCode.Randomness.Curby

public sealed class TokenService(ISecureRandom random)
{
    public byte[] NewKey() => random.GetBytes(32);

    public int RollDie() => random.NextInteger(1, 7);
}

Beacon adapters implement IRandomnessBeacon and register with AddBeacon<TBeacon>(). The repository's README and docs/ folder hold the full guide, the draw specification and the decision records.

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 (3)

Showing the top 3 NuGet packages that depend on NCode.Randomness:

Package Downloads
NCode.Randomness.Curby

The CURBy (CU Randomness Beacon, University of Colorado Boulder) adapter for NCode.Randomness: fetches pulses of the CURBy-RNG Twine chain and rounds of the CURBy-Q chain, or takes their saved documents offline, and verifies their content identifiers, RS256 signatures and precommitments against pinned chains before any byte is used.

NCode.Randomness.Drand

The drand adapter for NCode.Randomness: fetches rounds of the League of Entropy's quicknet chain, or takes saved round documents offline, and verifies their BLS12-381 threshold signatures against the pinned group public key before any byte is used.

NCode.Randomness.Nist

The NIST Randomness Beacon 2.0 adapter for NCode.Randomness: fetches pulses of the NIST beacon's chain, or takes saved pulse and certificate documents offline, and verifies their RSA signatures against pinned certificates, their output values, and their hash chain and precommitment to the previous pulse before any byte is used.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 52 11/26/2026
0.5.3 68 11/26/2026
0.5.2 51 11/26/2026
0.5.1 38 11/25/2026
0.5.0 48 11/25/2026
0.4.1 53 11/25/2026
0.4.0 53 11/25/2026
0.3.0 49 11/25/2026
0.2.0 51 11/25/2026