A fully homomorphic encryption (FHE) implementation of Rock Paper Scissors using CoFHE and Scaffold-ETH 2.
This project demonstrates how to build a privacy-preserving Rock Paper Scissors game using Fully Homomorphic Encryption (FHE) on the Fhenix blockchain. Players' choices remain encrypted throughout the game, ensuring complete privacy.
- 🔐 End-to-End Encryption: Player choices are encrypted using FHE
- 🎮 Real-Time Gameplay: Interactive UI for creating and joining games
- 💰 ETH Betting: Support for betting with ETH
- 🔍 Transparent Results: Clear display of game outcomes while maintaining privacy
- 🛠 Built with CoFHE: Leverages Fhenix's CoFHE for on-chain FHE computation
- Smart Contracts: Solidity 0.8.25 with CoFHE
- Frontend: Next.js, React, TailwindCSS
- Blockchain: Fhenix (Sepolia & Arbitrum Sepolia)
- Development: Hardhat, TypeScript
- Web3: Wagmi, Viem
- Node.js (>= v20.18.3)
- Yarn
- Git
- Clone the repository:
git clone https://github.com/FhenixProtocol/rps-cofhe-scaffold-example.git
cd rps-cofhe-scaffold-example
- Install dependencies:
yarn install
- Start a local network:
yarn chain
- Deploy the contract:
yarn deploy
- Start the frontend:
yarn start
Visit http://localhost:3000
to start playing!
- Game Creation: Players can create a new game by specifying a bet amount
- Joining Games: Other players can join existing games by matching the bet amount
- Making Moves: Players submit their choices (Rock, Paper, or Scissors) which are encrypted using FHE
- Revealing Results: Once both players have submitted their moves, the game creator can reveal the winner
- Prize Distribution: Winners receive the prize pool (2x bet amount)
- Smart contracts are in
packages/hardhat/contracts
- Frontend components are in
packages/nextjs/app
- Tests are in
packages/hardhat/test
This project is licensed under the MIT License - see the LICENSE file for details.