Skip to content

samkv2/P2P

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

P2P Secure Chat Application πŸ”

A modern, privacy-focused Peer-to-Peer (P2P) secure messaging and file transfer application built in Java with end-to-end encryption.

πŸ“‹ Table of Contents


🎯 Overview

P2P is a hybrid peer-to-peer communication system designed to provide secure, decentralized messaging without relying on centralized servers to store user data or messages. Unlike traditional messaging platforms (WhatsApp, Telegram) that maintain metadata and message logs on central servers, P2P facilitates direct encrypted connections between users while using a lightweight Discovery Server solely for peer lookups.

Key Philosophy

  • Privacy First: No central authority stores your conversations
  • User Control: Direct peer-to-peer connections for all communications
  • Modern Design: Beautiful glassmorphic UI built with Java Swing
  • Secure by Default: End-to-end encryption on all messages and files

✨ Features

πŸ’¬ Messaging

  • Real-time text messaging between peers
  • End-to-end encrypted conversations using RSA-2048 and AES-256
  • Message notifications and delivery status
  • User presence tracking with online/offline status
  • Peer discovery without exposing sensitive information

πŸ“ File Transfer

  • Secure file sharing with robust protocol handling
  • Large file support with fragmentation and reassembly
  • Complex filename support with dynamic protocol adaptation
  • Progress tracking for file transfers
  • Integrity verification of transferred files

🎨 User Interface

  • Glassmorphic design for modern aesthetics
  • Responsive UI with smooth animations
  • Cute custom components (buttons, text fields, progress bars)
  • Chat bubble visualization for message display
  • File preview and management
  • Customizable theme support

πŸ” Security Features

  • RSA-2048 asymmetric encryption for key exchange
  • AES-256 symmetric encryption for message and file transfer
  • Hybrid cryptosystem for optimal security and performance
  • No message or file data passes through the central server
  • Session-based encryption with secure key management

πŸ—οΈ Architecture

Hybrid P2P Topology

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           Discovery Server (Central)                 β”‚
β”‚     (Peer Registration & Lookup Only)                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚                            β”‚
     β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”              β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
     β”‚  Peer A   │─────────────│  Peer B    β”‚
     β”‚ Direct P2Pβ”‚ Connection  β”‚ Direct P2P β”‚
     β”‚ (Encrypted)              (Encrypted) β”‚
     β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜              β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
          β”‚                            β”‚
     β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”
     β”‚  Messages & Files Transferred           β”‚
     β”‚  Directly Between Peers (E2E Encrypted)β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core Components

  1. DiscoveryServer - Central server for peer registration and lookup
  2. PeerNode - Individual peer client with networking capabilities
  3. SecurityUtils - Cryptographic operations (RSA/AES)
  4. MainFrame - Primary UI container
  5. Custom UI Components - Glassmorphic design elements

πŸ”’ Security

Cryptographic Implementation

Key Exchange (RSA-2048)

1. Peer A generates RSA key pair and shares public key
2. Peer B generates RSA key pair and shares public key
3. Both peers exchange AES session keys encrypted with RSA
4. RSA is used only for initial handshake (computationally expensive)

Message Encryption (AES-256)

1. After key exchange, all messages use AES-256 encryption
2. Fast symmetric encryption suitable for large data streams
3. Session-specific keys ensure conversation privacy

Security Guarantees

  • βœ… Confidentiality: Messages visible only to sender and recipient
  • βœ… Integrity: No message tampering without detection
  • βœ… Forward Secrecy: Session keys are ephemeral
  • βœ… No Server Access: Discovery server never sees encrypted content

πŸ“¦ Installation

Prerequisites

  • Java Development Kit (JDK) 11+
  • Apache Maven (optional, for building)
  • Git (for cloning the repository)

Build Instructions

On Linux/macOS:

chmod +x build.sh
./build.sh

On Windows:

build.bat

Manual Build:

javac -d bin -sourcepath src $(find src -name "*.java")

πŸš€ Usage

Starting the Discovery Server

java -cp bin p2p.net.DiscoveryServer

The server will start on port 8888 and wait for peer connections.

Starting Peer Nodes

java -cp bin p2p.App
  1. Enter your username when prompted
  2. The application will automatically:
    • Generate RSA key pair for secure communication
    • Register with the Discovery Server
    • Start listening for incoming peer connections
  3. Connect with other peers and start messaging

UI Guide

  • Peer List Panel: Shows available peers for connection
  • Chat Panel: Displays conversation with selected peer
  • Message Input: Type messages and press Send
  • File Transfer: Use file buttons to share documents
  • Status Indicators: Green = Online, Gray = Offline

πŸ“‚ Project Structure

p2pv0/
β”œβ”€β”€ README.md                    # This file
β”œβ”€β”€ P2P_Project_Case_Study.md   # Detailed technical documentation
β”œβ”€β”€ build.sh                     # Linux/macOS build script
β”œβ”€β”€ build.bat                    # Windows build script
β”œβ”€β”€ 1p2p.png                     # Application screenshot 1
β”œβ”€β”€ 2p2p.png                     # Application screenshot 2
└── src/
    └── p2p/
        β”œβ”€β”€ App.java             # Entry point & application launcher
        β”œβ”€β”€ TestRunner.java      # Unit tests & test cases
        β”œβ”€β”€ net/
        β”‚   β”œβ”€β”€ DiscoveryServer.java    # Central peer discovery service
        β”‚   └── PeerNode.java           # Individual peer implementation
        β”œβ”€β”€ security/
        β”‚   └── SecurityUtils.java      # Cryptographic utilities (RSA/AES)
        └── ui/
            β”œβ”€β”€ MainFrame.java          # Main application window
            β”œβ”€β”€ ChatBubblePanel.java    # Message bubble display
            β”œβ”€β”€ FileBubble.java         # File transfer visualization
            β”œβ”€β”€ Theme.java              # UI theme management
            β”œβ”€β”€ GlassPanel.java         # Glassmorphic effect panel
            β”œβ”€β”€ CuteButton.java         # Custom button component
            β”œβ”€β”€ CuteTextField.java      # Custom text input
            β”œβ”€β”€ CuteProgressBar.java    # Custom progress indicator
            └── CuteFileButton.java     # Custom file selector button

πŸ’» Technology Stack

Category Technology
Language Java 11+
Networking Socket Programming (TCP)
Encryption RSA-2048, AES-256
UI Framework Java Swing
Design Pattern Hybrid P2P Architecture
Concurrency Java Threads, ExecutorService
Data Format Base64 encoding for encrypted data

πŸ“Έ Screenshots

Screenshot 1: Main Chat Interface

P2P Chat Application - Main Interface

The application's main window showing the modern glassmorphic UI design with peer list and active chat.

Screenshot 2: File Transfer Interface

P2P Chat Application - File Transfer

File transfer interface demonstrating secure file sharing capabilities.


πŸ”„ Data Flow

Message Exchange Flow

User A Types Message
        ↓
Message Encrypted with AES-256
        ↓
Message Sent via Direct TCP Connection to Peer B
        ↓
Peer B Receives & Decrypts Message
        ↓
Message Displayed in Peer B's UI

File Transfer Flow

User Selects File
        ↓
File Split into Chunks
        ↓
Each Chunk Encrypted with AES-256
        ↓
Chunks Sent via Direct P2P Connection
        ↓
Recipient Receives & Reassembles Chunks
        ↓
File Decrypted & Saved Locally

🀝 Development Team

Project Authored by: Shivam Kumar

Team Members:

  • Tushar
  • Saurabh
  • Shreya

Built with open-source community ideas and contributions.


πŸ“ Contributing & Feature Requests

We welcome contributions and suggestions from the community! Whether you want to:

🎯 Add New Features

  • Enhanced peer discovery mechanisms
  • Voice/video calling capabilities
  • Group messaging support
  • Message history with local encryption
  • Mobile client support
  • Additional cryptographic algorithms
  • Performance optimizations

πŸ› Report Issues

  • Security vulnerabilities
  • UI/UX improvements
  • Performance bottlenecks
  • Documentation enhancements
  • Bug fixes and edge cases

πŸ“’ How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure your code follows the project's coding standards and includes appropriate tests.


πŸ™ Gratitude

We express our heartfelt gratitude to:

  • The Open Source Community for their invaluable tools, libraries, and inspiration
  • All Contributors who help improve this project through code, feedback, and ideas
  • Security Researchers who help us maintain the highest security standards
  • Early Adopters who test and provide feedback on the application
  • You for taking the time to explore this project!

Special Thanks

This project represents months of research, development, and refinement. It combines cryptographic theory, distributed systems design, and modern UI principles. We're proud to share it with the community and look forward to its evolution.


πŸ“„ License & Legal

This project is developed as part of an academic case study and open-source initiative. Please refer to the project's license file for usage terms.


πŸ“ž Support & Contact

For questions, suggestions, or collaboration opportunities:

  • Review the case study: Check P2P_Project_Case_Study.md for detailed technical documentation
  • Explore the code: Well-commented source files in src/ directory
  • Run tests: Execute TestRunner.java for validation

🌟 Future Scope

Planned Enhancements

  • Group messaging (n-to-n encrypted conversations)
  • Voice and video calling with WebRTC
  • Message history with local database encryption
  • Mobile client (Android/iOS)
  • GUI improvements and theme customization
  • Performance optimization for large file transfers
  • Advanced privacy features (message expiration, disappearing messages)
  • Network resilience improvements

⭐ Support

If you find this project helpful, please consider:

  • ⭐ Starring the repository
  • πŸ“’ Sharing with friends and colleagues
  • πŸ› Reporting issues and suggesting improvements
  • 🀝 Contributing code and enhancements

Thank you for being part of the P2P revolution! πŸš€

Last Updated: December 7, 2025


Welcome Message

We warmly welcome anyone who wants to suggest features, report bugs, or contribute to this project. Whether you're a cryptography expert, UI designer, networking specialist, or enthusiast with ideasβ€”we'd love to hear from you! Together, we can make P2P even more secure, efficient, and user-friendly. Join us in building the future of decentralized communication! πŸ”βœ¨

About

A peer to peer chatting application with secure encryption which also support secure file sharing options. The once connection is established between peers they can chat even after server is not in active state. Server is only needed to established connection between peers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors