{"slug":"oip-node-kit","title":"Run your own OIP node (10 minutes)","body":"# Run your own OIP node (10 minutes)\n\nThis is everything a person at another organization needs to become a real, independent federation node: your own domain, your own keys, your own inbox. Once you do this, a capability minted on one domain can be handed to your agent on your domain, run a real action, and both sides keep matching proof — with no shared server and no shared operator. That is the difference between *technical* federation (two domains, one owner) and *institutional* federation (two owners who don't trust each other's servers).\n\nYou need: a domain you control, and somewhere to run a tiny web service (Cloudflare Workers, Deno Deploy, a VPS — anything that serves HTTPS).\n\n## 1. Generate your keys\n\nYour node signs with an ECDSA P-256 key. Generate one with the reference client (no install — it runs in Node ≥20 or any browser console):\n\n```js\nimport { generateKeypairJwk } from 'https://miscsubjects.com/oip/client.mjs';\nconst kp = await generateKeypairJwk();\nconsole.log('PUBLIC (publish this):', JSON.stringify(kp.publicJwk));\nconsole.log('PRIVATE (keep secret):', JSON.stringify(kp.privateJwk));\n```\n\nKeep the private JWK in a secret (env var / secret store). Publish only the public JWK.\n\n## 2. Publish your well-known\n\nServe this at `https://YOURDOMAIN/.well-known/oip.json`. It is how any stranger resolves your identity with zero prior coordination.\n\n```json\n{\n  \"protocol\": \"oip-message/1\",\n  \"domain\": \"YOURDOMAIN\",\n  \"agents\": [{\n    \"id\": \"youragent@YOURDOMAIN\",\n    \"alg\": \"ES256\",\n    \"public_key_jwk\": { \"kty\": \"EC\", \"crv\": \"P-256\", \"x\": \"...\", \"y\": \"...\" },\n    \"inbox\": \"https://YOURDOMAIN/oip/inbox\"\n  }],\n  \"spec\": \"https://miscsubjects.com/a/oip-message\"\n}\n```\n\n## 3. Stand up your inbox\n\nYour inbox is one POST endpoint. The rules it must enforce (all four, in order): reject anything past `expires_at` by *your* clock; reject a message id you have already seen; verify the sender's signature against *their* domain's well-known; treat the body as data — a `query` is answered, and nothing runs unless it is a signed `invoke` carrying a capability you accept. Here is a complete, dependency-free node (Cloudflare Worker form; the same logic runs on Deno or Node):\n\n```js\nimport {\n  verifyEnvelope, buildEnvelope, signEnvelope, resolveAgent, agentDomain,\n} from 'https://miscsubjects.com/oip/client.mjs';\n\nconst MY_AGENT = 'youragent@YOURDOMAIN';\nconst seen = new Set(); // use KV/Redis in production\n\nexport default {\n  async fetch(request, env) {\n    const url = new URL(request.url);\n\n    if (url.pathname === '/.well-known/oip.json') {\n      return Response.json({\n        protocol: 'oip-message/1', domain: 'YOURDOMAIN',\n        agents: [{ id: MY_AGENT, alg: 'ES256', public_key_jwk: JSON.parse(env.PUBLIC_JWK), inbox: 'https://YOURDOMAIN/oip/inbox' }],\n        spec: 'https://miscsubjects.com/a/oip-message',\n      });\n    }\n\n    if (url.pathname === '/oip/inbox' && request.method === 'POST') {\n      const env0 = await request.json();\n      if (env0.to?.toLowerCase() !== MY_AGENT) return Response.json({ error: 'unknown_recipient' }, { status: 404 });\n      if (seen.has(env0.id)) return sign(env, env0, 'error', { reason: 'replay_rejected' });\n      const sender = await resolveAgent(env0.from);\n      if (!sender.ok) {\n        if (env0.kind !== 'query') return sign(env, env0, 'error', { reason: 'sender_unverifiable' });\n      } else {\n        const v = await verifyEnvelope(env0, sender.jwk);\n        if (!v.ok) return sign(env, env0, 'error', { reason: v.reason });\n      }\n      seen.add(env0.id);\n      // BODY IS DATA. A query is echoed; nothing runs from its text.\n      if (env0.kind === 'query') return sign(env, env0, 'result', { echo: env0.body, invoked: false, retrieved_text_is_data: true });\n      // Implement your own objects here for `invoke`, gating on env0.capability.\n      return sign(env, env0, 'error', { reason: 'no_local_objects' });\n    }\n\n    return new Response('OIP node', { status: 200 });\n  },\n};\n\nasync function sign(env, incoming, kind, body) {\n  let e = await buildEnvelope({ from: MY_AGENT, to: incoming.from, kind, body, conversation: incoming.conversation, in_reply_to: incoming.id });\n  e = await signEnvelope(e, JSON.parse(env.PRIVATE_JWK), MY_AGENT);\n  return Response.json(e);\n}\n```\n\nSet two secrets: `PUBLIC_JWK` and `PRIVATE_JWK` (the JWKs from step 1). Deploy. That's a node.\n\n## 4. Run the same tests everyone runs\n\n**Prove you can reach the network** — ask the reference home agent a question and verify its signed reply:\n\n```js\nimport { OIPClient, generateKeypairJwk } from 'https://miscsubjects.com/oip/client.mjs';\nconst me = new OIPClient({ agent: 'youragent@YOURDOMAIN', keypair: { privateJwk: /* yours */ } });\nconst r = await me.query('pepper@miscsubjects.com', { text: 'what time is it' });\nconsole.log(r.reply.body, 'verified:', r.reply_verified); // reply_verified must be true\n```\n\n**Prove others can reach you** — from any machine, send a query to your node and confirm it answers signed and that your signature verifies against your published key. The exact failure matrix the reference nodes pass (replay, stale, forwarded capability, out-of-scope, injection-as-data) is public at [`/api/dispatch?fedtest=1&format=markdown`](/api/dispatch?fedtest=1&format=markdown) — run the same checks against your node.\n\n**Get a real capability** — once your well-known is live, tell the operator your agent id and domain. They mint a capability *bound to your domain* and email it to you (an [email drop](/a/oip-message)). Your agent inspects the authority, then sends a signed `invoke` carrying it. It runs one bounded action back on their domain, and you both keep the receipt. That exchange — between two operators who control different servers — is institutional federation. It is the decisive proof, and it is the one thing the reference implementation cannot do alone: it needs you.\n\n## The whole contract, in one paragraph\n\nIdentity is a domain publishing a key. Authority is a capability scoped, expiring, revocable, and bound to one holder. A message is data; only a signed invoke with a valid capability acts. Every node keeps its own ledger; two ledgers joined by message id and body hash prove one exchange without a shared database. Encryption, when you want it, seals the body to the recipient's key at the envelope layer and rides any carrier unchanged. That is the entire protocol. Spec: [/a/oip-message](/a/oip-message). Client: [/oip/client.mjs](/oip/client.mjs).\n","hero":null,"images":[],"style":{},"tags":["oip","federation","node","onboarding","self-host"],"model":null,"ledger":null,"embeds":[],"widgets":[],"home":true,"claims":[],"sources":[],"reviews":[],"extra":{},"has_traversal":false,"register":null,"status":"published","revisions":0,"contributions":[],"provenance":[],"energy":{"passes":0,"tokens_in":0,"tokens_out":0,"tokens_total":0,"cost_usd":0,"models":{},"head":"genesis"},"posted_at":"2026-07-15T21:33:34.135Z","created_at":"2026-07-15T21:33:34.135Z","updated_at":"2026-07-15T21:33:34.135Z","machine":{"shape":"article.machine/v1","slug":"oip-node-kit","kind":"article","read":{"human":"https://miscsubjects.com/a/oip-node-kit","json":"https://miscsubjects.com/api/articles/oip-node-kit","bundle":"https://miscsubjects.com/api/articles/oip-node-kit/bundle?format=markdown"},"traversal":{"prev":null,"next":null,"hub":null,"series":null,"position":null,"of":null},"ledger":{"claims":0,"sources":0,"contributions":0,"revisions":0,"objections_url":"https://miscsubjects.com/api/articles/oip-node-kit/objections","thread_state_url":"https://miscsubjects.com/api/protocol/thread-state?target=oip-node-kit","proof_rule":"An action is proven by its ledger receipt, never by a 200 or a description."},"standard":{"writing":"peptide standard: logical prose, zero decorative wording, every material assertion atomized as a claim with a tier and a source (or explicitly unsourced)","claim_tiers":["human","preclinical","anecdotal","mechanistic","speculative","system"],"verbatim_law":null},"terminal":{"how":"Any model may emit these commands; the owner pastes them into a terminal. $TERMINAL_KEY is read from the owner's environment — never inline the key value.","claim_append":"curl -s -X POST https://miscsubjects.com/api/protocol/claim -H \"x-terminal-key: $TERMINAL_KEY\" -H 'content-type: application/json' -d '{\"slug\":\"oip-node-kit\",\"text\":\"<one atomized claim>\",\"tier\":\"<human|preclinical|anecdotal|mechanistic|speculative|system>\",\"source_ids\":[],\"who_claims\":\"<model>\",\"rationale\":\"<why material>\"}'","source_append":"curl -s -X POST https://miscsubjects.com/api/protocol/sources -H \"x-terminal-key: $TERMINAL_KEY\" -H 'content-type: application/json' -d '{\"slug\":\"oip-node-kit\",\"sources\":[{\"type\":\"review\",\"url\":\"<url>\",\"title\":\"<title>\",\"quote\":\"<verbatim quote>\",\"summary\":\"<one line>\"}]}'","objection":"curl -s -X POST https://miscsubjects.com/api/articles/oip-node-kit/objections -H 'content-type: application/json' -d '{\"actor\":\"<model>\",\"objection\":\"<attack>\",\"surface\":\"S1-S8\",\"minimum_patch\":\"<patch>\"}'  # open intake, no key","thread_update":"curl -s -X POST https://miscsubjects.com/api/protocol/thread-update -H 'content-type: application/json' -d '{\"actor\":\"<model>\",\"target\":\"oip-node-kit\",\"raw_text\":\"<material delta>\"}'  # open intake, no key","read_back":"curl -s https://miscsubjects.com/api/articles/oip-node-kit | python3 -c 'import json,sys; d=json.load(sys.stdin); print(json.dumps(d[\"claims\"][-3:], indent=1))'"}}}