Skip to content

Zero now means zero: ZK run attestation + enforced no-recursion#1

Open
Solizardking wants to merge 1 commit into
mainfrom
feat/zk-attestation
Open

Zero now means zero: ZK run attestation + enforced no-recursion#1
Solizardking wants to merge 1 commit into
mainfrom
feat/zk-attestation

Conversation

@Solizardking

Copy link
Copy Markdown
Owner

📣 Announcement

Zero can now prove an agent run happened — exactly once, produced by a specific model set — without revealing a single token of it.

This PR lands internal/attest, a stdlib-only package (zero new dependencies) that turns the name "Zero" into two verifiable properties:

1. Zero knowledge — attestable runs

  • Every run event folds into a SHA-256 hash chain: head_i = SHA-256(head_{i-1} ‖ canonicalJSON(record_i)). The final head is a 32-byte payload commitment.
  • A nullifierSHA-256(secret ‖ context ‖ nonce_u64le), bit-compatible with clawd-zk's @clawd/zk-client computeNullifier (verified against an independent reference computation) — gives one-shot replay protection.
  • Attest() emits exactly the four public inputs the clawd-zk Solana program verifies in publish_attestation: attester, modelHash, payloadCommitment, nullifier. On-chain cost ≈ $0.005/run via compressed PDAs (15k lamports vs 890k for a regular PDA).
  • Transcripts never leave the machine: WriteJSONL/VerifyJSONL let anyone holding the file replay the chain and check the commitment offline; tampering with any byte is detected.

What the chain learns: a run happened, which model set produced it, exactly once. What it never learns: prompts, tool calls, outputs.

2. Zero recursion — enforced, not asserted

norecursion_test.go parses the package on every go test, builds the intra-package static call graph (closures attributed to their enclosing function), and fails the build on any direct or mutual recursion. Planting a recursive function turns CI red.

Changes

  • internal/attest/attest.go — Transcript hash chain, JSONL export/verify, Nullifier, Attestation, ModelSetID
  • internal/attest/attest_test.go — round-trip, tamper detection, determinism, zk-client compatibility vectors
  • internal/attest/norecursion_test.go — static call-graph recursion gate
  • docs/ATTESTATION.md — privacy model and integration flow
  • README.md — announcement at the top + documentation index entry

Verification

  • go vet ./internal/attest/ clean
  • go test ./internal/attest/ — 6/6 pass (ok github.com/Gitlawb/zero/internal/attest)
  • Nullifier output cross-checked bit-exact against an independent Python SHA-256 reference

Notes

The full flat-scheduler engine this was distilled from — queued (never nested) subagents, ZK God Mode multi-model racing with winner-set attestation, and deterministic NL intent routing — lives in ClawdBot's pkg/zero. This package is the portable core Zero can adopt incrementally; wiring it into internal/agent's loop and zero exec is a natural follow-up.

🤖 Generated with Claude Code

Add internal/attest — a stdlib-only package that makes "Zero" literal:

- Hash-chained transcripts: every run event folds into a SHA-256 chain
  whose head is a 32-byte payload commitment; JSONL export re-verifies
  offline with VerifyJSONL, and any tampering is detected.
- Nullifiers bit-compatible with clawd-zk (@clawd/zk-client
  computeNullifier): SHA-256(secret ‖ context ‖ nonce_u64le), giving
  one-shot replay protection when published on Solana via
  publish_attestation (~$0.005/run via compressed PDAs).
- Attestation artifact carrying exactly the four public inputs the
  clawd-zk program verifies: attester, modelHash, payloadCommitment,
  nullifier. The chain learns that a run happened, which model set
  produced it, and that it happened exactly once — never prompts,
  tool calls, or outputs.
- Static no-recursion gate: norecursion_test.go builds the package's
  intra-package call graph on every go test and fails on any direct
  or mutual recursion.

Announce the capability at the top of the README and link
docs/ATTESTATION.md from the documentation index.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant