Mini Project Report
Mini Project Report
BELAGAVI, KARNATAKA-590018
MINI-PROJECT REPORT ON
“Q-SECURE”
Submitted in partial fulfilment of the requirements for the Mini Project (BCS586)
Course of the 5th semester.
BACHELOR OF ENGINEERING IN
COMPUTER SCIENCE AND ENGINEERING
CERTIFICATE
This is to certify that the Mini Project entitled “Q-Secure” is a benefited work carried out by
Shreyas Salankimatt, Soorya Kumar, Suraj Vittal, Varun Kudli bearing USN’s
1JS22CS147, 1JS22CS154, 1JS22CS164, 1JS22CS180 Bona fide student of JSS Academy of
Technical Education in the partial fulfilment for the award of the Bachelor of Engineering in
Computer Science & Engineering of the Visvesvaraya Technological University, Belgaum,
during the year 2024-25. It is certified that all corrections / suggestions indicated for Internal
Assessment have been incorporated in the report deposited in the departmental library. The mini
report has been approved as it satisfies the academic requirements in respect of mini project
work prescribed for the said degree.
We extend our highest gratitude to Dr. Sharana Basavana Gowda, our project guide. He showed
his consistent support for the whole duration of the project in terms of expert guidance and
valuable feedback throughout the project. His continuous encouragement and deep knowledge
helped Q-Secure Chat Application reach successful completion and successful development.
We thank Dr. Prabhudev Jagadeesh M P, Head of the department, for his support of such
projects and creating an environment that is just ideal to work on. Under his visionary
leadership, our department has encouraged growth in a very friendly atmosphere throughout
our project.
We would like to thank the faculty and staff of the Department of Computer Science and
Engineering at JSS Academy of Technical Education, Bengaluru, for their constant support
and co-operation during the course of this project.
We would especially like to thank JSS Academy of Technical Education, giving us a field to
think innovatively, inspiring creativity, and equipping students with the tools that help them
solve today's challenges through practical execution and research.
TABLE OF CONTENTS
ABSTRACT I
Chapter 1: Introduction 1
Chapter 5: Methodology 14
Chapter 8: Demonstration 31
Chapter 9: Conclusion 35
This mini-project presents a real-time chat application designed toward private communication
between users within a dynamic and interactive interface. The application allows for the
possibility of one-to-one messaging with instantaneous updates thereby allowing users to
participate without interruptions. The architecture deployed in the platform is based on flask
for the backend and bootstrap for the frontend with sockt.io being used on the platform for real-
time bidirectional communication.
This includes a profile tray, holding user information, a search tool to find and integrate new
contacts, and a user-friendly chat panel to exchange messages. Each user is also provided with
a personalized interface for chatting, which features the current conversations, most recent
messages, and when the last interaction occurred. Users can start new conversations by
searching for other users, and the app continues to refresh the chat history with the latest
messages as they are sent or received.
In summary, the project demonstrates some basic principles behind web development, such as
authentication of users, rendering dynamic data using Jinja templating, and real-time
communication over WebSockets, in order to set up an all-around framework for building an
essentially simple yet functional chat application.
I
INTRODUCTION
Real-time communication in the modern information age plays a critical role that helps bridge
the world from across different continents. On-the-spot chatting applications or software allow
instant messaging, making an indispensable tool for personal use as well as for professional
communication with clients or customers. Mini-project: Development of a real-time chat
application, aiming at seamless and efficient instant message exchange.
It is developed using the backend Flask framework, which involves all the server-side handling
and fosters communication between the clients. The frontend aspect of this system is created
with Bootstrap. Thus, it ensures to offer a modern and highly responsive interface. Realtime
messaging functionality is provided through an efficient Socket.IO library allowing
bidirectional communication between client and the server.
The application provides an intuitive interface through which users can set up accounts, start
discussions, and engage in one-on-one private exchanges. Functions such as the ability to
search for new users, track active conversations, and send live messages make the application
more interactive and usable. Additionally, the site includes features that allow user
authentication, profile management, and the ability to delete chat logs, ensuring that the users
have complete control over their data and privacy.
This project will focus on the core aspects of web application development such as the server-
side rendering of dynamic content using Jinja templating that enables real-time communication
and the secure management of user data. The target is to achieve a user-friendly and highly
scalable chat application that one day could be a base system for more advanced messaging
structures. In this mini-project, we are going to show how the web development aspects can be
put into practice as we engineer an interactive communication tool.
1
PROBLEM STATEMENT
Messaging apps have become an indispensable part of everyday life, whether for personal or
professional correspondence. However, most current-day messaging apps are plagued with
issues like restricted live interactions, a less-than-perfect interface for the users, or issues of
security with the user information and the privacy of messages. To make matters worse, there
are some chat applications that don't even provide choices to allow users to have all-rounded
control over their messages, privacy settings, and conversation history.
2
Limit administration of chat histories:
Many chatting websites lack facilities in managing the log of conversations.
Users have problems finding specific messages, deleting previous conversations, or
getting their chat records organized in an orderly manner. In some cases, the websites
do not provide an adequate mechanism for the management of chat logs, thus giving
rise to dissatisfaction among the users. The project provides users with an ordered and
managed conversation log because the tools available for the deletion, searching, and
reviewing previous messages are user-friendly. This ensures the user remains fully in
control of the chat logs and allows maintaining secrecy or organizing conversations
based on wishes.
3
instant messaging, interface enhancements, facilitation of provision of chat history
management tools, as well as significant security in the form of proper privacy.
By addressing these critical issues, this project seeks to create a messaging platform that
enhances the overall communication experience. From real-time messaging to intuitive UI
design, chat history management, and robust security features, this mini-project aims to
provide users with a seamless, secure, and user-friendly platform for messaging. It ensures a
smooth, uninterrupted communication experience while giving users full control over their
privacy and conversation history. Ultimately, this project seeks to offer a messaging solution
that not only meets but exceeds the expectations of modern-day users.
4
LITERATURE REVIEW
5
Nene, M. and Implemented the Shor's Used MATLAB for the Successfully
Upadhyay, G. Algorithm for quantum implementation; analysed demonstrated the
(2016) factoring; provided quantum factoring practical implementation
practical implementation approaches; and of Shor's Algorithm;
insights evaluated performance identified the limitations
metrics with increasing value of
N; provided the
implementation
framework
Christoph Development of a Design and Creation of a future-
Döberl, quantum-resistant, end-to- implementation of proof communication
Manuela Kos, end secure messaging and quantum-resistant framework capable of
Wolfgang email communication cryptographic protocols withstanding quantum
Eibner, Florian system. to secure communication, attacks, enhancing the
Kutschera, ensuring protection security of messaging
Simon Gärtner, against quantum and email systems.
Sebastian computing threats.
Ramacher
6
REQUIREMENTS SPECIFICATION
User Registration:
o Users must be able to register with a unique username and password.
o The password must be securely hashed using modern hashing algorithms (e.g.,
bcrypt).
o Input validation should ensure valid usernames (no spaces, no special
characters, and a minimum length).
User Login:
o Users must log in using their registered username and password.
o The system should provide feedback on incorrect login attempts.
o Session management with a token-based system (JWT or sessions) to keep users
logged in across page reloads.
Password Recovery:
o Users should be able to reset their passwords through email verification.
Two-Factor Authentication (2FA) (Optional but recommended):
o Additional security layer via a second factor (SMS, Google Authenticator, or
email).
7
4.1.2 Real-Time Messaging
Description: The application should facilitate seamless real-time communication between
users using Socket.IO.
Features:
8
Search Chat History:
o The application should include a search bar to allow users to search for specific
messages by keyword within a particular conversation.
o Search results should be highlighted and sorted by date and relevance.
Archiving:
o Users should be able to archive old conversations, removing them from the main
list but keeping them accessible for future reference.
Profile Picture:
o Users should be able to upload and change their profile picture.
o Profile pictures should be automatically resized and cropped to fit the UI.
Edit Username and Bio:
o Users should be able to edit their username (if allowed) and add a short bio.
Account Settings:
o Users should have the ability to manage privacy settings (e.g., who can message
them, who can see their profile).
9
o Option to log out from all sessions or a specific device.
Encryption Protocol:
o Messages should be encrypted on the sender’s device before transmission and
decrypted on the recipient’s device.
o Encryption should be implemented using secure algorithms (e.g., AES, RSA).
Encryption Toggle:
o Users should be able to enable or disable encryption for specific conversations
(based on user choice).
o The system should notify users if encryption is turned off.
Encrypted Storage:
o Encrypted messages should be stored in the database so that even in the case of
data breach, the messages remain unreadable without the decryption key.
Push Notifications:
o Push notifications should be sent to users when they receive a new message or
interaction (when the app is minimized or closed).
In-App Notifications:
o The app should display a notification badge for unread messages on the main
chat screen.
o The system should allow users to mark notifications as read.
10
4.2.1 Security
Description: The system must ensure the security and privacy of all data.
Features:
Data Encryption:
o End-to-end encryption for all messages.
o Secure transmission of data using SSL/TLS.
Authentication and Authorization:
o Only authenticated users should have access to their accounts.
o Role-based access control for users and admins.
Protection Against Attacks:
o Prevent common attacks like Cross-Site Scripting (XSS), SQL Injection,
Cross-Site Request Forgery (CSRF).
o Regular security audits to identify and fix vulnerabilities.
4.2.2 Performance
Description: The system must handle a high number of concurrent users without
compromising performance.
Features:
Real-Time Communication:
o Real-time messaging should have low latency (<1 second) under normal usage
conditions.
Scalability:
o The system should scale to accommodate 1000+ concurrent users without
performance degradation.
o The backend should handle rapid increases in user load (via horizontal scaling
and load balancing).
11
4.2.3 Usability
Description: The system must be user-friendly and easy to navigate.
Features:
Responsive UI:
o The application must be responsive and work across devices (mobile, tablets,
desktops).
Intuitive Design:
o Clear visual indicators for unread messages, typing status, etc.
o Easy-to-use settings for managing notifications, profile, and security.
Accessibility:
o The app should follow accessibility guidelines (e.g., WCAG) for users with
disabilities.
Uptime:
o The system should provide 99.9% uptime, ensuring that the app is available
nearly all the time.
Redundancy:
o Use of database and server redundancy to ensure availability in case of failures.
4.2.5 Compatibility
Description: The system should be compatible with a wide range of devices and browsers.
Features:
Cross-Browser Compatibility:
o The system must work seamlessly on modern browsers (Chrome, Firefox,
Safari, Edge).
Mobile Platform Compatibility:
o Native apps for Android and iOS (optional but recommended for better user
experience).
12
4.2.6 Maintainability
Description: The system must be easy to maintain, with clear code documentation and modular
architecture.
Features:
Modular Architecture:
o The application’s codebase should be modular, enabling easy updates and
feature additions.
Documentation:
o Detailed documentation for both the backend and frontend code.
o Documentation on how to deploy and maintain the system.
13
METHODOLOGY
5.1 Development Approach
The development of Q-Secure follows with an iterative and with an incremental development
approach, allowing for continuous refinement and the improvement of features. The
methodology has been structured into several key phases:
Frontend: Built using the Bootstrap framework for the responsive and the user-friendly
interface design.
Backend: Implemented using the Flask framework for handling the server-side
operations.
Database: Stores the user data, chat histories, and the encrypted messages.
WebSocket Server: Socket.IO implementation for the real-time bidirectional
communication.
1. Backend Technologies:
o Flask: Python web framework for server-side development
o SQL Alchemy: ORM for database operations
o Socket.IO: For real-time bidirectional communication
o Bcrypt: For password hashing and security
2. Frontend Technologies:
o Bootstrap: For responsive UI design
o JavaScript: For client-side functionality
o HTML5/CSS3: For structure and styling
o Socket.IO Client: For real-time updates
3. Security Implementation:
o JWT (JSON Web Tokens): For secure authentication
14
o End-to-end encryption: For message security
o SSL/TLS: For secure data transmission
1. Planning Phase:
o Requirements gathering and analysis
o System architecture design
o Database schema design
o UI/UX wireframing
2. Implementation Phase:
o Setting up development environment
o Database implementation
o Backend API development
o Frontend development
o Integration of real-time messaging
o Security implementation
3. Testing Phase:
o Unit testing of individual components
o Integration testing
o Security testing
o Performance testing
o User acceptance testing
15
Real-time Messaging System
1. Data Protection:
o End-to-end encryption of messages
o Secure storage of user credentials
o Protection against SQL injection and XSS attacks
2. Authentication Security:
o Multi-factor authentication
o Session management
o Password policies and validation
3. Communication Security:
o SSL/TLS encryption for data transmission
16
o WebSocket security
o API endpoint protection
1. Unit Testing:
o Testing individual components
o API endpoint testing
o Database operation testing
2. Integration Testing:
o Testing component interactions
o End-to-end testing of features
o Real-time communication testing
3. Security Testing:
o Penetration testing
o Vulnerability assessment
o Authentication testing
4. Performance Testing:
o Load testing
o Stress testing
o Response time testing
1. Environment Setup:
o Server configuration
o Database setup
o SSL certificate installation
2. Application Deployment:
o Code deployment
17
o Database migration
o Security configuration
3. Monitoring and Maintenance:
o Performance monitoring
o Error logging
o Regular security updates
18
ANALYSIS OF CLASSICAL RSA AND QUANTUM
FACTORIZATION IMPLEMENTATION
The RSA cryptosystem's security is based on the computational difficulty of factoring large
composite numbers. The system requires two distinct prime numbers and relies on modular
arithmetic properties for key generation and encryption/decryption operations.
19
This function employs optimization techniques:
Shor's algorithm provides a quantum approach to factoring large numbers exponentially faster
than classical methods. It utilizes quantum superposition and period finding through quantum
phase estimation.
probability_distribution = circuit()
return np.argmax(probability_distribution)
20
Hadamard gates for quantum superposition
Controlled modular exponentiation
Inverse Quantum Fourier Transform
Probability measurement
x1 = pow(a, int(r) // 2, N)
if x1 == N - 1 or x1 == 1:
return None
f1 = math.gcd(x1 - 1, N)
f2 = math.gcd(x1 + 1, N)
factors = [factor for factor in (f1, f2) if factor != 1 and factor != N]
The implementation includes both classical and quantum factorization methods to demonstrate
the theoretical quantum advantage:
21
def classical_factorization(N):
for i in range(2, int(np.sqrt(N)) + 1):
if(add_delay):
simulate_classical_delay(i)
if N % i == 0:
return [i, N // i]
return []
python
Copy
def simulate_classical_delay(iterations):
for i in range(iterations):
_ = sum(itertools.islice(itertools.count(), i))
time.sleep(0.001)
22
Security Considerations
1. Key Generation:
o Prime number size selection
o Coprime generation methodology
o Key pair validation
2. Quantum Resistance:
o Impact of quantum computing on RSA
o Scalability of quantum attacks
o Future security implications
o
Future Improvements
1. Security Enhancements:
o Stronger prime generation
o Additional validation checks
o Padding scheme implementation
2. Performance Optimizations:
o Quantum circuit optimization
o Parallel processing implementation
o Qubit requirement reduction
23
TECHNICAL ANALYSIS
2. Password Security
24
7.1.2 Real-Time Communication
1. Socket.IO Setup
2. Message Handling
@socketio.on("send_message")
def handle_send_message(data):
receiver_id = data["receiver_id"]
content = data["content"]
25
7.1.3 User Authentication System
class User(UserMixin):
def __init__(self, user_id, username, email):
self.id = user_id
self.username = username
self.email = email
def get_id(self):
return self.id
2. Authentication Management
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "login_page"
@login_manager.user_loader
def load_user(user_id):
user = cred_collection.find_one({"_id": ObjectId(user_id)})
if user:
return User(user["_id"], user["username"], user["email"])
return None
@app.route("/get_chat/<chat_partner_id>", methods=["GET"])
@login_required
def get_chat(chat_partner_id):
messages = db.messages.find({
"$or": [
{"sender_id": current_user.id, "receiver_id": ObjectId(chat_partner_id)},
{"sender_id": ObjectId(chat_partner_id), "receiver_id": current_user.id}
]
}).sort("timestamp", 1)
26
message_list = []
for msg in messages:
message_list.append({
"message_id": msg["message_id"],
"sender_id": str(msg["sender_id"]),
"receiver_id": str(msg["receiver_id"]),
"content": encryption.decrypt(msg["content"], new_key),
"timestamp": msg["timestamp"].strftime("%Y-%m-%d %H:%M:%S")
})
2. Chat Deletion
@app.route("/delete_chat/<username>", methods=["POST"])
@login_required
def delete_chat(username):
user = db.credentials.find_one({"username": username})
if user:
chat_partner_id = str(user["_id"])
db.messages.delete_many({
"$or": [
{"sender_id": current_user.id, "receiver_id": ObjectId(chat_partner_id)},
{"sender_id": ObjectId(chat_partner_id), "receiver_id": current_user.id}
]
})
@app.route("/forgot_password", methods=["POST"])
def handle_forgot_password():
data = request.get_json()
email = data.get("email")
user = cred_collection.find_one({"email": email})
if user:
token = jwt.encode({
"email": email,
"exp": datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(hours=1)
}, app.config["SECRET_KEY"])
27
reset_link = url_for('reset_password_page', token=token, _external=True)
msg = Message(
"Password Reset Request",
sender=os.getenv("MAIL_USERNAME"),
recipients=[email]
)
msg.body = f"Please click the link to reset your password: {reset_link}"
mail.send(msg)
The project implements a theoretical quantum-safe encryption system designed specifically for
an academic setting. The implementation focuses on demonstrating fundamental encryption
concepts while maintaining simplicity and theoretical quantum resistance.
Core Implementation
class QuantumSafeEncryption:
def __init__(self, key_length=256):
self.key_length = key_length
def generate_key(self):
"""Generate a random key for encryption."""
return "".join(
random.choices(string.ascii_letters + string.digits, k=self.key_length)
)
28
raise ValueError(f"Key length must be {self.key_length}")
# Simple XOR encryption
encrypted_message = [
chr(ord(char) ^ ord(key[i % len(key)]))
for i, char in enumerate(plaintext)
]
encrypted_str = "".join(encrypted_message)
return base64.b64encode(encrypted_str.encode()).decode()
Key Features
Design Rationale
1. Academic Focus
o Designed for educational purposes
o Demonstrates fundamental encryption concepts
o Balances simplicity with security features
2. Quantum Safety Considerations
o Theoretical resistance to quantum computing attacks
o Based on OTP principles
o Uses random key generation
3. Implementation Advantages
29
o Simple and easy to understand
o Efficient implementation
o Suitable for demonstration purposes
o Clear encryption/decryption process
Technical Limitations
1. Key Management
o Fixed key length of 256 bits
o Limited to alphanumeric characters
o Requires secure key storage and transmission
2. Security Constraints
o XOR operation may not be optimal for large messages
o Simplified implementation for academic purposes
o Theoretical quantum safety
3. Practical Considerations
o Not recommended for production environments
o Designed for educational demonstration
o Limited cryptographic strength compared to industry standards
Implementation Process
1. Key Generation
o Random generation of 256-bit keys
o Uses Python's random module
o Alphanumeric character set
2. Encryption Process
o Message validation
o XOR operation with key
o Base64 encoding of result
3. Decryption Process
o Base64 decoding
o XOR operation with original key
o Message reconstructio
30
DEMONSTRATION
2. Login Page: A standard login form with fields for username and password, plus links
to register for new users or recover forgotten passwords.
31
3. Registration Page: A signup form with fields for username, email, and password, with
an option to login for existing users.
5. Empty Chat Interface: Shows the initial state of the chat application when a user has
no conversations yet, with a "Start a conversation!" prompt.
32
6. Active Chat (1): Shows a chat between two users, with "varun" initiating a
conversation with "hey" and timestamps visible.
7. Active Chat (2): Displays a conversation between users, including messages like "hi!
how are you?" and discussions about weekend plans.
8. User Search: Shows a search interface listing usernames beginning with certain letters,
including "shreyas23" and "shreyas1234".
33
9. Chat Options Menu: Displays a dropdown menu in a chat window with options
including "Delete Chat for Both Users" and "Encryption Technique Used".
10. Message Data: Shows technical backend data of messages including message IDs,
sender/receiver IDs, content (which appears to be encrypted), and timestamps.
11. User Database: Displays user account information including usernames, email
addresses, and hashed passwords using pbkdf2 with SHA-256 for several users.
34
CONCLUSION
The Q-Secure project represents a significant advancement in secure messaging applications,
successfully combining modern security protocols with user-friendly design principles. This
implementation demonstrates the feasibility of creating practical, quantum-resistant
communication systems while maintaining an intuitive user experience.
1. Key Achievements
Security Implementation
Technical Innovation
User Experience
35
Efficient user search and contact management capabilities
Seamless message synchronization across sessions
System Architecture
The project's architecture has been designed with several key considerations:
Future Implications
The success of the Q-Secure project has several important implications for the future of secure
communications:
Final Assessment
The Q-Secure project successfully bridges the gap between theoretical security concepts and
practical application, creating a messaging platform that not only meets current security
standards but also anticipates future challenges in the quantum computing era. Through careful
attention to both security and usability, the project demonstrates how modern chat applications
can maintain high security standards while providing an intuitive user experience.
While the current implementation serves as a proof of concept, it provides a solid foundation
for future enhancements and features. The success of this project shows that secure, quantum-
36
resistant communication systems are not only theoretically possible but can be practically
implemented in user-friendly applications.
37
REFERENCES
1) An Efficient Quantum Computing technique for cracking RSA using Shor’s Algorithm
2) Leveraging the power of quantum computing for breaking RSA encryption
3) Cryptographic Attack Possibilities over RSA Algorithm through Classical and Quantum
Computation
4) Quantum-resistant End-to-End Secure Messaging and Email Communication
38