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
- Go to Azure Portal.
- Create an AI Document Intelligence (Form Recognizer) resource.
- Copy your Endpoint and Key from Keys and Endpoint.
- Update
config.pyor 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
- Set up Flask for API handling.
- Integrated Azure Form Recognizer for DOB extraction.
- Developed a ZKP mechanism with SHA-256 hashing.
- Created API endpoints for document verification.
- 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.
Log in or sign up for Devpost to join the conversation.