Repository avatar
Other Tools
v0.3.1
active

mnemoward

org.mnemoward/mnemoward

Agent reads of personal records are logged with witnesses before a key is released.

Documentation

Mnemoward

No read without a trace. An AI agent gets the key to your private record only after its read request is in a public log cosigned by witnesses meant to be run by independent operators (on the dev log they are still local test keys, see Limits). You see every read and every denied attempt, and when you forget a record you get a receipt that its key no longer exists.

Status: experimental prototype (v0.3). Not audited. Do not use for real data yet.

Why

AI assistants now read notes, chats and medical records. Today you cannot check which agent read what and why, or whether a "deleted" record can still be opened. Access logs, where they exist, are kept by the same service that reads the data.

Mnemoward moves the proof out of the reader's hands:

  1. Request. The agent signs a read request (who, which record, purpose).
  2. Log. The request goes into an append-only Merkle log. Witnesses cosign the log only if it never rewrites history.
  3. Release. Key guardians (2 of 3) check the logged request, then each releases its share of the record key to the agent.
  4. Audit. Your auditor reads the log through the witnesses and shows a feed: who, what, why, when, and what was refused.

Forget: each guardian punctures its key tree so the record's key can no longer be derived, and logs a signed statement. Anyone can verify the receipt with public keys.

Quick start

Node.js 20+, no dependencies, no network.

node demo.js            # 16 scenarios, exit code 0 if all behave as expected
bash mcp/demo.sh        # 2-minute MCP demo on test records (PAUSE=2 for screen recording)
node test.js            # Merkle proofs vs a naive RFC 9162 implementation
node test_keytree.js    # puncturable key tree
node test_c2sp.js       # C2SP signed notes, cosignatures, add-checkpoint, RFC 6962 vectors
node mcp/test_mcp.js    # end-to-end MCP server test
node test_fast.js       # read modes: strict and fast, split view caught by the auditor
node bench.js           # 1M-entry log and end-to-end reads
RM_SIG=ml-dsa-44 bun demo.js   # same with ML-DSA-44 signatures (Bun or Node 24+)
MNEMOWARD_LOG=... MNEMOWARD_LOG_TOKEN=... node bench_remote.js   # latency against a live log, strict vs fast

MCP

mcp/server.js is a stdio MCP server. An agent sees two tools:

  • vault_list(tag?): record IDs, titles and tags, no content;
  • vault_read(ids, purpose): logged request, 2-of-3 key release, decrypted text plus a receipt summary.

Forget, grants and the feed exist only in the owner CLI:

node mcp/cli.js init
node mcp/cli.js import ./notes --tag notes
node mcp/cli.js grant claude-code --scopes notes --max 50 --days 30
claude mcp add mnemoward -- node "$PWD/mcp/server.js"
node mcp/cli.js feed          # who, what, why, outcome
node mcp/cli.js forget <id>   # one receipt per guardian
node mcp/cli.js verify <receipt.json> --trust trust.json

Environment: MNEMOWARD_VAULT (vault directory), MNEMOWARD_AGENT (agent name for the server), MNEMOWARD_LOG (use a remote Tessera log instead of the local one).

Remote guardians: each guardian can run as its own server (node guardian/server.js serve, no dependencies). The owner's vault talks to them over HTTPS and signs every write (shares, grants, forgets) with the owner key; a guardian releases its share only for a logged, witnessed request, reads the public log itself and holds no log write token. Setup: MNEMOWARD_LOG=... MNEMOWARD_GUARDIANS=url1,url2,url3 node mcp/cli.js init, then node guardian/server.js init <setup file> on each machine, then node mcp/cli.js guardians-connect. See deploy/guardian/README.md. Tests: node test_guardian.js (offline) and test_guardian_http.js (three processes against the public log).

Read modes: by default a guardian releases a key only on a checkpoint that witnesses cosigned (strict). MNEMOWARD_MODE=fast at init lets guardians release on a log-signed checkpoint and has the owner's feed check witness cosigning afterwards; it detects a hidden read instead of preventing it. See SPEC section 5.1.

What is in the box

  • src/merkle.js: RFC 9162 tree, inclusion and consistency proofs; passes the transparency-dev/merkle vectors.
  • src/note.js: C2SP signed note, checkpoint, cosignature/v1 (Ed25519 0x04, ML-DSA-44 0x06), add-checkpoint bodies.
  • src/keytree.js: puncturable GGM key tree (depth 32).
  • src/shamir.js: Shamir t-of-n over GF(256).
  • src/parties.js: log, witness, guardian, threshold gate, agent, auditor, receipt verification.
  • src/remote.js: client for a remote Tessera log (tlog-tiles, token-gated writes).
  • mcp/: vault with persistent state, owner CLI, MCP server, tests, demo.
  • deploy/: configuration of the public dev log (no secrets).
  • test/interop/: cross-check against Go reference code (golang.org/x/mod/sumdb/note, transparency-dev/formats).

Formal verification

Tamarin models cover reads (S1), the threshold (T) and forget (F). S1 and T are verified. Tamarin found two attacks on forget. Attack 1: an agent keeps one share from before the forget and later asks the guardian that missed it (fixed: guardians apply each other's forgets from the log before any release; demo.js scenario 15). Attack 2: a forget cosigned by 2 of 3 witnesses, one of them compromised, can be hidden from the third witness with a log fork (fixed: a forget is complete only when all n guardians punctured and all n witnesses cosigned it, and configurations with q_forget + q_read - n <= f are rejected; demo.js scenario 16). The fixed model is verified for 3 witnesses and 3 guardians. Details in SPEC.md section 7 and tamarin/.

Honest limits

  • Witnesses on the dev log are local test keys for now. Independent witnesses come once the log joins the Witness Network.
  • Guardians can run as separate servers (guardian/server.js). The development deployment runs guardian 1 on the owner's laptop, guardian 2 on the log's server and guardian 3 on a second cloud server. All three still belong to one person and two of them to one cloud provider, so this protects against theft or compromise of one machine, not against collusion. The next step is a guardian run by an independent party. Since v0.3.1 guardians do not hold the owner's audit key: each sees only the requests it serves, never the owner's feed. An agent can now log an audit copy the owner cannot read; the owner's auditor then names the agent from its signature and warns (SPEC section 8).
  • An agent that already read a record may keep a copy. The log proves that it read; cryptography cannot unread.
  • Plaintext that enters a model's context is outside the protocol.
  • The purpose in a request is signed and shown to the owner, but it is the agent's statement. It does not prove how the data was actually used.
  • A forget receipt shows that guardians following the protocol destroyed their key material. It cannot prove that no copy of the key or the text exists anywhere else.
  • Titles are visible to the agent in vault_list. Pseudonyms are planned.
  • Key wrapping to the agent is X25519, not yet post-quantum. Shamir, HMAC and AES layers are.

How this was built

The code, tests, models and documents were written with an AI assistant (Claude). The author reviews, runs and is responsible for them. Please report problems through issues.

License

Apache License 2.0. See LICENSE and NOTICE.

NPM
mnemoward-mcp
Install Command
npm install mnemoward-mcp