🌟 Inspiration
Traditional online lotteries and web3 gaming mechanics suffer from a fundamental trust paradox: either players must expose their lucky numbers and ticket choices to a public ledger, or they have to trust a centralized operator managing a black-box database.
We deliberately grabbed this concept straight from the Official Midnight Startup Ideas list because it represents a massive, real-world product demand. Global gaming platforms are desperately looking for a way to prove absolute fairness without leaking user data or proprietary competitive strategies.
We built Confidential Lottery to answer that demand and prove that players don't have to choose between complete privacy and mathematical verifiability. By leveraging the Midnight Network's zero-knowledge paradigm, we designed a framework where ticket choices remain strictly private as client-side witnesses, while fair play, draws, and winning claims are completely auditable on-chain.
⚙️ What It Does
Confidential Lottery is a privacy-preserving gaming prototype built for the Midnight ecosystem. The application flow follows a secure, cryptographic lifecycle:
- Commit: A player selects a ticket number \( x \) (where \( 1 \le x \le 1000 \)). The application generates a cryptographically secure random private nonce \( r \) and hashes them locally to create a public commitment: $$C = \text{Hash}(x, r)$$
- Submit: The public commitment \( C \) is recorded along with metadata, while the private inputs never leave the user's domain.
- Draw: The operator triggers a live draw, revealing a winning number \( W \).
- Verifiable Claim: The winner generates a Zero-Knowledge proof demonstrating that their private ticket input matches the drawn number (\( x = W \)) using the commitment \( C \), without exposing losing numbers or uncovering player identity.
To maximize judge evaluation efficiency, the application includes a Judge Demo Mode that automates the generation of a pre-filled winning path (Draw number 905), a Proof Transparency Panel, and a Public Audit Timeline.
🛠️ How We Built It
We engineered a decoupled full-stack architecture designed to handle fast data indexing alongside zero-knowledge state mutation:
- Frontend (React, Vite, Tailwind CSS): Styled with a clean, Coinbase-inspired dark-mode rhythm. It interfaces directly with the Lace Wallet extension, utilizing the native
tNIGHT-to-tDUSTtransaction fuel mechanics to power the application layer. - Backend (FastAPI, SQLite): Serves as an efficient off-chain data store for public metadata tracking, receipt export parameters, and state orchestration.
- Privacy Layer (Midnight Paradigm): Modeled directly around Midnight's Compact language architecture, isolating private state (ticket inputs, nonces) from public ledger commitments.
🧠 Challenges We Faced
Navigating the cutting-edge dual-token model (tNIGHT and tDUST) and bridging decentralized state changes to a fast React frontend presented unique hurdles. Synchronizing wallet state logic and debugging initial network registration errors forced us to think deeply about decentralized state lifecycles.
We overcame this by integrating a robust mock-fallback engine within our Proof Transparency Panel so the system gracefully balances native Lace wallet interactions with seamless, uninterrupted client-side execution.
📚 What We Learned
This weekend was a massive leap forward in our understanding of cutting-edge cryptography. We dove headfirst into Zero-Knowledge (ZK) mechanics, mastering how to cleanly separate public ledger data from private witness variables.
Crucially, we learned the architecture of Compact, Midnight's smart contract language. Understanding how Compact compiles down into private circuits while simultaneously maintaining public state transitions on the ledger gave us a brand-new mental model for building decentralized applications (dApps). We walked away knowing exactly how to use Midnight and Lace to build highly capable consumer applications that process sensitive data without ever compromising personal digital privacy.
🔮 What's Next for Confidential Lottery
Our future roadmap directly mirrors Midnight's rollout phases:
- On-Chain Settlement: Migrating our off-chain backend architecture fully into native production Compact smart contracts deployed directly to the Midnight testnet.
- Decentralized Randomness: Replacing local operator drawing with a decentralized Verifiable Random Function (VRF) or cryptographic multi-party commit-reveal schemes.
- Multi-Chain SDK: Packaging this private-state framework into an open-source Web3 gaming SDK so developers across other networks can use Midnight to protect hidden game states (like poker hands or fog-of-war) without having to write low-level cryptography.
Log in or sign up for Devpost to join the conversation.