From 9dc8c23874befaf9c0a9ed844cf1e4228480407b Mon Sep 17 00:00:00 2001 From: Monserrat Mendoza <210256392+M0nsxx@users.noreply.github.com> Date: Sat, 7 Nov 2026 10:54:31 -0600 Subject: [PATCH] feat(cli): nirium anchor --sign - attach an agent attestation Adds --sign and --key-env to `nirium anchor`. Signs nirium-audit-v1: locally with ed25519 - the secret key (from --key-env or the config store's secretKey) never leaves this process, only the signature and derived public key do. 7 new tests with a fake agent server that verifies the signature for real (ed25519 over the same statement the real node checks), so a genuinely bad signature gets a real 400 and nothing is cataloged as anchored; the happy path round-trips through `nirium verify`, which reports SIGNATURE: VALID against the same key. Full suite 83/83. Closes #134 Co-Authored-By: Claude Sonnet 5 --- packages/cli/CHANGELOG.md | 1 + packages/cli/README.md | 19 +++ packages/cli/bin/nirium.js | 49 +++++- packages/cli/package.json | 2 +- packages/cli/test/anchor-sign.test.js | 215 ++++++++++++++++++++++++++ 5 files changed, 281 insertions(+), 5 deletions(-) create mode 100644 packages/cli/test/anchor-sign.test.js diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 280b78a..489dbad 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to the `nirium-cli` package are documented here. ### Added - `nirium anchor` ([#133](https://github.com/nirium-protocol/nirium/issues/133)): anchors a sha-256 hash (`--hash`), a file's sha-256 (`--file`, the file itself is never uploaded), or a small JSON record (`--record`, max 8KB, enforced client-side) to IPFS via an Audit Trail node's `POST /api/audit/log`. Optional `--tx`/`--tag`; no `--network` flag by design - the agent box decides its own network. Prints the CID, content hash, gateway URL, and a `nirium verify` suggestion. +- `nirium anchor --sign` ([#134](https://github.com/nirium-protocol/nirium/issues/134)): attaches an ed25519 attestation of which key produced the anchor. Signs `nirium-audit-v1:` locally with a key from `--key-env ` or the config store's `secretKey` - the secret key itself never leaves this process. A rejected signature gets a `400` and anchors nothing; `nirium verify` reports `SIGNATURE: VALID` on the round trip. - `nirium verify --gateway` is now repeatable, tried in order as fallbacks, with `--retries`/`--timeout` ([#135](https://github.com/nirium-protocol/nirium/issues/135)). A `404` retries the *same* gateway with backoff (a fresh pin can take a moment to propagate); any other failure moves straight to the next gateway. When every gateway 404s, that's reported as `availability: "not_yet_available"`, distinct from a real hash mismatch - nothing was fetched to compare in the first place. - `nirium report summary` and `nirium report export anchors|payments|payroll` ([#136](https://github.com/nirium-protocol/nirium/issues/136)): thin client for the Reporting node. `export anchors` prints exactly one CID per line on stdout (nothing else), pipeable straight into `nirium verify`; the row count and the "not certified regulatory reporting" disclaimer print to stderr so they never land in that pipe. `--csv ` writes the server's CSV instead; `--json` prints the full response. diff --git a/packages/cli/README.md b/packages/cli/README.md index 9362a4d..b18b975 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -235,6 +235,8 @@ client-supplied network field is rejected server-side anyway. | `--record ` | anchor this small JSON object verbatim | none | | `--tx ` | associate a transaction hash | none | | `--tag