Skip to content

feat: receipt context inside the signed record, plus app-key attestation (0.7.0) - #45

Merged
M0nsxx merged 1 commit into
mainfrom
feat/receipt-context-inside
Nov 29, 2026
Merged

M0nsxx merged 1 commit into
mainfrom
feat/receipt-context-inside

Conversation

@Eras256

@Eras256 Eras256 commented Nov 29, 2026

Copy link
Copy Markdown
Member

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

  • anchorOnTransactionSuccess takes context: (state) => {...}. The context goes into the anchored record, so the record's hash and the signature cover it. If the app passes context and it returns nothing or {}, nothing is anchored and onError gets MissingReceiptContextError. The hash can still be anchored later when Pollar replays it.
  • contextDigestOnly: true stores only contextSha256 (sha-256 of JSON.stringify(context)), for apps that keep the context private.
  • createNiriumAdapter({ attester }) signs every anchorAuditRecord() call with nirium-audit-v1:<content_sha256>, the statement the node checks, and throws if the node does not confirm the same key in attestedBy. keypairAttester(), attestReceipt() and receiptContentSha256() are exported. It uses Web Crypto, so it works in Node 22+ and the browser.
  • AuditAnchorInput takes agent for callers who sign elsewhere. The txHash doc now says it is node metadata outside the signature.
  • README: the old advice to put the order id "next to txHash" is replaced by the context + attester example, plus what a receipt still doesn't prove.
  • Version 0.7.0. Default behaviour without context or attester is unchanged.

Checked

  • npm run typecheck clean. npm test: 38/38 (31 existing + 7 new in test/receiptContext.test.mjs).
  • Live on testnet 29-nov: record with context inside, signed through attester with a fresh key: QmYEodovqiwJeGtsN4cHnMwm5ouXzG2VSUFtvigHNfqMdU. npx nirium-cli verify gives 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

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 M0nsxx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@M0nsxx
M0nsxx merged commit 6e330aa into main Nov 29, 2026
4 checks passed
@M0nsxx
M0nsxx deleted the feat/receipt-context-inside branch November 29, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants