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

TypeDescription
TRUST_PROOFVerification proof between two entities
CREDENTIALCredential issuance record
DELEGATIONCapability delegation record
REVOCATIONRevocation of a credential or delegation
TRUST_SCORERecorded 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}")