NCode.Randomness.Nist 0.5.2

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

NCode.Randomness.Nist

The NIST Randomness Beacon 2.0 adapter for NCode.Randomness. The beacon of the National Institute of Standards and Technology publishes a signed, hash-chained pulse of 512 random bits every minute. This package fetches pulses of its chain 2, registered as the beacon nist, and verifies each one before any byte is used:

  • the pulse's certificate is one of the pinned identifiers in NistDefaults.CertificateIds, each the SHA-512 hash of a certificate's DER encoding, so no server, mirror or certificate authority can substitute another key; the certificate holds an RSA key of at least 2048 bits and its validity covers the pulse's timestamp;
  • the pulse is version 2.0 with cipher suite 0 (RSA PKCS #1 v1.5 with SHA-512) on the pinned chain, and its signature has the exact length of the certificate's modulus and verifies over the pulse's signed fields, which the adapter rebuilds byte for byte as the NIST XSD lists them;
  • the pulse's output value is the SHA-512 hash of its signed bytes and its signature;
  • the pulse is used only with its verified predecessor, on the same chain, one index earlier and earlier in time: the pulse's first list value, of type previous, is the predecessor's output value, and the SHA-512 hash of the pulse's local random value is the predecessor's precommitment value.

Because every pulse needs a predecessor, a round below 2 is reported as not found. Members of a pulse that are not signed are ignored.

The randomness is the pulse's 64-byte output value. The beacon's pulse carries the chain index 2 as its chain, the pulse index as its round, the output value in uppercase hex as its identifier, and the pulse's timestamp.

builder.Services
    .AddRandomness(builder.Configuration.GetSection(RandomnessOptions.SectionName))
    .AddNistBeacon(builder.Configuration.GetSection(NistBeaconOptions.SectionName));

Settings bind from RandomnessBeacons:Nist: BaseAddress (default https://beacon.nist.gov/beacon/2.0/; a mirror can withhold pulses but never forge one), ChainIndex (default 2), CertificateIds (empty by default, which trusts NistDefaults.CertificateIds; a configured list replaces them), CertificateRetryDelay (default 1 minute; how long a failed certificate fetch is remembered before a pulse that names the certificate tries again; each certificate is fetched once, under its own 30-second timeout, for every caller) and MaxResponseBytes (default 64 KiB). Requests use a named HttpClient, NistDefaults.HttpClientName, with retries, attempt and total timeouts and a circuit breaker; add a proxy or other handlers to it with services.AddHttpClient(NistDefaults.HttpClientName).

The pinned certificates are not validated as a WebPKI chain, which would trust any public certificate authority's certificate for the name; they are trusted by identifier alone, as ADR-1009 records.

Verifying Saved Documents

NistPulseVerifier makes the same checks without the network, on documents a caller supplies: a pulse and its predecessor, each the UTF-8 JSON the API serves at chain/<chain>/pulse/<index>, and the PEM certificate it serves at certificate/<id> for the identifier the pulse names, with the predecessor's too when it names another one, as across a certificate rotation. It pins chain 2 and NistDefaults.CertificateIds, or the chain index and certificate identifiers its constructor takes, and returns the pulse the beacon returns for that index, or throws a BeaconException with InvalidPulse. A certificate must cover the pulse's timestamp, not today, so a pulse stays checkable after its certificate expires. Pass the pulse to VerifiableRandom.Create to recompute a published draw, as docs/draws.md describes:

var pulse = new NistPulseVerifier().Verify(pulseJson, predecessorJson, certificatePem);
using var draw = VerifiableRandom.Create(pulse, context);

Certificate rotation

NIST replaces its signing certificate about once a year, and the current one expires on 2027-03-20. The beacon refuses a pulse signed with a certificate that is not pinned, and a release pins the next certificate only once NIST publishes it. Until one does, list every identifier to trust under RandomnessBeacons:Nist:CertificateIds, which replaces the defaults, after checking that:

  • https://beacon.nist.gov/beacon/2.0/certificate/<id> is NIST's engine.beacon.nist.gov certificate; and
  • the SHA-512 hash of its DER encoding is the identifier.

The pulses 1925734 to 1996050 name a certificate that does not verify them, so the beacon refuses them, and it refuses pulse 1996051 too, since a pulse is used only with its verified predecessor.

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 49 11/26/2026
0.5.3 55 11/26/2026
0.5.2 49 11/26/2026
0.5.1 37 11/25/2026
0.5.0 42 11/25/2026
0.4.1 47 11/25/2026
0.4.0 51 11/25/2026
0.3.0 44 11/25/2026