Inspiration Social-deduction games (Mafia, Werewolf, Among Us) all share one dirty secret: you have to trust the server. Someone — the host, the platform, a moderator — can see everyone's hidden roles. We wanted to know: what if no one could cheat, because no one could see the hidden state at all? Midnight's zero-knowledge ledger made that question answerable. The result is a neon-noir deduction game where deception is confidential and provably fair — trustless hidden information as a Web3 primitive.

What it does

Veil Protocol is a real-time multiplayer social-deduction game set in a cyberpunk city. Players join a room by short code, get a secret role (Shadow, Oracle, Aegis, Citizen), and move through a live neon map across Night/Day/Voting phases — investigating, protecting, eliminating, and voting. The twist: every piece of sensitive state — role assignment, night actions, investigations, and win conditions — is committed and verified on Midnight through zero-knowledge proofs. The server runs the city, but it cannot peek at or forge who's who. Only what you're authorized to see ever reaches your client.

How we built it

A deliberate hybrid architecture:

  • Java (Spring Boot) — the authoritative real-time server: lobby/matchmaking, movement, NPCs, chat, phase timers, and a strict per-viewer redaction boundary so clients only receive their authorized slice.
  • Midnight (Compact contracts) — the confidential referee: role commitments, night-action authorization, and win resolution as zk-circuits. The backend talks to it through a single ConfidentialGateway seam, with a relayer that submits transactions on players' behalf (no wallet friction for players).
  • React + PixiJS + Framer Motion — a render-only client: the animated neon map, glassmorphic HUD, and cinematic role/night/victory overlays.
  • Ollama — local LLM giving NPC witnesses natural, deterministic dialogue scoped strictly to what they actually observed.

Challenges we ran into

  • Drawing the trust line. Deciding exactly what belongs on-chain (confidential, must be trustless) vs. in the Java server (public, must be fast) was the core design tension of the whole project.
  • Bridging Java ↔ Midnight. Midnight's SDK is TypeScript, our engine is Java — so we built a Node relayer sidecar and a clean HTTP gateway, with fail-safe behavior so an outage can never silently authorize a kill or hand out a win.
  • Redaction leaks. Making sure a role never leaked — even placeholder roles in the lobby, even through chat channels — required a single, tested source of truth for who can see and post what.
  • Keeping NPC AI honest. An LLM that hallucinates facts would break deduction, so we constrained it to witnessed observations and made answers deterministic.

Accomplishments that we're proud of

  • A genuinely trustless social-deduction game — the host literally cannot cheat.
  • A clean, swappable confidentiality seam: the same game runs against an in-process mock or real Midnight zk-circuits with zero game-logic changes.
  • End-to-end it actually works: room-code multiplayer, live map, confidential referee, and a full test suite (unit + Spring integration + an HTTP e2e) all green.
  • It looks and feels like a real game — animated PixiJS city, cinematic overlays, and NPCs you can interrogate.

What we learned

  • How to model confidential state with commitments and selective disclosure — reveal a single faction bit, never the role.
  • Practical hybrid Web3 architecture: keep real-time gameplay off-chain and fast, put only the trust-critical state on-chain.
  • Zero-knowledge isn't just for finance — it's a powerful primitive for hidden-information games and any app where privacy is the product.

What's next for Veil Protocol

  • Deploy the confidential layer to Midnight Preprod/testnet (relayer wired to live zk-circuits) and show contracts on the block explorer.
  • Optional player-held wallets for a fully self-custodial mode alongside the relayer.
  • More roles, bigger cities, spectator mode, and a public leaderboard with on-chain match attestations.
  • Harden and open-source the ConfidentialGateway pattern so other devs can build their own confidential multiplayer games on Midnight.

Built With

Share this project:

Updates