Polaris is a complete zero-knowledge identity verification system built on Stellar blockchain. It enables privacy-preserving identity verification using ZK-SNARKs (Groth16) for documents like Aadhaar, PAN, Driving License, and Passport.

- 🔐 Zero-Knowledge Proofs - Verify identity without revealing sensitive data
- 📄 Multi-Document Support - Aadhaar, PAN, DL, Passport
- 🎨 Modern Frontend - Next.js 16 with Tailwind CSS & Radix UI
- 🐍 OCR Processing - Python server with EasyOCR for document scanning
- ⚡ Soroban Smart Contracts - Deployed on Stellar testnet
- 🔗 Freighter Wallet Integration - Seamless Stellar wallet connection
polaris/
├── circom/ # Circom compiler source
├── circuits/ # ZK circuits
│ ├── compiled/ # Built circuit files
│ ├── ptau/ # Powers of Tau
│ └── identity_verifier.circom
├── contracts/ # Soroban smart contracts
│ └── identity-verifier/
├── frontend/ # Next.js frontend
│ ├── app/ # App router pages
│ ├── components/ # UI components
│ └── lib/ # Utilities
├── python_server/ # OCR server
│ ├── app.py # Flask application
│ └── requirements.txt
├── scripts/ # Automation scripts
│ ├── compile-circuit.sh
│ ├── deploy-contract.sh
│ ├── test.cjs
│ └── test-second-doc.cjs
├── server/ # Node.js backend
│ └── server.js
├── package.json # Backend dependencies
└── .env # Configuration
| Task | Command |
|---|---|
| Compile Circuit | ./scripts/compile-circuit.sh |
| Deploy Contract | ./scripts/deploy-contract.sh |
| Start Backend | npm start |
| Start Python OCR | python python_server/app.py |
| Start Frontend | cd frontend && npm run dev |
| Test Flow | node scripts/test.cjs |
| Build Frontend | cd frontend && npm run build |
| Component | Port | URL |
|---|---|---|
| Backend API | 3000 | http://localhost:3000 |
| Frontend | 3001 | http://localhost:3001 |
| Python OCR | 5000 | http://localhost:5000 |
| File | Description | Size |
|---|---|---|
identity_verifier.circom |
Circuit source | ~5KB |
identity_verifier.r1cs |
Constraint system | ~200KB |
identity_verifier_final.zkey |
Proving key | ~5MB |
verification_key.json |
Verification key | ~1KB |
| Function | Description |
|---|---|
initialize |
Initialize contract (once) |
register_verified_identity |
Register identity with ZK proof |
get_user_doc_count |
Get user's document count |
check_verification |
Check if user is verified |
| Issue | Solution |
|---|---|
| Circuit compilation fails | Check circom version >= 2.1.0, install circomlib |
| Contract deploy fails | Check Stellar CLI installed, account funded |
| Server won't start | Check .env has ADMIN_SECRET and CONTRACT_ID |
| Proof generation slow | Normal, takes 5-15 seconds for first proof |
| Transaction timeout | Check RPC_URL and network accessibility |
| Payment required error | Provide userSecret for 2nd+ documents |
| OCR extraction fails | Check image quality, supported document types |
| Frontend build errors | Run npm install in frontend directory |
| Python dependencies fail | Use Python 3.10+, create virtual environment |
"circom: command not found"
cd circom && cargo install --path circom"stellar: command not found"
cargo install --locked stellar-cli --features opt"No such file or directory: circuit_final.zkey"
./scripts/compile-circuit.sh"Contract not initialized"
node scripts/initialize-contract.cjs"EasyOCR models not found"
- First run downloads models (~140MB automatically)
- Wait for download to complete
- Node.js v18+ installed
- Rust & Cargo installed
- Circom built from
circom/directory - snarkjs installed globally
- Stellar CLI installed
- Python 3.10+ installed
- Testnet account created & funded
- Root
npm installcompleted - Frontend
npm installcompleted - Python
pip install -r requirements.txtcompleted -
.envfile configured
- Circuit compiled (
circuit_final.zkeyexists) - Verification key exported
- Circuit tested and validated
- Contract built (WASM file exists)
- Contract deployed (CONTRACT_ID saved)
- Contract initialized
-
.envupdated with CONTRACT_ID
- Backend server running (port 3000)
- Python OCR server running (port 5000)
- Frontend dev server running (port 3001)
- All health checks passing
- First document test passed
- Second document test passed (payment)
- API endpoints tested
- OCR extraction tested
- Frontend UI tested
- Mainnet contract deployed
- PM2 configured
- Nginx reverse proxy configured
- SSL certificates installed
- Environment variables updated
- Monitoring enabled
- Backups configured
Your Polaris ZK Identity Verification System is fully operational!
✅ Zero-knowledge proof circuits (Circom + Groth16)
✅ Soroban smart contracts on Stellar
✅ Node.js backend API
✅ Python OCR server with EasyOCR
✅ Modern Next.js frontend
✅ Complete identity verification flow
- 🧪 Test with real documents
- 🎨 Customize frontend UI
- 📈 Add analytics & monitoring
- 🔐 Enhance security measures
- 🚀 Deploy to production
- Stellar Documentation
- Soroban Docs
- Circom Documentation
- snarkjs Guide
- Next.js Documentation
- EasyOCR Documentation
-
Multi-Country Support
- Add support for international documents (US SSN, UK Passport, EU ID)
- Localization for multiple languages
- Country-specific validation rules
-
Advanced ZK Features
- Range proofs (prove age is between 18-65 without exact DOB)
- Selective disclosure (choose which attributes to reveal)
- Recursive proofs for complex verifications
-
Mobile Applications
- React Native mobile app for iOS/Android
- QR code scanning for in-person verification
- Biometric authentication integration
-
Business Integration
- REST API with API keys for enterprise clients
- Webhooks for real-time verification notifications
- Bulk verification endpoints
- White-label solutions
-
Compliance & Auditing
- GDPR compliance tools
- Audit trail and logging
- Regulatory reporting dashboard
- Third-party security audits
-
Advanced OCR
- Support for more document types (voter ID, health cards)
- Video KYC (liveness detection)
- Document authenticity verification (holograms, watermarks)
-
DeFi Integration
- Age-gated DeFi protocols (18+ only pools)
- KYC-compliant DEX listings
- Credit scoring based on verified identity
-
Cross-Chain Support
- Bridge to Ethereum, Polygon, Solana
- Multi-chain identity portability
- Universal identity standard
-
DAO Governance
- Community voting on verification criteria
- Token-based governance model
- Decentralized dispute resolution
-
Privacy Enhancements
- Zero-knowledge machine learning models
- Homomorphic encryption for data processing
- Anonymous credentials (Idemix, U-Prove)
-
Decentralized Storage
- IPFS integration for encrypted document storage
- Filecoin for long-term archival
- User-controlled data vaults
-
AI/ML Integration
- Fraud detection using ML models
- Risk scoring and anomaly detection
- Automated document classification
-
Global Identity Network
- Interoperable identity verification across platforms
- Universal reputation system
- Decentralized identity standard (W3C DID)
-
Social Impact
- Financial inclusion for unbanked populations
- Portable identity for refugees
- Digital citizenship solutions
-
Research & Innovation
- Quantum-resistant cryptography
- New ZK-SNARK schemes (PLONK, STARKs)
- Academic partnerships and publications
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- 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
- 🔐 Zero-knowledge circuit optimization
- 🎨 Frontend UI/UX improvements
- 🐍 OCR accuracy enhancements
- 📱 Mobile app development
- 📚 Documentation and tutorials
- 🧪 Testing and quality assurance
This project is licensed under the MIT License - see the LICENSE file for details.
- Stellar Development Foundation - For Soroban smart contract platform
- iden3 - For Circom and snarkjs ZK-SNARK tools
- Hermez Network - For Powers of Tau ceremony files
- EasyOCR Community - For open-source OCR capabilities
- Vercel - For Next.js framework and hosting
-
Multi-Country Support
- Add support for international documents (US SSN, UK Passport, EU ID)
- Localization for multiple languages
- Country-specific validation rules
-
Advanced ZK Features
- Range proofs (prove age is between 18-65 without exact DOB)
- Selective disclosure (choose which attributes to reveal)
- Recursive proofs for complex verifications
-
Mobile Applications
- React Native mobile app for iOS/Android
- QR code scanning for in-person verification
- Biometric authentication integration
-
Business Integration
- REST API with API keys for enterprise clients
- Webhooks for real-time verification notifications
- Bulk verification endpoints
- White-label solutions
-
Compliance & Auditing
- GDPR compliance tools
- Audit trail and logging
- Regulatory reporting dashboard
- Third-party security audits
-
Advanced OCR
- Support for more document types (voter ID, health cards)
- Video KYC (liveness detection)
- Document authenticity verification (holograms, watermarks)
-
DeFi Integration
- Age-gated DeFi protocols (18+ only pools)
- KYC-compliant DEX listings
- Credit scoring based on verified identity
-
Cross-Chain Support
- Bridge to Ethereum, Polygon, Solana
- Multi-chain identity portability
- Universal identity standard
-
DAO Governance
- Community voting on verification criteria
- Token-based governance model
- Decentralized dispute resolution
-
Privacy Enhancements
- Zero-knowledge machine learning models
- Homomorphic encryption for data processing
- Anonymous credentials (Idemix, U-Prove)
-
Decentralized Storage
- IPFS integration for encrypted document storage
- Filecoin for long-term archival
- User-controlled data vaults
-
AI/ML Integration
- Fraud detection using ML models
- Risk scoring and anomaly detection
- Automated document classification
-
Global Identity Network
- Interoperable identity verification across platforms
- Universal reputation system
- Decentralized identity standard (W3C DID)
-
Social Impact
- Financial inclusion for unbanked populations
- Portable identity for refugees
- Digital citizenship solutions
-
Research & Innovation
- Quantum-resistant cryptography
- New ZK-SNARK schemes (PLONK, STARKs)
- Academic partnerships and publications
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- 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
- 🔐 Zero-knowledge circuit optimization
- 🎨 Frontend UI/UX improvements
- 🐍 OCR accuracy enhancements
- 📱 Mobile app development
- 📚 Documentation and tutorials
- 🧪 Testing and quality assurance
This project is licensed under the MIT License - see the LICENSE file for details.
- GitHub Issues: Report bugs or request features
- Discord: Join our community (Coming Soon)
- Twitter: @PolarisZK (Coming Soon)
- Email: support@polaris.dev (Coming Soon)
⭐ Star us on GitHub if you find this project useful!
- Prerequisites Installation
- Project Setup
- Circuit Compilation
- Contract Building & Deployment
- Contract Initialization
- Server Setup & Running
- Python OCR Server
- Frontend Development
- Testing the Flow
- Production Deployment
# Check current version
node --version
# If not installed or < v18:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejscurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
# Add WASM targets
rustup target add wasm32-unknown-unknown
# Verify installation
rustc --version
cargo --versioncd /home/shiv/Codes/blockchain/polaris/circom
# Build circom from source
cargo build --release
cargo install --path circom
# Verify installation
circom --version # Should show v2.1.x or highernpm install -g snarkjs
# Verify installation
snarkjs --version # Should show 0.7.x or highercargo install --locked stellar-cli --features opt
# Verify installation
stellar --version
# Configure testnet
stellar network add \
--global testnet \
--rpc-url https://soroban-testnet.stellar.org:443 \
--network-passphrase "Test SDF Network ; September 2015"# Check Python version
python3 --version
# Install if needed
sudo apt-get update
sudo apt-get install -y python3 python3-pip python3-venv# Generate keypair and save as 'admin'
stellar keys generate --global admin --network testnet
# Fund account with testnet XLM (friendbot)
stellar keys fund admin --network testnet
# Check balance (should have 10,000 XLM)
stellar keys address admin
# Copy this address, you'll need it!
# Get your secret key (KEEP THIS SECRET!)
stellar keys show admin
# View account details
stellar keys address admin | xargs -I {} curl "https://horizon-testnet.stellar.org/accounts/{}"cd /home/shiv/Codes/blockchain/polaris# Install Node.js dependencies (backend server)
npm installExpected packages:
- @stellar/stellar-sdk
- snarkjs
- circomlibjs
- express, cors, dotenv
- poseidon-lite
- And more...
cd frontend
npm install
# or use pnpm
pnpm install
cd ..# Copy example file (if exists) or create new
touch .env
# Edit the file
nano .envSet these values in .env:
# Admin credentials (from step 1.7)
ADMIN_SECRET=SXXX... # Your secret key from 'stellar keys show admin'
# Contract configuration (update after deployment)
CONTRACT_ID=CXXX... # Will be set in step 4
NETWORK=testnet
RPC_URL=https://soroban-testnet.stellar.org:443
# Server configuration
PORT=3000
NODE_ENV=developmentSave and close the file (Ctrl+X, Y, Enter).
The project includes a comprehensive script that handles all circuit compilation steps:
cd /home/shiv/Codes/blockchain/polaris
# Make script executable
chmod +x scripts/compile-circuit.sh
# Run the compilation script
./scripts/compile-circuit.shWhat the script does:
- ✅ Checks prerequisites (circom, snarkjs)
- 📦 Installs circomlib if needed
- 🔧 Compiles circuit to R1CS and WASM
- 📊 Generates circuit information
- ⬇️ Downloads Powers of Tau (or generates locally)
- 🔑 Generates Groth16 proving key
- 🔐 Performs trusted setup ceremony
- 📤 Exports verification key
- 📋 Generates Solidity verifier
Expected output:
=========================================
ZK Identity Verifier - Circuit Compilation
=========================================
✓ Prerequisites check passed
✓ circomlib ready
✓ Circuit compiled
✓ Circuit info generated
✓ Powers of Tau file ready
✓ Proving key generated
✓ Verification key exported
✓ Solidity verifier generated
=========================================
✅ COMPILATION COMPLETE
=========================================
If you prefer manual steps or need to debug:
cd circuits
# Download (if not present)
mkdir -p ptau
wget -O ptau/powersOfTau28_hez_final_12.ptau \
https://storage.googleapis.com/zkevm/ptau/powersOfTau28_hez_final_12.ptaucd /home/shiv/Codes/blockchain/polaris/circuits
# Compile circuit
circom identity_verifier.circom \
--r1cs \
--wasm \
--sym \
-l ../node_modules \
-o compiled
# Verify output files created
ls -lh compiled/identity_verifier.r1cs
ls -lh compiled/identity_verifier_js/cd compiled
# Setup
snarkjs groth16 setup \
identity_verifier.r1cs \
../ptau/powersOfTau28_hez_final_12.ptau \
identity_verifier_0000.zkey
# Contribute to ceremony
snarkjs zkey contribute \
identity_verifier_0000.zkey \
identity_verifier_final.zkey \
--name="First Contributor" \
-v \
-e="random entropy $(date +%s)"
# Export verification key
snarkjs zkey export verificationkey \
identity_verifier_final.zkey \
verification_key.json# Check constraint count
snarkjs r1cs info circuits/compiled/identity_verifier.r1cs
# Expected output:
# Curve: bn-128
# # of Wires: ~5234
# # of Constraints: ~4891
# # of Private Inputs: 11
# # of Public Inputs: 7
# # of Outputs: 3✅ Circuit compilation complete!
Generated files:
circuits/compiled/identity_verifier.r1cs- Constraint systemcircuits/compiled/identity_verifier_final.zkey- Proving key (~5MB)circuits/compiled/verification_key.json- Verification keycircuits/compiled/verifier.sol- Solidity verifier (optional)
The project includes a comprehensive deployment script that handles building, deploying, and initializing:
cd /home/shiv/Codes/blockchain/polaris
# Make script executable
chmod +x scripts/deploy-contract.sh
# Run the deployment script
./scripts/deploy-contract.shWhat the script does:
- ✅ Checks prerequisites (Stellar CLI, Node.js)
- 🔧 Builds the contract with optimization
- 🚀 Deploys to Stellar testnet/mainnet
- 💾 Updates
.envwith CONTRACT_ID - 📋 Generates deployment report (
deployment.json) - 🔐 Initializes the contract
- ✅ Verifies deployment
Expected output:
=========================================
Universal ZK Verifier Deployment
=========================================
✓ Using CLI: stellar
Building contract...
✓ Build complete
Optimizing WASM...
✓ Using optimized WASM
Deploying to testnet...
=========================================
✓ DEPLOYMENT SUCCESSFUL
=========================================
Contract ID: CA663VKXGRMCBQAKN26VNJPX5ZW7K73WDCVJQQLQCFXA7UKB2JXTNGH2
Updated .env with new CONTRACT_ID
Initializing contract...
🔧 Simulating initialization...
✅ Simulation successful
⏳ Transaction Sent
🎉 Contract Initialized Successfully!
cd contracts/identity-verifier
# Add WASM target
rustup target add wasm32-unknown-unknown
# Build in release mode
cargo build --target wasm32-unknown-unknown --release
# Verify WASM file
ls -lh target/wasm32-unknown-unknown/release/universal_verifier.wasm# Optimize WASM
stellar contract optimize \
--wasm target/wasm32-unknown-unknown/release/universal_verifier.wasmcd /home/shiv/Codes/blockchain/polaris
stellar contract deploy \
--wasm contracts/identity-verifier/target/wasm32-unknown-unknown/release/universal_verifier.wasm \
--source admin \
--network testnet
# Output: CA663VKXGRMCBQAKN26VNJPX5ZW7K73WDCVJQQLQCFXA7UKB2JXTNGH2# Edit .env file
nano .env
# Update this line:
CONTRACT_ID=<YOUR_CONTRACT_ID_FROM_DEPLOYMENT>✅ Contract deployed!
The contract must be initialized once before use. If you used the automated deployment script, this is already done!
cd /home/shiv/Codes/blockchain/polaris
# Run initialization script
node scripts/initialize-contract.cjsExpected output:
🔧 Initializing Contract...
Contract ID: CA663VKXGRMCBQAKN26VNJPX5ZW7K73WDCVJQQLQCFXA7UKB2JXTNGH2
Admin: GBRXNKUEVE66W35ZIUEM3JDFWYQFMIGZJJ7DGLQ2PZINMD3JM5SMJZGH
🧪 Simulating initialization...
✅ Simulation successful
⏳ Transaction Sent. Hash: <txn_hash>
Polling attempt 1/30 - Status: SUCCESS
🎉 Contract Initialized Successfully!
# Check if contract is initialized by calling a read function
stellar contract invoke \
--id <YOUR_CONTRACT_ID> \
--source admin \
--network testnet \
-- \
get_user_doc_count \
--user <YOUR_ADMIN_ADDRESS>
# Should return: 0✅ Contract initialized and ready!
cd /home/shiv/Codes/blockchain/polaris
# Check .env file has all required values
cat .env
# Required:
# - ADMIN_SECRET
# - CONTRACT_ID
# - NETWORK
# - RPC_URL
# - PORT# Production mode
npm start
# OR Development mode (auto-reload)
npm run devExpected output:
╔════════════════════════════════════════════════════════════╗
║ 🔐 ZK Identity Verification Server ║
╠════════════════════════════════════════════════════════════╣
║ Status: ✅ Running ║
║ Port: 3000 ║
║ Network: Stellar Testnet ║
║ Contract: CA663VKXGR... ║
║ RPC: https://soroban-testnet.stellar.org:443 ║
╠════════════════════════════════════════════════════════════╣
║ Endpoints: ║
║ • POST /api/register - Register identity ║
║ • GET /api/user/:address - Get user info ║
║ • GET /api/transaction/:hash - Get transaction ║
║ • POST /api/generate-proof - Generate proof only ║
║ • GET /api/health - Health check ║
╚════════════════════════════════════════════════════════════╝
# In a new terminal
curl http://localhost:3000/api/health
# Expected response:
# {"status":"ok","contractId":"CA663...","network":"testnet","timestamp":"..."}✅ Backend server running!
The Python server provides OCR (Optical Character Recognition) capabilities to extract identity data from document images.
cd /home/shiv/Codes/blockchain/polaris/python_server
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate # On Linux/Mac
# OR
venv\Scripts\activate # On Windows# Install required packages
pip install -r requirements.txtInstalled packages:
flask- Web frameworkflask-cors- Cross-origin supportpillow- Image processingnumpy- Numerical operationsopencv-python- Computer visioneasyocr- OCR engine (no Tesseract needed!)torch&torchvision- Deep learning backend
Note: First run will download EasyOCR models (~140MB). This happens automatically.
# Make sure virtual environment is activated
python app.pyExpected output:
🔥 Initializing OCR Engines...
📦 Loading EasyOCR (for ALL documents)...
✅ EasyOCR Ready!
🚀 Server ready - NO Tesseract required!
* Running on http://127.0.0.1:5000
* Debug mode: on
Supported Documents:
- ✅ Aadhaar Card (front/back)
- ✅ PAN Card
- ✅ Driving License
- ✅ Passport
Extracted Fields:
- Name
- Date of Birth (DOB)
- Gender
- Document ID/Number
API Endpoint:
POST http://localhost:5000/extract
Content-Type: multipart/form-data
# Body: image file# In a new terminal
curl -X POST http://localhost:5000/extract \
-F "image=@/path/to/document.jpg"
# Expected response:
{
"success": true,
"data": {
"name": "JOHN DOE",
"dob": {
"year": 1990,
"month": 5,
"day": 15
},
"gender": "Male",
"document_type": "aadhaar",
"document_id": "1234 5678 9012"
}
}Terminal 1 - Python OCR Server:
cd python_server
source venv/bin/activate
python app.py
# Runs on http://localhost:5000Terminal 2 - Node.js Backend:
cd /home/shiv/Codes/blockchain/polaris
npm start
# Runs on http://localhost:3000Terminal 3 - Frontend (optional, see next section):
cd frontend
npm run dev
# Runs on http://localhost:3001✅ Python OCR server running!
The frontend is a Next.js 16 application with modern UI components.
cd /home/shiv/Codes/blockchain/polaris/frontendnpm install
# or
pnpm installnpm run dev
# or
pnpm devExpected output:
▲ Next.js 16.0.10
- Local: http://localhost:3001
- Network: http://192.168.1.x:3001
✓ Ready in 2.5s
Open your browser and navigate to:
http://localhost:3001
Features:
- 🏠 Home page with features overview
- 📝 Register Identity (with document upload)
- 🔍 Lookup User verification status
- 🔗 Freighter wallet integration
- 📊 Dashboard (verify, lookup transactions)
# Build optimized production bundle
npm run build
# Start production server
npm startThe frontend connects to:
- Backend API:
http://localhost:3000/api - Python OCR:
http://localhost:5000/extract - Stellar Network: Testnet (via Freighter)
Update API URLs in frontend/lib/constants.ts if needed.
✅ Frontend running!
cd /home/shiv/Codes/blockchain/polaris
# Run test script
node scripts/test.cjsExpected output:
🚀 Starting Identity Verification for: GBRXNKUEVE...
💰 Native XLM Contract Address: CDLZFC3SYJY...
⚡ Generating ZK Proof...
✅ Proof verified off-chain.
🔗 Submitting to Soroban...
🧪 Simulating transaction...
✅ Simulation successful
⏳ Transaction Sent. Hash: <hash>
Polling attempt 1/30 - Status: SUCCESS
🎉 Transaction Successful!
🔎 Fetching result from ledger...
📜 On-Chain Record Found!
Doc count: 1
✅ Full Flow Complete!
# Run second document test
node scripts/test-second-doc.cjsExpected output:
🚀 Registering SECOND Document for: GBRXNKUEVE...
💡 This should trigger 30 XLM payment...
📊 Checking current document count...
Current doc count: 1
✅ User already has documents. Payment will be required.
⚡ Generating ZK Proof...
✅ Proof verified off-chain.
🔗 Submitting to Soroban...
🧪 Simulating transaction...
✅ Simulation successful
⏳ Transaction Sent. Hash: <hash>
Polling attempt 1/30 - Status: SUCCESS
🎉 Transaction Successful!
💰 30 XLM payment was processed
📊 Checking updated document count...
New doc count: 2
✅ Second Document Registration Complete!
curl http://localhost:3000/api/healthcurl http://localhost:3000/api/user/<YOUR_ADMIN_ADDRESS>Expected response:
{
"address": "GBRXNKUEVE...",
"verified": true,
"docCount": 2,
"commitmentHash": "17d0cfa2c6544...",
"timestamp": "1736611200"
}curl -X POST http://localhost:3000/api/register \
-H "Content-Type: application/json" \
-d '{
"userAddress": "GBRXNKUEVE66W35ZIUEM3JDFWYQFMIGZJJ7DGLQ2PZINMD3JM5SMJZGH",
"identityData": {
"name": "JANE SMITH",
"dob": {"year": 1990, "month": 3, "day": 20},
"gender": 2,
"docType": 1,
"docId": "AADHAAR123456",
"secretSalt": "random-salt-123"
}
}'curl -X POST http://localhost:3000/api/register \
-H "Content-Type: application/json" \
-d '{
"userAddress": "GBRXNKUEVE66W35ZIUEM3JDFWYQFMIGZJJ7DGLQ2PZINMD3JM5SMJZGH",
"userSecret": "SDFKQHNP76DELAWQLTF3GMPNKOXTV6POZO4YVI5OIYGQFKWMFWEIPRDZ",
"identityData": {
"name": "JANE SMITH",
"dob": {"year": 1990, "month": 3, "day": 20},
"gender": 2,
"docType": 2,
"docId": "PAN-XYZ789",
"secretSalt": "another-random-salt-456"
}
}'# Upload document image to Python server
curl -X POST http://localhost:5000/extract \
-F "image=@/path/to/aadhaar.jpg"
# Response will contain extracted data- Open browser:
http://localhost:3001 - Navigate to "Register Identity" tab
- Click "Upload Document" to use OCR (optional)
- Or manually fill the form:
- Address: Your Stellar address (or connect Freighter wallet)
- Secret Key: Leave blank for first doc, fill for 2nd+
- Name: JOHN DOE
- DOB: 1995-05-15
- Gender: Male
- Doc Type: PAN Card
- Doc ID: ABCDE1234F
- Secret Salt: random123
- Click "Register Identity"
- Wait for transaction (20-30 seconds)
- View success message with transaction hash
Test Lookup:
- Navigate to "Lookup User" tab
- Enter your address
- Click "Lookup User"
- See document count and commitment hash
✅ All tests passing!
# Add mainnet network
stellar network add \
--global mainnet \
--rpc-url https://soroban-mainnet.stellar.org:443 \
--network-passphrase "Public Global Stellar Network ; September 2015"
# Create mainnet account (use real funds!)
stellar keys generate --global mainnet-admin --network mainnet
# Fund with real XLM (use exchange or another wallet)cd /home/shiv/Codes/blockchain/polaris
# Update .env
echo "NETWORK=mainnet" >> .env
# Run deployment script
./scripts/deploy-contract.sh# Update .env with mainnet credentials
# - CONTRACT_ID (from deployment)
# - ADMIN_SECRET (mainnet admin secret)
# - NETWORK=mainnet
# - RPC_URL=https://soroban-mainnet.stellar.org:443
node scripts/initialize-contract.cjs# Install PM2
npm install -g pm2
# Start backend server with PM2
pm2 start server/server.js --name polaris-backend
# Configure auto-restart on system boot
pm2 startup
pm2 save
# View logs
pm2 logs polaris-backend
# Monitor
pm2 monitcd python_server
# Use production WSGI server (Gunicorn)
pip install gunicorn
# Start with PM2
pm2 start "gunicorn -w 4 -b 0.0.0.0:5000 app:app" --name polaris-ocr
# Or use systemd service
sudo nano /etc/systemd/system/polaris-ocr.serviceSystemd service file:
[Unit]
Description=Polaris OCR Server
After=network.target
[Service]
User=your-username
WorkingDirectory=/home/shiv/Codes/blockchain/polaris/python_server
Environment="PATH=/home/shiv/Codes/blockchain/polaris/python_server/venv/bin"
ExecStart=/home/shiv/Codes/blockchain/polaris/python_server/venv/bin/gunicorn -w 4 -b 0.0.0.0:5000 app:app
Restart=always
[Install]
WantedBy=multi-user.targetsudo systemctl enable polaris-ocr
sudo systemctl start polaris-ocrcd frontend
# Build for production
npm run build
# Start production server
pm2 start "npm start" --name polaris-frontend
# Or deploy to Vercel
npm install -g vercel
vercel --prod# Install nginx
sudo apt-get install -y nginx
# Create nginx config
sudo nano /etc/nginx/sites-available/polaris
# Add this configuration:# Backend API
server {
listen 80;
server_name api.polaris.example.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
# Python OCR Server
server {
listen 80;
server_name ocr.polaris.example.com;
client_max_body_size 10M;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
# Frontend
server {
listen 80;
server_name polaris.example.com;
location / {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}# Enable site
sudo ln -s /etc/nginx/sites-available/polaris /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx# Install certbot
sudo apt-get install -y certbot python3-certbot-nginx
# Get certificates for all domains
sudo certbot --nginx -d polaris.example.com
sudo certbot --nginx -d api.polaris.example.com
sudo certbot --nginx -d ocr.polaris.example.com
# Auto-renewal is set up automatically
# Test renewal
sudo certbot renew --dry-run# Production .env
NODE_ENV=production
PORT=3000
# Mainnet Configuration
NETWORK=mainnet
ADMIN_SECRET=<mainnet_secret>
CONTRACT_ID=<mainnet_contract_id>
RPC_URL=https://soroban-mainnet.stellar.org:443
# Security
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100
# CORS Origins (update with your domains)
ALLOWED_ORIGINS=https://polaris.example.com,https://api.polaris.example.com# View PM2 logs
pm2 logs polaris-backend --lines 100
pm2 logs polaris-ocr --lines 100
pm2 logs polaris-frontend --lines 100
# View nginx logs
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.log
# View application logs
tail -f logs/combined.log
tail -f logs/error.log
# Monitor system resources
pm2 monit# Backup critical files
mkdir -p backups
# Backup .env
cp .env backups/.env.backup
# Backup deployment info
cp deployment.json backups/deployment.json.backup
# Backup circuit keys
tar -czf backups/circuit-keys-$(date +%Y%m%d).tar.gz \
circuits/compiled/identity_verifier_final.zkey \
circuits/compiled/verification_key.json
# Backup to cloud (example)
# aws s3 sync backups/ s3://your-bucket/polaris-backups/