Skip to main content

verify_chain

Function verify_chain 

Source
pub fn verify_chain(receipts: &[Payload]) -> Result<ChainReport>
Expand description

Verifies a slice of receipts as one contiguous chain.

This checks only the chain-level relationships between adjacent receipts. It does NOT re-verify any receipt’s own chain.hash against its content. Payload::from_json already did that at parse time, for every receipt in the slice.

Rules, applied in this order:

  • An empty slice is rejected.
  • The head of the presentation (receipts[0]) MUST carry seq == 0 and prevHash == None. Per-receipt validation already enforces the seq0/prevHash-null pairing in general; this is the additional chain-level rule that the head of a presentation specifically must be sequence zero.
  • For each adjacent pair, seq MUST be contiguous: seq[i] == seq[i-1] + 1.
  • For each adjacent pair, prevHash[i] MUST equal Some(hash[i-1]).
  • A change in issuerAffiliation between adjacent receipts is recorded in the returned ChainReport and does NOT invalidate the presentation. See the module documentation for why this one is not a rejection.

§Errors

Returns Error::Validation on the first structural rule violated, in the order listed above.