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§
- MinEntropy
Report - Min-entropy analysis report with individual estimator results.
- Quality
Report
Enums§
- Conditioning
Mode - 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
MinEntropyReportwith 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_outputbytes 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.