Skip to main content

verify_chain

Function verify_chain 

Source
pub fn verify_chain(
    records: &[AuditRecord],
    checkpoints: &[Checkpoint],
    keys: &[TrustedKey],
) -> ChainReport
Available on crate feature audit only.
Expand description

Verifies records, which must be one chain in seq order, against the checkpoints written for it, trusting signatures by keys.

Checked, in order, and the first failure is reported:

  1. every record is of SCHEMA and of the same chain;
  2. each record’s hash is the hash of its content;
  3. seq rises by exactly one from record to record;
  4. each prev is the hash of the record before it; the first record’s is absent at seq 1, and otherwise must equal the hash of an anchor checkpoint at seq − 1 — a chain that starts later with no anchor has lost its beginning;
  5. every checkpoint whose seq is in the range names the hash the record at that seq has, and its signature verifies under keys;
  6. no checkpoint’s seq lies beyond the last record — one that does proves records were removed from the end.

With keys empty, a signed checkpoint cannot be verified and fails rule 5: pass the keys, or pass no checkpoints to check the hash chain alone.