Skip to content

arvd-a/Multi-Level-Secure-Authentication-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Multi-Level-Secure-Authentication-System

S1 POE project

The project is for a better aid for factors that need very effiecient and strong security

πŸ“œ Prabhāsa Mantra β€” A Dual-Channel, Multi-Factor Authentication System

High-Security Hardware + Software Authentication Platform

Prabhāsa Mantra is a custom multi-factor authentication system designed for high-security entry control. It combines:

  1. Facial Recognition (Laptop, Python + OpenCV)

  2. Cryptographic TOTP Mantra transmitted through:

    • Light channel (color flashes via phone screen)
    • Sound channel (high-frequency tones)

The authentication lock is implemented on an ESP32-S3 microcontroller, which receives the mantra via sensors, verifies its integrity, computes its own TOTP, and grants/denies access.

This repository contains all hardware, software, and protocol details required to fully build, flash, and run the system.


πŸ”’ Project Overview

The system uses two layers of authentication:

Factor 1 β€” Face Authentication (Laptop)

  • Python script using OpenCV (LBPH recognizer)
  • Runs continuously, scanning the camera feed
  • When an authorized face is detected β†’ sends LISTEN_FOR_MANTRA to the ESP32

Factor 2 β€” Mantra Authentication (ESP32-S3)

After receiving the signal:

  1. ESP32 activates:

    • TCS34725 Color Sensor
    • MAX9814 Microphone (FFT-based audio decoding)
  2. Waits for the user to transmit the Prabhāsa Mantra from the mobile app:

    • 6-digit TOTP (SHA-256, 30s window)
    • Transmitted first as color flashes, then as sound tones
  3. ESP32 decodes both sequences

  4. Validates:

    • Light == Sound consistency
    • Light == ESP32’s own internally generated TOTP

If valid β†’ sends ACCESS_GRANTED Otherwise β†’ sends ACCESS_DENIED


🧠 Technology Stack

Hardware

  • ESP32-S3 DevKitC-1
  • TCS34725 RGB Color Sensor
  • MAX9814 Microphone + Automatic Gain Control
  • USB-Serial connection to laptop

Software

  • Flutter App (Android/iOS)

    • Displays TOTP
    • Emits Light+Sound Mantra
  • Firebase

    • Authentication (email + password)
    • Firestore user profiles
  • ESP32 C++ Code (Arduino Framework)

    • TOTP (HMAC-SHA256 using mbedTLS)
    • FFT audio classification
    • TCS34725 color classification
    • Serial commands + state machine
  • Python Script (Laptop)

    • OpenCV LBPH face recognition
    • Serial communication with ESP32

πŸ”‘ Shared Secret & TOTP Specification

Base32 Secret Key:

GAXG2435ONV6Y3T7MFQZ227VMFQ4W4ZKWSKCA53KPOJ4NEYLTMZVKGIY=

TOTP Parameters

Parameter Value
Digits 6
Hash SHA-256
Step 30 seconds
Window Strict (0 tolerance)

πŸ“‘ Mantra Transmission Protocol

πŸ“ 1. Light Channel

6 color flashes, each:

  • 500 ms color
  • 200 ms black gap
Digit Color Hex
0 Red #FF0000
1 Green #00FF00
2 Blue #0000FF
3 Yellow #FFFF00
4 Magenta #FF00FF
5 Cyan #00FFFF
6 Orange #FFA500
7 Purple #800080
8 White #FFFFFF
9 Turquoise #40E0D0

πŸ”Š 2. Sound Channel

6 high-frequency tones, each:

  • 500 ms tone
  • 200 ms silence
Digit Frequency
0 12000 Hz
1 12500 Hz
2 13000 Hz
3 13500 Hz
4 14000 Hz
5 14500 Hz
6 15000 Hz
7 15500 Hz
8 16000 Hz
9 16500 Hz

🧩 Serial Protocol (Laptop ↔ ESP32)

Direction Message Meaning
ESP32 β†’ Laptop TIME_REQUEST ESP32 asks laptop for current epoch
Laptop β†’ ESP32 TIME_RESPONSE <epoch> Laptop sends UNIX time (sec)
Laptop β†’ ESP32 LISTEN_FOR_MANTRA Face recognized; begin mantra capture
ESP32 β†’ Laptop ACCESS_GRANTED Lock opens
ESP32 β†’ Laptop ACCESS_DENIED Lock stays closed

πŸ”Œ Hardware Wiring

TCS34725 β†’ ESP32-S3

TCS34725 Pin ESP32-S3 Pin
VIN 3.3V
GND GND
LED 3.3V
SDA GPIO 8
SCL GPIO 9

MAX9814 β†’ ESP32-S3

MAX9814 Pin ESP32-S3
VDD 3.3V
GND GND
OUT GPIO 4 (ADC1_CH3)

🧭 System Flowchart

      +-----------------+
      |    Laptop       |
      |  Face Detect    |
      +--------+--------+
               |
               | LISTEN_FOR_MANTRA
               |
      +--------v--------+
      |    ESP32        |
      |   State: LISTEN |
      +--------+--------+
               |
     -------------------------
     |                       |
 +---v---+             +-----v-----+
 | Light |             |  Sound    |
 | Decode|             |  Decode   |
 +---+---+             +-----+-----+
     |                       |
     -----------+------------
                 |
        +--------v--------+
        |  Compare codes  |
        +--------+--------+
                 |
          +------v------+
          |  Generate    |
          |    TOTP      |
          +------+-------+
                 |
      +----------v-----------+
      |   Access Granted?    |
      +----------+-----------+
                 |
     Yes ------------------- No
     |                       |
 ACCESS_GRANTED      ACCESS_DENIED

πŸ›  Build & Run Instructions

ESP32-S3 (Arduino IDE / PlatformIO)

  1. Install Espressif ESP32 Arduino Core

  2. Select board: ESP32S3 Dev Module

  3. Install libraries:

    • Adafruit_TCS34725
    • ArduinoFFT
  4. Wire hardware as shown above

  5. Flash main.cpp to the ESP32


Laptop (Python, Conda Environment)

Install dependencies:

conda install -c conda-forge opencv numpy
pip install pyserial opencv-contrib-python

Run the script:

python main.py

Place enrollment images:

/enroll
   face1.jpg
   face2.jpg

πŸ“± Flutter App

Features:

  • Firebase Login

  • Biometric Unlock

  • TOTP generation using above secret

  • β€œTRANSMIT” button to emit:

    • Light flashes (full-screen color)
    • Audio tones (Ultrasonic band)

πŸ§ͺ Testing Procedure

  1. Run Python script β†’ ensure β€œTIME_REQUEST” appears

  2. Bring face into camera β†’ wait for recognition

  3. When instructed, transmit mantra from phone:

    • Hold phone screen 1–5 cm from color sensor
    • Hold speaker close to MAX9814
  4. Check ACCESS_GRANTED / ACCESS_DENIED on laptop


πŸ›‘ Security Features

  • Two-factor authentication (biometric + cryptographic)
  • Offline, air-gapped transmission channels
  • TOTP SHA-256 with strict window consistency
  • Secret never transmitted over air or serial
  • Sound + Light redundancy to prevent spoofing
  • Laptop provides authoritative time sync

πŸ“‚ Repository Structure

/
β”œβ”€β”€ firmware/
β”‚   └── main.cpp                # ESP32-S3 Firmware
β”œβ”€β”€ laptop/
β”‚   └── main.py                 # Face recognition + serial control
β”œβ”€β”€ flutter_app/                # Mobile app source (if included)
β”œβ”€β”€ hardware/
β”‚   β”œβ”€β”€ wiring_diagram.png
β”‚   └── notes.md
└── README.md

🀝 Contributing

Contributions are welcome! Feel free to open:

  • Issues
  • Pull Requests
  • Feature suggestions

πŸ“„ License

About

S1 POE project

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors