Trust Ledger
The Trust Ledger is an append-only, hash-chained record of trust events. Each entry is linked to the previous via SHA3-256 hashing, creating a tamper-evident chain.
Entry Types
| Type | Description |
|---|---|
| TRUST_PROOF | Verification proof between two entities |
| CREDENTIAL | Credential issuance record |
| DELEGATION | Capability delegation record |
| REVOCATION | Revocation of a credential or delegation |
| TRUST_SCORE | Recorded trust score computation |
Usage
from trusthub import LedgerStore
from trusthub.constants import LedgerEntryType
store = LedgerStore("ledger.db")
# Append entries
store.append(
entry_type=LedgerEntryType.TRUST_PROOF,
issuer_did=admin.did,
subject_did=agent.did,
payload={"proof_type": "identity_verified"}
)
# Query entries
entries = store.query(
subject_did=agent.did,
entry_type=LedgerEntryType.TRUST_PROOF
)Hash Chain Verification
from trusthub.ledger.integrity import verify_ledger_chain
is_valid, errors = verify_ledger_chain(store)
print(f"Chain valid: {is_valid}")