Flask-Based Age Verification Using Azure Form Recognizer

πŸ“Œ Overview

This project is a Flask-based API that verifies a user's age by extracting the Date of Birth (DOB) from an uploaded ID document using Azure Form Recognizer. It then generates a Zero-Knowledge Proof (ZKP) using SHA-256 hashing to confirm if the user is over 18 without revealing the actual DOB.

πŸš€ Features

  • πŸ“„ Extract DOB from ID documents using Azure Form Recognizer.
  • πŸ” Zero-Knowledge Proof (ZKP) to verify age without exposing full DOB.
  • πŸ–ΌοΈ Supports image-based ID document uploads.
  • 🌍 Built using Flask with Azure AI integration.

πŸ› οΈ Setup and Installation

1️⃣ Create a Conda Environment

conda create -n flask-azure-id python=3.9 -y
conda activate flask-azure-id

2️⃣ Install Dependencies

pip install flask azure-ai-formrecognizer azure-identity

3️⃣ Set Up Azure Form Recognizer

  1. Go to Azure Portal.
  2. Create an AI Document Intelligence (Form Recognizer) resource.
  3. Copy your Endpoint and Key from Keys and Endpoint.
  4. Update config.py or export environment variables: bash export FORM_RECOGNIZER_ENDPOINT="https://your-resource-name.cognitiveservices.azure.com/" export FORM_RECOGNIZER_KEY="your-secret-key"

4️⃣ Run the Flask Server

python app.py

The server should start at http://127.0.0.1:5000/.


πŸ”— API Endpoints

1️⃣ Verify Age from ID Document

Endpoint: /verify (POST)

Request:

curl -X POST -F "file=@sample_id.jpg" http://127.0.0.1:5000/verify

Response:

{
  "proof": "8b5d7e6b6f...", 
  "claim": "Over 18"
}

πŸ† Inspiration

The idea for this project came from the growing need for privacy-preserving age verification. Traditional systems expose users’ full date of birth, leading to unnecessary data exposure. The goal was to build a Zero-Knowledge Proof (ZKP) mechanism that allows users to prove their age without revealing personal details.

πŸ“š What I Learned

  • How to integrate Azure Form Recognizer for document data extraction.
  • Implementing Zero-Knowledge Proof (ZKP) using SHA-256 hashing.
  • Handling image uploads in a Flask API.
  • Working with Azure Identity authentication.

πŸ”¨ How I Built It

  1. Set up Flask for API handling.
  2. Integrated Azure Form Recognizer for DOB extraction.
  3. Developed a ZKP mechanism with SHA-256 hashing.
  4. Created API endpoints for document verification.
  5. Tested using cURL & Postman.

🚧 Challenges Faced

  • Azure Configuration Issues: Setting up the Form Recognizer API correctly took time.
  • Handling Various ID Formats: Some IDs had different field placements, making extraction inconsistent.
  • Optimizing the ZKP Mechanism: Ensuring proof generation remained efficient while being secure.

πŸ“œ License

This project is licensed under the MIT License.


πŸ™Œ Acknowledgments

  • Flask for the API framework.
  • Azure Form Recognizer for ID document processing.
  • SHA-256 for Zero-Knowledge Proof hashing.

Built With

Share this project:

Updates