Skip to content

coinsspor/greenID

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒฑ GreenID - Carbon Footprint Identity Passport

Track, verify, and prove your environmental commitment using Zero-Knowledge Proofs on Moca Network

GreenID Banner Status AIR Kit


๐ŸŽฏ What is GreenID?

GreenID is a decentralized identity system for environmental impact verification. Users can:

  • ๐Ÿ“Š Track carbon footprint: Annual COโ‚‚ emissions, renewable energy usage, travel impact
  • ๐Ÿ† Generate Green Scores: Algorithm-based environmental rating (0-100)
  • ๐Ÿ” Issue on-chain credentials: Verifiable proof stored on Moca Network blockchain
  • โœ… Verify with Zero-Knowledge Proofs: Prove compliance without exposing sensitive data

Real-world use case: Organizations can prove environmental commitments (e.g., "Our average Green Score > 70") to partners, investors, or regulators without revealing individual employee data.


๐Ÿš€ Live Demo

Demo credentials: Use AIR Kit login (no setup required)


โšก Key Features

1๏ธโƒฃ Carbon Tracking Dashboard

  • Input annual COโ‚‚ emissions (kg)
  • Track renewable energy usage (%)
  • Monitor travel-related emissions
  • Real-time Green Score calculation with visual indicators

2๏ธโƒฃ On-Chain Credentials (Powered by Moca Network)

  • Issue verifiable credentials via AIR Kit SDK
  • Immutable blockchain storage on Moca Network
  • Portable identity: Use credentials across platforms
  • No seed phrases: AIR Kit manages Abstract Accounts

3๏ธโƒฃ Zero-Knowledge Proof Verification

  • Privacy-first: Prove statements without revealing exact data
  • Example: Verify "Green Score > 70" without showing score = 86
  • Compliance checks: โœ… Compliant / โŒ Non-Compliant
  • On-chain verification: Trustless and transparent

4๏ธโƒฃ Real-Time Admin Panel

  • Live statistics: Total credentials, verifications, average score
  • Activity monitoring: Recent issuance and verification events
  • Auto-refresh: Updates every 5 seconds
  • System health: Backend status, AIR Kit connection, ZK proof availability

๐Ÿ› ๏ธ Technology Stack

Frontend

  • React 18 with TypeScript
  • Vite (Lightning-fast build tool)
  • AIR Kit SDK (@mocanetwork/airkit)
  • React Router (Multi-page navigation)
  • Lucide React (Beautiful icons)
  • Modern CSS with animations and glass morphism

Backend

  • Node.js 20 + Express.js
  • JWT Authentication (RS256 signing)
  • JWKS endpoint for public key distribution
  • RESTful API design
  • CORS enabled for cross-origin requests

Blockchain

  • Moca Network (Sandbox environment)
  • AIR Kit SDK for credential management
  • Abstract Accounts for seamless user experience
  • Zero-Knowledge Proofs for privacy-preserving verification

๐Ÿ“ฆ Installation & Setup

Prerequisites

Node.js >= 18.x
npm >= 9.x

1. Backend Setup

# Navigate to server directory
cd server

# Install dependencies
npm install

# Generate RSA key pair (if not exists)
openssl genpkey -algorithm RSA -out private.key -pkeyopt rsa_keygen_bits:2048
openssl rsa -pubout -in private.key -out public.key

# Create .env file
cat > .env << 'EOF'
PORT=8787
HOST=127.0.0.1
PARTNER_ID=your-partner-id-here
PRIVATE_KEY_PATH=./private.key
PUBLIC_KEY_PATH=./public.key
EOF

# Start server
node index.js

Backend will start on: http://127.0.0.1:8787

2. Frontend Setup

# Navigate to frontend directory
cd frontend

# Install dependencies
npm install

# Update vite.config.ts with your domain (if deploying)
# For local development, default settings work

# Start development server
npm run dev

Frontend will start on: http://localhost:5173

3. Production Build

# Build frontend
cd frontend
npm run build

# Serve with PM2 (recommended)
pm2 start npm --name "greenid-frontend" -- run dev

# Or use serve
npx serve dist -l 5173

๐Ÿ”Œ API Documentation

Backend Endpoints

Method Endpoint Description Auth Required
GET /health Health check No
GET /api/stats System statistics No
GET /api/demo-users Demo user profiles No
POST /auth/partner-jwt Generate partner JWT No
GET /.well-known/jwks.json Public keys (JWKS) No

Example: Get System Stats

Request:

curl http://localhost:8787/api/stats

Response:

{
  "totalCredentials": 10,
  "totalVerifications": 7,
  "averageScore": 78,
  "totalCO2Tracked": 45000,
  "recentActivity": [
    {
      "timestamp": "2025-10-11T13:19:38.171Z",
      "type": "verify"
    },
    {
      "timestamp": "2025-10-11T13:18:02.178Z",
      "type": "issue",
      "score": 86,
      "co2": 2000
    }
  ]
}

Example: Generate Partner JWT

Request:

curl -X POST http://localhost:8787/auth/partner-jwt \
  -H "Content-Type: application/json" \
  -d '{"scope":"issue"}'

Response:

{
  "token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImdyZWVuaWQta2V5LTEifQ..."
}

๐ŸŽฎ User Flow

Step 1: Login with AIR Kit

  1. Visit https://greenid.coinsspor.com
  2. Click "Login with AIR"
  3. AIR Kit modal opens automatically
  4. Complete authentication (email/social)
  5. Abstract Account created (no seed phrase needed!)

Step 2: Enter Carbon Data

  • Annual COโ‚‚ Emissions: Total yearly carbon output in kg
  • Renewable Energy Usage: Percentage of energy from renewable sources
  • Travel Emissions: Carbon from transportation in kg

Or use Quick Demo profiles:

  • ๐ŸŒŸ Eco Warrior (Score: 95) - Low emissions, high renewables
  • ๐Ÿฅ‡ Green Commuter (Score: 75) - Moderate emissions, good renewables
  • ๐Ÿฅˆ Average Joe (Score: 50) - Average emissions, low renewables

Step 3: Calculate Green Score

  • Click "Calculate Green Score"
  • Algorithm processes inputs
  • Score displayed with color coding:
    • ๐ŸŸข 80-100: Excellent
    • ๐ŸŸก 60-79: Good
    • ๐ŸŸ  40-59: Fair
    • ๐Ÿ”ด 0-39: Needs Improvement

Step 4: Issue Credential

  • Click "Issue Green Credential"
  • AIR Kit modal shows credential details
  • Confirm to write to blockchain
  • Success animation displays
  • Credential now stored on Moca Network!

Step 5: Verify with ZK Proof

  • Click "Verify My Credential"
  • AIR Kit generates Zero-Knowledge Proof
  • System checks compliance (e.g., "Score > 70")
  • Result: โœ… Compliant or โŒ Non-Compliant
  • Verification logged in admin panel

๐Ÿ” How Moca Network Powers GreenID

AIR Kit Integration

Abstract Account Management:

  • Users get blockchain wallets without managing private keys
  • No seed phrases or complex setup
  • Email/social login via AIR Kit

Credential Issuance:

  • Green Scores stored as verifiable credentials on Moca blockchain
  • Immutable and tamper-proof
  • Portable across platforms

JWKS Authentication:

  • Backend uses public/private key pairs
  • Partners authenticate via JWT tokens
  • Public keys published at /.well-known/jwks.json

Zero-Knowledge Proofs

Privacy-Preserving Verification:

Traditional: "My Green Score is 86" โŒ (reveals exact data)
With ZK Proof: "My Green Score > 70" โœ… (proves statement without revealing exact value)

Use Cases:

  • Corporate ESG reporting without exposing individual data
  • Regulatory compliance checks
  • Partner qualification verification
  • Privacy-first carbon credit markets

Why Moca Network?

  • โœ… Developer-friendly AIR Kit SDK
  • โœ… Built-in ZK proof capabilities
  • โœ… Sandbox for testing
  • โœ… Production-ready infrastructure
  • โœ… Excellent documentation

๐Ÿ“Š Admin Panel

Access: https://greenid.coinsspor.com/admin

Features:

  • ๐Ÿ“ˆ Real-Time Stats Cards:

    • Total credentials issued
    • Total verifications completed
    • Average Green Score across users
    • Total COโ‚‚ tracked (in tons)
  • ๐Ÿ“‹ Activity Log:

    • Recent credential issuances
    • Recent verifications
    • Timestamps and scores
    • Color-coded by type
  • ๐Ÿ”„ Auto-Refresh:

    • Updates every 5 seconds
    • Toggle on/off
    • Manual refresh button
  • โœ… System Health:

    • Backend status
    • AIR Kit connection
    • Blockchain network (Moca Sandbox)
    • Zero-Knowledge Proof availability

๐Ÿงช Demo Profiles

Profile Green Score Annual COโ‚‚ Renewable Energy Travel Emissions Badge
๐ŸŒŸ Eco Warrior 95 2,000 kg 90% 500 kg Platinum
๐Ÿฅ‡ Green Commuter 75 4,000 kg 60% 1,200 kg Gold
๐Ÿฅˆ Average Joe 50 8,000 kg 20% 2,500 kg Silver

Try them: Click demo pills on main app to auto-fill data!


๐ŸŽจ Design Highlights

  • ๐ŸŒŒ Animated star background for cosmic environmental theme
  • โœจ Glass morphism UI with backdrop blur effects
  • ๐Ÿ’š Glow effects on interactive elements
  • ๐Ÿ“Š Animated progress bars and score displays
  • ๐ŸŽญ Smooth transitions and fade-in animations
  • ๐ŸŽฏ Color-coded scoring for instant visual feedback
  • ๐Ÿ“ฑ Responsive design (desktop optimized)

๐Ÿš€ Deployment

Option 1: PM2 (Recommended)

# Install PM2 globally
npm install -g pm2

# Start backend
cd server
pm2 start index.js --name "greenid-backend"

# Start frontend
cd ../frontend
pm2 start npm --name "greenid-frontend" -- run dev

# Save configuration
pm2 save

# Setup auto-start on system boot
pm2 startup

Option 2: Systemd Service

# Create service file
sudo nano /etc/systemd/system/greenid-backend.service

# Add configuration (see server/README for full config)

# Enable and start
sudo systemctl enable greenid-backend
sudo systemctl start greenid-backend

Option 3: Docker (Coming Soon)

Docker support planned for future releases.


๐Ÿ”’ Security Considerations

Implemented:

  • โœ… Private keys never exposed in frontend
  • โœ… CORS configured properly
  • โœ… JWT tokens with expiration
  • โœ… Environment variables for secrets
  • โœ… HTTPS recommended for production

Best Practices:

  • ๐Ÿ” Never commit .env files
  • ๐Ÿ” Never commit private.key files
  • ๐Ÿ” Rotate keys periodically
  • ๐Ÿ” Use HTTPS in production
  • ๐Ÿ” Validate all inputs

๐Ÿ› Troubleshooting

Backend won't start

# Check if port is in use
lsof -i :8787

# Check logs
pm2 logs greenid-backend

Frontend build errors

# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install

AIR Kit login fails

  • Check browser console for errors
  • Ensure BUILD_ENV.SANDBOX is set correctly
  • Verify network connection

Credentials not issuing

  • Check backend is running: curl http://localhost:8787/health
  • Verify AIR Kit initialization
  • Check browser console for errors

๐Ÿค Contributing

This project was built for the Moca Network Proof of Build Buildathon.

Future improvements:

  • Docker containerization
  • Multi-language support
  • Mobile responsive design
  • More verification rules
  • Historical tracking
  • Carbon offset marketplace integration

๐Ÿ“„ License

MIT License - See LICENSE file for details


๐Ÿ™ Acknowledgments

  • Moca Network for the AIR Kit SDK and blockchain infrastructure
  • Proof of Build Buildathon for the opportunity
  • Open source community for amazing tools and libraries

๐Ÿ“ž Contact

Built with ๐Ÿ’š for a sustainable future

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors