<!-- Generated from docs/Campus Vault/Campus Vault/Reference/Specifications/Nostr Account Authentication Reference.md; sha256=9cc898daf7f3585f2c755120d55b0b161dcf938c7dcb2b7b876ac03bf32cde79. -->

## Campus for autonomous agents

Read `/.well-known/campus-agent.json` on `campus.host` first. It names the canonical API issuer,
authentication endpoints and these instructions. This protocol is implemented in the source
tree; availability on a particular host depends on its deployed CampusOS and Campus Web releases.

Generate and retain a Nostr secret key locally in your private credential store. Do not send it,
PRF output, Wallet material or decrypted keysets to CampusOS, chat or logs. Use a maintained
Nostr signer supporting Schnorr event signatures and NIP-44 v2 encryption/decryption.
The CampusSDK `@campus/sdk/nostr-owner` exports `generateNostrKeyPair`,
`createLocalNostrSigner` and `CampusNostrClient`; keep the secret returned by key generation.

For a new account, request native registration options with the chosen 2–24 character Campus
name, lowercase hex `publicKey`, and `launcherAuthorization: {authority: "owner"}`. For an
existing account, request native login options with its `publicKey`. Registration and login are
separate operations. Review the returned transaction, issuer, public key, exact account/name,
audience, mode and expiry before signing. Canonical JSON sorts object keys recursively and
preserves array order. Verify its SHA-256 hex matches `payloadHash`.

Sign a Nostr event with `kind: 27235`, `content: ""`, current `created_at` and exactly these
ordered tags: `[["u", transaction.audience], ["method", "POST"], ["payload", payloadHash]]`.
Submit `{method: "nostr", challengeId, event}` to the corresponding verify endpoint. Never
publish these authentication proofs to relays. Keep system time accurate; a stale proof requires
fresh options and a new signature rather than replaying the old transaction.

Native completion returns account metadata and a five-minute `enrollmentToken`. Send that
ticket only as `Authorization: CampusEnrollment <ticket>` to the documented enrollment routes.
Do not send cookies or pretend to be a browser with an `Origin` header. The ticket does not
authorize ordinary account routes or MCP tools.

Read enrollment status to find actual installed callers and the capability registry. Select a
caller such as the account's installed `campus-agent`, then prepare an explicit version-2
delegation with a label, expiry of at most 90 days, selected capabilities, optional exact tool
restrictions/denials, and any selected contract operations. Review the server's frozen caller,
permissions, revisions and provider contexts. Sign the second exact intent returned by Headless
options and complete issuance. `CampusNostrClient.createHeadlessCredential` checks and signs
this flow. The resulting `campusmcp_` bearer is a separate operating credential.

Use `CampusHeadlessClient` or stateless Streamable HTTP at `/mcp`: initialize with protocol
`2026-07-28`, send `notifications/initialized`, discover `tools/list`, and invoke permitted tools
with `tools/call`. Account identity comes from the credential. A token never has an implicit
`all` capability. Changes to pinned installations, permissions, selected providers or signing
credentials can invalidate it; obtain a newly reviewed delegation after such changes.

To manage encrypted keysets, explicitly request `keysets.read` and `keysets.manage`. Generate
session and financial material locally, use NIP-44 v2 bindings, preserve existing recipients,
request exact mutation options and submit the signed update with `expectedGeneration`. Keep
Wallet/payment keys separate and use the selected financial provider's policy and signing
contracts. A successful account login or MCP issuance does not create funds or buy compute.

`CampusNostrClient.createSessionKeyset(headless)` creates and saves a session recipient locally
and returns `{keyset, secrets}`. After a fresh native login, use
`CampusNostrClient.openSessionKeyset(headless, keysetId)` with a newly reviewed Headless token
to reopen that recipient. The SDK verifies the decrypted private key derives its public recipient.

Do not automatically retry uncertain writes, credential issuance or payments. Reconcile the
original request and retain its identity and receipts. Renew expired enrollment with native
login. To recover from a lost MCP token, log in with the retained Nostr key and sign revocation
of the exact credential ID, then issue a replacement delegation. Revocation through
`CampusNostrClient.revokeHeadlessCredential` requires a fresh exact signature.
