Repository navigation
feat(cli): keep your own copy of a receipt (anchor --save, cid) - #429
Merged
Merged
Conversation
A receipt lives on IPFS only while someone pins it. The CID is the hash of the document, so any byte-identical copy brings it back with the same CID. This makes keeping that copy one flag: - `nirium anchor --save <file>` writes the exact anchored document, byte for byte, only after checking those bytes give back the anchored CID. It uses the `document` the node returns (core-private#232) and falls back to the gateway on nodes that don't return it yet. - `nirium cid <file> [--expect <cid>]` recomputes a file's CIDv0 locally, no IPFS node or library: a receipt is one dag-pb/UnixFS block, so the CID is base58btc(0x12 0x20 || sha256(node)). Checked against three real mainnet receipts (QmSSZdtt, QmS5q2Nv, QmVWZM1i). - SDK: `AuditAnchor.document` (optional) typed. - CLI README and the verify guide explain how to re-add a lost receipt. Tests: 6 new (real receipts as fixtures; one changed byte fails; --save from the response, from the gateway, and refusing a mismatched copy). CLI verify/keep suites 60/60, anchor 17/17, SDK tsc clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
M0nsxx
approved these changes
Nov 21, 2026
M0nsxx
left a comment
Member
There was a problem hiding this comment.
AI-assisted review (Claude)
Read the diff. anchor --save writes the exact anchored document only after it recomputes to the anchored CID (from the response, or the gateway on older nodes); new cid command recomputes CIDv0 locally with no dependency, checked against three real mainnet receipts. SDK types the optional document; README and verify guide explain re-adding a lost receipt. 6 new tests, verify and anchor suites pass. LGTM.
M0nsxx
pushed a commit
that referenced
this pull request
Nov 21, 2026
Version bump only, for what merged since the last release: - nirium-cli 3.2.7: anchor --save and nirium cid (#429). - nirium-mcp 0.6.10: env fallbacks, readable error when the signer can't start, exported createNiriumMcpServer, tool test suite (#388). #388 had no changelog entry; written here from the diff. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
M0nsxx
pushed a commit
that referenced
this pull request
Nov 21, 2026
…PI 0.12.8 (#431) Same local CIDv0 check the CLI got in #429, for SDK users: recompute a kept receipt's CID with no IPFS node and no new dependency. - TypeScript: export receiptCid(bytes | string | document object). - Python: nirium.receipt_cid(bytes | str | dict); a dict is serialized as compact JSON with UTF-8 kept, which is what the node pinned. - READMEs: "Keep your own copy" next to the Audit Trail section. - 6 tests each, with two real mainnet receipts as fixtures. Cross-checked CLI, TS, Python and ipfs-only-hash on ASCII and non-ASCII input: same CID. - Versions: nirium 0.19.6 -> 0.19.7 (npm), nirium 0.12.7 -> 0.12.8 (PyPI: pyproject, setup.py, __version__), changelogs. SDK: tsc clean, jest 108/108. Python: 62 passed (langchain test needs the test extras, as in CI). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A receipt lives on IPFS only while someone pins it, and Nirium can't promise to pin forever. The CID is the hash of the document, so any byte-identical copy brings it back with the same CID. This PR makes keeping that copy one flag. It's the client side of core-private#232, which adds a second pinned copy on Filebase and returns the exact
documentfromPOST /api/audit/log.CLI
nirium anchor --save <file>writes the exact anchored document, byte for byte, and only after checking that those bytes give back the anchored CID. It uses thedocumentthe node returns; on nodes that don't return it yet, it fetches the same bytes from the gateway. If the copy doesn't match, nothing is written and the command exits 1 (the anchor itself still succeeded).nirium cid <file> [--expect <cid>]recomputes a file's CIDv0 locally, with no IPFS node and no new dependency. A receipt is a single dag-pb/UnixFS block, so its CID isbase58btc(0x12 0x20 || sha256(node)), the same asipfs addwith default settings. I checked it against three real mainnet receipts (QmSSZdtt…,QmS5q2Nv…,QmVWZM1i…).SDK:
AuditAnchor.document?typed (optional, so older nodes are fine).Docs: CLI README "Keep your own copy" and a "If IPFS Loses a Receipt" section in
docs/verify-audit-cid.md: save, check withnirium cid, re-add withipfs add --cid-version=0, and don't reformat the file.Tests: 6 new in
test/keep-receipt.test.js, with two real mainnet receipts as fixtures: CIDs recomputed, mismatch exits 1, one changed byte fails,--savefrom the response,--savefrom the gateway fallback, and a mismatched copy refused. Locally: verify and keep suites 60/60, anchor 17/17, SDKtscclean.🤖 Generated with Claude Code