Skip to content

jzry/GhostPIN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GhostPIN - Anti-Phishing Payment Verification System

GhostPIN is a comprehensive anti-phishing payment verification system that provides cryptographic proof of authenticity between users, merchant pages, and payment gateways. It makes phishing and fake checkout pages cryptographically impossible.

πŸ” Core Features

  • One-Line SDK Integration: Simple <script> tag integration for merchants
  • Visual Nonce Embedding: Steganographic nonce embedding in checkout buttons
  • WebAuthn Integration: Face ID, Touch ID, hardware key, and OTP fallback
  • Cryptographic Verification: Nonce + page authenticity bound to signed payload
  • Real-Time Fraud Analytics: Comprehensive dashboard with fraud detection
  • Privacy-First: No biometrics stored, no user tracking

πŸš€ Quick Start

1. Install Dependencies

npm install

2. Set Up Environment

cp .env.example .env
# Edit .env with your configuration

3. Start Development Server

npm run dev

4. Access Dashboard

πŸ“ Project Structure

GhostPIN/
β”œβ”€β”€ backend/                 # Node.js backend service
β”‚   β”œβ”€β”€ routes/             # API route handlers
β”‚   β”œβ”€β”€ services/           # Business logic
β”‚   β”œβ”€β”€ utils/              # Database and Redis utilities
β”‚   └── server.js           # Main server file
β”œβ”€β”€ sdk/                    # Client-side SDK
β”‚   └── ghostpin.js         # Main SDK file
β”œβ”€β”€ dashboard/              # Next.js dashboard
β”‚   β”œβ”€β”€ components/        # React components
β”‚   β”œβ”€β”€ pages/             # Next.js pages
β”‚   └── styles/            # CSS styles
β”œβ”€β”€ tests/                 # Test suites
β”‚   β”œβ”€β”€ verification.test.js
β”‚   β”œβ”€β”€ sdk.test.js
β”‚   β”œβ”€β”€ security.test.js
β”‚   └── integration.test.js
└── docs/                  # Documentation

πŸ”§ Configuration

Environment Variables

# Database
DB_HOST=localhost
DB_PORT=5432
DB_NAME=ghostpin
DB_USER=ghostpin
DB_PASSWORD=your_password

# Redis
REDIS_URL=redis://localhost:6379

# Security
JWT_SECRET=your_jwt_secret
ALLOWED_ORIGINS=http://localhost:3000,https://yourdomain.com

# Merchant Configuration
MERCHANT_DEMO_MERCHANT_ORIGIN=https://demo-merchant.com

Merchant Setup

  1. Register Merchant:
// Add merchant to database
INSERT INTO merchants (merchant_id, name, public_key, origin, active) 
VALUES ('your-merchant', 'Your Store', 'your-public-key', 'https://yourstore.com', true);
  1. Configure Environment:
MERCHANT_YOUR_MERCHANT_ORIGIN=https://yourstore.com

πŸ’» SDK Integration

Basic Integration

<!DOCTYPE html>
<html>
<head>
    <title>Your Store</title>
</head>
<body>
    <!-- Add GhostPIN SDK -->
    <script 
        src="https://cdn.ghostpin.com/ghostpin.js"
        data-merchant-id="your-merchant-id"
        data-api-url="https://api.ghostpin.com">
    </script>
    
    <!-- Your checkout button -->
    <button id="checkout-btn" onclick="initiatePayment()">
        Pay $99.99
    </button>
    
    <script>
        async function initiatePayment() {
            try {
                const result = await window.GhostPIN.verifyPayment({
                    amount: 9999,
                    currency: 'USD'
                }, {
                    targetElement: document.getElementById('checkout-btn')
                });
                
                if (result.verified) {
                    // Proceed with payment
                    processPayment();
                } else {
                    alert('Verification failed: ' + result.reason);
                }
            } catch (error) {
                console.error('GhostPIN error:', error);
            }
        }
    </script>
</body>
</html>

Advanced Integration

// Initialize GhostPIN with custom options
const ghostpin = new GhostPIN({
    merchantId: 'your-merchant-id',
    apiUrl: 'https://api.ghostpin.com',
    fallbackToOTP: true
});

// Listen for events
ghostpin.on('verification', (event) => {
    console.log('Verification result:', event.detail);
});

// Custom verification
const result = await ghostpin.verifyPayment({
    amount: 5000,
    currency: 'USD',
    description: 'Premium Plan'
}, {
    targetElement: document.getElementById('checkout-btn'),
    requireBiometric: true
});

πŸ›‘οΈ Security Features

Cryptographic Security

  • SHA-256 Nonce Generation: Cryptographically secure nonce generation
  • WebAuthn Integration: Hardware-backed authentication
  • Signature Verification: Cryptographic signature validation
  • Replay Attack Prevention: Nonce-based replay protection
  • Timestamp Validation: Time-based request validation

Fraud Detection

  • Origin Validation: Domain binding verification
  • Rate Limiting: Request rate limiting
  • Anomaly Detection: Behavioral pattern analysis
  • Real-Time Monitoring: Live fraud detection
  • Audit Logging: Comprehensive audit trails

πŸ“Š Dashboard Features

Real-Time Metrics

  • Verification Statistics: Success/failure rates
  • Fraud Alerts: Real-time security alerts
  • Domain Analysis: Suspicious domain detection
  • Performance Metrics: Response times and throughput

Analytics

  • Hourly Breakdown: Time-based analysis
  • Domain Statistics: Origin-based metrics
  • Failure Analysis: Error reason tracking
  • Risk Scoring: Dynamic risk assessment

πŸ§ͺ Testing

Run All Tests

npm test

Run Specific Test Suites

# Unit tests
npm run test:unit

# Integration tests
npm run test:integration

# Security tests
npm run test:security

# SDK tests
npm run test:sdk

Test Coverage

npm run test:coverage

πŸš€ Deployment

Docker Deployment

# Build Docker image
docker build -t ghostpin .

# Run with Docker Compose
docker-compose up -d

Production Deployment

  1. Set up production environment:
export NODE_ENV=production
export DB_HOST=your-db-host
export REDIS_URL=your-redis-url
export JWT_SECRET=your-secure-secret
  1. Deploy backend:
npm run build:backend
npm start
  1. Deploy dashboard:
cd dashboard
npm run build
npm start

Environment-Specific Configuration

Development

NODE_ENV=development
DB_HOST=localhost
REDIS_URL=redis://localhost:6379
ALLOWED_ORIGINS=http://localhost:3000

Production

NODE_ENV=production
DB_HOST=your-production-db
REDIS_URL=redis://your-redis-cluster
ALLOWED_ORIGINS=https://yourdomain.com

πŸ“ˆ Monitoring

Health Checks

  • API Health: GET /health
  • Database Health: Automatic connection monitoring
  • Redis Health: Cache availability monitoring

Metrics

  • Response Times: API performance metrics
  • Error Rates: Failure rate tracking
  • Throughput: Request volume monitoring
  • Fraud Detection: Security metrics

Logging

  • Structured Logging: JSON-formatted logs
  • Audit Trails: Complete verification logs
  • Error Tracking: Comprehensive error logging
  • Performance Logs: Response time tracking

πŸ”’ Security Best Practices

Merchant Security

  1. HTTPS Only: Enforce HTTPS for all communications
  2. Domain Validation: Strict origin validation
  3. Key Management: Secure key storage and rotation
  4. Rate Limiting: Implement request rate limiting

API Security

  1. Input Validation: Comprehensive input sanitization
  2. Authentication: JWT-based authentication
  3. Authorization: Role-based access control
  4. Encryption: End-to-end encryption

Data Protection

  1. No Biometric Storage: Biometrics never stored
  2. Minimal Data Collection: Only necessary data
  3. Secure Transmission: TLS 1.3 encryption
  4. Data Retention: Automatic data cleanup

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

Development Setup

# Clone repository
git clone https://github.com/your-org/ghostpin.git
cd ghostpin

# Install dependencies
npm install

# Set up development environment
cp .env.example .env
# Edit .env with your configuration

# Start development servers
npm run dev

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

🎯 Roadmap

Phase 1 (Current)

  • βœ… Core SDK implementation
  • βœ… Backend verification service
  • βœ… Basic dashboard
  • βœ… Security testing

Phase 2 (Next)

  • πŸ”„ Advanced fraud detection
  • πŸ”„ Machine learning integration
  • πŸ”„ Multi-tenant support
  • πŸ”„ Mobile SDK

Phase 3 (Future)

  • πŸ“‹ Blockchain integration
  • πŸ“‹ Decentralized verification
  • πŸ“‹ Cross-platform support
  • πŸ“‹ Enterprise features

GhostPIN - Making online payments cryptographically secure, one verification at a time.

About

HackHarvard

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors