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.
VeriLaw consists of several interconnected components working together to provide secure legal document analysis:
- Frontend UI - Modern React-based web application with Echo authentication
- Chatbot Backend - WebSocket-based AI chat service using Anthropic Claude
- Main Backend - Flask API for document processing and attestation management
- TEE Service - Trusted execution environment for secure document analysis
- Database - Supabase for storing proofs and attestations
- 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
- Documents are processed in a secure enclave
- Original documents are automatically deleted after processing
- Cryptographic proofs ensure result integrity
- Zero-knowledge privacy guarantees
- 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
- Secure user authentication via Echo SDK
- Token-based access control
- Integrated with Merit Systems infrastructure
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
- Python 3.8+
- Node.js 18+
- Docker
- Git
Create .env files in the appropriate directories with the following 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_mnemonicANTHROPIC_API_KEY=your_anthropic_api_key-
Clone the repository
git clone <repository-url> cd a16z25-main
-
Set up the backend
cd lawthing/backend pip install -r requirements.txt python app/__init__.py -
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
-
Set up the chatbot backend
cd lawthing/frontend-ui/chatbot-backend pip install -r requirements.txt python main.py -
Set up the frontend
cd lawthing/frontend-ui/chatbot-frontend npm install npm run dev
- Document Upload: User uploads a PDF document via the web interface
- Encryption: Document is encrypted locally before transmission
- 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
- Attestation Generation:
- Cryptographic hashes are computed
- Attestation package is created and signed
- Proof is stored in Supabase
- Result Delivery: Analysis results and proof are returned to user
- Authentication: User logs in via Echo authentication system
- Session Management: WebSocket connection established for real-time chat
- Message Processing: User messages are processed by Anthropic Claude
- Response Generation: AI provides legal guidance and information
- Context Management: Conversation history maintained for continuity
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/{signature}
Response:
{
"doc_name": "document.pdf",
"doc_hash": "sha256_hash",
"result_hash": "sha256_hash",
"attestation": {...}
}GET /proof/{signature}/download
Response: JSON file downloadGET /proof/{signature}/verify
Response:
{
"package_signature_valid": true,
"tee_attestation_verified": true
}POST /verify
Content-Type: multipart/form-data
X-API-Key: your_api_key
Response:
{
"message": "Document verified successfully inside TEE",
"attestation": {...},
"compliance_summary": "..."
}-
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
-
Access the application:
- Frontend: http://localhost:5173
- Main API: http://localhost:5000
- TEE Service: http://localhost:8080
- Chat WebSocket: ws://localhost:8765
# Backend tests
cd lawthing/backend
python -m pytest tests/
# Frontend tests
cd lawthing/frontend-ui/chatbot-frontend
npm test-
Build TEE container:
cd lawthing/backend/eigen docker build -t verilaw-tee .
-
Deploy to EigenCloud:
eigenx auth generate --store eigenx app deploy username/verilaw-tee
- Set
EIGENCLOUD_MODE=livefor production - Use secure TEE secret keys
- Configure proper CORS settings
- Set up SSL/TLS certificates
- Configure database connection pooling
- Environment Variables: Never commit API keys or secrets to version control
- TEE Security: Use production-grade TEE environments for sensitive data
- Network Security: Implement proper firewall rules and access controls
- Data Retention: Configure automatic cleanup of temporary files
- Audit Logging: Implement comprehensive logging for compliance
- 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
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 for Python code
- Use TypeScript for frontend development
- Write comprehensive tests
- Update documentation for new features
- Follow semantic versioning
This project is licensed under the terms specified in the License file.
For support and questions:
- Create an issue in the GitHub repository
- Contact the development team
- Check the documentation wiki
- 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
- 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.
