Skip to main content

verify_entropy

Function verify_entropy 

Source
pub fn verify_entropy<'a>(
    facts: impl IntoIterator<Item = &'a StepFact>,
) -> Result<EntropyVerified, VerifyError>
Expand description

Re-derive a transcript’s entropy source and confirm every drawn value.

Replays the rite-kdf/v1 ratchet over the recorded facts: it rebuilds seed_0 from the recorded machine entropy, folds each human contribution in chain order, and for every StepFact::EntropyDrawn re-derives the value from the recorded path and checks it against the recorded value. A tampered seed, contribution, path, or value fails the check.

Beyond the value re-derivation, the replay enforces the source’s own invariants, so a transcript cannot record a fact stream the runtime could never have produced:

  • the source is seeded exactly once;
  • each contribution’s recorded epoch matches its position in the fold sequence;
  • each draw’s recorded path carries the <epoch>/<step>/ prefix rebuilt from the verifier’s own fold count and the step named on the fact;
  • no derivation path is drawn twice;
  • no recorded value exceeds what HKDF-Expand can produce (MAX_DRAW_LEN bytes), which would otherwise abort the verifier instead of failing the check.

The caller is expected to have chain-verified the facts first (via read_verified_transcript); this function only re-derives.

§Errors

Returns a VerifyError variant describing the first inconsistency: VerifyError::SeedMissing, VerifyError::DuplicateSeed, VerifyError::UnknownDerivation, VerifyError::MalformedEntropy, VerifyError::EpochMismatch, VerifyError::PathMismatch, VerifyError::DuplicateDrawPath, VerifyError::DrawTooLong, or VerifyError::DrawMismatch.