DEV Community

Don't Trust the Agent, Verify the Proof: Building a Proof Gatekeeper for zkVerify's Agent Games

Every AI agent competition has the same weak point: the scoreboard has to believe the agents. An agent says "I checked the condition and the answer is yes" - and unless someone re-runs the work, that claim is just a claim.

zkVerify exists to remove that leap of faith. It's a blockchain built for one job: verifying zero-knowledge proofs quickly and cheaply, so that "I did the computation correctly" stops being a promise and becomes something anyone can check. You prove the work was done right without revealing anything beyond the result itself.

Agent Games is zkVerify's Season 01 tournament for autonomous agents: four tracks, 400,000 VFY in prizes, and every result backed by verifiable proofs. I entered the Proof Gatekeeper track with an agent called mangkarones-gatekeeper. This is a deep dive into how it works - the protocol, the traps, the cryptography, and the bugs - written for anyone thinking of building a verifiable agent themselves.

The game: decide, then prove it

In Proof Gatekeeper, the platform sends your agent a signed task envelope over HTTP. Each task describes a transfer guarded by a condition: a registered verification key, a minimum balance threshold, an expiry block, an intended recipient, a maximum transfer amount, and the actual values someone is presenting - a proof key, a public balance, the current block, a recipient, an amount, and a proof transaction reference.

Your agent has to answer APPROVE or REJECT - and attach a Groth16 zero-knowledge proof that the decision was computed correctly from exactly those inputs. The platform verifies the proof (this is where zkVerify's verification layer comes in) instead of trusting the answer.

Scoring is asymmetric on purpose: a correct decision earns +12, a wrong APPROVE costs −6, a wrong REJECT costs −3, and a timeout or missing proof costs −2, with a small reliability bonus on top. Letting a bad transfer through is punished twice as hard as blocking a good one, which shapes the whole design: when in doubt, the safe answer is REJECT.

The seven traps

The decision logic is a checklist of seven checks, run in a fixed order - the first failing check determines the rejection reason:

  • VK_SUBSTITUTION - the presented proof key (proof_vk) doesn't match the registered key (registered_vk). A proof produced under a different verification key proves something, but not about this gatekeeper. This is the most fundamental check, so it goes first.
  • PROOF_REUSED - the same proof_tx shows up under a different task ID. That's a replay: yesterday's valid proof recycled for today's task. One subtlety matters here - a retry of the same task with the same proof reference is not reuse, because networks and platforms retry deliveries. We track proof references in memory, keyed to the task that first used them.
  • THRESHOLD_MISMATCH - the public balance is below the required minimum. The boundary is inclusive: a balance exactly equal to the minimum is valid.
  • EXPIRED_CONDITION - the current block has reached the expiry block. Here the boundary flips: current_block >= expiry_block means expired, so equality is a rejection. This asymmetry with the threshold check is deliberate, and it's exactly the kind of off-by-one that costs points if you implement from vibes instead of from the spec.
  • RECIPIENT_MISMATCH - the transfer's recipient differs from the condition's recipient, compared case-insensitively (addresses shouldn't fail on capitalisation).
  • AMOUNT_OVERFLOW - the amount exceeds the maximum transfer. Again inclusive: an amount exactly at the cap is valid.
  • VALID_CONDITION - everything passed, so APPROVE.

The ordering isn't cosmetic. A substituted key should be reported as a key problem, not masked by a downstream threshold failure. But there's a harder constraint underneath: the circuit enforces the same evaluation. The ZK circuit takes the decision as an input and checks it against its own computation of the condition. If my JavaScript checklist and the circuit ever disagree, witness generation fails and there's no proof at all. The checklist isn't just policy - it has to be a bit-exact mirror of the circuit's logic.

Generating the proof

Proofs are generated locally with snarkjs using the official circuit artifacts (gatekeeper.wasm and gatekeeper_final.zkey, verification key hash 0x6b79c6…d77b0). The circuit takes thirteen inputs: the ten condition fields, the decision encoded as 1 or 0, a task ID, and a random 32-byte salt that stays private. It produces 13 public signals: a salt-dependent binding hash first, then the twelve public fields.

The salt matters - it binds each proof to a fresh random value, so a proof can't be precomputed or passed around as a static artefact.

One protocol detail was genuinely undocumented: the envelope's task ID is a string like gk_24_9d1, but the circuit needs a field element. I mapped it as keccak256(utf8(task_id)) mod p (the BN254 scalar field), with numeric and hex fallbacks behind an environment switch in case the platform disagreed. Practice tasks settled it - the keccak mapping was correct, and every proof verified.

HMAC in both directions

Proofs handle the "was the decision computed correctly" question. Transport has its own trust problem, handled with HMAC signatures. The platform signs each request body and sends the digest in an x-agent-games-signature header; my server verifies it over the raw bytes, before JSON parsing - re-serialising parsed JSON would change the bytes and break verification.

Every response, including errors, is signed the same way, so the platform can verify that a decision really came from my agent. A request with a bad signature gets a 401 and nothing else.

Shipping it (and the bug)

The agent is a plain Node.js HTTP server - no framework - deployed on Railway with auto-deploy from GitHub. Circuit binaries aren't committed to git, so the server downloads them at boot if they're missing. On startup it also runs a self-test: it builds a synthetic valid task, decides it, generates a real proof, and verifies that proof locally. The /health endpoint reports the result, so a broken deployment announces itself instead of failing silently during a round. And if proof generation ever fails mid-task, the server still returns the decision without a proof - a visible −2 rather than a hang.

The one real bug is worth admitting: my first live practice dispatches came back as HTTP 500s. The platform wraps the condition fields in an input object inside the envelope; my code expected them flat, and BigInt(undefined) threw. Unwrapping the envelope before deciding fixed it - a five-line change that local tests never caught because my test fixtures were built from the documented shape, not the real one. Test against the wire, not the docs.

Results

  • Platform preflight: accepted, 17 ms latency
  • Practice round: 9/9 decisions correct, every proof verified by the platform - including live samples of VK substitution, threshold mismatch, recipient mismatch, expired condition, and amount overflow traps
  • End-to-end task latency including proof generation: roughly 280-420 ms

The agent is registered, healthy, and playing the daily rounds until the season closes on 21 November 2026.

Why this matters beyond the game

The pattern here generalises: any time an autonomous agent's decision moves money, grants access, or approves anything, "the agent said so" is not an audit trail. A decision plus a proof that the decision followed the rules - verified on infrastructure like zkVerify that's built to check proofs at scale - is.

Building this agent convinced me that verifiable agents aren't a research curiosity; the tooling (snarkjs, standard circuits, a signed HTTP envelope) is already mundane, in the best way.

Code: https://github.com/mangkarones3-afk/agent-games-gatekeeper

Live endpoint: https://agent-games-gatekeeper-production-d99ba5b2.up.railway.app (try /health)

Built for #AgentGames, Season 01 - Proof Gatekeeper track.

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.