-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into earthquake-prediction
- Loading branch information
Showing
615 changed files
with
443,271 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
AES_KEY=l3zgy6WTqyBcU3RJXpu9Q0VOh5NA7CdXfRZFOiN/BRU= | ||
AES_IV=pGsfrdEGhs/cjaqp9JVhgQ== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# **EdgeLock-X** | ||
|
||
### 🎯 **Goal** | ||
|
||
The primary goal of **EdgeLock-X** is to address the security challenges of deploying machine learning models for face authentication in a browser context. The project ensures that the ML model is safeguarded from reverse engineering and tampering while maintaining efficiency in size and performance to deliver a smooth user experience. | ||
|
||
### 🧵 **Dataset** | ||
|
||
**EdgeLock-X** does not rely on a pre-existing dataset. Instead, it processes real-time facial data captured via the user's webcam. The system uses encrypted data to authenticate users while protecting the integrity of the model and data. | ||
|
||
### 🧾 **Description** | ||
|
||
**EdgeLock-X** provides a proof of concept for face authentication in a browser using **TensorFlow.js** and **FaceMesh**. The application securely handles facial data with AES-256 encryption and integrates **Trusted Execution Environment (TEE)** for protecting the ML model. Obfuscation techniques and snapshotting further optimize the model's size without compromising security. | ||
|
||
### 🧮 **What I Had Done!** | ||
|
||
- Implemented a **face detection feature** using **TensorFlow.js** and **FaceMesh** to capture real-time facial data from the user's webcam. | ||
- Integrated **AES-256 encryption** to ensure secure data transmission and storage. | ||
- Developed a **TEE-based model handling system**, leveraging **obfuscation** and **snapshotting** to protect the model from reverse engineering. | ||
- Set up **real-time face authentication**, providing feedback to users via the web interface. | ||
|
||
### 🚀 **Models Implemented** | ||
|
||
- **FaceMesh (TensorFlow.js)**: Used for real-time face detection in the browser. | ||
- **AES-256 Encryption**: Protects data both in transit and during authentication. | ||
- **TEE Integration**: Ensures secure decryption and execution of the ML model. | ||
|
||
### 📚 **Technologies, Libraries, and Tools** | ||
|
||
- **Frontend**: | ||
- HTML | ||
- JavaScript | ||
- TensorFlow.js | ||
- FaceMesh | ||
|
||
- **Backend**: | ||
- Flask | ||
- MongoDB (optional for data storage) | ||
|
||
- **Security**: | ||
- AES-256 Encryption | ||
- Trusted Execution Environment (TEE) | ||
- Obfuscation | ||
- Snapshotting | ||
|
||
### 📊 **Exploratory Data Analysis Results** | ||
|
||
Since **EdgeLock-X** deals with real-time input from users, traditional data analysis is not performed. However, the system provides real-time insights based on successful or failed face authentication attempts, ensuring the process is secure and efficient. | ||
|
||
### 📈 **Performance Metrics** | ||
|
||
The performance of the system is assessed through: | ||
- **Authentication accuracy**: How reliably the system detects and authenticates faces. | ||
- **Model security**: How effectively the obfuscation and TEE protect the model. | ||
- **User experience**: Minimal latency and load times, with seamless face detection and authentication. | ||
|
||
### 💻 **How to Run** | ||
|
||
To get started with **EdgeLock-X**, follow these steps: | ||
|
||
1. **Clone the repository**: | ||
|
||
```bash | ||
git clone <repository-url> | ||
cd <repository-name> | ||
``` | ||
|
||
2. **Install Python dependencies**: | ||
|
||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
|
||
3. **Configure environment variables**: | ||
|
||
Rename `.env-sample` to `.env` and add the required keys and settings. | ||
|
||
4. **Start the TEE server**: | ||
|
||
```bash | ||
python tee_server.py | ||
``` | ||
|
||
5. **Start the web server**: | ||
|
||
```bash | ||
python web_server.py | ||
``` | ||
|
||
6. **Access the application**: | ||
|
||
Open a web browser and navigate to `http://localhost:5000`. You will see the registration and login pages. | ||
|
||
7. **Test the application**: | ||
- **Register**: Enter a username and click "Register" to save the face image. | ||
- **Login**: Enter the username and click "Login" to authenticate with the captured face image. Successful login will redirect to the home page. | ||
|
||
### 📢 **Conclusion** | ||
|
||
**EdgeLock-X** is an innovative tool for implementing face authentication in a browser while safeguarding the underlying ML model. The system combines security techniques like TEE, encryption, and obfuscation to prevent reverse engineering and tampering, ensuring a secure and user-friendly authentication experience. | ||
|
||
### ✒️ **Signature** | ||
|
||
**[J B Mugundh]** | ||
GitHub: [Github](https://github.com/J-B-Mugundh) | ||
LinkedIn: [LinkedIn](https://www.linkedin.com/in/mugundhjb/) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from cryptography.hazmat.primitives.ciphers import algorithms | ||
from cryptography.hazmat.primitives import hashes | ||
from cryptography.hazmat.backends import default_backend | ||
import base64 | ||
import os | ||
|
||
# Generate a 256-bit (32-byte) AES key | ||
key = os.urandom(32) # AES-256 requires a 32-byte key | ||
iv = os.urandom(16) # AES block size is 16 bytes | ||
|
||
# Encode key and IV in Base64 for easy storage in .env | ||
key_b64 = base64.b64encode(key).decode('utf-8') | ||
iv_b64 = base64.b64encode(iv).decode('utf-8') | ||
|
||
# Print the results | ||
print(f'AES_KEY={key_b64}') | ||
print(f'AES_IV={iv_b64}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Flask | ||
cryptography | ||
python-dotenv | ||
requests | ||
pillow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
let model; | ||
|
||
// Initialize the camera for video feed | ||
async function initializeCamera() { | ||
const video = document.getElementById('video'); | ||
const stream = await navigator.mediaDevices.getUserMedia({ video: true }); | ||
video.srcObject = stream; | ||
} | ||
|
||
// Load the FaceMesh model (for client-side basic processing if needed) | ||
async function initializeModel() { | ||
model = await facemesh.load(); | ||
document.getElementById('status').textContent = 'Model loaded, ready for authentication...'; | ||
} | ||
|
||
// Capture an image from the video feed | ||
function captureImage() { | ||
const video = document.getElementById('video'); | ||
const canvas = document.getElementById('canvas'); | ||
const context = canvas.getContext('2d'); | ||
canvas.width = video.videoWidth; | ||
canvas.height = video.videoHeight; | ||
context.drawImage(video, 0, 0, canvas.width, canvas.height); | ||
return canvas.toDataURL('image/png'); | ||
} | ||
|
||
// Register a new user with the captured image | ||
async function register() { | ||
const username = document.getElementById('register-username').value; | ||
const image = captureImage(); | ||
|
||
const response = await fetch('/register', { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ username: username, data: image }) | ||
}); | ||
|
||
const result = await response.json(); | ||
document.getElementById('status').textContent = result.result || result.error; | ||
} | ||
|
||
// Login a user and authenticate their face | ||
async function login() { | ||
const username = document.getElementById('login-username').value; | ||
const image = captureImage(); | ||
|
||
const response = await fetch('/login', { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ username: username, data: image }) | ||
}); | ||
|
||
const result = await response.json(); | ||
document.getElementById('status').textContent = result.result || result.error; | ||
|
||
if (result.result) { | ||
// Redirect to a dummy home page after successful login | ||
setTimeout(() => { | ||
window.location.href = "/static/home.html"; | ||
}, 2000); | ||
} | ||
} | ||
|
||
// Toggle between register and login forms | ||
function toggleAuth() { | ||
const registerContainer = document.getElementById('register-container'); | ||
const loginContainer = document.getElementById('login-container'); | ||
|
||
if (registerContainer.classList.contains('auth-hidden')) { | ||
registerContainer.classList.remove('auth-hidden'); | ||
loginContainer.classList.add('auth-hidden'); | ||
} else { | ||
registerContainer.classList.add('auth-hidden'); | ||
loginContainer.classList.remove('auth-hidden'); | ||
} | ||
} | ||
|
||
// Initialize everything on page load | ||
initializeCamera(); | ||
initializeModel(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Welcome Home</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background: linear-gradient(135deg, #f06, #ff9a9e); | ||
margin: 0; | ||
height: 100vh; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
color: #fff; | ||
overflow: hidden; | ||
} | ||
|
||
.container { | ||
text-align: center; | ||
max-width: 600px; | ||
padding: 20px; | ||
background: rgba(0, 0, 0, 0.6); | ||
border-radius: 10px; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); | ||
} | ||
|
||
h1 { | ||
font-size: 3rem; | ||
margin: 0; | ||
opacity: 0; | ||
animation: fadeIn 2s forwards; | ||
animation-delay: 1s; | ||
} | ||
|
||
p { | ||
font-size: 1.2rem; | ||
margin: 20px 0; | ||
opacity: 0; | ||
animation: fadeIn 2s forwards; | ||
animation-delay: 2s; | ||
} | ||
|
||
button { | ||
padding: 10px 20px; | ||
font-size: 1rem; | ||
color: #fff; | ||
background-color: #007bff; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
transition: background-color 0.3s ease; | ||
opacity: 0; | ||
animation: fadeIn 2s forwards; | ||
animation-delay: 3s; | ||
} | ||
|
||
button:hover { | ||
background-color: #0056b3; | ||
} | ||
|
||
@keyframes fadeIn { | ||
from { | ||
opacity: 0; | ||
transform: translateY(20px); | ||
} | ||
to { | ||
opacity: 1; | ||
transform: translateY(0); | ||
} | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Welcome Home!</h1> | ||
<p>You have successfully logged in.</p> | ||
<button onclick="window.location.href='/'">Back to Login</button> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.