File size: 10,252 Bytes
86deab0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# QCrypt RNG β€” Project Overview

A high-level explanation of what QCrypt RNG is, what it does, and how it is built.

---

## What Is QCrypt RNG?

**QCrypt RNG** is a platform for **quantum-enhanced randomness** and **post-quantum cryptography**. It exposes a REST API and web UI for:

- Generating cryptographically secure random data using quantum-style entropy
- Running NIST-standard post-quantum algorithms (signatures and key exchange)
- Providing a verifiable random function (VRF) for blockchains
- Encrypting and protecting data with quantum-derived keys

It is intended for developers, researchers, and teams building quantum-resistant or blockchain-facing applications.

---

## Core Capabilities

### 1. Quantum Random Number Generation (QRNG)

- **Random bytes** β€” Configurable length and qubit count (8/12/16)
- **Keys** β€” AES, RSA, ECDSA keys with quantum entropy
- **UUIDs** β€” RFC 4122 v4 UUIDs
- **Passwords** β€” Configurable length and character sets
- **Session tokens** β€” URL-safe, with optional expiry
- **Batch mode** β€” Multiple samples in parallel

**How it works:** The system uses a pluggable backend (simulation, Qrisp, or real hardware). Random values are obtained from a hardware abstraction layer, post-processed with SHA3-256, and mixed with system entropy. Results are stored in an entropy pool for quality checks (Shannon entropy, min-entropy, chi-square).

---

### 2. Post-Quantum Cryptography (PQC)

Supports NIST-standard algorithms via **liboqs** (with fallbacks when liboqs is not available).

**Signature schemes:**

- **DILITHIUM** β€” Level 2, 3, 5
- **FALCON** β€” 512 / 1024
- **SPHINCS+** β€” Hash-based variant (e.g., SHA2-128f)

**Key encapsulation (KEM):**

- **Kyber** β€” 512 / 768 / 1024
- **NTRU-HPS** β€” 2048-509, 2048-677
- **SABER** β€” LIGHTSABER, SABER, FIRESABER

The Kyber KEM flow includes:

1. Recipient generates a keypair
2. Sender encapsulates a shared secret with the recipient’s public key
3. Recipient decapsulates with their private key
4. Both derive the same shared secret for symmetric cryptography

---

### 3. Quantum VRF (Verifiable Random Function)

A VRF backed by quantum entropy with a **commit–reveal** flow:

1. **Seed** β€” 32-byte quantum seed is generated and committed via Keccak-256
2. **Prove** β€” For any input (alpha), output = Keccak256(seed || alpha)
3. **Reveal** β€” Seed is revealed so anyone can verify
4. **Verify** β€” Checks that commitment and output match the seed and alpha

The Keccak-256 format is compatible with Ethereum/Solidity.

---

### 4. On-Chain Oracle Fulfillment

Supports submit-and-fulfill oracle randomness on blockchains:

- **Chains:** Ethereum, Polygon, BSC, Avalanche, Fantom
- **Flow:** Configure chain (RPC, private key, explorer), create request, commit on-chain, reveal randomness
- **Status:** Track PENDING β†’ COMMIT_SUBMITTED β†’ REVEAL_CONFIRMED β†’ COMPLETED
- **Retry:** Retry failed fulfillments

---

### 5. Data Protection

- **Encryption** β€” AES-256-GCM, AES-128-GCM, AES-256-CBC (quantum or user keys)
- **File encryption** β€” Up to 10 MB
- **Signing** β€” HMAC-SHA256, HMAC-SHA512
- **Hashing** β€” SHA3-256, SHA3-512, PBKDF2-SHA256, BLAKE2b-256
- **Salt** β€” Quantum-generated salts for hashing

---

### 6. Blockchain Security Tools

- **Wallet creation** β€” Compare classical (ECDSA) vs quantum-safe (DILITHIUM/KYBER) wallets
- **Attack simulation** β€” Simulate Shor’s algorithm on RSA, ECDSA, DILITHIUM, KYBER
- **Blockchain comparison** β€” Side-by-side vulnerable vs quantum-safe chain models
- **Demo mining** β€” Proof-of-work-style mining for both types

---

### 7. Threat Intelligence

- **Algorithm assessment** β€” β€œQubits to break” and migration guidance for RSA, ECDSA, etc.
- **Oracle benchmark** β€” Latency and throughput
- **Entropy quality** β€” Shannon entropy, min-entropy, chi-square, autocorrelation

---

### 8. Quantum Hardware Abstraction

Pluggable backends for different sources:

- **Simulation** β€” Classical fallback for dev/demo
- **Qrisp** β€” Quantum simulation when available
- **ID Quantique Quantis** β€” Photonic QRNG (USB, PCIe, network)
- **QuintessenceLabs qStream** β€” Photonic QRNG over TCP/IP

Includes entropy quality checks (NIST SP 800-90B–style analysis).

---

## Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Next.js Dashboard (quantum-oracle-ui)                       β”‚
β”‚  Port 3000 (dev) / served by Nginx (prod)                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  FastAPI Backend (app/)                                      β”‚
β”‚  Port 8000 | Base path: /api/v2                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Endpoints:                                                  β”‚
β”‚  - /generate/*    Quantum RNG                                β”‚
β”‚  - /protect/*     Encryption, signing, hashing               β”‚
β”‚  - /pqc/*         Post-quantum crypto (incl. KEM)            β”‚
β”‚  - /oracle/*      VRF, oracle requests, fulfillment         β”‚
β”‚  - /blockchain/*  Wallets, attack sim, mining                β”‚
β”‚  - /quantum/*     Entropy, stats, reseed                     β”‚
β”‚  - /hardware/*    Device list, benchmark, connect            β”‚
β”‚  - /monitoring/*  Metrics, analytics                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Core Modules (app/quantum/, app/blockchain/)                β”‚
β”‚  - qrng.py            Quantum RNG engine                     β”‚
β”‚  - commitment.py      Keccak-256 commitments                 β”‚
β”‚  - pqc.py             liboqs PQC (Dilithium, Kyber, etc.)    β”‚
β”‚  - hardware_interface β”‚ Photonic, superconducting, simulated β”‚
β”‚  - oracle_service.py  On-chain fulfillment                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## Tech Stack

| Layer        | Technology                                      |
|-------------|--------------------------------------------------|
| Backend     | Python 3.8+, FastAPI, Uvicorn                    |
| Frontend    | Next.js 16, React, TypeScript, Tailwind CSS      |
| Quantum     | Qrisp (optional), custom hardware abstraction   |
| Crypto      | PyCryptodome (Keccak), cryptography, liboqs     |
| Deployment  | Docker (single image), Compose, Kubernetes       |
| Monitoring  | Prometheus metrics, analytics service            |

---

## Project Layout

```
qcrypt-rng/
β”œβ”€β”€ app/                    # FastAPI backend
β”‚   β”œβ”€β”€ api/v2/endpoints/   # REST routes
β”‚   β”œβ”€β”€ quantum/            # QRNG, PQC, commitment, hardware
β”‚   β”œβ”€β”€ blockchain/         # Chain adapters, oracle service
β”‚   β”œβ”€β”€ utils/              # Logging, monitoring, middleware
β”‚   └── config.py
β”œβ”€β”€ quantum-oracle-ui/      # Next.js dashboard
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ unit/               # Pytest unit tests
β”‚   β”œβ”€β”€ integration/        # Pytest integration tests
β”‚   └── manual/             # Standalone scripts (not collected by pytest)
β”œβ”€β”€ docs/                   # PRODUCTION, guides, business, archive, roadmaps
β”œβ”€β”€ examples/               # Standalone sample scripts
β”œβ”€β”€ legacy/                 # Streamlit + static HTML (deprecated UI path)
β”œβ”€β”€ scripts/                # e.g. start.py (API + Next.js for dev)
β”œβ”€β”€ quantum-oracle/         # Oracle node, contracts, SDKs
β”œβ”€β”€ client_sdk/python/      # Python client library
β”œβ”€β”€ k8s/                    # Kubernetes manifests
β”œβ”€β”€ run_api.py              # Start API server only
β”œβ”€β”€ requirements.txt
└── Dockerfile              # Single image for production
```

---

## Running the Project

**Backend:**
```bash
pip install -r requirements.txt
python run_api.py
```
β†’ API at http://localhost:8000, docs at http://localhost:8000/docs

**Dashboard:**
```bash
cd quantum-oracle-ui && npm install && npm run dev
```
β†’ Dashboard at http://localhost:3000 (uses API on 8000–8004 by default)

**Production:** `docker-compose up -d` or `./deploy.sh` (Kubernetes)

**Hugging Face Spaces:** Use root `Dockerfile` for a Docker Space on port 7860.

---

## Security Notes

- Simulation and classical fallback are for development/demo only.
- Use a validated QRNG or trusted HRNG in production.
- VRF seeds are kept in memory; consider hardened storage for high assurance.
- Private keys for on-chain fulfillment must be stored and handled securely (no production keys in demos).
- Enable rate limiting and API key auth in production.

---

## Related Documents

- [README.md](../README.md) β€” Quick start and API summary
- [TECHNICAL_PAPER.md](TECHNICAL_PAPER.md) β€” Architecture and algorithms
- [PRODUCTION.md](PRODUCTION.md) β€” Deployment and operations
- [NEXT_STEPS.md](NEXT_STEPS.md) β€” Completed roadmap
- [NEXT_STEPS_PHASE2.md](NEXT_STEPS_PHASE2.md) β€” Phase 2 roadmap
- [DASHBOARD_MONITORING_PLAN.md](DASHBOARD_MONITORING_PLAN.md) β€” UI and monitoring plan

---

*Last updated: 2026-03-06*