Skip to main content

Module conditioning

Module conditioning 

Source
Expand description

Centralized entropy conditioning module.

ALL post-processing of raw entropy lives here — no conditioning code should exist in individual source implementations. Sources produce raw bytes; this module is the single, auditable gateway for any transformation.

§Architecture

Source → Raw Bytes → Conditioning Layer (this module) → Output

§Conditioning Modes

  • Raw: No processing. XOR-combined bytes pass through unchanged. Preserves the actual hardware noise signal for research.
  • VonNeumann: Debias only. Removes first-order bias without destroying the noise structure. Output is shorter than input (~25% yield).
  • Sha256: Full SHA-256 conditioning with counter and timestamp mixing. Produces cryptographically strong output but destroys the raw signal.

Most QRNG APIs (ANU, Outshift/Cisco) apply DRBG post-processing that makes output indistinguishable from PRNG. The Raw mode here is what makes openentropy useful for researchers studying actual hardware noise.

Structs§

MinEntropyReport
Min-entropy analysis report with individual estimator results.
QualityReport

Enums§

ConditioningMode
Conditioning mode for entropy output.

Functions§

collision_estimate
Collision estimator — NIST SP 800-90B Section 6.3.2. Measures average distance between repeated values. Returns estimated min-entropy bits per sample.
compression_estimate
Compression estimator — NIST SP 800-90B Section 6.3.4. Uses Maurer’s universal statistic to estimate entropy via compression. Returns estimated min-entropy bits per sample.
condition
Apply the specified conditioning mode to raw entropy bytes.
grade_min_entropy
Grade a source based on its min-entropy (H∞) value.
markov_estimate
Markov estimator — NIST SP 800-90B Section 6.3.3. Models first-order dependencies between consecutive samples. Returns estimated min-entropy bits per sample.
mcv_estimate
Most Common Value (MCV) estimator — NIST SP 800-90B Section 6.3.1. Estimates min-entropy with upper bound on p_max using confidence interval. Returns (min_entropy_bits_per_sample, p_max_upper_bound).
min_entropy
Min-entropy estimate: H∞ = -log2(max probability). More conservative than Shannon — reflects worst-case guessing probability. Returns bits per sample (0.0 to 8.0 for byte-valued data).
min_entropy_estimate
Combined min-entropy estimate using multiple estimators. Takes the minimum (most conservative) across all methods. Returns a MinEntropyReport with individual and combined estimates.
quick_min_entropy
Quick min-entropy (just the combined estimate, no full report).
quick_quality
Quick quality assessment.
quick_shannon
Quick Shannon entropy in bits/byte for a byte slice.
sha256_condition
SHA-256 condition with explicit state, sample, counter, and extra data. Returns (new_state, 32-byte digest).
sha256_condition_bytes
SHA-256 chained conditioning: stretches or compresses raw bytes to exactly n_output bytes using counter-mode hashing.
t_tuple_estimate
t-Tuple estimator — NIST SP 800-90B Section 6.3.5. Estimates entropy from most frequent t-length tuple. Returns estimated min-entropy bits per sample.
von_neumann_debias
Von Neumann debiasing: extract unbiased bits from a biased stream.
xor_fold
XOR-fold: reduce data by XORing the first half with the second half.