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.
Secure random values
Section titled “Secure random values”| Member | Signature | What it does | Explained on |
|---|---|---|---|
ISecureRandom | public interface ISecureRandom : IRandomSource | A 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/ |
IRandomSource | public interface IRandomSource | Produces uniformly distributed random bytes. Every typed value, range, shuffle and selection in this library is built on this one operation. | /guides/draw-values/ |
IRandomSource.Fill | void Fill(Span<byte> destination) | Fills destination with random bytes. An empty buffer is left as it is. | /guides/draw-values/ |
SystemRandomSource | public sealed class SystemRandomSource : ISecureRandom | The 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.Instance | public 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.Fill | public void Fill(Span<byte> destination) | Fills destination with bytes from RandomNumberGenerator. | /guides/make-a-secret/ |
RandomSourceExtensions | public 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.AsRandom | public 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.GetBytes | public 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.GetItem | public 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.GetItems | public 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.GetString | public 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.NextBoolean | public static bool NextBoolean(this IRandomSource source) | Returns true or false with equal probability. | /guides/draw-values/ |
RandomSourceExtensions.NextDouble | public 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.NextGuid | public static Guid NextGuid(this IRandomSource source) | Returns a random RFC 9562 version 4 Guid, with 122 random bits. | /guides/draw-values/ |
RandomSourceExtensions.NextInteger | public 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.NextSingle | public 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.Shuffle | public 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/ |
Registration and hosting
Section titled “Registration and hosting”| Member | Signature | What it does | Explained on |
|---|---|---|---|
RandomnessServiceCollectionExtensions | public static class RandomnessServiceCollectionExtensionsextension(IServiceCollection services) | Registers the secure generator, the beacon collector and reproducible draws. | /guides/add-beacons/ |
RandomnessServiceCollectionExtensions.AddRandomness | public 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/ |
IRandomnessBuilder | public interface IRandomnessBuilder | Adds beacons and other parts to the randomness services that AddRandomness() registers or a RandomnessHost builds. | /guides/add-beacons/ |
IRandomnessBuilder.Services | IServiceCollection Services { get; } | Gets the service collection. | /guides/add-beacons/ |
RandomnessBuilderExtensions | public static class RandomnessBuilderExtensionsextension(IRandomnessBuilder builder) | Registers randomness beacons. | /guides/add-beacons/ |
RandomnessBuilderExtensions.AddBeacon | public 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/ |
RandomnessHost | public sealed class RandomnessHost : IAsyncDisposable | The 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.CreateBuilder | public 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.SecureRandom | public ISecureRandom SecureRandom { get; } | Gets the secure generator. | /guides/run-without-a-host/ |
RandomnessHost.BeaconStatus | public IBeaconStatus BeaconStatus { get; } | Gets the health of the beacon collection. | /guides/run-without-a-host/ |
RandomnessHost.VerifiableRandomFactory | public IVerifiableRandomFactory VerifiableRandomFactory { get; } | Gets the factory for reproducible draws. | /guides/run-without-a-host/ |
RandomnessHost.DisposeAsync | public 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/ |
RandomnessHostBuilder | public sealed class RandomnessHostBuilder : IRandomnessBuilder | Composes a RandomnessHost: add beacons with the adapters' extension members, such as AddCurbyBeacon(), then call BuildAsync once. | /guides/run-without-a-host/ |
RandomnessHostBuilder.Services | public 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.BuildAsync | public 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/ |
RandomnessOptions | public sealed class RandomnessOptionspublic RandomnessOptions() | Settings for the secure generator and the beacon collector, bound from the Randomness configuration section. | /reference/configuration/ |
RandomnessOptions.SectionName | public const string SectionName = "Randomness" | The configuration section these options bind from by convention. | /reference/configuration/ |
RandomnessOptions.Mode | public BeaconMode Mode { get; set; } | How the registered beacons are used. The default is BeaconMode.Continuous. | /reference/configuration/ |
RandomnessOptions.RefreshInterval | public 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.MaxRetryDelay | public 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.FetchTimeout | public TimeSpan FetchTimeout { get; set; } | How long one attempt to fetch a pulse may take. The default is thirty seconds. | /reference/configuration/ |
RandomnessOptions.MaxPulseAge | public 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.MaxPulseAgeByBeacon | public 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.MaxClockSkew | public 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.RequireInitialPulse | public 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.InitialPulseTimeout | public 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.ReseedInterval | public 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.ReseedAfterBytes | public 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/ |
BeaconMode | public enum BeaconModeContinuous = 0InitializeOnly = 1Offline = 2 | How 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/ |
Beacons and their status
Section titled “Beacons and their status”| Member | Signature | What it does | Explained on |
|---|---|---|---|
IRandomnessBeacon | public interface IRandomnessBeacon | A 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.Name | string Name { get; } | Gets the name the beacon is registered under, unique among the registered beacons, such as curby. | /reference/beacons/ |
IRandomnessBeacon.GetLatestPulseAsync | ValueTask<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.GetPulseAsync | ValueTask<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/ |
BeaconPulse | public 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.MinRandomnessLength | public const int MinRandomnessLength = 32 | The fewest random bytes a pulse may carry: enough to seed a generator at a security strength of 256 bits. | /reference/beacons/ |
BeaconPulse.Beacon | public string Beacon { get; } | Gets the name the beacon is registered under. | /reference/beacons/ |
BeaconPulse.Chain | public string Chain { get; } | Gets the vendor's identifier of the sequence the pulse belongs to. | /reference/beacons/ |
BeaconPulse.Round | public long Round { get; } | Gets the pulse's position in its chain. | /reference/beacons/ |
BeaconPulse.Id | public string Id { get; } | Gets the vendor's identifier of this pulse. | /reference/beacons/ |
BeaconPulse.Timestamp | public DateTimeOffset Timestamp { get; } | Gets when the beacon published the pulse. | /reference/beacons/ |
BeaconPulse.Randomness | public ReadOnlySpan<byte> Randomness { get; } | Gets the pulse's public random bytes. | /reference/beacons/ |
BeaconPulse.ToString | public override string ToString() | Describes the pulse by its beacon, round and ID, as curby round 1620423 (bafyri...). | /reference/beacons/ |
BeaconError | public enum BeaconErrorUnavailable = 0PulseNotFound = 1InvalidPulse = 2StalePulse = 3RolledBack = 4 | Why 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/ |
BeaconException | public 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.Error | public BeaconError Error { get; } | Gets why the beacon gave no usable pulse. | /concepts/outages/ |
BeaconException.Beacon | public string Beacon { get; } | Gets the name of the beacon. | /concepts/outages/ |
IBeaconStatus | public interface IBeaconStatus | What the beacon collector has done: for status pages, health checks, and code that waits for beacon entropy. | /guides/monitor-beacons/ |
IBeaconStatus.Mode | BeaconMode Mode { get; } | Gets the mode the collector runs in. | /guides/monitor-beacons/ |
IBeaconStatus.Beacons | IReadOnlyList<BeaconState> Beacons { get; } | Gets a snapshot of each registered beacon, in registration order. | /guides/monitor-beacons/ |
IBeaconStatus.WaitForPulseAsync | ValueTask 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/ |
BeaconState | public sealed class BeaconStatepublic BeaconState() | A snapshot of one beacon's state. | /guides/monitor-beacons/ |
BeaconState.Name | public required string Name { get; init; } | Gets the name the beacon is registered under. | /guides/monitor-beacons/ |
BeaconState.Health | public BeaconHealth Health { get; init; } | Gets how the beacon is doing. | /guides/monitor-beacons/ |
BeaconState.LastPulse | public BeaconPulse? LastPulse { get; init; } | Gets the last pulse mixed in from the beacon, or null when there is none. | /guides/monitor-beacons/ |
BeaconState.LastAttempt | public DateTimeOffset? LastAttempt { get; init; } | Gets when the last fetch finished, or null when none has. | /guides/monitor-beacons/ |
BeaconState.LastError | public BeaconError? LastError { get; init; } | Gets why the last fetch gave no usable pulse, or null when it gave one. | /guides/monitor-beacons/ |
BeaconState.ConsecutiveFailures | public int ConsecutiveFailures { get; init; } | Gets how many fetches in a row have given no usable pulse. | /guides/monitor-beacons/ |
BeaconHealth | public enum BeaconHealthPending = 0Healthy = 1Unavailable = 2 | How 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/ |
RandomnessHealthChecksBuilderExtensions | public static class RandomnessHealthChecksBuilderExtensionsextension(IHealthChecksBuilder builder) | Registers the randomness beacons' health check. | /guides/monitor-beacons/ |
RandomnessHealthChecksBuilderExtensions.BeaconsCheckName | public const string BeaconsCheckName = "randomness-beacons" | The name the health check is registered under. | /guides/monitor-beacons/ |
RandomnessHealthChecksBuilderExtensions.AddRandomnessBeacons | public 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/ |
RandomnessDiagnostics | public static class RandomnessDiagnostics | The names under which the library reports its telemetry. | /guides/monitor-beacons/ |
RandomnessDiagnostics.MeterName | public const string MeterName = "NCode.Randomness" | The name of the library's Meter. | /guides/monitor-beacons/ |
Reproducible draws
Section titled “Reproducible draws”| Member | Signature | What it does | Explained on |
|---|---|---|---|
IVerifiableRandomFactory | public interface IVerifiableRandomFactory | Creates reproducible draws from the registered beacons' pulses. | /guides/run-a-public-draw/ |
IVerifiableRandomFactory.CreateAsync | ValueTask<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/ |
VerifiableRandom | public sealed class VerifiableRandom : IRandomSource, IDisposable | A 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.MaxContextLength | public const int MaxContextLength = 1024 | The longest context, in characters. | /guides/run-a-public-draw/ |
VerifiableRandom.Algorithm | public static string Algorithm { get; } | Gets the name and version of the derivation and sampling algorithms: ncode-randomness-draw/1. | /reference/draw-algorithm/ |
VerifiableRandom.Pulse | public BeaconPulse Pulse { get; } | Gets the pulse the stream is derived from. | /guides/run-a-public-draw/ |
VerifiableRandom.Context | public string Context { get; } | Gets the context label the stream is derived with. | /guides/run-a-public-draw/ |
VerifiableRandom.Create | public 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.Fill | public 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.Dispose | public void Dispose() | Zeroes the stream's buffered bytes and releases its generator. The stream cannot be read afterwards. | /guides/run-a-public-draw/ |
NCode.Randomness.Curby
Section titled “NCode.Randomness.Curby”| Member | Signature | What it does | Explained on |
|---|---|---|---|
CurbyRandomnessBuilderExtensions | public static class CurbyRandomnessBuilderExtensionsextension(IRandomnessBuilder builder) | Registers the CURBy beacons. | /reference/beacons/ |
CurbyRandomnessBuilderExtensions.AddCurbyBeacon | public 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.AddCurbyQuantumBeacon | public 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/ |
CurbyDefaults | public static class CurbyDefaults | The CURBy beacon's published identifiers. | /reference/beacons/ |
CurbyDefaults.BeaconName | public const string BeaconName = "curby" | The name the CURBy beacon is registered under: curby. | /reference/beacons/ |
CurbyDefaults.RngChainId | public 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.QuantumBeaconName | public const string QuantumBeaconName = "curby-q" | The name the CURBy-Q beacon is registered under: curby-q. | /reference/beacons/ |
CurbyDefaults.QuantumChainId | public 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.BellChainId | public 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.BaseAddress | public const string BaseAddress = "https://api.entwine.me/" | The base address of the HTTP API that serves CURBy's Twine chains. | /reference/beacons/ |
CurbyDefaults.HttpClientName | public 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/ |
CurbyBeaconOptions | public 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.SectionName | public const string SectionName = "RandomnessBeacons:Curby" | The configuration section these options bind from by convention. | /reference/configuration/ |
CurbyBeaconOptions.BaseAddress | public 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.ChainId | public string ChainId { get; set; } | The content identifier of the chain to trust. The default is CurbyDefaults.RngChainId. | /reference/configuration/ |
CurbyBeaconOptions.QuantumChainId | public string QuantumChainId { get; set; } | The content identifier of the CURBy-Q chain to trust. The default is CurbyDefaults.QuantumChainId. | /reference/configuration/ |
CurbyBeaconOptions.BellChainId | public 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.MaxResponseBytes | public 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.ChainRetryDelay | public 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/ |
CurbyPulseVerifier | public 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.Verify | public 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/ |
CurbyQuantumRoundVerifier | public 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.Verify | public 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/ |
NCode.Randomness.Nist
Section titled “NCode.Randomness.Nist”| Member | Signature | What it does | Explained on |
|---|---|---|---|
NistRandomnessBuilderExtensions | public static class NistRandomnessBuilderExtensionsextension(IRandomnessBuilder builder) | Registers the NIST beacon. | /reference/beacons/ |
NistRandomnessBuilderExtensions.AddNistBeacon | public 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/ |
NistDefaults | public static class NistDefaults | The NIST Randomness Beacon's published identifiers. | /reference/beacons/ |
NistDefaults.BeaconName | public const string BeaconName = "nist" | The name the NIST beacon is registered under: nist. | /reference/beacons/ |
NistDefaults.BaseAddress | public 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.ChainIndex | public const long ChainIndex = 2 | The index of the chain the beacon trusts: chain 2, which publishes a pulse every minute. | /reference/beacons/ |
NistDefaults.HttpClientName | public 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.CertificateIds | public 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/ |
NistBeaconOptions | public 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.SectionName | public const string SectionName = "RandomnessBeacons:Nist" | The configuration section these options bind from by convention. | /reference/configuration/ |
NistBeaconOptions.BaseAddress | public 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.ChainIndex | public long ChainIndex { get; set; } | The index of the chain to trust. The default is NistDefaults.ChainIndex. | /reference/configuration/ |
NistBeaconOptions.CertificateIds | public 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.CertificateRetryDelay | public 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.MaxResponseBytes | public int MaxResponseBytes { get; set; } | The largest response body read, in bytes. The default is 64 KiB; a pulse is about 2 KiB. | /reference/configuration/ |
NistPulseVerifier | public 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.Verify | public 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/ |
NCode.Randomness.Drand
Section titled “NCode.Randomness.Drand”| Member | Signature | What it does | Explained on |
|---|---|---|---|
DrandRandomnessBuilderExtensions | public static class DrandRandomnessBuilderExtensionsextension(IRandomnessBuilder builder) | Registers the drand beacon. | /reference/beacons/ |
DrandRandomnessBuilderExtensions.AddDrandBeacon | public 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/ |
DrandDefaults | public static class DrandDefaults | The drand quicknet chain's published constants. | /reference/beacons/ |
DrandDefaults.BeaconName | public const string BeaconName = "drand" | The name the drand beacon is registered under: drand. | /reference/beacons/ |
DrandDefaults.BaseAddress | public const string BaseAddress = "https://api.drand.sh/" | The base address of the drand HTTP API. | /reference/beacons/ |
DrandDefaults.ChainHash | public const string ChainHash = "52db9ba7…" | The hash of the quicknet chain, in lowercase hex: its identifier in the HTTP API. | /reference/beacons/ |
DrandDefaults.PublicKey | public 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.GenesisTime | public const long GenesisTime = 1692803367 | The time of round 1, in Unix seconds. | /reference/beacons/ |
DrandDefaults.Period | public const int Period = 3 | The seconds between rounds. | /reference/beacons/ |
DrandDefaults.HttpClientName | public 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/ |
DrandBeaconOptions | public 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.SectionName | public const string SectionName = "RandomnessBeacons:Drand" | The configuration section these options bind from by convention. | /reference/configuration/ |
DrandBeaconOptions.BaseAddress | public 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.MaxResponseBytes | public int MaxResponseBytes { get; set; } | The largest response body read, in bytes. The default is 16 KiB; a round is about 200 bytes. | /reference/configuration/ |
DrandRoundVerifier | public 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.Verify | public 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/ |
Extension members
Section titled “Extension members”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.
Packages
Section titled “Packages”dotnet add package NCode.Randomnessdotnet add package NCode.Randomness.Curbydotnet add package NCode.Randomness.Nistdotnet add package NCode.Randomness.DrandEach package targets net10.0, and nuget.org lists its target framework on its Frameworks tab.