Skip to content

Repository files navigation

πŸ” Privia - Secure Encrypted Meetings

Privacy-first meetings powered by Zama's Fully Homomorphic Encryption on Ethereum

Privia is a decentralized meeting platform that ensures complete privacy through blockchain and Zama FHE technology. Host instant or scheduled meetings with end-to-end encrypted messages that remain private even on the blockchain.

Built with Zama FHE Ethereum Sepolia License: MIT TypeScript

Created by @altbright_

✨ Features

Meeting Management

  • ⚑ Instant Meetings - Create and join meetings immediately
  • πŸ“… Scheduled Meetings - Plan meetings for future dates/times
  • πŸ” Encrypted Chat - All messages encrypted with FHE
  • πŸ‘₯ Participant Management - Approve/reject join requests
  • 🎯 Meeting Types - Public or Private modes

Chat Features

  • πŸ’¬ Real-time Messaging - Send and receive encrypted messages
  • πŸ” Message Search - Search through chat history
  • πŸ”“ Bulk Decryption - Decrypt all messages at once
  • πŸ‘€ Participant List - See who's in the meeting
  • πŸ“Š Progress Tracking - Visual progress bars for encryption/decryption
  • ❓ In-app Guide - Comprehensive help modal

Host Controls

  • 🎀 Co-host Support - Assign additional meeting moderators
  • ⏰ Start/End Meetings - Full control over meeting lifecycle
  • βœ‹ Waiting Room - Review and approve pending participants
  • πŸšͺ Access Control - Manage who can join your meetings
  • πŸ“Š Meeting Stats - View participant and message counts

Privacy & Security

  • πŸ”’ FHE Encryption - Messages encrypted using Fully Homomorphic Encryption
  • 🎯 Access Control - Only meeting participants can decrypt messages
  • 🌐 Blockchain Storage - Immutable and tamper-proof on Ethereum
  • πŸ›‘οΈ Decentralized - No central server storing your data
  • πŸ”‘ Wallet-based Auth - Secure authentication via Web3 wallets

πŸš€ Quick Start

# Install dependencies
npm install && cd frontend && npm install && cd ..

# Deploy contract
npx hardhat run scripts/deploySecureChat.js --network sepolia

# Configure frontend
cd frontend
cp .env.example .env
# Add your contract address to .env: VITE_SECURECHAT_CONTRACT_ADDRESS=0x...

# Run frontend
npm run dev

πŸ“– How It Works

Creating a Meeting:

  1. Connect Wallet β†’ Connect your Web3 wallet
  2. New Meeting β†’ Click "Start Meeting" for instant or "Schedule Meeting" for later
  3. Configure β†’ Choose meeting type (Public/Private) and approval settings
  4. Share ID β†’ Share the meeting ID with participants

Joining a Meeting:

  1. Get Meeting ID β†’ Receive meeting ID from host
  2. Join β†’ Enter meeting ID and click "Join Meeting"
  3. Wait for Approval β†’ If required, wait for host to approve
  4. Enter Meeting β†’ Start chatting once approved

During the Meeting:

  1. Send Messages β†’ Type and send encrypted messages
  2. Search β†’ Search through message history
  3. Manage Participants β†’ Host can approve/reject join requests
  4. Add Co-hosts β†’ Host can assign co-hosts for help managing
  5. End Meeting β†’ Host can end the meeting for everyone

πŸ—οΈ Tech Stack

  • Smart Contracts: Solidity 0.8.24 + Zama FHE
  • Frontend: React 18 + TypeScript + Vite
  • Web3: Wagmi + RainbowKit
  • Styling: TailwindCSS
  • Network: Ethereum Sepolia Testnet
  • Encryption: fhevmjs (Zama FHE library)

πŸ“± Contract Details

Contract: SecureChat.sol
Network: Sepolia Testnet
Features:

  • Instant and scheduled meetings
  • Encrypted message storage
  • Participant management
  • Co-host functionality
  • Waiting room with approval system

🎯 Meeting Types

  • 🌐 Public - Anyone can join instantly
  • πŸ”’ Private - Requires host approval to join

Note: All messages are encrypted with FHE regardless of meeting type

πŸ“Š Meeting Status

  • πŸ“… Scheduled - Meeting planned for future
  • βœ… Active - Meeting in progress
  • 🏁 Ended - Meeting completed
  • ❌ Cancelled - Meeting cancelled

πŸ’» Code Overview

Smart Contract Structure

// Core data structures
enum MeetingStatus { Scheduled, Active, Ended, Cancelled }
enum MeetingType { Public, Private }
enum ParticipantStatus { Pending, Approved, Rejected, Left }

struct Meeting {
    uint256 id;
    address host;
    string title;
    uint256 scheduledTime;     // 0 for instant meetings
    uint256 startedAt;
    uint256 endedAt;
    MeetingStatus status;
    MeetingType meetingType;
    bool requiresApproval;
    uint256 participantCount;
    uint256 messageCount;
}

struct Message {
    uint256 id;
    uint256 meetingId;
    address sender;
    uint256 timestamp;
    bool isActive;
    bool isRead;
    // encrypted content stored separately as euint32
}

struct Participant {
    address participantAddress;
    ParticipantStatus status;
    uint256 joinedAt;
    bool isCoHost;
    uint256 messagesRead;
}

// Key contract functions
function createInstantMeeting(string title, MeetingType type, bool requiresApproval) returns (uint256)
function scheduleMeeting(string title, uint256 scheduledTime, MeetingType type, bool requiresApproval) returns (uint256)
function joinMeeting(uint256 meetingId)
function approveParticipant(uint256 meetingId, address participant)
function sendMessage(uint256 meetingId, externalEuint128 encryptedContent, bytes proof) returns (uint256)
function endMeeting(uint256 meetingId)
function addCoHost(uint256 meetingId, address coHost)

FHE Encryption Flow

Client-side Encryption (TypeScript):

import { createInstance } from 'fhevmjs';

// Initialize FHE instance
const instance = await createInstance({ chainId, publicKey });

// Encrypt message
const messageValue = convertMessageToNumber(message);
const encrypted = await instance.encrypt128(messageValue);

// Send to contract
await contract.sendMessage(meetingId, encrypted.data, encrypted.proof);

Decryption (for participants):

// Get encrypted message from contract
const encryptedMsg = await contract.getEncryptedMessage(meetingId, messageId);

// Decrypt (only works if you're a participant)
const decrypted = await instance.decrypt(address, encryptedMsg);

Frontend Architecture

frontend/src/
β”œβ”€β”€ pages/
β”‚   β”œβ”€β”€ ChatHomePage.tsx          # Home page with meeting list
β”‚   β”œβ”€β”€ ScheduleMeetingPage.tsx   # Schedule future meetings
β”‚   β”œβ”€β”€ MeetingLobbyPage.tsx      # Pre-meeting lobby
β”‚   └── ActiveMeetingPage.tsx     # Active meeting with chat
β”œβ”€β”€ hooks/
β”‚   └── useSecureChat.ts          # Contract interaction hook
β”œβ”€β”€ components/
β”‚   └── ChainGuard.tsx            # Network validation
└── config/
    └── wagmi.ts                  # Web3 configuration

Key Pages:

  • ChatHomePage: Create/join meetings, view recent meetings
  • ScheduleMeetingPage: Schedule meetings with date/time picker
  • MeetingLobbyPage: Waiting room with participant list and join requests
  • ActiveMeetingPage: Chat interface with real-time messaging

useSecureChat Hook Functions:

createInstantMeeting(title, type, requiresApproval)
scheduleMeeting(title, scheduledTime, type, requiresApproval)
joinMeeting(meetingId)
approveParticipant(meetingId, participant)
sendMessage(meetingId, message)
getMeeting(meetingId)
getParticipants(meetingId)
endMeeting(meetingId)

πŸš€ Deployment

1. Deploy Smart Contract

# Compile contract
npx hardhat compile

# Deploy to Sepolia
npx hardhat run scripts/deploySecureChat.js --network sepolia

# Copy the deployed contract address

2. Configure Frontend

cd frontend
cp .env.example .env

# Edit .env and add:
# VITE_SECURECHAT_CONTRACT_ADDRESS=0x...

3. Run Application

# Development
npm run dev

# Production build
npm run build
npm run preview

πŸ”§ Development

# Install dependencies
npm install
cd frontend && npm install && cd ..

# Run local Hardhat node
npx hardhat node

# Deploy to local network
npx hardhat run scripts/deploySecureChat.js --network localhost

# Run tests
npx hardhat test

🀝 Contributing

Contributions welcome! Feel free to submit a Pull Request.

πŸ“„ License

MIT License

πŸ“š Documentation

πŸ™ Acknowledgments

Built with Zama FHE, Hardhat, and RainbowKit

πŸ‘¨β€πŸ’» Creator

@altbright_ - Follow for updates and more projects


Built with ❀️ for private, secure communication

About

Privia is a decentralized meeting platform that ensures complete privacy through blockchain and Zama FHE technology. Host instant or scheduled meetings with end-to-end encrypted messages that remain private even on the blockchain.

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages