project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4

Dark Factory (ZKP)

Dark Factory combines the exploration of Dark Forest with the automation of Factorio. Players design layouts for islands to optimize resource production, leveraging blockchain and ZKP for privacy, security, and decentralized gameplay. Creativity and strategy are key!

Dark Factory (ZKP)

Created At

ETHGlobal Bangkok

Winner of

Blockscout - Blockscout Explorer Big Pool Prize

Prize Pool

Scroll - Innovate on Scroll 2nd place

Polygon - Best Zero-Knowledge Application on Polygon zkEVM 1st place

World - World Pool Prize

Prize Pool

Project Description

Dark Factory is a game that blends the strategic exploration of Dark Forest with the automation and resource management systems of Factorio. Unlike Dark Forest, which relies on random planetary data, Dark Factory empowers players to design and optimize island(planet) layouts, fostering creativity and strategic thinking.

Key innovations include:

  • Strategic Challenge: Design and manage resource-generating "islands" to maximize efficiency and rewards.
  • Privacy by ZKP in Blockchain: Leveraging zero-knowledge proofs (ZKP), the game ensures transparent, secure, and decentralized mechanics without exposing sensitive data.
  • Rewarding Creativity: Players are incentivized for thoughtful layouts and planning, creating a gameplay experience that's engaging and rewarding.

By merging the best of both worlds, Dark Factory introduces a unique, privacy-focused take on strategy and resource management games, filling a gap in the current gaming landscape.

Why This Challenge Is Difficult: Our team consists of experienced ZKP circuit engineers, yet the early stages of this project were fraught with challenges. We needed to design circuits capable of proving production rates and capacity while incorporating the game's strategic mechanism. For example:

  • All factories must be built adjacent to roads.
  • Only factories connected to ports via roads are considered valid.

This involved solving complex problems, such as transforming the variable-length road search into fixed-length verifiable constraints, and designing hint path for efficient verification in the circuit. We also had to balance the circuit size to maintain performance and user experience.

Through meticulous optimization, we managed to keep the circuit around 100k constraints, enabling proof generation in just a few seconds, even on mobile browsers. This achievement ensures Dark Factory is ready for mass adoption, combining cutting-edge technology with accessible gameplay.

How it's Made

Dark Factory combines cutting-edge technologies to deliver a seamless gaming experience powered by ZKP and blockchain integration. Here's a breakdown of the technology stack and the development process:

Technology Stack

  • Circom: Used to write ZKP circuits for game mechanics.
  • Circomlib: Provided essential building blocks for circuit development.
  • SnarkJS: Enabled in-browser ZKP proof generation for efficient client-side operations.
  • Vue.js/Quasar: The front-end framework powering the game's UI/UX.
  • Foundry: Development tools for creating and testing smart contracts.
  • Solidity: Programming language for implementing the main game logic as smart contracts.
  • Typechain: Generated contract interfaces for seamless integration between the front-end and blockchain.
  • Ethers.js: Facilitated blockchain interactions.

Development Workflow

  1. Circuit Development:

    • Circom was used to define the ZKP circuits, capturing key game constraints such as validating island layouts and production logic.
    • A Solidity verifier contract was generated from the compiled Circom code and integrated into the main contract, Game.sol.
  2. Smart Contract Integration:

    • The verifier and main contract were deployed on an EVM-compatible blockchain, allowing rapid prototyping and testing.
  3. Front-End and Proof Generation:

    • Circom output also produced a WASM file for generating proofs directly in the browser using SnarkJS.
    • The game's UI was developed with Vue.js/Quasar, incorporating a canvas-based system for intuitive layout design.
  4. Automation with Typechain:

    • Typechain streamlined contract interaction by generating interfaces directly used in the front-end, ensuring a smooth workflow.

*Unique Challenges and Notable Hacks

  • Constraint Logic Design:
    The most complex part of the project was encoding game logic into ZKP circuits. We invested significant effort in designing constraints on paper, exploring various methods to check and optimize constraints for efficiency.

  • Optimizing Performance:
    Achieving a balance between circuit size and execution efficiency was critical. We reduced constraints to under 100k, ensuring proof generation in seconds, even on mobile browsers, enhancing accessibility.

  • Canvas-Based Interaction:
    Directly manipulating the canvas for layout creation brought the game's strategy to life, providing an intuitive experience for players while ensuring the layout's compliance with constraints.

By leveraging EVM-compatible chains, we were able to iterate quickly, validating ideas and ensuring smooth integration of blockchain technology into gameplay. The result is a highly efficient and accessible system that bridges the gap between blockchain innovation and an engaging gaming experience.

background image mobile

Join the mailing list

Get the latest news and updates