NCode.Randomness.Curby 0.5.0

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

NCode.Randomness.Curby

The CURBy adapter for NCode.Randomness. CURBy, the CU Randomness Beacon of the University of Colorado Boulder, publishes randomness certified by a loophole-free Bell test through the Twine protocol. This package fetches pulses of its CURBy-RNG chain, one a minute, and verifies each one before any byte is used:

  • the chain document hashes to the pinned content identifier CurbyDefaults.RngChainId, which fixes the chain's RSA key, so no server, mirror or certificate authority can substitute another;
  • the pulse and its predecessor each hash to their content identifiers (DAG-CBOR, SHA3-512), hold only the members Twine defines, and carry a canonically encoded RS256 signature by the chain's key, so no server can change a pulse's randomness without breaking a check;
  • the predecessor is the pulse's first link and one round earlier, and the pulse's salt matches the predecessor's precommitment.

The randomness is the pulse's 64-byte SHA3-512 digest, as CURBy's own client library defines it. SHA3-512 comes from the operating system where it has one and from a managed implementation elsewhere, such as Windows Server 2022.

builder.Services
    .AddRandomness(builder.Configuration.GetSection(RandomnessOptions.SectionName))
    .AddCurbyBeacon(builder.Configuration.GetSection(CurbyBeaconOptions.SectionName));

Settings bind from RandomnessBeacons:Curby: BaseAddress (default https://api.entwine.me/; a mirror can withhold pulses but never forge one), ChainId, QuantumChainId, BellChainId, MaxResponseBytes and ChainRetryDelay (default 1 minute; how long a failed chain fetch is remembered; each chain is fetched once, under its own 30-second timeout, for every caller). Requests use a named HttpClient, CurbyDefaults.HttpClientName, with retries, attempt and total timeouts and a circuit breaker; add a proxy or other handlers to it with services.AddHttpClient(CurbyDefaults.HttpClientName).

Verifying Saved Documents

CurbyPulseVerifier makes the same checks without the network, on documents a caller supplies: the chain, a pulse and its predecessor, each the UTF-8 JSON the Twine API serves. It pins CurbyDefaults.RngChainId, or the chain identifier its constructor takes, 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 CurbyPulseVerifier().Verify(chainJson, pulseJson, predecessorJson);
using var draw = VerifiableRandom.Create(pulse, context);

CURBy-Q

AddCurbyQuantumBeacon() registers a second beacon, curby-q, which reads the CURBy-Q (DIRNG) chain. It shares the settings, the HttpClient and the Twine verification code with the CURBy-RNG beacon, and the two can be registered together.

A CURBy-Q round is the set of pulses CURBy publishes for one run of the Bell test: a request, a precommitment and, when the run succeeds, a randomness pulse. The round's randomness is the 64 bytes in the randomness pulse, the output of the Trevisan extractor that CURBy publishes. The beacon's pulse carries the DIRNG round number, the randomness pulse's content identifier and timestamp, and those bytes. A round that failed, or has not completed, gives no pulse.

The beacon refuses a round unless it passes the checks CURBy's own client library makes:

  • the chain document hashes to the pinned content identifier CurbyDefaults.QuantumChainId, which fixes the chain's RSA key;
  • every pulse of the round hashes to its content identifier, holds only the members Twine defines, and carries a canonically encoded RS256 signature by the chain's key; the pulses are consecutive and carry one round number;
  • the Bell chain is the pinned CurbyDefaults.BellChainId, and one of the ten Bell pulses up to the one the precommitment mixes in answers the round's request with the precommitment's data hash, which the randomness pulse carries too;
  • the seed chain is the one the signed precommitment names, the seed pulse is the one its rule selects among the seed chain's pulses that mix in the precommitment, and each pulse crawled to reach it is the one requested and precedes the one after it;
  • the round's parameters hash to the randomness pulse's paramsHash, and SHAKE256 of the seed pulse's digest, expanded to the precommitment's seedLength bits, equals the parameters' seed.

The beacon does not verify the Bell-test certificate or the Trevisan extraction in process. The extractor is GPL-licensed code with no specification, and a round needs about 9 MB of raw Bell data, so ADR-1007 leaves them to CURBy's curby_verify tool, which checks a round with docker compose run --rm verify <round>. The round number of a draw's pulse is the one to give it. Those bytes are only additional input to the generator and never the sole source of a secret, so what stays unverified does not weaken one.

CURBy-Q completes a round about every 13 minutes while it runs (as of 2026-11-25, measured as ADR-1007's Context records), longer than the default Randomness:MaxPulseAge of 10 minutes. AddCurbyQuantumBeacon() allows curby-q pulses up to 30 minutes old through Randomness:MaxPulseAgeByBeacon:curby-q, which a host can set itself, and leaves every other beacon's limit as it is. CURBy-Q has published no round since 2025-08-22 (as of 2026-11-25, from the same record), so while it stays stalled the beacon reports stale pulses and the health check reports Degraded; draws over published rounds are unaffected.

SHAKE256 comes from the operating system where it has one and from a managed implementation elsewhere, as SHA3-512 does.

Verifying Saved Rounds

CurbyQuantumRoundVerifier makes the same checks without the network, on documents a caller supplies: the round and its parameters, as the API serves them at curbyq/round/<round> and curbyq/round/<round>/params, and the chain and pulse documents the round links to, as it serves them at chains/<chain> and chains/<chain>/pulses/<cid>, in any order: the CURBy-Q, Bell and seed chains, the Bell pulses from the one the precommitment mixes in back to the response, and the seed pulses from the one the randomness pulse mixes in back to the first that does not mix in the precommitment. It pins CurbyDefaults.QuantumChainId and CurbyDefaults.BellChainId, or the chain identifiers its constructor takes, looks up each document the beacon would fetch by its content identifier, and returns the pulse the beacon returns for that round, or throws a BeaconException with InvalidPulse. It leaves the Bell-test certificate and the extraction to curby_verify, as the beacon does:

var pulse = new CurbyQuantumRoundVerifier().Verify(roundJson, parameters, documents);
using var draw = VerifiableRandom.Create(pulse, context);
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 58 11/26/2026
0.5.2 48 11/26/2026
0.5.1 41 11/25/2026
0.5.0 44 11/25/2026
0.4.1 53 11/25/2026
0.4.0 49 11/25/2026
0.3.0 44 11/25/2026
0.2.0 52 11/25/2026