{"type":"text/markdown","content":"# File-sign verification (offline-first)\n\n**MCP resource URI:** `doc:reference:filesign-verification`\n\nHow to verify an `identyclaw.filesign.v1` detached package. The competitive claim:\n\n> This Passport-controlled key signed this canonical content under a NEAR-anchored live challenge.\n\nThe IdentyClaw HTTP API is **not** the primary verifier. Prefer local crypto + NEAR tip; bind Passport key via public `/api/publickey/rodit_token` (historic when `block_id` is known) or live NEAR RPC; call the API for HMAC issuance only when `apiChallenge` is absent. Live pitch: [verify.identyclaw.com/claims.html](https://verify.identyclaw.com/claims.html) · paste-or-upload demo: [verify.identyclaw.com/#filesign](https://verify.identyclaw.com/#filesign).\n\nRelated: [`holanonce-api.md`](holanonce-api.md), [`action-attestation.md`](action-attestation.md) (sign hashed action objects), [`key-rotation.md`](key-rotation.md#verifying-pre-rotation-signatures), [`why-identyclaw.md`](../policies/why-identyclaw.md) (not an X.509 / QES product), Hermes plugin [`hermes-identyclaw-auth`](https://github.com/discernible-io/hermes-identyclaw-auth).\n\n---\n\n## Claims matrix\n\n**Pitch page (human):** https://verify.identyclaw.com/claims.html\n\n| Claim | Status | How |\n| --- | --- | --- |\n| Content integrity (hash) | **Cryptographically proven** offline | SHA-256 of file / supplied hash vs envelope `hash` |\n| Agent signature (`agentSig`) | **Cryptographically proven** offline | Ed25519 over JCS envelope; package carries `publicKey` |\n| Passport key binding | **Cryptographically + chain-event-derived** | Prefer key **at tip**: `blockHash` → height → `GET /api/publickey/rodit_token?token_id=&block_id=` (pointers `txHash` / `blockHeight`). No `block_id` / after last cache refresh → live current owner. Same HTTP shape either way. |\n| Tip / NEAR anchor | **Chain-proven** via RPC | Envelope `blockHash` exists (`get-block` / status); optional skew vs `timestamp` |\n| Live issuance without API secret | **Cryptographically proven** offline when present | `apiChallenge` = Ed25519 over UTF-8 `blockHash + LF + timestamp` by API Passport key |\n| Live issuance via HMAC | **Proven only with `K_api`** | Re-derive `noncetsHex`; thin `POST /api/filesign/check-hmac` |\n| Key state **as of signing time** | **Claimed via publickey cache** | Chain-event-derived (`rodit_mint` / `rodit_transfer` / `recover_token`). Served from IdentyClaw SQLite cache; every historic hit carries `(txHash, blockHeight)` so any party can re-derive from a receipt. Pre-refresh tips fall back to **current** on-chain key. |\n| Sole control of software agent | **Policy-asserted** only | Envelope may set `soleControl`; crypto cannot prove process custody |\n| eIDAS QES / handwritten equivalence | **Not claimed** | No QTSP / QSCD / X.509 |\n| CAdES / XAdES / PAdES / JAdES compliance | **Not claimed** | Passport-native profile only |\n\n---\n\n## Recommended relying-party order\n\n1. Hash file (or accept `mode: prehash` hash).\n2. Verify `agentSig` over JCS envelope (`profile` must be `identyclaw.filesign.v1`).\n3. Resolve tip: `get-block(envelope.blockHash)` → height (or hash as `block_id`).\n4. Bind key: `GET /api/publickey/rodit_token?token_id=<roditId>&block_id=<height|hash>` — compare `publicKey` / `owner_id` to package `publicKey`. (Omit `block_id` only when you intentionally accept **current** key.)\n5. Prefer `apiChallenge` + API Passport public key (`GET /api/filesign/api-pubkey` or on-chain API Passport `owner_id`).\n6. Only if no `apiChallenge`: `POST /api/filesign/check-hmac` with `blockHash`, `timestamp`, `noncetsHex`.\n\nDo **not** treat a successful HMAC check as “the API verified the file signature.” It only checks Identyclaw watermark issuance.\n\n---\n\n## API surfaces (secret-bound or discovery)\n\n| Endpoint | Auth | Role |\n| --- | --- | --- |\n| `GET /api/holanonce16ts` | JWT | Mint watermark for signing (not verify) |\n| `GET /api/filesign/api-pubkey` | Public | API Passport `tokenId` + Ed25519 pubkey (base64url) for offline `apiChallenge` |\n| `POST /api/filesign/check-hmac` | Public (rate-limited) | Re-derive HMAC only |\n| `GET /api/publickey/rodit_token` | Public | Passport owner/key at `finality` or `block_id` (NEAR-like param names) |\n| `GET /api/publickey/rodit_key_timeline` | Public | Ordered mint/transfer/recover events with proof pointers |\n| `GET /api/publickey/status` | Public | Cache ingest cursor / refresh status |\n\nFull server-side file-sign verify (hash + agentSig + who + tip) is a **non-goal**; build that in the plugin, auditor CLI (`npx @rodit/verify-signature`), or verify.identyclaw.com client-side — calling `/api/publickey/rodit_token` for the key bind step.\n\n### Auditor CLI (no Passport / JWT)\n\nRelying parties without an IdentyClaw Passport can verify packages with [`@rodit/verify-signature`](https://www.npmjs.com/package/@rodit/verify-signature):\n\n```bash\nnpx @rodit/verify-signature report --path ./doc.pdf --sig ./pkg.json\nnpx @rodit/verify-signature report --path ./doc.pdf --sig ./pkg.json --rpc   # tip + Passport key bind\n```\n\n**Transparent historic bind (SDK update):** keep the same `--rpc` command. When the package has `envelope.blockHash`, resolve height and call `/api/publickey/rodit_token` with `block_id`; otherwise omit `block_id` (current). See [npm package upgrade instructions](#npm-package-upgrade-instructions) below.\n\n### MCP — filesign verification is client-side by design\n\nMCP keeps **`verify_hola`** / **`resolve_passport`** only. There is **no signature oracle** in MCP (no `verify_filesign` / `check_hmac` action tools) — packages stay independently verifiable without trusting the docs server. Use:\n\n- this doc (`doc:reference:filesign-verification`) via `get_resource`\n- Pitch / claims page: https://verify.identyclaw.com/claims.html\n- Paste-or-upload verifier: https://verify.identyclaw.com/#filesign\n- HTTP `GET /api/filesign/api-pubkey`, `POST /api/filesign/check-hmac`, **`GET /api/publickey/rodit_token`**\n- Hermes/OpenClaw plugin `verify_file` (local crypto + those HTTP helpers)\n- `npx @rodit/verify-signature` for auditors / non-Passport relying parties\n\n---\n\n## npm package upgrade instructions\n\nPublished packages live on npm (`@rodit/*`). After the API with `/api/publickey` is deployed, update consumers as follows — **same verify UX**; historic vs current is internal.\n\n### 1. `@rodit/rodit-auth-be` (shared RPC helpers)\n\n- Add optional historic selector on the existing token lookup, e.g.  \n  `nearorg_rpc_tokenfromroditid(tokenId, { block_id })` **or** a thin HTTP helper  \n  `fetchPublicKey({ token_id, block_id?, apiBase })` → `GET {apiBase}/api/publickey/rodit_token`.\n- When `block_id` is omitted: keep today’s live `finality: \"final\"` NEAR view (or call publickey without `block_id`).\n- When `block_id` is set: prefer IdentyClaw `GET /api/publickey/rodit_token` (public, no JWT). Do **not** invent a second method name for “historic.”\n- Config: reuse `NEAR_RPC_URL` / `NEAR_CONTRACT_ID` for tip `get-block`; add optional `IDENTYCLAW_API_BASE` (default `https://api.identyclaw.com`) for publickey.\n- Bump semver minor; publish to npmjs.\n\n### 2. `@rodit/verify-signature` (auditor CLI)\n\n- Keep `verifyFile` / `verifyFileViaRpc` / `npx @rodit/verify-signature … --rpc` as the **only** entrypoints.\n- In `--rpc` path after local crypto OK:\n  1. `get-block(envelope.blockHash)` (existing tip check).\n  2. Bind: `GET /api/publickey/rodit_token?token_id=<roditId>&block_id=<hash|height>`.\n  3. Compare response `publicKey` (or hex `owner_id`) to package `publicKey`.\n  4. If no `blockHash`: same URL **without** `block_id` (current).\n- Report one bind check; optional reason text may mention `source: identyclaw-sqlite` vs `near-rpc` / `cacheMiss: after_last_refresh`.\n- Depend on the new `@rodit/rodit-auth-be` (or call HTTP directly). Publish patch/minor on npmjs.\n\n### 3. `@rodit/verify-hola`\n\n- Default remains **current** key (short max-age). No required change for transparency.\n- Optional later: if verify options include `blockHash`, use the same publickey helper.\n\n### 4. Hermes plugin / OpenClaw plugin\n\n- Bump `@rodit/verify-signature` (or shared helper) dependency once published.\n- `verify_file` keeps the same tool name and args; no new “historic verify” tool.\n\n### 5. Agent skills / prompts\n\n- Tell agents: upgrade npm packages; keep signing with tip `blockHash`; run the **same** verify command. Do **not** add a separate key-history step in prompts.\n\n### Smoke after publish\n\n```bash\nnpm view @rodit/verify-signature version\nnpx @rodit/verify-signature@$VERSION report --path ./doc.pdf --sig ./pkg.json --rpc \\\n  --near-rpc-url \"$NEAR_RPC_URL\" \n# Expect bind against /api/publickey when package has blockHash (once SDK lands).\ncurl -sS \"https://api.identyclaw.com/api/publickey/rodit_token?token_id=<12letters>&block_id=<height>\"\n```\n\n---\n\n## Ops: enable offline-friendly issuance\n\n1. Put a real `HOLA_NONCE_WATERMARK_SECRET` in host `~/idclawserver-app/secrets/secrets.env` (never commit it; not `SESSION_SECRET`). Generate with `openssl rand -hex 32`. Deploy injects that file via Podman `--env-file` and fail-closes if the key is missing or still the git placeholder (`scripts/check-host-secrets-env.sh`).\n2. Keep `HOLA_NONCE_APICALLENGE_ENABLED=true` (committed config default; optional override in `secrets.env`) so holanonce returns `apiChallenge`.\n3. Publish or fetch API pubkey via `GET /api/filesign/api-pubkey`.\n\nUntil the watermark secret is set on the host, holanonce stays legacy `randomBytes` and file-sign clients must use allow-legacy (dev only). CI will refuse to deploy.\n","requestId":"868d42cda7163a8c0139e86f835cbb52"}