Skip to Content
DocumentationCompanion MemoryDecentralized trust (KERI & ToIP)

Decentralized trust (KERI and ToIP)

Companion Memory is a personal memory bank holding messages, photos, financial documents, health records, and private communications. Building federated peer-to-peer interactions across such sensitive archives requires an identity and trust architecture that eliminates centralized intermediaries, third-party token brokers, and single points of surveillance.

To achieve this, Companion Memory implements the Trust Over IP (ToIP) dual-stack architecture using Key Event Receipt Infrastructure (KERI).


Why traditional identity models fail personal memory

Existing identity architectures create unacceptable failure modes when applied to private personal memory:

Identity modelThe fatal flaw for personal memory
Centralized OIDC / OAuthSurveillance and dependency. A centralized token server (such as Google, Apple, or Companion Portal) knows every time Companion A communicates with Companion B, can revoke access at will, and can suffer outages that paralyze peer communication.
Public Blockchain DIDsCost, latency, and permanent correlation. Every key rotation costs gas fees and takes minutes to confirm. Worse, public ledgers permanently record transaction timestamps and transaction graphs, creating permanent correlation trails that violate privacy rights.
Domain-based DIDs (did:web)DNS and CA vulnerability. If a domain expires, changes hands, or experiences a DNS hijacking, the owner’s entire identity and historical trust graph is severed or compromised.
Autonomic Identity (KERI)Sovereign, ledgerless, and secure. Identity is rooted directly in the controller’s cryptographic keys. Rotations are recorded in lightweight, pairwise Key Event Logs (KEL). No cloud server, blockchain, or domain authority is needed.

KERI core primitives

KERI operates on the principle that identity should be autonomic—self-contained and self-governing.

1. Autonomic Identifiers (AIDs)

An AID is a decentralized identifier that self-certifies its controller:

  • Basic identifier (did:keri:D...): For single-key edge devices (such as a local Companion Hub), the AID is the Ed25519 public key itself, encoded in Composable Event Streaming Representation (CESR).
  • Self-addressing identifier (did:keri:E...): For personas and appliances with rotatable keys, the identifier is the cryptographic digest of the inception event (icp). The identifier never changes, even when private keys are rotated.

2. Key Event Logs (KEL)

An entity’s history is recorded in an immutable, append-only Key Event Log:

  • icp (Inception): Establishes the AID, the initial signing key, the pre-rotation hash, and configuration parameters.
  • rot (Rotation): Rotates the signing authority to a new key pair while simultaneously establishing a commitment to the subsequent key pair.
  • ixn (Interaction): Seals and anchors external data (such as standing grant SAIDs) without changing the active signing keys.

3. Pre-rotation commitments (quantum and compromise defense)

Pre-rotation is KERI’s signature cryptographic innovation. During every key generation, two key pairs are minted:

  1. Current signing key (K0): Used to sign requests and assertions.
  2. Next key pair (K1): Kept completely offline in secure storage. Only its cryptographic hash, H(K1), is published in the nxt field of the current event.

Even if an attacker gains root access to the active appliance and steals K0, they cannot hijack the AID because they cannot create a valid rotation event without K1.


Composable Event Streaming Representation (CESR)

Companion Memory uses CESR for binary-text dual representation. CESR allows cryptographic data (public keys, signatures, and digests) to be streamed over standard JSON or binary protocols with zero ambiguity:

Selector prefixMeaningByte sizeFormatted lengthExample
BEd25519 public key32 bytes44 charactersB4Xz...
DBasic Ed25519 AID prefix32 bytes44 charactersdid:keri:D4Xz...
ESHA-256 digest / SAID32 bytes44 charactersEP8k...
0AEd25519 signature64 bytes88 characters0ACd...

Because CESR specifies the exact cryptographic primitive in its prefix code, verifiers know which algorithm to apply without out-of-band metadata negotiation.


Self-Addressing Identifiers (SAID) for audit non-repudiation

Companion Memory uses SAIDs (RFC 8785 canonical JSON with embedded Blake3 or SHA-256 digests) to make consent grants and audit records tamper-evident:

The verification property

When either party needs to verify the authenticity of an audit record:

  1. Replace field d with SAID_PLACEHOLDER_44 (# repeated 44 times).
  2. Serialize canonically.
  3. Compute the SHA-256 digest.
  4. Verify that computedDigest === originalValue(d).

If a single byte of the query, response count, or timestamp was tampered with, the digest fails to match, providing cryptographic proof of tampering.


Out-of-Band Introductions (OOBI)

Companions establish bilateral peer relationships using OOBI URLs:

https://hub.example.com/.well-known/keri/oobi/did:keri:D4Xz9a8b...

When two users pair their Companions:

Neither party needs to contact Companion Portal or any centralized server during this exchange. The link is established directly between the two appliances. (If CI_PEER_DIRECTORY_URL is configured, users can optionally publish and resolve handles via the Companion Portal peer directory at /api/peers/resolve/:handle as a convenience discovery step before verifying the peer’s KEL directly.)


Solving the three federation failure modes

The KERI integration in Companion Memory directly resolves three critical architectural vulnerabilities:

1. Eliminating the centralized token dependency (Gap G3)

  • Previous behavior: /agent/v1/ask required a Companion Portal OIDC bearer token addressed to the responder’s configured peers.audience. If Companion Portal went offline, or if two users were running off-grid without internet access, federated asks failed completely.
  • KERI solution: If a request carries an RFC 9421 HTTP Message Signature signed by a verified KERI AID (keyid="did:keri:..."), Companion Memory authenticates the peer directly as { issuer: 'did:keri', subject: keyid }. Asks work offline over local LAN or private mesh networks.

2. Ending username and directory drift

  • Previous behavior: Hub forward-auth identified users by email address or ephemeral directory UUIDs. If a user changed their email, or if a Hub was restored onto a fresh database with a new directory UUID, the user was placed into an empty account, losing their memory graph.
  • KERI solution: Companion Hub derives a permanent sovereign AID (did:keri:<user-aid>) from the user’s immutable public ID. Companion Memory indexes (issuer: 'did:keri', subject: userAid) in ci.federated_identities. Renaming an address or reinstalling Hub never detaches the user from their memory database.

3. Cryptographic grant revocation without policy leakage

  • Previous behavior: Revoking a permission required notifying external peers or synchronizing a shared policy file, which could leak when and why a relationship cooled.
  • KERI solution: Grants are represented as Authentic Chained Data Containers (ACDC) governed by Transaction Event Logs (TEL). Revoking a grant writes a rev event to the local TEL. When an incoming ask arrives, the responder’s engine verifies the local TEL and denies the ask with standard delivered status, without revealing revocation reasons to the asker.

Last updated on