Skip to content

PraneethO/a16z25

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

VeriLaw - AI-Powered Legal Compliance Platform

VeriLaw is a cutting-edge legal technology platform that combines AI-powered document analysis with trusted execution environment (TEE) technology to provide secure, verifiable legal compliance checking. The platform leverages EigenCloud, Echo authentication, and cryptographic attestation to ensure document privacy and result integrity.

Demo Video

Watch the demo

๐Ÿ—๏ธ Architecture Overview

VeriLaw consists of several interconnected components working together to provide secure legal document analysis:

Core Components

  1. Frontend UI - Modern React-based web application with Echo authentication
  2. Chatbot Backend - WebSocket-based AI chat service using Anthropic Claude
  3. Main Backend - Flask API for document processing and attestation management
  4. TEE Service - Trusted execution environment for secure document analysis
  5. Database - Supabase for storing proofs and attestations

Technology Stack

  • Frontend: React 18, TypeScript, Tailwind CSS, Vite
  • Backend: Flask, Python 3.x
  • AI Services: Anthropic Claude, OpenAI GPT-4o-mini
  • Authentication: Echo SDK by Merit Systems
  • TEE Platform: EigenCloud
  • Database: Supabase
  • Containerization: Docker

๐Ÿ” Security & Privacy Features

Trusted Execution Environment (TEE)

  • Documents are processed in a secure enclave
  • Original documents are automatically deleted after processing
  • Cryptographic proofs ensure result integrity
  • Zero-knowledge privacy guarantees

Attestation System

  • Document Hash: SHA-256 hash of original document
  • Result Hash: SHA-256 hash of AI analysis result
  • Code Hash: SHA-256 hash of processing code
  • Timestamp: ISO timestamp of processing
  • Signature: HMAC-SHA256 signature for integrity verification

Echo Authentication

  • Secure user authentication via Echo SDK
  • Token-based access control
  • Integrated with Merit Systems infrastructure

๐Ÿ“ Project Structure

lawthing/
โ”œโ”€โ”€ backend/                    # Main Flask backend
โ”‚   โ”œโ”€โ”€ app/                   # Core application modules
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py       # Flask app initialization
โ”‚   โ”‚   โ”œโ”€โ”€ attestation.py    # Cryptographic attestation
โ”‚   โ”‚   โ”œโ”€โ”€ eigencloud_client.py # EigenCloud integration
โ”‚   โ”‚   โ”œโ”€โ”€ tee_service.py    # TEE processing service
โ”‚   โ”‚   โ””โ”€โ”€ utils.py          # Utility functions
โ”‚   โ”œโ”€โ”€ eigen/                # TEE container service
โ”‚   โ”‚   โ”œโ”€โ”€ Dockerfile        # Container configuration
โ”‚   โ”‚   โ”œโ”€โ”€ requirements.txt  # Python dependencies
โ”‚   โ”‚   โ””โ”€โ”€ src/
โ”‚   โ”‚       โ””โ”€โ”€ main.py       # TEE processing logic
โ”‚   โ”œโ”€โ”€ requirements.txt      # Backend dependencies
โ”‚   โ””โ”€โ”€ teeUtil.py           # TEE utility functions
โ”œโ”€โ”€ frontend-ui/              # React frontend application
โ”‚   โ”œโ”€โ”€ chatbot-backend/      # WebSocket chat service
โ”‚   โ”‚   โ”œโ”€โ”€ main.py          # Chat server implementation
โ”‚   โ”‚   โ”œโ”€โ”€ config.py        # Configuration settings
โ”‚   โ”‚   โ””โ”€โ”€ requirements.txt # Chat service dependencies
โ”‚   โ””โ”€โ”€ chatbot-frontend/     # React frontend
โ”‚       โ”œโ”€โ”€ src/             # Source code
โ”‚       โ”‚   โ”œโ”€โ”€ components/  # React components
โ”‚       โ”‚   โ”œโ”€โ”€ lib/         # Utility libraries
โ”‚       โ”‚   โ”œโ”€โ”€ App.tsx      # Main application
โ”‚       โ”‚   โ”œโ”€โ”€ ChatPage.tsx # Chat interface
โ”‚       โ”‚   โ””โ”€โ”€ AboutPage.tsx # Landing page
โ”‚       โ”œโ”€โ”€ package.json     # Frontend dependencies
โ”‚       โ””โ”€โ”€ vite.config.ts   # Vite configuration
โ”œโ”€โ”€ License                   # Project license
โ””โ”€โ”€ README.md               # This file

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.8+
  • Node.js 18+
  • Docker
  • Git

Environment Variables

Create .env files in the appropriate directories with the following variables:

Backend Environment Variables

# Supabase Configuration
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_key

# TEE Configuration
TEE_SECRET_KEY=your_tee_secret_key
ENCLAVE_ID=verilaw-enclave

# EigenCloud Configuration
EIGENCLOUD_API_BASE=your_eigencloud_url
EIGENCLOUD_JOB_ID=your_job_id
EIGENCLOUD_API_KEY=your_api_key
EIGENCLOUD_MODE=live  # or 'mock' for testing

# Ethereum Configuration (for TEE)
MNEMONIC=your_wallet_mnemonic

Chatbot Backend Environment Variables

ANTHROPIC_API_KEY=your_anthropic_api_key

Installation & Setup

  1. Clone the repository

    git clone <repository-url>
    cd a16z25-main
  2. Set up the backend

    cd lawthing/backend
    pip install -r requirements.txt
    python app/__init__.py
  3. Set up the TEE service

    cd lawthing/backend/eigen
    pip install -r requirements.txt
    # For Docker deployment:
    docker build -t verilaw-tee .
    docker run --env-file .env -p 8080:8080 verilaw-tee
  4. Set up the chatbot backend

    cd lawthing/frontend-ui/chatbot-backend
    pip install -r requirements.txt
    python main.py
  5. Set up the frontend

    cd lawthing/frontend-ui/chatbot-frontend
    npm install
    npm run dev

๐Ÿ”„ Workflow Process

Document Analysis Workflow

  1. Document Upload: User uploads a PDF document via the web interface
  2. Encryption: Document is encrypted locally before transmission
  3. TEE Processing:
    • Document is sent to EigenCloud TEE environment
    • Document is decrypted inside the secure enclave
    • Text is extracted from the PDF
    • AI analysis is performed using Echo router
    • Document is permanently deleted from TEE
  4. Attestation Generation:
    • Cryptographic hashes are computed
    • Attestation package is created and signed
    • Proof is stored in Supabase
  5. Result Delivery: Analysis results and proof are returned to user

Chat Workflow

  1. Authentication: User logs in via Echo authentication system
  2. Session Management: WebSocket connection established for real-time chat
  3. Message Processing: User messages are processed by Anthropic Claude
  4. Response Generation: AI provides legal guidance and information
  5. Context Management: Conversation history maintained for continuity

๐Ÿ“ก API Endpoints

Main Backend API

Upload Document

POST /upload
Content-Type: multipart/form-data

Response:
{
  "message": "Document analyzed in TEE",
  "proof_url": "/proof/{proof_id}",
  "download_url": "/proof/{proof_id}/download",
  "verify_url": "/proof/{proof_id}/verify",
  "proof": {...},
  "compliance_result": {...}
}

Get Proof

GET /proof/{signature}

Response:
{
  "doc_name": "document.pdf",
  "doc_hash": "sha256_hash",
  "result_hash": "sha256_hash",
  "attestation": {...}
}

Download Proof

GET /proof/{signature}/download

Response: JSON file download

Verify Proof

GET /proof/{signature}/verify

Response:
{
  "package_signature_valid": true,
  "tee_attestation_verified": true
}

TEE Service API

Verify Document

POST /verify
Content-Type: multipart/form-data
X-API-Key: your_api_key

Response:
{
  "message": "Document verified successfully inside TEE",
  "attestation": {...},
  "compliance_summary": "..."
}

๐Ÿ”ง Development

Running in Development Mode

  1. Start all services:

    # Terminal 1: Main backend
    cd lawthing/backend && python app/__init__.py
    
    # Terminal 2: TEE service
    cd lawthing/backend/eigen && python src/main.py
    
    # Terminal 3: Chatbot backend
    cd lawthing/frontend-ui/chatbot-backend && python main.py
    
    # Terminal 4: Frontend
    cd lawthing/frontend-ui/chatbot-frontend && npm run dev
  2. Access the application:

Testing

# Backend tests
cd lawthing/backend
python -m pytest tests/

# Frontend tests
cd lawthing/frontend-ui/chatbot-frontend
npm test

๐Ÿšข Deployment

Docker Deployment

  1. Build TEE container:

    cd lawthing/backend/eigen
    docker build -t verilaw-tee .
  2. Deploy to EigenCloud:

    eigenx auth generate --store
    eigenx app deploy username/verilaw-tee

Production Configuration

  • Set EIGENCLOUD_MODE=live for production
  • Use secure TEE secret keys
  • Configure proper CORS settings
  • Set up SSL/TLS certificates
  • Configure database connection pooling

๐Ÿ”’ Security Considerations

Best Practices

  1. Environment Variables: Never commit API keys or secrets to version control
  2. TEE Security: Use production-grade TEE environments for sensitive data
  3. Network Security: Implement proper firewall rules and access controls
  4. Data Retention: Configure automatic cleanup of temporary files
  5. Audit Logging: Implement comprehensive logging for compliance

Compliance Features

  • GDPR Compliance: Automatic data deletion after processing
  • SOC 2: Audit trail through cryptographic proofs
  • HIPAA Ready: Secure processing environment with attestation
  • Legal Hold: Immutable proof storage for legal proceedings

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 for Python code
  • Use TypeScript for frontend development
  • Write comprehensive tests
  • Update documentation for new features
  • Follow semantic versioning

๐Ÿ“„ License

This project is licensed under the terms specified in the License file.

๐Ÿ†˜ Support

For support and questions:

  • Create an issue in the GitHub repository
  • Contact the development team
  • Check the documentation wiki

๐Ÿ”ฎ Roadmap

Upcoming Features

  • Multi-language document support
  • Advanced legal reasoning capabilities
  • Integration with legal databases
  • Mobile application
  • API rate limiting and usage analytics
  • Enhanced audit and compliance reporting

Long-term Vision

  • Expand to cover additional legal domains
  • Integration with blockchain networks for immutable proof storage
  • Machine learning model fine-tuning for legal domains
  • Enterprise-grade deployment options

VeriLaw - Transforming legal document analysis through AI and cryptographic security.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors