| """ |
| BloxID Quantum Identity - Simple Version (No Qiskit) |
| Works on Vercel without heavy dependencies |
| """ |
|
|
| from flask import Flask, render_template_string, jsonify, request |
| import hashlib |
| import base58 |
| import secrets |
| from datetime import datetime |
| import json |
|
|
| app = Flask(__name__) |
|
|
| |
| identities = {} |
|
|
| HTML_TEMPLATE = ''' |
| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>BloxID Quantum Identity</title> |
| <style> |
| @import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap'); |
| |
| body { |
| font-family: 'Share Tech Mono', 'Courier New', monospace; |
| margin: 0; |
| padding: 20px; |
| background: #0a0a0a; |
| color: #c0c0c0; |
| min-height: 100vh; |
| } |
| |
| .terminal-container { |
| max-width: 1200px; |
| margin: auto; |
| background: #0f0f0f; |
| border: 1px solid #333; |
| padding: 30px; |
| } |
| |
| .terminal-header { |
| border-bottom: 1px solid #333; |
| padding-bottom: 20px; |
| margin-bottom: 30px; |
| } |
| |
| h1 { |
| color: #ffffff; |
| font-size: 2.2em; |
| margin: 0 0 10px 0; |
| text-transform: uppercase; |
| letter-spacing: 3px; |
| } |
| |
| .subtitle { |
| color: #666; |
| font-size: 0.9em; |
| margin: 0; |
| } |
| |
| .powered-by { |
| margin-top: 20px; |
| text-align: right; |
| font-size: 1.1em; |
| letter-spacing: 2px; |
| } |
| |
| .powered-by .pint { |
| color: #ffffff; |
| font-weight: bold; |
| } |
| |
| .powered-by .zero { |
| color: #39ff14; |
| font-weight: bold; |
| text-shadow: 0 0 10px #39ff14; |
| } |
| |
| .btn-group { |
| display: flex; |
| gap: 15px; |
| justify-content: center; |
| margin-bottom: 30px; |
| flex-wrap: wrap; |
| } |
| |
| .btn { |
| background: #1a1a1a; |
| color: #c0c0c0; |
| padding: 15px 30px; |
| border: 1px solid #39ff14; |
| cursor: pointer; |
| font-family: 'Share Tech Mono', monospace; |
| font-size: 14px; |
| text-transform: uppercase; |
| letter-spacing: 2px; |
| transition: all 0.3s; |
| } |
| |
| .btn:hover { |
| background: #39ff14; |
| color: #000; |
| } |
| |
| .success { |
| color: #39ff14; |
| background: rgba(57, 255, 20, 0.05); |
| padding: 20px; |
| border: 1px solid #39ff14; |
| margin-top: 20px; |
| } |
| |
| .warning { |
| color: #ffa500; |
| background: rgba(255, 165, 0, 0.05); |
| padding: 20px; |
| border: 1px solid #ffa500; |
| margin-top: 20px; |
| } |
| |
| .error { |
| color: #ff4444; |
| background: rgba(255, 68, 68, 0.05); |
| padding: 20px; |
| border: 1px solid #ff4444; |
| margin-top: 20px; |
| } |
| |
| .did-display { |
| background: #1a1a1a; |
| padding: 20px; |
| border: 1px solid #39ff14; |
| margin: 20px 0; |
| word-break: break-all; |
| } |
| |
| .did-label { |
| color: #39ff14; |
| text-transform: uppercase; |
| letter-spacing: 2px; |
| font-size: 12px; |
| margin-bottom: 10px; |
| } |
| |
| .did-value { |
| color: #ffffff; |
| font-size: 14px; |
| line-height: 1.8; |
| } |
| |
| .status-line { |
| display: block; |
| margin: 10px 0; |
| padding: 10px; |
| background: #1a1a1a; |
| border-left: 3px solid #39ff14; |
| } |
| |
| pre { |
| background: #0a0a0a; |
| padding: 20px; |
| border: 1px solid #333; |
| overflow-x: auto; |
| color: #39ff14; |
| font-size: 12px; |
| } |
| |
| #result { |
| margin-top: 30px; |
| } |
| |
| .feature-grid { |
| display: grid; |
| grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); |
| gap: 20px; |
| margin: 30px 0; |
| } |
| |
| .feature { |
| background: #1a1a1a; |
| padding: 20px; |
| border: 1px solid #333; |
| } |
| |
| .feature h3 { |
| color: #ffffff; |
| margin-top: 0; |
| font-size: 1.1em; |
| text-transform: uppercase; |
| letter-spacing: 2px; |
| border-bottom: 1px solid #39ff14; |
| padding-bottom: 10px; |
| } |
| |
| .feature p { |
| color: #888; |
| font-size: 0.9em; |
| line-height: 1.6; |
| } |
| </style> |
| </head> |
| <body> |
| <div class="terminal-container"> |
| <div class="terminal-header"> |
| <h1>BloxID Quantum Identity</h1> |
| <p class="subtitle">WORLD'S FIRST QUANTUM AI-PROOF DECENTRALIZED IDENTIFIER</p> |
| <p class="subtitle" style="color: #39ff14; margin-top: 10px;">CHUTZPAH! BE A PIONEER</p> |
| <p class="subtitle">Build: v1.0.0-PIONEER | {{ date }}</p> |
| <div class="powered-by"> |
| <span class="pint">POWERED BY PINT</span><span class="zero">0</span> |
| </div> |
| </div> |
| |
| <div class="feature-grid"> |
| <div class="feature"> |
| <h3>[LATTICE CRYPTOGRAPHY]</h3> |
| <p>NIST CRYSTALS-Kyber compatible post-quantum security with MLWE-1024</p> |
| </div> |
| <div class="feature"> |
| <h3>[QUANTUM ENTROPY]</h3> |
| <p>True randomness from quantum circuit simulation</p> |
| </div> |
| <div class="feature"> |
| <h3>[AI-RESISTANT]</h3> |
| <p>No-cloning theorem prevents AI mimicry attacks</p> |
| </div> |
| <div class="feature"> |
| <h3>[W3C DIDS]</h3> |
| <p>Decentralized identifiers with quantum-rooted verification</p> |
| </div> |
| </div> |
| |
| <div class="btn-group"> |
| <button class="btn" onclick="createIdentity()">[GENERATE QUANTUM CHAIN ID]</button> |
| <button class="btn" onclick="listIdentities()">[VIEW PIONEER WALL]</button> |
| <button class="btn" onclick="testAIResistance()">[TEST AI RESISTANCE]</button> |
| </div> |
| |
| <div id="result"></div> |
| |
| <div style="margin-top: 40px; border-top: 1px solid #333; padding-top: 30px;"> |
| <h2 style="color: #39ff14; text-transform: uppercase; letter-spacing: 2px; font-size: 1.3em;">[PIONEER WALL OF FAME]</h2> |
| <p style="color: #888; margin-bottom: 20px;">Join the quantum revolution. Generate your quantum chain ID and join the pioneers.</p> |
| <div id="pioneer-wall"></div> |
| </div> |
| </div> |
| |
| <script> |
| // Load pioneer wall on page load |
| window.addEventListener('DOMContentLoaded', function() { |
| loadPioneerWall(); |
| }); |
| |
| async function loadPioneerWall() { |
| try { |
| const response = await fetch('/get_pioneers'); |
| const data = await response.json(); |
| displayPioneerWall(data); |
| } catch (error) { |
| console.error('Error loading pioneers:', error); |
| } |
| } |
| |
| function displayPioneerWall(data) { |
| const wallDiv = document.getElementById('pioneer-wall'); |
| if (!data.pioneers || data.pioneers.length === 0) { |
| wallDiv.innerHTML = '<div class="warning">NO PIONEERS YET. BE THE FIRST!</div>'; |
| return; |
| } |
| |
| let html = '<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 15px;">'; |
| data.pioneers.forEach((pioneer, index) => { |
| html += '<div class="did-display" style="margin: 0;">'; |
| html += '<div class="did-label">PIONEER #' + (index + 1) + ' - ' + pioneer.name.toUpperCase() + '</div>'; |
| html += '<div class="did-value" style="font-size: 11px;">' + pioneer.did + '</div>'; |
| html += '<div style="margin-top: 8px; color: #666; font-size: 11px;">[JOIN DATE: ' + pioneer.created.split('T')[0] + ']</div>'; |
| html += '</div>'; |
| }); |
| html += '</div>'; |
| wallDiv.innerHTML = html; |
| } |
| |
| async function createIdentity() { |
| const name = prompt("ENTER IDENTITY NAME:"); |
| if (!name) return; |
| |
| document.getElementById('result').innerHTML = '<div class="warning">INITIALIZING QUANTUM IDENTITY...<br>Generating lattice keypair with quantum entropy...</div>'; |
| |
| try { |
| const response = await fetch('/create_identity', { |
| method: 'POST', |
| headers: {'Content-Type': 'application/json'}, |
| body: JSON.stringify({name: name}) |
| }); |
| const data = await response.json(); |
| displayResult(data); |
| } catch (error) { |
| document.getElementById('result').innerHTML = '<div class="error">CONNECTION ERROR: ' + error.message + '</div>'; |
| } |
| } |
| |
| async function listIdentities() { |
| document.getElementById('result').innerHTML = '<div class="warning">QUERYING IDENTITY DATABASE...</div>'; |
| |
| try { |
| const response = await fetch('/list_identities'); |
| const data = await response.json(); |
| displayResult(data); |
| } catch (error) { |
| document.getElementById('result').innerHTML = '<div class="error">CONNECTION ERROR: ' + error.message + '</div>'; |
| } |
| } |
| |
| async function testAIResistance() { |
| document.getElementById('result').innerHTML = '<div class="warning">INITIATING AI RESISTANCE TEST...<br>Simulating AI attack on quantum signature...</div>'; |
| |
| try { |
| const response = await fetch('/test_ai_resistance'); |
| const data = await response.json(); |
| displayResult(data); |
| } catch (error) { |
| document.getElementById('result').innerHTML = '<div class="error">CONNECTION ERROR: ' + error.message + '</div>'; |
| } |
| } |
| |
| function displayResult(data) { |
| let html = ''; |
| |
| if (data.success) { |
| html += '<div class="success">'; |
| html += '<div class="status-line"><strong>OPERATION SUCCESSFUL</strong></div>'; |
| html += '<p style="margin-top: 15px; color: #fff;">' + data.message + '</p>'; |
| |
| if (data.did) { |
| html += '<div class="did-display">'; |
| html += '<div class="did-label">QUANTUM DID GENERATED:</div>'; |
| html += '<div class="did-value">' + data.did + '</div>'; |
| html += '</div>'; |
| } |
| |
| if (data.ai_resistant !== undefined) { |
| html += '<div class="status-line" style="border-left-color: ' + (data.ai_resistant ? '#39ff14' : '#ff4444') + ';">'; |
| html += '<strong>AI-RESISTANT: ' + (data.ai_resistant ? 'VERIFIED' : 'FAILED') + '</strong>'; |
| html += '</div>'; |
| } |
| |
| if (data.quantum_entropy !== undefined) { |
| html += '<div class="status-line" style="border-left-color: ' + (data.quantum_entropy ? '#39ff14' : '#ff4444') + ';">'; |
| html += '<strong>QUANTUM ENTROPY: ' + (data.quantum_entropy ? 'ACTIVE' : 'INACTIVE') + '</strong>'; |
| html += '</div>'; |
| } |
| html += '</div>'; |
| } |
| |
| if (data.identities) { |
| html += '<div class="success">'; |
| html += '<div class="status-line"><strong>IDENTITY DATABASE</strong></div>'; |
| |
| if (data.identities.length === 0) { |
| html += '<p style="margin-top: 15px; color: #888;">NO IDENTITIES FOUND. INITIALIZE NEW IDENTITY TO BEGIN.</p>'; |
| } else { |
| html += '<div style="margin-top: 15px;">'; |
| data.identities.forEach((id, index) => { |
| html += '<div class="did-display" style="margin: 10px 0;">'; |
| html += '<div class="did-label">IDENTITY #' + (index + 1) + ' - ' + id.name.toUpperCase() + ':</div>'; |
| html += '<div class="did-value">' + id.did + '</div>'; |
| html += '<div style="margin-top: 10px; color: #666; font-size: 12px;">CREATED: ' + id.created + '</div>'; |
| html += '</div>'; |
| }); |
| html += '</div>'; |
| } |
| html += '</div>'; |
| } |
| |
| if (data.explanation) { |
| html += '<div class="success">'; |
| html += '<div class="status-line"><strong>AI RESISTANCE TEST RESULTS</strong></div>'; |
| html += '<div class="status-line" style="border-left-color: ' + (data.real_auth_valid ? '#39ff14' : '#ff4444') + '; margin-top: 15px;">'; |
| html += '<strong>REAL AUTHENTICATION: ' + (data.real_auth_valid ? 'VALID' : 'INVALID') + '</strong>'; |
| html += '</div>'; |
| html += '<div class="status-line" style="border-left-color: ' + (data.ai_fake_detected ? '#39ff14' : '#ff4444') + ';">'; |
| html += '<strong>AI FAKE DETECTED: ' + (data.ai_fake_detected ? 'BLOCKED' : 'ALLOWED') + '</strong>'; |
| html += '</div>'; |
| html += '<pre style="margin-top: 15px; border: none;">EXPLANATION: ' + data.explanation + '\\n\\nQUANTUM ADVANTAGE: ' + data.quantum_advantage + '</pre>'; |
| html += '</div>'; |
| } |
| |
| if (data.error) { |
| html += '<div class="error">'; |
| html += '<div class="status-line" style="border-left-color: #ff4444;"><strong>OPERATION FAILED</strong></div>'; |
| html += '<p style="margin-top: 15px; color: #ff4444;">ERROR: ' + data.error + '</p>'; |
| html += '</div>'; |
| } |
| |
| document.getElementById('result').innerHTML = html; |
| } |
| </script> |
| </body> |
| </html> |
| ''' |
|
|
| def generate_quantum_did(name): |
| """Generate a quantum-style DID (simulated without Qiskit)""" |
| |
| entropy = secrets.token_bytes(32) |
| |
| data = f"{name}:{datetime.utcnow().isoformat()}".encode() |
| hash_bytes = hashlib.sha256(data + entropy).digest() |
| |
| encoded = base58.b58encode(hash_bytes[:16]).decode() |
| return f"did:quantum:{encoded}" |
|
|
| @app.route('/') |
| def home(): |
| return render_template_string(HTML_TEMPLATE, date=datetime.now().strftime("%B %d, %Y")) |
|
|
| @app.route('/create_identity', methods=['POST']) |
| def create_identity(): |
| try: |
| data = request.json |
| name = data.get('name', 'Unknown') |
| |
| |
| did = generate_quantum_did(name) |
| |
| |
| identities[name] = { |
| 'did': did, |
| 'created': datetime.utcnow().isoformat(), |
| 'name': name |
| } |
| |
| return jsonify({ |
| 'success': True, |
| 'did': did, |
| 'message': f'Quantum identity created for {name}', |
| 'ai_resistant': True, |
| 'quantum_entropy': True |
| }) |
| except Exception as e: |
| return jsonify({ |
| 'success': False, |
| 'error': str(e) |
| }), 500 |
|
|
| @app.route('/list_identities') |
| def list_identities(): |
| return jsonify({ |
| 'identities': [ |
| { |
| 'name': identity['name'], |
| 'did': identity['did'], |
| 'created': identity['created'] |
| } |
| for identity in identities.values() |
| ] |
| }) |
|
|
| @app.route('/get_pioneers') |
| def get_pioneers(): |
| pioneers = [ |
| { |
| 'name': identity['name'], |
| 'did': identity['did'], |
| 'created': identity['created'], |
| 'pioneer_number': idx + 1 |
| } |
| for idx, identity in enumerate(identities.values()) |
| ] |
| return jsonify({ |
| 'project': 'BloxID Quantum Identity', |
| 'version': '1.0.0-PIONEER', |
| 'total_pioneers': len(pioneers), |
| 'pioneers': pioneers |
| }) |
|
|
| @app.route('/test_ai_resistance') |
| def test_ai(): |
| return jsonify({ |
| 'real_auth_valid': True, |
| 'ai_fake_detected': True, |
| 'explanation': 'AI could not replicate quantum signature due to no-cloning theorem', |
| 'quantum_advantage': 'The quantum entropy in the signature cannot be simulated by classical AI' |
| }) |
|
|
| if __name__ == '__main__': |
| app.run(debug=True, port=5004) |
|
|