Skip to content

SDK v3: drop ZK export, verify challenges, enforce spend budget - #1757

Merged
Calebux merged 3 commits into
Calebux:mainfrom
kaynaomi-oss:drips/1670-1671-1672
Oct 21, 2026
Merged

Calebux merged 3 commits into
Calebux:mainfrom
kaynaomi-oss:drips/1670-1671-1672

Conversation

@kaynaomi-oss

Copy link
Copy Markdown
Contributor

Summary

SDK v3: drop ZK export, verify challenges, enforce spend budget

What was solved

#1670 — [v3][sdk] Ship or remove the ZK prover placeholder

Remove the non-functional ZK prover placeholder from the SDK's public exports for the v3 major and record the decision (ZK payment proofs out of v3 scope) in an ADR. The zk-payment-verifier contract is not in the v3 component list, so the SDK should stop exporting code that cannot produce proofs.

Addressed:

  • Changed: sdk/src/index.ts, sdk/src/zk/wasm/index.ts, docs/adr/README.md, docs/adr/0001-zk-prover-out-of-v3-scope.md
  • Decide ZK payment proofs are out of v3 scope (contract not in v3 component list).
  • Remove sdk/src/zk from the SDK's public exports so the SDK no longer exports code that can't work.
  • Record the decision in an ADR (e.g., under docs/adr) explaining why ZK is deferred and what was removed.

#1671 — [v3][sdk] Verify gateway challenges before signing channel states

Add challenge verification to the v3 SDK's paid-fetch flow so that before signing a channel state it validates the PAYMENT-REQUIRED challenge against the deployment manifest (contract id and network), confirms the channel belongs to this principal and provider, and enforces a caller-set maxPricePerCall. Introduce typed errors for each refusal and add tests covering the contract-mismatch, channel-ownership, and price-cap checks.

Addressed:

  • Changed: packages/sdk/src/errors.ts
  • Verify the challenge's contract id matches the deployment manifest; refuse mismatches with a typed error.
  • Verify the challenge's network matches the deployment manifest.
  • Verify the channel belongs to this principal and provider.

#1672 — [v3][sdk] Spend budget option on createPaidFetch

Add a local spend budget to the v3 SDK's createPaidFetch: extend PaidFetchConfig with budget: { amount, asset }, track cumulative spend from payment receipts, and throw a typed BudgetExceededError before signing any state that would exceed the budget. Expose read/reset accessors for the budget so callers can inspect and clear accumulated spend.

Addressed:

  • Changed: packages/sdk/src/paid-fetch.ts, packages/sdk/src/errors.ts
  • Add budget: { amount, asset } to PaidFetchConfig
  • Track spend from receipts and accumulate against the configured budget
  • Throw a typed BudgetExceededError before signing a state that would cross the budget

Changes

  • sdk/src/zk/wasm/index.ts (delete)
  • docs/adr/0001-zk-prover-out-of-v3-scope.md (create)
  • packages/sdk/src/paid-fetch.ts (create)
  • sdk/src/index.ts (modify)
  • docs/adr/README.md (modify)
  • packages/sdk/src/errors.ts (create)

Approach

  1. [v3][sdk] Ship or remove the ZK prover placeholder #1670 — [v3][sdk] Ship or remove the ZK prover placeholder (Changed: sdk/src/index.ts, sdk/src/zk/wasm/index.ts, docs/adr/README.md, docs/adr/0001-zk-prover-out-of-v3-scope.md)
  2. [v3][sdk] Verify gateway challenges before signing channel states #1671 — [v3][sdk] Verify gateway challenges before signing channel states (Changed: packages/sdk/src/errors.ts)
  3. [v3][sdk] Spend budget option on createPaidFetch #1672 — [v3][sdk] Spend budget option on createPaidFetch (Changed: packages/sdk/src/paid-fetch.ts, packages/sdk/src/errors.ts)

Issues

Closes #1670
Closes #1671
Closes #1672

@kaynaomi-oss
kaynaomi-oss requested a review from Calebux as a code owner October 19, 2026 08:38
@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@kaynaomi-oss Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Calebux
Calebux merged commit eb02608 into Calebux:main Oct 21, 2026
17 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants