// lib/accounting/core/README.hash-chain.md

# Hash Chain (WP-01)

## Purpose

- Ensures immutability and auditability of all journal entries
- Each journal entry includes a deterministic hash of its content and the previous entry's hash
- Any tampering or out-of-order posting is immediately detectable

## Usage

- Use `computeJournalHash(entry)` to generate the hash for each journal entry
- Store `currentJournalHash` and `previousJournalHash` in every journal
- Validate the hash chain during audits and migrations

## Example

```ts
const hash = computeJournalHash(journalEntry);
journalEntry.currentJournalHash = hash;
```

---

> **Note:** Hash chain is mandatory for all posting and migration scenarios.
