Skip to main content

Verify Hash Chain Integrity

# Verify complete thread hash chain
query {
  verifyThreadIntegrity(threadId: "thread-123") {
    verified
    totalEvents
    brokenAt
    error
  }
}

# Verify specific step
query {
  verifyStepIntegrity(
    threadId: "thread-123"
    stepName: "order_placed"
    idempotencyKey: "order_456"
  ) {
    verified
    hash
    prevHash
  }
}

# Get hash chain data
query {
  thread(id: "thread-123") {
    lastHash
    steps {
      stepName
      hash
      prevHash
      verified
    }
  }
}

Hash Chain Status Fields

FieldTypeDescription
verifiedBoolean!Chain integrity verified
lastVerifiedAtString!Last verification timestamp
totalEventsInt!Total events in chain
brokenAtStringTimestamp where chain broke
errorStringError message (if broken)

Step Integrity Fields

FieldTypeDescription
verifiedBoolean!Step integrity verified
hashStringStep hash
prevHashStringPrevious step hash
errorStringError message (if invalid)

How Hash Chains Work

  1. First Step: Hash = HMAC-SHA256(prevHash:threadID:stepID:stepName:idempotencyKey:timestamp)
  2. Subsequent Steps: Each step’s hash includes the previous step’s hash
  3. Verification: Recalculate hashes and compare with stored values
  4. Tamper Detection: Any modification breaks the chain

Use Cases

Use CaseDescription
Audit TrailVerify execution history hasn’t been tampered with
Detect TamperingIdentify where integrity was compromised
Step VerificationVerify individual step integrity
ComplianceProve execution order for regulatory requirements

Next Steps