Repository navigation
feat: receipt context inside the signed record, plus app-key attestation (0.7.0) - #45
Conversation
anchorOnTransactionSuccess takes a required-when-set context that goes inside the anchored record (or only its sha-256 with contextDigestOnly). Missing context anchors nothing and reports MissingReceiptContextError. createNiriumAdapter takes an attester that signs every anchor with the app key and checks the node confirmed it. README drops the "next to txHash" advice. Version 0.7.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
M0nsxx
left a comment
There was a problem hiding this comment.
AI-assisted review (Claude)
Read the diff in src/index.ts, the new test file and the README. The context now goes inside the anchored record, and a missing or empty context anchors nothing and reports MissingReceiptContextError, so an "optional" context can't silently turn into a missing one. contextDigestOnly stores only the sha-256, which keeps private context out of IPFS. The attester signs nirium-audit-v1:<content_sha256> with the app's key, and anchorAuditRecord throws if the node doesn't confirm that key. Default behaviour without context or attester is unchanged. 38/38 tests and CI green. The testnet receipt QmYEodovqiwJeGtsN4cHnMwm5ouXzG2VSUFtvigHNfqMdU verifies with nirium-cli. Approving; I'll publish 0.7.0 after merge.
Context goes inside the receipt, and the app can sign it with its own key. Follows pollar-xyz/pollar#95, where @zambodotdev pointed out that the context that settles a dispute has to be inside the signed record, and that optional context ends up as missing context.
What changes
anchorOnTransactionSuccesstakescontext: (state) => {...}. The context goes into the anchored record, so the record's hash and the signature cover it. If the app passescontextand it returns nothing or{}, nothing is anchored andonErrorgetsMissingReceiptContextError. The hash can still be anchored later when Pollar replays it.contextDigestOnly: truestores onlycontextSha256(sha-256 ofJSON.stringify(context)), for apps that keep the context private.createNiriumAdapter({ attester })signs everyanchorAuditRecord()call withnirium-audit-v1:<content_sha256>, the statement the node checks, and throws if the node does not confirm the same key inattestedBy.keypairAttester(),attestReceipt()andreceiptContentSha256()are exported. It uses Web Crypto, so it works in Node 22+ and the browser.AuditAnchorInputtakesagentfor callers who sign elsewhere. ThetxHashdoc now says it is node metadata outside the signature.txHash" is replaced by thecontext+attesterexample, plus what a receipt still doesn't prove.contextorattesteris unchanged.Checked
npm run typecheckclean.npm test: 38/38 (31 existing + 7 new intest/receiptContext.test.mjs).contextinside, signed throughattesterwith a fresh key:QmYEodovqiwJeGtsN4cHnMwm5ouXzG2VSUFtvigHNfqMdU.npx nirium-cli verifygives HASH MATCH, SIGNATURE VALID, VERIFICATION PASSED. Self-test, not usage.Not in this PR: checking the record against the transaction on-chain (binding). That's a separate verifier step.
After merge: publish 0.7.0 to npm (Monse).
🤖 Generated with Claude Code