Skip to content

ReferenceAPI map

API map

Every public type and member, with its signature, what it does and the page that explains it.

This page lists every public type and member of the four packages NCode.Randomness, NCode.Randomness.Curby, NCode.Randomness.Nist and NCode.Randomness.Drand. The gate fails when this map and the four packages’ PublicAPI files differ, so every member that ships has an entry.

MemberSignatureWhat it doesExplained on
ISecureRandompublic interface ISecureRandom : IRandomSourceA cryptographically secure random source: its bytes are unpredictable to everyone, so they suit keys, secrets, tokens, salts and nonces. It adds no member to IRandomSource; it is a capability that the type system checks./guides/make-a-secret/
IRandomSourcepublic interface IRandomSourceProduces uniformly distributed random bytes. Every typed value, range, shuffle and selection in this library is built on this one operation./guides/draw-values/
IRandomSource.Fillvoid Fill(Span<byte> destination)Fills destination with random bytes. An empty buffer is left as it is./guides/draw-values/
SystemRandomSourcepublic sealed class SystemRandomSource : ISecureRandomThe operating system's cryptographically secure random number generator as an ISecureRandom. Use it wherever no beacon is wanted, such as in an air-gapped deployment./guides/make-a-secret/
SystemRandomSource.Instancepublic static SystemRandomSource Instance { get; }The shared instance. The type is stateless and thread-safe, so the one instance serves every caller, and it needs no disposal./guides/make-a-secret/
SystemRandomSource.Fillpublic void Fill(Span<byte> destination)Fills destination with bytes from RandomNumberGenerator./guides/make-a-secret/
RandomSourceExtensionspublic static class RandomSourceExtensionsextension(IRandomSource source)Typed values, ranges, shuffles and selections over any IRandomSource. Every member is unbiased, and deterministic given the source's bytes./guides/draw-values/
RandomSourceExtensions.AsRandompublic static Random AsRandom(this IRandomSource source)Returns a Random that draws every value from this source, for an API that takes one. It is as secret, and as thread-safe, as the source./guides/draw-values/
RandomSourceExtensions.GetBytespublic static byte[] GetBytes(this IRandomSource source, int count)Returns a new array of count random bytes. The array is neither pinned nor cleared, so for a key call Fill on a stackalloc or pinned span and clear it after use./guides/draw-values/
RandomSourceExtensions.GetItempublic static T GetItem<T>(this IRandomSource source, ReadOnlySpan<T> choices)Returns one of choices, each equally likely. There must be at least one choice./guides/draw-values/
RandomSourceExtensions.GetItemspublic static void GetItems<T>(this IRandomSource source, ReadOnlySpan<T> choices, Span<T> destination)Fills destination with values chosen independently from choices, each equally likely, with repetition./guides/draw-values/
RandomSourceExtensions.GetStringpublic static string GetString(this IRandomSource source, string alphabet, int length)Returns a string of length characters chosen independently from alphabet, such as a password or a recovery code. Each character of the alphabet must be distinct./guides/draw-values/
RandomSourceExtensions.NextBooleanpublic static bool NextBoolean(this IRandomSource source)Returns true or false with equal probability./guides/draw-values/
RandomSourceExtensions.NextDoublepublic static double NextDouble(this IRandomSource source)Returns a double drawn uniformly from [0, 1), with all 53 bits of its mantissa random./guides/draw-values/
RandomSourceExtensions.NextGuidpublic static Guid NextGuid(this IRandomSource source)Returns a random RFC 9562 version 4 Guid, with 122 random bits./guides/draw-values/
RandomSourceExtensions.NextIntegerpublic static T NextInteger<T>(this IRandomSource source) where T : IBinaryInteger<T>, IMinMaxValue<T>public static T NextInteger<T>(this IRandomSource source, T maxExclusive) where T : IBinaryInteger<T>, IMinMaxValue<T>public static T NextInteger<T>(this IRandomSource source, T minInclusive, T maxExclusive) where T : IBinaryInteger<T>, IMinMaxValue<T>Returns an integer drawn uniformly from every value of T, from zero up to maxExclusive, or from minInclusive up to maxExclusive. A die roll is NextInteger(1, 7)./guides/draw-values/
RandomSourceExtensions.NextSinglepublic static float NextSingle(this IRandomSource source)Returns a float drawn uniformly from [0, 1), with all 24 bits of its mantissa random./guides/draw-values/
RandomSourceExtensions.Shufflepublic static void Shuffle<T>(this IRandomSource source, Span<T> values)Shuffles values in place with the Fisher–Yates algorithm, so every order is equally likely./guides/draw-values/
MemberSignatureWhat it doesExplained on
RandomnessServiceCollectionExtensionspublic static class RandomnessServiceCollectionExtensionsextension(IServiceCollection services)Registers the secure generator, the beacon collector and reproducible draws./guides/add-beacons/
RandomnessServiceCollectionExtensions.AddRandomnesspublic static IRandomnessBuilder AddRandomness(this IServiceCollection services)public static IRandomnessBuilder AddRandomness(this IServiceCollection services, Action<RandomnessOptions> configure)public static IRandomnessBuilder AddRandomness(this IServiceCollection services, IConfiguration configuration)Registers ISecureRandom, IBeaconStatus, IVerifiableRandomFactory and the background beacon collector, with default options, options set by configure or options bound from configuration. Add beacons to the returned builder; with none, the generator runs from the operating system's entropy alone./guides/add-beacons/
IRandomnessBuilderpublic interface IRandomnessBuilderAdds beacons and other parts to the randomness services that AddRandomness() registers or a RandomnessHost builds./guides/add-beacons/
IRandomnessBuilder.ServicesIServiceCollection Services { get; }Gets the service collection./guides/add-beacons/
RandomnessBuilderExtensionspublic static class RandomnessBuilderExtensionsextension(IRandomnessBuilder builder)Registers randomness beacons./guides/add-beacons/
RandomnessBuilderExtensions.AddBeaconpublic static IRandomnessBuilder AddBeacon<TBeacon>(this IRandomnessBuilder builder)Registers TBeacon as a singleton beacon. Each beacon class registers once, and its IRandomnessBeacon.Name must be unique among the registered beacons./guides/add-beacons/
RandomnessHostpublic sealed class RandomnessHost : IAsyncDisposableThe secure generator, the background beacon collection and reproducible draws, composed without dependency injection, for console tools and libraries that run without a host. Keep one instance for the life of the application./guides/run-without-a-host/
RandomnessHost.CreateBuilderpublic static RandomnessHostBuilder CreateBuilder()public static RandomnessHostBuilder CreateBuilder(Action<RandomnessOptions> configure)public static RandomnessHostBuilder CreateBuilder(IConfiguration configuration)Creates a builder with default options, options set by configure or options bound from configuration. An unknown configuration key fails BuildAsync, so a misspelled setting is never silently ignored./guides/run-without-a-host/
RandomnessHost.SecureRandompublic ISecureRandom SecureRandom { get; }Gets the secure generator./guides/run-without-a-host/
RandomnessHost.BeaconStatuspublic IBeaconStatus BeaconStatus { get; }Gets the health of the beacon collection./guides/run-without-a-host/
RandomnessHost.VerifiableRandomFactorypublic IVerifiableRandomFactory VerifiableRandomFactory { get; }Gets the factory for reproducible draws./guides/run-without-a-host/
RandomnessHost.DisposeAsyncpublic ValueTask DisposeAsync()Stops the beacon collection, waiting up to 30 seconds, and disposes the generator, zeroing its state. A second call does nothing./guides/run-without-a-host/
RandomnessHostBuilderpublic sealed class RandomnessHostBuilder : IRandomnessBuilderComposes a RandomnessHost: add beacons with the adapters' extension members, such as AddCurbyBeacon(), then call BuildAsync once./guides/run-without-a-host/
RandomnessHostBuilder.Servicespublic IServiceCollection Services { get; }Gets the services the host is built from. Add what a host would add, such as a logging provider; a registration made after BuildAsync has no effect./guides/run-without-a-host/
RandomnessHostBuilder.BuildAsyncpublic ValueTask<RandomnessHost> BuildAsync(CancellationToken cancellationToken)Builds the host: checks every setting, as a host does at start, and starts collecting beacon pulses in the background. With RequireInitialPulse set, it waits for the first pulse./guides/run-without-a-host/
RandomnessOptionspublic sealed class RandomnessOptionspublic RandomnessOptions()Settings for the secure generator and the beacon collector, bound from the Randomness configuration section./reference/configuration/
RandomnessOptions.SectionNamepublic const string SectionName = "Randomness"The configuration section these options bind from by convention./reference/configuration/
RandomnessOptions.Modepublic BeaconMode Mode { get; set; }How the registered beacons are used. The default is BeaconMode.Continuous./reference/configuration/
RandomnessOptions.RefreshIntervalpublic TimeSpan RefreshInterval { get; set; }How often each beacon is asked for its latest pulse. The default is one minute, the cadence at which CURBy publishes./reference/configuration/
RandomnessOptions.MaxRetryDelaypublic TimeSpan MaxRetryDelay { get; set; }The longest wait between attempts while a beacon fails; the wait doubles from RefreshInterval up to it, with jitter. The default is fifteen minutes./reference/configuration/
RandomnessOptions.FetchTimeoutpublic TimeSpan FetchTimeout { get; set; }How long one attempt to fetch a pulse may take. The default is thirty seconds./reference/configuration/
RandomnessOptions.MaxPulseAgepublic TimeSpan MaxPulseAge { get; set; }The oldest a pulse may be, by its own timestamp, to be mixed in; an older one means a beacon or a mirror has stalled. The default is ten minutes./reference/configuration/
RandomnessOptions.MaxPulseAgeByBeaconpublic Dictionary<string, TimeSpan> MaxPulseAgeByBeacon { get; set; }The oldest a pulse may be, by beacon name, in place of MaxPulseAge, for a beacon that publishes less often. A name that no registered beacon has fails the host at start. Empty by default./reference/configuration/
RandomnessOptions.MaxClockSkewpublic TimeSpan MaxClockSkew { get; set; }How far a pulse's timestamp may lie ahead of this machine's clock. The default is two minutes./reference/configuration/
RandomnessOptions.RequireInitialPulsepublic bool RequireInitialPulse { get; set; }Whether the host fails to start unless a beacon pulse is mixed in within InitialPulseTimeout. The default is false: a beacon outage never stops an application./reference/configuration/
RandomnessOptions.InitialPulseTimeoutpublic TimeSpan InitialPulseTimeout { get; set; }How long the host waits at start for the first pulse when RequireInitialPulse is set. The default is thirty seconds./reference/configuration/
RandomnessOptions.ReseedIntervalpublic TimeSpan ReseedInterval { get; set; }The longest any generator shard runs before it reseeds from the operating system. The default is one minute./reference/configuration/
RandomnessOptions.ReseedAfterBytespublic int ReseedAfterBytes { get; set; }The most bytes any generator shard produces before it reseeds from the operating system. The default is one mebibyte./reference/configuration/
BeaconModepublic enum BeaconModeContinuous = 0InitializeOnly = 1Offline = 2How the library uses the registered randomness beacons. Continuous fetches at start and every RefreshInterval, InitializeOnly fetches until each beacon has given one pulse, and Offline contacts no beacon. In every mode, random values are generated locally and never wait on a beacon./guides/choose-a-mode/
MemberSignatureWhat it doesExplained on
IRandomnessBeaconpublic interface IRandomnessBeaconA public randomness beacon, such as CURBy: the port each vendor's adapter implements. An implementation verifies every pulse as its vendor's protocol specifies before it returns it, and throws BeaconException rather than return a pulse it could not verify./reference/beacons/
IRandomnessBeacon.Namestring Name { get; }Gets the name the beacon is registered under, unique among the registered beacons, such as curby./reference/beacons/
IRandomnessBeacon.GetLatestPulseAsyncValueTask<BeaconPulse> GetLatestPulseAsync(CancellationToken cancellationToken)Fetches and verifies the beacon's latest pulse. It throws BeaconException when the beacon gave no verifiable pulse./reference/beacons/
IRandomnessBeacon.GetPulseAsyncValueTask<BeaconPulse> GetPulseAsync(long round, CancellationToken cancellationToken)Fetches and verifies the pulse of round. It throws BeaconException, with BeaconError.PulseNotFound when the round has not been published./reference/beacons/
BeaconPulsepublic sealed class BeaconPulsepublic BeaconPulse(string beacon, string chain, long round, string id, DateTimeOffset timestamp, ReadOnlySpan<byte> randomness)One verified output of a randomness beacon. A beacon adapter returns a pulse only after it has verified it as its vendor's protocol specifies, so every pulse that reaches the library is authentic. Its randomness is public: everyone who reads the beacon sees the same bytes./reference/beacons/
BeaconPulse.MinRandomnessLengthpublic const int MinRandomnessLength = 32The fewest random bytes a pulse may carry: enough to seed a generator at a security strength of 256 bits./reference/beacons/
BeaconPulse.Beaconpublic string Beacon { get; }Gets the name the beacon is registered under./reference/beacons/
BeaconPulse.Chainpublic string Chain { get; }Gets the vendor's identifier of the sequence the pulse belongs to./reference/beacons/
BeaconPulse.Roundpublic long Round { get; }Gets the pulse's position in its chain./reference/beacons/
BeaconPulse.Idpublic string Id { get; }Gets the vendor's identifier of this pulse./reference/beacons/
BeaconPulse.Timestamppublic DateTimeOffset Timestamp { get; }Gets when the beacon published the pulse./reference/beacons/
BeaconPulse.Randomnesspublic ReadOnlySpan<byte> Randomness { get; }Gets the pulse's public random bytes./reference/beacons/
BeaconPulse.ToStringpublic override string ToString()Describes the pulse by its beacon, round and ID, as curby round 1620423 (bafyri...)./reference/beacons/
BeaconErrorpublic enum BeaconErrorUnavailable = 0PulseNotFound = 1InvalidPulse = 2StalePulse = 3RolledBack = 4Why a beacon gave no usable pulse. Unavailable is a beacon that could not be reached, PulseNotFound a round it has not published, InvalidPulse an answer that failed verification, StalePulse a pulse too old or too far ahead, and RolledBack a round earlier than one already mixed in./concepts/outages/
BeaconExceptionpublic sealed class BeaconException : Exceptionpublic BeaconException(BeaconError error, string beacon, string message)public BeaconException(BeaconError error, string beacon, string message, Exception innerException)A beacon gave no usable pulse. Error says why, for code to act on./concepts/outages/
BeaconException.Errorpublic BeaconError Error { get; }Gets why the beacon gave no usable pulse./concepts/outages/
BeaconException.Beaconpublic string Beacon { get; }Gets the name of the beacon./concepts/outages/
IBeaconStatuspublic interface IBeaconStatusWhat the beacon collector has done: for status pages, health checks, and code that waits for beacon entropy./guides/monitor-beacons/
IBeaconStatus.ModeBeaconMode Mode { get; }Gets the mode the collector runs in./guides/monitor-beacons/
IBeaconStatus.BeaconsIReadOnlyList<BeaconState> Beacons { get; }Gets a snapshot of each registered beacon, in registration order./guides/monitor-beacons/
IBeaconStatus.WaitForPulseAsyncValueTask WaitForPulseAsync(CancellationToken cancellationToken)Waits until at least one beacon pulse has been mixed into the generator. Generation never needs this; use it where a policy demands beacon entropy before some operation./guides/monitor-beacons/
BeaconStatepublic sealed class BeaconStatepublic BeaconState()A snapshot of one beacon's state./guides/monitor-beacons/
BeaconState.Namepublic required string Name { get; init; }Gets the name the beacon is registered under./guides/monitor-beacons/
BeaconState.Healthpublic BeaconHealth Health { get; init; }Gets how the beacon is doing./guides/monitor-beacons/
BeaconState.LastPulsepublic BeaconPulse? LastPulse { get; init; }Gets the last pulse mixed in from the beacon, or null when there is none./guides/monitor-beacons/
BeaconState.LastAttemptpublic DateTimeOffset? LastAttempt { get; init; }Gets when the last fetch finished, or null when none has./guides/monitor-beacons/
BeaconState.LastErrorpublic BeaconError? LastError { get; init; }Gets why the last fetch gave no usable pulse, or null when it gave one./guides/monitor-beacons/
BeaconState.ConsecutiveFailurespublic int ConsecutiveFailures { get; init; }Gets how many fetches in a row have given no usable pulse./guides/monitor-beacons/
BeaconHealthpublic enum BeaconHealthPending = 0Healthy = 1Unavailable = 2How a beacon is doing, as the collector last saw it. Pending is a beacon whose first fetch has not finished, Healthy one whose last fetch gave a verified, fresh pulse, and Unavailable one whose last fetch failed or whose pulse was refused. Random values stay secure while a beacon is unavailable./guides/monitor-beacons/
RandomnessHealthChecksBuilderExtensionspublic static class RandomnessHealthChecksBuilderExtensionsextension(IHealthChecksBuilder builder)Registers the randomness beacons' health check./guides/monitor-beacons/
RandomnessHealthChecksBuilderExtensions.BeaconsCheckNamepublic const string BeaconsCheckName = "randomness-beacons"The name the health check is registered under./guides/monitor-beacons/
RandomnessHealthChecksBuilderExtensions.AddRandomnessBeaconspublic static IHealthChecksBuilder AddRandomnessBeacons(this IHealthChecksBuilder builder, params IEnumerable<string> tags)Adds a check that reports Degraded while any beacon is unavailable. Tag it to keep it out of a liveness probe: a beacon is an external dependency./guides/monitor-beacons/
RandomnessDiagnosticspublic static class RandomnessDiagnosticsThe names under which the library reports its telemetry./guides/monitor-beacons/
RandomnessDiagnostics.MeterNamepublic const string MeterName = "NCode.Randomness"The name of the library's Meter./guides/monitor-beacons/
MemberSignatureWhat it doesExplained on
IVerifiableRandomFactorypublic interface IVerifiableRandomFactoryCreates reproducible draws from the registered beacons' pulses./guides/run-a-public-draw/
IVerifiableRandomFactory.CreateAsyncValueTask<VerifiableRandom> CreateAsync(string beacon, long round, string context, CancellationToken cancellationToken)Fetches and verifies the pulse of round from beacon, and derives its stream for context. Dispose the stream when the draw is done./guides/run-a-public-draw/
VerifiableRandompublic sealed class VerifiableRandom : IRandomSource, IDisposableA reproducible random stream derived from one verified beacon pulse and a context label: a draw that anyone can check. Its bytes are public to everyone who reads the pulse, so it is deliberately not an ISecureRandom./guides/run-a-public-draw/
VerifiableRandom.MaxContextLengthpublic const int MaxContextLength = 1024The longest context, in characters./guides/run-a-public-draw/
VerifiableRandom.Algorithmpublic static string Algorithm { get; }Gets the name and version of the derivation and sampling algorithms: ncode-randomness-draw/1./reference/draw-algorithm/
VerifiableRandom.Pulsepublic BeaconPulse Pulse { get; }Gets the pulse the stream is derived from./guides/run-a-public-draw/
VerifiableRandom.Contextpublic string Context { get; }Gets the context label the stream is derived with./guides/run-a-public-draw/
VerifiableRandom.Createpublic static VerifiableRandom Create(BeaconPulse pulse, string context)Derives the stream of pulse for context. The draw is as trustworthy as the pulse: this method verifies nothing, so pass a pulse a beacon adapter returned, or use IVerifiableRandomFactory.CreateAsync./guides/run-a-public-draw/
VerifiableRandom.Fillpublic void Fill(Span<byte> destination)Fills destination with the next bytes of the stream, read as consecutive 64-byte blocks. Consume the stream from one thread, in a fixed order: values depend on the order in which they are drawn./guides/run-a-public-draw/
VerifiableRandom.Disposepublic void Dispose()Zeroes the stream's buffered bytes and releases its generator. The stream cannot be read afterwards./guides/run-a-public-draw/
MemberSignatureWhat it doesExplained on
CurbyRandomnessBuilderExtensionspublic static class CurbyRandomnessBuilderExtensionsextension(IRandomnessBuilder builder)Registers the CURBy beacons./reference/beacons/
CurbyRandomnessBuilderExtensions.AddCurbyBeaconpublic static IRandomnessBuilder AddCurbyBeacon(this IRandomnessBuilder builder)public static IRandomnessBuilder AddCurbyBeacon(this IRandomnessBuilder builder, Action<CurbyBeaconOptions> configure)public static IRandomnessBuilder AddCurbyBeacon(this IRandomnessBuilder builder, IConfiguration configuration)Registers the CURBy beacon, named curby, with its default options (the CURBy-RNG chain served by CurbyDefaults.BaseAddress), options set by configure or options bound from configuration, such as configuration.GetSection("RandomnessBeacons:Curby"). An unknown configuration key fails the host at start./reference/beacons/
CurbyRandomnessBuilderExtensions.AddCurbyQuantumBeaconpublic static IRandomnessBuilder AddCurbyQuantumBeacon(this IRandomnessBuilder builder)public static IRandomnessBuilder AddCurbyQuantumBeacon(this IRandomnessBuilder builder, Action<CurbyBeaconOptions> configure)public static IRandomnessBuilder AddCurbyQuantumBeacon(this IRandomnessBuilder builder, IConfiguration configuration)Registers the CURBy-Q beacon, named curby-q, with its default options (the CURBy-Q and Bell chains served by CurbyDefaults.BaseAddress), options set by configure or options bound from configuration. It allows curby-q pulses up to 30 minutes old, unless Randomness:MaxPulseAgeByBeacon:curby-q or a longer Randomness:MaxPulseAge is set./reference/beacons/
CurbyDefaultspublic static class CurbyDefaultsThe CURBy beacon's published identifiers./reference/beacons/
CurbyDefaults.BeaconNamepublic const string BeaconName = "curby"The name the CURBy beacon is registered under: curby./reference/beacons/
CurbyDefaults.RngChainIdpublic const string RngChainId = "bafyriqci…"The content identifier of the CURBy-RNG chain, the beacon's randomness chain, which publishes a pulse every minute. A content identifier is the hash of the chain's document, which holds the chain's signing key, so pinning it pins the key: no server, mirror or TLS certificate can substitute another./reference/beacons/
CurbyDefaults.QuantumBeaconNamepublic const string QuantumBeaconName = "curby-q"The name the CURBy-Q beacon is registered under: curby-q./reference/beacons/
CurbyDefaults.QuantumChainIdpublic const string QuantumChainId = "bafyriqhi…"The content identifier of the CURBy-Q (DIRNG) chain, whose rounds publish randomness extracted from a loophole-free Bell test. A content identifier is the hash of the chain's document, which holds the chain's signing key, so pinning it pins the key./reference/beacons/
CurbyDefaults.BellChainIdpublic const string BellChainId = "bafyriqe3…"The content identifier of the Bell chain, on which the Bell experiment answers each CURBy-Q request with the hash of its data. Pinning it pins its signing key./reference/beacons/
CurbyDefaults.BaseAddresspublic const string BaseAddress = "https://api.entwine.me/"The base address of the HTTP API that serves CURBy's Twine chains./reference/beacons/
CurbyDefaults.HttpClientNamepublic const string HttpClientName = "NCode.Randomness.Curby"The name of the HttpClient the beacon uses, for a host that adds its own handlers, such as a proxy, with services.AddHttpClient(CurbyDefaults.HttpClientName)./reference/beacons/
CurbyBeaconOptionspublic sealed class CurbyBeaconOptionspublic CurbyBeaconOptions()Settings for the CURBy and CURBy-Q beacons, which share them, bound from the RandomnessBeacons:Curby configuration section, beside the Randomness section of the core options, whose strict binding refuses any key it does not know./reference/configuration/
CurbyBeaconOptions.SectionNamepublic const string SectionName = "RandomnessBeacons:Curby"The configuration section these options bind from by convention./reference/configuration/
CurbyBeaconOptions.BaseAddresspublic Uri BaseAddress { get; set; }The base address of the Twine HTTP API, an absolute https URL ending in /, with no user info, query or fragment. The default is CurbyDefaults.BaseAddress. A mirror serves the same data: every document is verified against ChainId, so a mirror can withhold pulses but never forge one./reference/configuration/
CurbyBeaconOptions.ChainIdpublic string ChainId { get; set; }The content identifier of the chain to trust. The default is CurbyDefaults.RngChainId./reference/configuration/
CurbyBeaconOptions.QuantumChainIdpublic string QuantumChainId { get; set; }The content identifier of the CURBy-Q chain to trust. The default is CurbyDefaults.QuantumChainId./reference/configuration/
CurbyBeaconOptions.BellChainIdpublic string BellChainId { get; set; }The content identifier of the Bell chain to trust, on which the Bell experiment answers each CURBy-Q request. The default is CurbyDefaults.BellChainId./reference/configuration/
CurbyBeaconOptions.MaxResponseBytespublic int MaxResponseBytes { get; set; }The largest response body read, in bytes. The default is 256 KiB; a pulse is about 4 KiB./reference/configuration/
CurbyBeaconOptions.ChainRetryDelaypublic TimeSpan ChainRetryDelay { get; set; }How long a failed chain fetch is remembered: until it passes, a pulse on that chain fails at once, without another request. The default is 1 minute; it must be from 1 second to 1 day./reference/configuration/
CurbyPulseVerifierpublic sealed class CurbyPulseVerifierpublic CurbyPulseVerifier()public CurbyPulseVerifier(string chainId)Verifies CURBy-RNG pulse documents that a caller supplies, without the network, by every check the CURBy beacon makes: chain, pulse and predecessor each hash to their CIDs and are signed by the chain's key, the predecessor is one round earlier, and the pulse's salt matches its precommitment. An instance is immutable and thread-safe./guides/check-a-draw/
CurbyPulseVerifier.Verifypublic BeaconPulse Verify(ReadOnlySpan<byte> chain, ReadOnlySpan<byte> pulse, ReadOnlySpan<byte> predecessor)Verifies a pulse against the pinned chain and returns it as the CURBy beacon returns it. Each document is the UTF-8 JSON the Twine API serves; predecessor is the pulse one round before pulse. It throws BeaconException when a document is malformed or any check fails./guides/check-a-draw/
CurbyQuantumRoundVerifierpublic sealed class CurbyQuantumRoundVerifierpublic CurbyQuantumRoundVerifier()public CurbyQuantumRoundVerifier(string quantumChainId, string bellChainId)Verifies a CURBy-Q round from documents that a caller supplies, without the network, by every check the CURBy-Q beacon makes. The Bell-test certificate and the extraction are not verified. An instance is immutable and thread-safe./guides/check-a-draw/
CurbyQuantumRoundVerifier.Verifypublic BeaconPulse Verify(ReadOnlySpan<byte> round, ReadOnlySpan<byte> parameters, IReadOnlyCollection<ReadOnlyMemory<byte>> documents)Verifies a round against the pinned chains and returns its pulse as the CURBy-Q beacon returns it. round is the JSON array of its pulses, parameters the extractor's parameters, and documents the chain and pulse documents the round links to, in any order. It throws BeaconException when a document is malformed or missing, the round has no randomness, or any check fails./guides/check-a-draw/
MemberSignatureWhat it doesExplained on
NistRandomnessBuilderExtensionspublic static class NistRandomnessBuilderExtensionsextension(IRandomnessBuilder builder)Registers the NIST beacon./reference/beacons/
NistRandomnessBuilderExtensions.AddNistBeaconpublic static IRandomnessBuilder AddNistBeacon(this IRandomnessBuilder builder)public static IRandomnessBuilder AddNistBeacon(this IRandomnessBuilder builder, Action<NistBeaconOptions> configure)public static IRandomnessBuilder AddNistBeacon(this IRandomnessBuilder builder, IConfiguration configuration)Registers the NIST beacon, named nist, with its default options (chain 2 of the NIST Randomness Beacon 2.0 served by NistDefaults.BaseAddress, verified against the certificates of NistDefaults.CertificateIds), options set by configure or options bound from configuration, such as configuration.GetSection("RandomnessBeacons:Nist"). An unknown configuration key fails the host at start./reference/beacons/
NistDefaultspublic static class NistDefaultsThe NIST Randomness Beacon's published identifiers./reference/beacons/
NistDefaults.BeaconNamepublic const string BeaconName = "nist"The name the NIST beacon is registered under: nist./reference/beacons/
NistDefaults.BaseAddresspublic const string BaseAddress = "https://beacon.nist.gov/beacon/2.0/"The base address of the NIST Randomness Beacon 2.0 HTTP API./reference/beacons/
NistDefaults.ChainIndexpublic const long ChainIndex = 2The index of the chain the beacon trusts: chain 2, which publishes a pulse every minute./reference/beacons/
NistDefaults.HttpClientNamepublic const string HttpClientName = "NCode.Randomness.Nist"The name of the HttpClient the beacon uses, for a host that adds its own handlers, such as a proxy, with services.AddHttpClient(NistDefaults.HttpClientName)./reference/beacons/
NistDefaults.CertificateIdspublic static ImmutableArray<string> CertificateIds { get; }The identifiers, oldest first, of the certificates NIST signs chain 2 with. An identifier is the SHA-512 hash of a certificate's DER encoding in lowercase hex, so pinning it pins the certificate and its key: no server, mirror or TLS certificate can substitute another./reference/beacons/
NistBeaconOptionspublic sealed class NistBeaconOptionspublic NistBeaconOptions()Settings for the NIST beacon, bound from the RandomnessBeacons:Nist configuration section, beside the Randomness section of the core options, whose strict binding refuses any key it does not know./reference/configuration/
NistBeaconOptions.SectionNamepublic const string SectionName = "RandomnessBeacons:Nist"The configuration section these options bind from by convention./reference/configuration/
NistBeaconOptions.BaseAddresspublic Uri BaseAddress { get; set; }The base address of the NIST HTTP API, an absolute https URL ending in /, with no user info, query or fragment. The default is NistDefaults.BaseAddress. A mirror serves the same data: every pulse is verified against the pinned certificates, so a mirror can withhold pulses but never forge one./reference/configuration/
NistBeaconOptions.ChainIndexpublic long ChainIndex { get; set; }The index of the chain to trust. The default is NistDefaults.ChainIndex./reference/configuration/
NistBeaconOptions.CertificateIdspublic List<string> CertificateIds { get; set; }The identifiers of the certificates to trust, each the SHA-512 hash of a certificate's DER encoding in hex. When empty, the default, NistDefaults.CertificateIds applies; a configured list replaces the defaults./reference/configuration/
NistBeaconOptions.CertificateRetryDelaypublic TimeSpan CertificateRetryDelay { get; set; }How long a failed certificate fetch is remembered: until it passes, a pulse that names the certificate fails at once, without another request. The default is 1 minute; it must be from 1 second to 1 day./reference/configuration/
NistBeaconOptions.MaxResponseBytespublic int MaxResponseBytes { get; set; }The largest response body read, in bytes. The default is 64 KiB; a pulse is about 2 KiB./reference/configuration/
NistPulseVerifierpublic sealed class NistPulseVerifierpublic NistPulseVerifier()public NistPulseVerifier(long chainIndex, IReadOnlyCollection<string> certificateIds)Verifies NIST Randomness Beacon 2.0 pulse documents that a caller supplies, without the network, by every check the NIST beacon makes: the pinned chain and certificate, the certificate's hash, key size and validity, the pulse's version, cipher suite, signature and output value, and the predecessor's index, time, hash link and precommitment. An instance is immutable and thread-safe./guides/check-a-draw/
NistPulseVerifier.Verifypublic BeaconPulse Verify(ReadOnlySpan<byte> pulse, ReadOnlySpan<byte> predecessor, ReadOnlySpan<byte> certificate)public BeaconPulse Verify(ReadOnlySpan<byte> pulse, ReadOnlySpan<byte> predecessor, ReadOnlySpan<byte> certificate, ReadOnlySpan<byte> predecessorCertificate)Verifies a pulse and its predecessor and returns the pulse as the NIST beacon returns it. Each document is as the NIST API serves it: the pulses in UTF-8 JSON, the certificate as PEM. The first overload takes one certificate, for a predecessor that names the same certificate; the second takes a predecessorCertificate too, as across a certificate rotation. It throws BeaconException when a document is malformed or any check fails./guides/check-a-draw/
MemberSignatureWhat it doesExplained on
DrandRandomnessBuilderExtensionspublic static class DrandRandomnessBuilderExtensionsextension(IRandomnessBuilder builder)Registers the drand beacon./reference/beacons/
DrandRandomnessBuilderExtensions.AddDrandBeaconpublic static IRandomnessBuilder AddDrandBeacon(this IRandomnessBuilder builder)public static IRandomnessBuilder AddDrandBeacon(this IRandomnessBuilder builder, Action<DrandBeaconOptions> configure)public static IRandomnessBuilder AddDrandBeacon(this IRandomnessBuilder builder, IConfiguration configuration)Registers the drand beacon, named drand, with its default options (the quicknet chain served by DrandDefaults.BaseAddress, verified against the chain's pinned group public key), options set by configure or options bound from configuration, such as configuration.GetSection("RandomnessBeacons:Drand"). An unknown configuration key fails the host at start./reference/beacons/
DrandDefaultspublic static class DrandDefaultsThe drand quicknet chain's published constants./reference/beacons/
DrandDefaults.BeaconNamepublic const string BeaconName = "drand"The name the drand beacon is registered under: drand./reference/beacons/
DrandDefaults.BaseAddresspublic const string BaseAddress = "https://api.drand.sh/"The base address of the drand HTTP API./reference/beacons/
DrandDefaults.ChainHashpublic const string ChainHash = "52db9ba7…"The hash of the quicknet chain, in lowercase hex: its identifier in the HTTP API./reference/beacons/
DrandDefaults.PublicKeypublic const string PublicKey = "83cf0f28…"The quicknet chain's pinned group public key: a compressed G2 point in lowercase hex. Every round is verified against it, so no server or mirror can substitute another./reference/beacons/
DrandDefaults.GenesisTimepublic const long GenesisTime = 1692803367The time of round 1, in Unix seconds./reference/beacons/
DrandDefaults.Periodpublic const int Period = 3The seconds between rounds./reference/beacons/
DrandDefaults.HttpClientNamepublic const string HttpClientName = "NCode.Randomness.Drand"The name of the HttpClient the beacon uses, for a host that adds its own handlers, such as a proxy, with services.AddHttpClient(DrandDefaults.HttpClientName)./reference/beacons/
DrandBeaconOptionspublic sealed class DrandBeaconOptionspublic DrandBeaconOptions()Settings for the drand beacon, bound from the RandomnessBeacons:Drand configuration section, beside the Randomness section of the core options, whose strict binding refuses any key it does not know./reference/configuration/
DrandBeaconOptions.SectionNamepublic const string SectionName = "RandomnessBeacons:Drand"The configuration section these options bind from by convention./reference/configuration/
DrandBeaconOptions.BaseAddresspublic Uri BaseAddress { get; set; }The base address of the drand HTTP API, an absolute https URL ending in /, with no user info, query or fragment. The default is DrandDefaults.BaseAddress. A mirror serves the same data: every round is verified against the pinned group key, so a mirror can withhold rounds but never forge one./reference/configuration/
DrandBeaconOptions.MaxResponseBytespublic int MaxResponseBytes { get; set; }The largest response body read, in bytes. The default is 16 KiB; a round is about 200 bytes./reference/configuration/
DrandRoundVerifierpublic sealed class DrandRoundVerifierpublic DrandRoundVerifier()Verifies drand quicknet round documents that a caller supplies, without the network, by every check the drand beacon makes: the round's signature must be a point of G1 other than the identity and verify against the pinned group public key for the round number, and a randomness member, when present, must be the SHA-256 of the signature. An instance is immutable and thread-safe./guides/check-a-draw/
DrandRoundVerifier.Verifypublic BeaconPulse Verify(ReadOnlySpan<byte> round)Verifies a round against the pinned chain and returns it as the drand beacon returns it. round is the round document, as the drand API serves it, in UTF-8 JSON. It throws BeaconException when the document is malformed or a check fails./guides/check-a-draw/

RandomSourceExtensions, RandomnessServiceCollectionExtensions, RandomnessBuilderExtensions, RandomnessHealthChecksBuilderExtensions, CurbyRandomnessBuilderExtensions, NistRandomnessBuilderExtensions and DrandRandomnessBuilderExtensions are C# 14 extension blocks compiled to ordinary static extension methods, so a project on an earlier C# version calls them the same way, or in their static form.

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

Each package targets net10.0, and nuget.org lists its target framework on its Frameworks tab.