Skip to content

erzawansyah/fhedback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

151 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” FHEdback - Confidential Survey Platform

A privacy-preserving survey platform built on Fully Homomorphic Encryption (FHE) that guarantees absolute privacy. Individual responses remain encrypted forever, while still enabling aggregate statistical analysis by survey creators.

License Solidity Live Demo


๐ŸŒŸ Overview

โŒ Traditional Survey Platform Problems

Traditional survey platforms pose significant privacy risks:

  • Unrestricted Access: Individual responses can be accessed by survey creators or third parties
  • Data Breach Risks: Data stored in plain text or simple encryption
  • Imperfect Anonymization: Individual data can still be linked back to respondents
  • Centralized Trust: Reliance on administrators to maintain privacy

โœ… The FHEdback Solution

FHEdback leverages Fully Homomorphic Encryption (FHE) from Zama to provide a revolutionary solution:

How FHE Works:

  • Responses are encrypted on the client-side before sending
  • Data remains encrypted at all times on the blockchain
  • Mathematical operations are performed directly on encrypted data
  • Aggregate results can be decrypted without accessing individual data

Result: Survey creators get accurate statistical insights without ever being able to view individual respondent answers.

๐ŸŽฏ FHEdback Advantages

  • ๐Ÿ”’ Absolute Privacy: Individual answers can never be accessed in plain text
  • ๐Ÿ›ก๏ธ High Security: Data is always end-to-end encrypted, reducing data breach risks
  • ๐Ÿ“Š Statistical Analysis: Supports various statistical operations on encrypted data (sum, average, min, max, frequency)
  • ๐ŸŒ Decentralization: Data stored on-chain, no single point of failure
  • ๐Ÿ” Transparency: Open source smart contracts enable independent audits
  • โšก Zero-Knowledge Proofs: Response validation without revealing actual values

๐Ÿ‘ฅ Who Needs FHEdback?

"Anyone who cares about their data privacy can leverage FHEdback to gather insights without compromising privacy."

  • Research Organizations: Sensitive surveys with guaranteed respondent privacy
  • Corporations: Employee feedback without risk of individual identification
  • Educational Institutions: Safe and private learning evaluations
  • Healthcare: Health surveys with HIPAA/GDPR compliance
  • Government: Public polling with guaranteed privacy

๐Ÿ”„ Survey Lifecycle

FHEdback Workflow

1. CREATE      โ†’  Survey creator defines questions and metadata
                  Survey contract deployed to blockchain
   โ†“
2. PUBLISH     โ†’  Survey published and accessible to respondents
                  FHE statistics initialized
   โ†“
3. RESPOND     โ†’  Respondents fill out survey
                  Answers encrypted with FHE on client-side
                  Encrypted data sent to blockchain
   โ†“
4. STORE       โ†’  Encrypted answers stored on-chain
                  Statistics updated homomorphically
   โ†“
5. CLOSE       โ†’  Survey closed after reaching target respondents
                  or manually closed by creator
   โ†“
6. ANALYZE     โ†’  Survey creator can access aggregate statistics
                  Decryption only for aggregates, not individuals

When Can Surveys Be Analyzed?

  • โœ… Survey reaches minimum number of respondents as predetermined
  • โœ… Survey creator manually closes the survey early
  • โŒ Individual answers can never be accessed in decrypted form

๐Ÿ”— Live Demo & Smart Contracts

๐ŸŒ Live Application

Frontend Demo:

Network: Sepolia Testnet (Chain ID: 11155111)

๐Ÿ“œ Smart Contracts (Sepolia)

Factory Contract - Main Entry Point

Address:  0x82C34294A1D9c8e38B43CE916D0C566416b1d7DC
Status:   โœ… Active
Network:  Sepolia Testnet
Purpose:  Factory to create new survey contracts
Explorer: https://eth-sepolia.blockscout.com/address/0x82C34294A1D9c8e38B43CE916D0C566416b1d7DC

Example Survey Contract

Address:  0x1d1eBa567d9797e344AEBed9e29b8966B7084960
Status:   โœ… Active Survey Instance
Explorer: https://eth-sepolia.blockscout.com/address/0x1d1eBa567d9797e344AEBed9e29b8966B7084960

๐Ÿ—๏ธ Contract Architecture

ConfidentialSurvey_Factory

  • Creates new ConfidentialSurvey instances for each survey
  • Each survey has a unique contract address
  • Factory records and manages all created surveys
  • Facilitates tracking and survey management

ConfidentialSurvey

  • Individual survey instance with FHE capabilities
  • Stores questions, metadata, and encrypted responses
  • Manages survey lifecycle (Created โ†’ Active โ†’ Closed)
  • Provides encrypted aggregate statistics

๐Ÿ“š Technical Documentation

For complete technical documentation, please review the README in each directory:

๐Ÿ“ Smart Contracts

contracts/README.md

  • Complete smart contract implementation
  • Survey creation management
  • Encrypted response storage
  • Data aggregation process with FHE
  • Testing & deployment guide

๐Ÿ“ Frontend Application

frontend/README.md

  • Web application source code
  • Survey creation and publication
  • Response submission interface
  • Aggregate results visualization
  • Setup & development guide

๐Ÿš€ Quick Start

For Users (Non-Technical)

  1. Access application: Visit fhedback.vercel.app
  2. Connect wallet: Connect your MetaMask or other wallet
  3. Create survey: Use the form builder to create a survey
  4. Share link: Share the survey link with respondents
  5. View results: Access dashboard to view aggregate statistics

For Developers

See complete documentation at:


๐Ÿ”ฎ Potential Development Areas

This section outlines potential enhancements and technical challenges identified during development. These represent areas of interest for future exploration, not committed roadmap items.

1. ๐Ÿ“ Multiple Question Types

Current State: Only supports rating scale questions (1-5)

Potential Additions:

  • Multiple choice (single selection)
  • Checkbox (multiple selections)
  • Yes/No questions
  • Text input (open-ended responses with FHE)
  • Ranking questions
  • Matrix/Grid questions

Challenge: Each question type requires different FHE encoding and aggregation methods.

2. ๐Ÿ’ฐ Incentive Mechanism

Concept: Token-based rewards from survey creators to respondents

Considerations:

  • Reward escrow during survey period
  • Automatic distribution upon submission
  • Support for ETH and ERC-20 tokens
  • Fair distribution for partial completions

3. ๐Ÿค– Bot Prevention

Challenge: If rewards are implemented, bot abuse becomes critical

Potential Approaches:

  • On-chain identity verification (WorldID, Proof of Humanity, Gitcoin Passport)
  • Minimal staking requirements
  • Rate limiting and cooldown periods
  • reCAPTCHA integration for high-value surveys
  • Balancing privacy with accountability

4. ๐Ÿ” Advanced Survey Discovery

Current State: Basic survey listing

Potential Features:

  • Filtering (category, status, rewards, completion rate)
  • Sorting (date, popularity, deadline)
  • Search functionality (title, tags, creator)
  • The Graph integration for efficient querying

5. ๐Ÿ“Š Demographic Analysis

Concept: Optional demographic profiling while maintaining privacy

Approach:

  • Encrypted demographic data (age, location, gender)
  • Selective disclosure by respondents
  • Aggregate-only analysis with k-anonymity
  • Example: "Average rating by age group"

6. ๐Ÿ“ˆ Advanced Statistics

Current State: Basic operations (sum, average, count)

Potential Operations:

  • Standard deviation and variance
  • Median and mode
  • Correlation between questions
  • Conditional statistics

Challenge: FHE computational complexity and gas costs increase significantly.

7. โš™๏ธ BeaconProxy Pattern

Issue: Reported to Zama Team

Problem: BeaconProxy implementation causes FHE decryption failures

Current Workaround: Using direct contract deployment

Impact if Resolved:

  • ~80% reduction in deployment gas costs
  • Ability to upgrade contracts without data migration
  • Standardized interface across all surveys

Status: Awaiting feedback from Zama team on fhEVM compatibility with proxy patterns


๐Ÿค Contributing

Contributions are very welcome! Please:

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/feature-name
  3. Commit changes: git commit -m "feat: description"
  4. Push to branch: git push origin feature/feature-name
  5. Open a Pull Request

๐Ÿ“„ License

This project uses MIT License.


๐Ÿ™ Acknowledgments


๐Ÿ“ž Contact & Social

Project Links:

Connect with the Developer:


Built with โค๏ธ using Zama's Fully Homomorphic Encryption