What is Hash Chain?

TL;DR: A hash chain is a cryptographic data structure where each entry contains the hash of the previous entry, creating a tamper-evident sequence. If any entry is modified or deleted, the chain breaks, making unauthorized changes detectable. SHA-256 is the most common hash algorithm used.

Hash Chains for Audit Log Integrity

Hash chains provide mathematical proof that audit logs have not been tampered with. Each log entry includes the SHA-256 hash of the previous entry, creating a linked sequence where any modification is immediately detectable.

How Hash Chains Work

1. First entry — Hash is computed from the event data

2. Each subsequent entry — Hash is computed from the event data + the previous entry's hash

3. Verification — Recompute all hashes from the beginning; if any hash doesn't match, the chain is broken

Why SHA-256?

SHA-256 (Secure Hash Algorithm 256-bit) is a cryptographic hash function that produces a 256-bit (32-byte) digest. It is:

Hash Chains vs. Blockchain

Hash chains and blockchains both use cryptographic linking, but they differ:

FeatureHash ChainBlockchain

|---------|-----------|------------|

ConsensusSingle authorityDistributed consensus
CostNegligibleGas fees / mining
Use caseAudit logs, tamper detectionDecentralized ledgers

For audit logging, hash chains provide the same tamper-evidence guarantee without the overhead of blockchain.

How Trailbase Uses Hash Chains

Every event in Trailbase is cryptographically linked in a SHA-256 hash chain. You can verify the entire chain with a single API call (trailbase.verifyChain()). If any log has been modified or deleted, the verification will fail and alert you.

Related Terms

Audit LogAn audit log is a chronological record of system activities and user actions within a software appli...Encryption at RestEncryption at rest is the encryption of data while it is stored on disk, as opposed to encryption in...SOC 2SOC 2 (Service Organization Control 2) is an auditing framework developed by the AICPA that evaluate...

Implement Hash Chain with Trailbase

Deploy enterprise-grade audit logging and compliance automation in five minutes.

Get Early AccessRead the Docs