Skip to content

amiabix/flappy_bird

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flappy Bird ZisK

A proof generation system for Flappy Bird game scores using ZisK. This project generates proofs for game score's that can be verified without revealing the original game data.

image

What This System Does

This system lets you play Flappy Bird, submit your scores, and automatically generates proofs that verify your score's are real, Anyone can verify these proofs without seeing your actual gameplay.

Architecture

System Components

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   Frontend      │    │   Backend API   │    │   ZisK Engine   │
│   (React)       │◄──►│   (Flask)       │◄──►│   (Proof Gen)   │
└─────────────────┘    └─────────────────┘    └─────────────────┘

Port Configuration

  • Frontend: Port 5173 (React + Vite)
  • Backend API: Port 8000 (Flask)

Installation & Setup

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • Rust toolchain
  • ZisK installation

1. Clone the Repository

git clone <repository-url>
cd flappy_bird

2. Install Dependencies

Backend (Python)

pip install flask flask-cors

Frontend (React)

cd flappy-bird-game
npm install

ZisK (Rust)

cd flappy_zisk
cargo build --release

3. Configure ZisK: Before proceeding, ensure ZisK is installed by following the official installation guide, ZisK Installation Instructions

Running the System

1. Start the Backend API

python3 api_server.py

API Endpoints:

  • GET /api/health - System health check
  • GET /api/system-status - Check if system is ready for submissions
  • POST /api/submit-score - Submit a game score for proof generation
  • GET /api/proof-status/{job_id} - Check proof generation status
  • GET /api/leaderboard/{difficulty} - View leaderboard

2. Start the Frontend

cd flappy-bird-game
npm run dev

Access the game at: http://localhost:5173

3. Generate ZisK Proofs

# Manual proof generation
./generate_zk_proof_fixed.sh <score>

# Example: Generate proof for score 5
./generate_zk_proof_fixed.sh 5

How It Works

1. Score Submission

  1. User plays Flappy Bird and achieves a score
  2. Frontend submits score to backend API
  3. Backend validates score and creates proof generation job
  4. System checks if ZisK is available (global execution lock)

2. Proof Generation

  1. Input Generation: Create binary input file with score data
  2. ZisK Compilation: Compile Flappy Bird game with ZisK
  3. Execution: Run game in ZisK environment
  4. Proof Creation: Generate proof
  5. Verification: Verify proof integrity

3. System Flow

Game Score → API Validation → Job Creation → ZisK Processing → Proof Generation → Status Updates

API configuration

export FLASK_ENV=development export FLASK_DEBUG=1


### Customization Options
- **Timeouts**: Adjust timeout values in API server
- **Worker Count**: Change worker thread count
- **Deduplication Window**: Modify `DEDUP_WINDOW_SECONDS`

## API Reference

### Submit Score
```bash
POST /api/submit-score
Content-Type: application/json

{
  "player_id": "player_123",
  "score": 15,
  "difficulty": 1
}

Response Format

{
  "success": true,
  "job_id": "uuid-here",
  "message": "Score submitted successfully",
  "proof_status": "pending"
}

Contributing

Development Setup

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

Testing

# Test backend API
python3 -m pytest tests/

# Test frontend
cd flappy-bird-game
npm test

# Test ZisK integration
./generate_zk_proof_fixed.sh 5

Happy Gaming and Proof Generation with ZisK!

About

This version of the classic Flappy Bird game, combined with a proof system that verifies scores using the ZisK toolchain. The idea is simple: whenever you finish a game you generate a ZisK proof

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors