537 lines
18 KiB
Markdown
537 lines
18 KiB
Markdown
|
||
# 🔐 ChaosCrypt - Chaos Encryption System (v2.0)
|
||
|
||
**A fully self-designed, quantum-resistant, math-attack-resistant symmetric encryption system**
|
||
|
||
*No NIST, no elliptic curves, no prime factorization—only randomness itself*
|
||
|
||
**v2.0 New Addition 💬 ChaosCryptChat: End-to-end encrypted chat system (text/images/files/voice) built on ChaosCrypt**
|
||
|
||
---
|
||
|
||
## 📖 Table of Contents
|
||
|
||
1. [Project Overview](#project-overview)
|
||
2. [Design Philosophy](#design-philosophy)
|
||
3. [Core Features](#core-features)
|
||
4. [Encryption Workflow](#encryption-workflow)
|
||
5. [Security Analysis](#security-analysis)
|
||
6. [Why This Is Actually Secure (No-BS Edition)](#why-this-is-actually-secure-no-bs-edition)
|
||
7. [Quick Start](#quick-start)
|
||
8. [Usage Guide](#usage-guide)
|
||
9. [API Reference](#api-reference)
|
||
10. [FAQ](#faq)
|
||
11. [💬 ChaosCryptChat](#-chaoscryptchat-chaos-encrypted-chat)
|
||
12. [Project Structure](#project-structure)
|
||
13. [Disclaimer](#disclaimer)
|
||
|
||
---
|
||
|
||
## Project Overview
|
||
|
||
**ChaosCrypt** is a fully self-designed symmetric encryption system. It relies on no third-party crypto libraries (only `base64` for encoding)—all encryption logic is original.
|
||
|
||
**Core idea**: Replace **mathematical structure** with **randomness**, replace **algebraic equations** with **multi-layer obfuscation**, and use an **immense key space** to completely shut down brute force.
|
||
|
||
> This is not an improvement on existing algorithms—it's a redefinition of what "secure" means.
|
||
|
||
**v2.0 New**: Built **ChaosCryptChat**, an end-to-end encrypted chat system on top of the ChaosCrypt kernel, bringing chaos encryption to real-time communication.
|
||
|
||
---
|
||
|
||
## Design Philosophy
|
||
|
||
There's a consensus in the crypto world: *"Only NIST-certified, mathematically elegant, academically vetted algorithms are secure."*
|
||
|
||
ChaosCrypt says:
|
||
|
||
> **"You're not wrong, but I don't buy it."**
|
||
|
||
- **Dual_EC_DRBG** is still fresh—NIST standard, NSA backdoor, the whole world fooled for years.
|
||
- **RSA** is mathematically beautiful, right? Standard, right? **Shor kills it instantly.**
|
||
- **AES** has a clean structure, a well-reasoned S-Box, right? **Grover gives you a square-root speedup.**
|
||
|
||
**ChaosCrypt takes another path:**
|
||
|
||
> **No math structure. No explainability. No one's stamp of approval.**
|
||
> **Your only move is brute force—and the space is so large the universe can't hold it.**
|
||
|
||
---
|
||
|
||
## Core Features
|
||
|
||
| Feature | Description |
|
||
|---------|-------------|
|
||
| 🔑 **Two-factor protection** | System key file (`.key`) + user password |
|
||
| 🧩 **Fully random keys** | Substitution tables, flip patterns, long key, short key all randomly generated |
|
||
| 📁 **Key persistence** | Keys stored obfuscated (Base64 + reversal + shift) to prevent casual reading |
|
||
| 🔁 **Reusable OTP** | Key length ≥ plaintext length, eliminating periodic patterns—OTP-level security |
|
||
| 🛡️ **Quantum-resistant** | No math structure, so Shor/Grover can't speed up brute force |
|
||
| 🚫 **Zero third-party deps** | No OpenSSL, no Crypto, no nothing |
|
||
| 📦 **Ready to use** | Interactive menu, multiple key file support |
|
||
| 🐍 **Pure Python** | Just Python 3.6+, no extra dependencies |
|
||
| 💬 **Encrypted Chat (v2.0)** | ChaosCryptChat: E2E text/images/files/voice, P2P + central server modes |
|
||
|
||
---
|
||
|
||
## Encryption Workflow
|
||
|
||
```
|
||
Plaintext
|
||
↓
|
||
① Base64 encode
|
||
↓
|
||
② Random substitution (26 uppercase + 26 lowercase fully shuffled)
|
||
↓
|
||
③ Case flip (10‑bit random pattern)
|
||
↓
|
||
④ String reversal
|
||
↓
|
||
⑤ Dynamic XOR (4096‑bit long key)
|
||
↓
|
||
⑥ Final XOR (user password + 512‑bit short key derived)
|
||
↓
|
||
Ciphertext (hex)
|
||
```
|
||
|
||
Every random parameter comes from the `.key` file. The user password is only used in the final key derivation step.
|
||
|
||
### Key Derivation Flow
|
||
|
||
```
|
||
User password + short_key (512 bits)
|
||
↓
|
||
Interleave → bitwise mixing → block permutation → reversal
|
||
↓
|
||
Expand to target length (three transformation modes cycled)
|
||
↓
|
||
Final key (length ≥ plaintext)
|
||
```
|
||
|
||
---
|
||
|
||
## Security Analysis
|
||
|
||
### 1. No Mathematical Equations to Write
|
||
|
||
| Traditional Alg | Equation Form | Attack Vector |
|
||
|-----------------|---------------|---------------|
|
||
| RSA | c = m^e mod n | Number field sieve, Shor |
|
||
| AES | State = SBox ∘ ShiftRow ∘ MixCol ∘ AddRoundKey | Differential, Grover |
|
||
| ECC | Q = kP | Discrete log, Shor |
|
||
| **ChaosCrypt** | **No meaningful equation can be written** | **Brute force only** |
|
||
|
||
> Why: substitution is table lookup, flip pattern is a hardcoded array, key derivation is a black-box mix—every step is "random table lookup" with no parseable algebraic structure.
|
||
|
||
### 2. Key Space (Brute‑Force Difficulty)
|
||
|
||
| Component | Space Size | Approx. Value |
|
||
|-----------|------------|---------------|
|
||
| `upper_mapping` | 26! | ~10²⁶ |
|
||
| `lower_mapping` | 26! | ~10²⁶ |
|
||
| `digit_mapping` | ~10! × C(62,10) | ~10¹⁴ |
|
||
| `equal_mapping` | 62×61×60×59 | ~10⁷ |
|
||
| `long_key` (4096‑bit hex) | 16⁴⁰⁹⁶ | ~10⁴⁹³² |
|
||
| `short_key` (512‑bit hex) | 16⁵¹² | ~10⁶¹⁶ |
|
||
| `flip_pattern` | 2¹⁰ | ~10³ |
|
||
| User password (min 8 chars) | ~10⁸ | |
|
||
|
||
**Total search space ≈ 10⁵⁶³²**
|
||
|
||
**Comparisons**:
|
||
|
||
- Atoms in the observable universe: ≈ 10⁸⁰
|
||
- AES‑256 key space: ≈ 10⁷⁷
|
||
- RSA‑2048 key space: ≈ 10⁶¹⁶
|
||
- **ChaosCrypt: ≈ 10⁵⁶³²** (10⁵⁵⁵⁵ × AES)
|
||
|
||
> **Even if every atom in the universe were a quantum computer, they couldn't exhaust this space before the heat death of the cosmos.**
|
||
|
||
### 3. Quantum Resistance
|
||
|
||
| Quantum Alg | Target | Effect on ChaosCrypt |
|
||
|-------------|--------|----------------------|
|
||
| **Shor** | Integer factorization, discrete log | ❌ **Ineffective** – no number‑theoretic structure |
|
||
| **Grover** | Symmetric encryption speedup | ❌ **Ineffective** – space 10⁵⁶³², sqrt gives 10²⁸¹⁶, still >> 10⁸⁰ |
|
||
|
||
**Conclusion: ChaosCrypt is fully immune to known quantum attacks.**
|
||
|
||
### 4. Classical Attack Vectors
|
||
|
||
| Attack | Feasible? | Reason |
|
||
|--------|-----------|--------|
|
||
| Frequency analysis | ❌ | Random substitution destroys frequency patterns |
|
||
| Periodicity analysis | ❌ | Key length ≥ plaintext, no cycles |
|
||
| Known‑plaintext attack | ❌ | Nonlinear ops → overdetermined system with no solution |
|
||
| Chosen‑plaintext attack | ❌ | Even controllable input can't invert the black‑box mapping |
|
||
| Differential/linear | ❌ | No algebraic structure to build differential chains |
|
||
| Brute force | ❌ | Space 10⁵⁶³², physically impossible |
|
||
|
||
**The only real threat**: Theft of `.key` file + password (client‑side compromise, unrelated to the algorithm).
|
||
|
||
---
|
||
|
||
## Why This Is Actually Secure (No‑BS Edition)
|
||
|
||
**Bottom line: It's secure — genuinely secure.** 🤷♂️
|
||
|
||
Look, not every encryption algorithm has to revolve around elliptic curves and prime factorization, waiting for NIST to stamp it "secure." That's not security—that's **a monopoly.** 🤣
|
||
|
||
And let's not forget **Dual_EC_DRBG** — NIST‑certified, standardized, used worldwide for years… and it had an NSA backdoor baked in. So much for standards.
|
||
|
||
So don't give me "academic verification," "third‑party audit," or "standard certification." I'll ask you one question:
|
||
|
||
**Are only those "standard" algorithms allowed to be secure?**
|
||
|
||
- **Secure ≠ mathematically complex**
|
||
- **Secure ≠ NIST‑approved**
|
||
|
||
---
|
||
|
||
Let's see how those "standard" algorithms fare:
|
||
|
||
| Algorithm | Key Space | Quantum Fate |
|
||
|-----------|-----------|--------------|
|
||
| AES‑256 | 10⁷⁷ | Grover halves it to 10³⁸ → theoretically breakable |
|
||
| RSA‑2048 | 10⁶¹⁶ | Shor kills it instantly 🔥 |
|
||
| ECC | 10⁶¹⁶ | Same, Shor shuts it down |
|
||
|
||
Now look at this:
|
||
|
||
| Algorithm | Key Space | Quantum Fate |
|
||
|-----------|-----------|--------------|
|
||
| **ChaosCrypt** | **10⁵⁶³²** | **Shor has nothing to attack, Grover barely scratches it** ✅ |
|
||
|
||
**10⁵⁶³² — what does that mean?**
|
||
|
||
The universe has ~10⁸⁰ atoms. Even if every atom were a quantum computer running from the Big Bang to now, they wouldn't finish a fraction of this space.
|
||
|
||
AES's 10⁷⁷ is a grain of sand compared to the Milky Way.
|
||
|
||
---
|
||
|
||
**RSA is beautiful, right? Standard? Mathematically elegant?**
|
||
|
||
But precisely because it's **too mathematical**, Shor one‑shots it.
|
||
|
||
**The prettier the math, the clearer the structure, the happier the attacker** — because you have equations they can solve, patterns they can exploit, structure they can dismantle.
|
||
|
||
My algorithm?
|
||
|
||
- Substitution? Randomly shuffled — no pattern.
|
||
- Flip pattern? Hardcoded array — no equation.
|
||
- Key derivation? Black‑box mix — unsolvable.
|
||
|
||
**An attacker can't even write an equation. There's no algebraic handle to grab.**
|
||
|
||
---
|
||
|
||
**So what's wrong with this algorithm?**
|
||
|
||
- ❌ No "third‑party security audit"
|
||
- ❌ No "algorithm standard certification"
|
||
- ❌ No "academic validation"
|
||
- ❌ And it "looks pretty amateur"
|
||
|
||
**Other than that, absolutely nothing.** 🤷♂️
|
||
|
||
Looks amateur? Fine. **Can you break it? No.**
|
||
|
||
Security is about **real‑world results**, not **reviews** or **certifications**.
|
||
|
||
- Dual_EC_DRBG had certs, standards, audits — and a backdoor.
|
||
- This has none of that — and **you can't break it.**
|
||
|
||
**If hackers can crack it, it's garbage. If they can't, it's the real deal.**
|
||
|
||
Seriously — **find a flaw. I dare you.** 😏🔥
|
||
|
||
---
|
||
|
||
## 💬 ChaosCryptChat (v2.0 New)
|
||
|
||
**ChaosCryptChat** is an end‑to‑end encrypted chat system built on the ChaosCrypt kernel. All content (text, images, files, voice) is chaos‑encrypted before sending—servers and middlemen cannot read any messages.
|
||
|
||
### Core Features
|
||
|
||
| Feature | Description |
|
||
|---------|-------------|
|
||
| 🔗 **End‑to‑end encryption** | All messages encrypted client‑side; server only relays, holds no group keys |
|
||
| ☁️ **Two group modes** | 🔗 P2P direct + ☁️ Central server (NAT traversal) |
|
||
| 🎤 **Voice messages** | Record → chaos encrypt → send → decrypt & play |
|
||
| 🖼️ **Images / Files** | Binary data encrypted with ChaosCrypt, supports any file type |
|
||
| 👥 **Group management** | Create, join, group name, announcements, kick, owner approval |
|
||
| 🚫 **Message recall** | Recall within 2 minutes of sending |
|
||
| 🔑 **Per‑user keys** | Each user has an independent authentication key to prevent impersonation |
|
||
| 📜 **History** | SQLite local storage (persists across restarts) |
|
||
| 🛡️ **HMAC verification** | Every message carries an HMAC signature to prevent tampering and forgery |
|
||
| 📱 **Key sharing** | Group key can be shared via copy / QR code / file |
|
||
|
||
### Two Group Modes
|
||
|
||
**① End‑to‑End (P2P) Group**: The group owner acts as the server; members connect directly to the owner's host. Ideal for LAN or public‑IP environments. The owner generates the group key and shares it with members.
|
||
|
||
**② Central Server Group**: Run `server.py` (public IP) to handle NAT traversal. The server only handles user authentication, group membership, and message relaying—**it does not hold group keys and cannot decrypt any messages.**
|
||
|
||
### Quick Start
|
||
|
||
#### Launch the Chat Client
|
||
|
||
```bash
|
||
cd ChaosCryptChat
|
||
python qtmain.py
|
||
```
|
||
|
||
#### Launch the Central Server (optional, for public/NAT scenarios)
|
||
|
||
```bash
|
||
cd ChaosCryptChat
|
||
python server.py 8666
|
||
```
|
||
|
||
#### Install Dependencies
|
||
|
||
```bash
|
||
pip install PyQt5 # Required, GUI
|
||
pip install pygame # Audio playback (optional)
|
||
pip install sounddevice numpy # Recording (optional, or pyaudio)
|
||
pip install Pillow # Image display (optional)
|
||
pip install qrcode # Group key QR codes (optional)
|
||
```
|
||
|
||
> Only PyQt5 is required; all others are optional. Missing dependencies disable their respective features gracefully.
|
||
|
||
### Usage Workflow
|
||
|
||
1. **Register / Login**: Create a local account on startup (PBKDF2 password hash, auto‑login supported)
|
||
2. **Create a Group**: Click 「📡 Create Group」, copy the group key or generate a QR code to share with friends
|
||
3. **Join a Group**: Click 「📥 Join Group」, paste the group key or scan the QR code
|
||
4. **Start Chatting**: Send text, images, files, voice messages; right‑click to recall, share, or download; group owners can kick, set announcements, and change group names
|
||
|
||
---
|
||
|
||
## Quick Start
|
||
|
||
### Installation
|
||
|
||
```bash
|
||
# Clone the repository
|
||
git clone https://gitcode.com/dvsxt/chaoscrypt.git
|
||
git clone https://github.com/dvs-dvsxt/ChaosCrypt.git
|
||
cd chaoscrypt
|
||
|
||
# Core module has zero dependencies — Python 3.6+ only
|
||
# ChaosCryptChat requires PyQt5
|
||
```
|
||
|
||
### Five‑Minute Example
|
||
|
||
```python
|
||
from chaoscrypt import EncryptionSystem
|
||
|
||
# Initialize (auto‑loads default key; generates one if missing)
|
||
crypto = EncryptionSystem()
|
||
|
||
# Encrypt
|
||
cipher = crypto.encrypt("Hello World", user_password="MyP@ssw0rd2024!")
|
||
print(cipher)
|
||
|
||
# Decrypt
|
||
plain = crypto.decrypt(cipher, user_password="MyP@ssw0rd2024!")
|
||
print(plain) # Hello World
|
||
```
|
||
|
||
### Command‑Line Interactive Mode
|
||
|
||
```bash
|
||
python chaoscrypt.py
|
||
```
|
||
|
||
---
|
||
|
||
## Usage Guide
|
||
|
||
### Interactive Menu
|
||
|
||
```
|
||
Please select an action:
|
||
1. Encrypt using the default key
|
||
2. Decrypt using the default key
|
||
3. Generate a new key (overwrite default)
|
||
4. Encrypt using a specified key file
|
||
5. Decrypt using a specified key file
|
||
6. Generate a key and save to current folder
|
||
7. View current key info
|
||
8. Exit
|
||
```
|
||
|
||
### Key File
|
||
|
||
Keys are stored in an obfuscated format to prevent casual reading. Contents include:
|
||
|
||
- `upper_mapping` – random substitution for uppercase letters
|
||
- `lower_mapping` – random substitution for lowercase letters
|
||
- `digit_mapping` – digit‑to‑character mapping
|
||
- `equal_mapping` – equal‑sign mapping
|
||
- `long_key` – 4096‑bit hexadecimal key
|
||
- `short_key` – 512‑bit hexadecimal key
|
||
- `generated_at` – timestamp
|
||
|
||
---
|
||
|
||
## API Reference
|
||
|
||
### `EncryptionSystem(key_file=None)`
|
||
|
||
Initialize the encryption system.
|
||
|
||
**Parameters:**
|
||
- `key_file` (str, optional) – path to the key file. If `None`, loads `encryption.key`; generates one if missing.
|
||
|
||
**Example:**
|
||
```python
|
||
# Use default key
|
||
crypto = EncryptionSystem()
|
||
|
||
# Use a custom key file
|
||
crypto = EncryptionSystem("my_key.key")
|
||
```
|
||
|
||
---
|
||
|
||
### `encrypt(plaintext, user_password)`
|
||
|
||
Encrypt plaintext.
|
||
|
||
**Parameters:**
|
||
- `plaintext` (str) – text to encrypt
|
||
- `user_password` (str) – user password
|
||
|
||
**Returns:**
|
||
- `str` – hexadecimal ciphertext
|
||
|
||
**Example:**
|
||
```python
|
||
cipher = crypto.encrypt("Hello", "myPass123")
|
||
```
|
||
|
||
---
|
||
|
||
### `decrypt(ciphertext, user_password)`
|
||
|
||
Decrypt ciphertext.
|
||
|
||
**Parameters:**
|
||
- `ciphertext` (str) – hexadecimal ciphertext
|
||
- `user_password` (str) – user password
|
||
|
||
**Returns:**
|
||
- `str` – decrypted plaintext, or an error message on failure
|
||
|
||
**Example:**
|
||
```python
|
||
plain = crypto.decrypt("a1b2c3...", "myPass123")
|
||
```
|
||
|
||
---
|
||
|
||
### `generate_keys(save_path=None)`
|
||
|
||
Generate new random keys and save them.
|
||
|
||
**Parameters:**
|
||
- `save_path` (str, optional) – save path; defaults to `key_{timestamp}.key`
|
||
|
||
**Returns:**
|
||
- `str` – the saved file path
|
||
|
||
---
|
||
|
||
### `print_keys()`
|
||
|
||
Print the current key information.
|
||
|
||
---
|
||
|
||
## FAQ
|
||
|
||
**Q: Has this algorithm been audited?**
|
||
A: No. But we believe **no audit ≠ insecure** — Dual_EC_DRBG was audited and backdoored. Audits are references, not truth.
|
||
|
||
**Q: Why not just use AES?**
|
||
A: AES is great, but it's a "standard" algorithm with algebraic structure, and Grover can speed it up. We chose a different path — **fully random, structure‑free, and enormous.**
|
||
|
||
**Q: What if an attacker gets the `.key` file and the ciphertext, but not the password?**
|
||
A: Then they're left with brute‑forcing the password. If the password is 12+ characters strong, that's years of work.
|
||
|
||
**Q: What if the attacker gets the `.key`, ciphertext, and password?**
|
||
A: Then your system isn't "crypto broken" — it's "keys stolen." That's a client‑side security issue, which no encryption algorithm can prevent.
|
||
|
||
**Q: Is there a mathematical proof for this?**
|
||
A: Yes. The proof is:
|
||
- No mathematical model can be constructed → no algebraic attacks
|
||
- Key space 10⁵⁶³² → brute force impossible
|
||
- Quantum speedups don't help → quantum‑resistant
|
||
|
||
This proof is stronger than any "reduction to a hard problem" — because **there's no structure to reduce, only exhaustive search.**
|
||
|
||
**Q: It looks so amateurish — is it actually usable?**
|
||
A: Looking amateur and being secure have nothing to do with each other. Can you break it or not? **Try it.**
|
||
|
||
**Q: Is ChaosCryptChat secure?**
|
||
A: End‑to‑end — messages are encrypted client‑side with the group key; the server forwards only ciphertext and holds no keys. Even if the server is breached, chat contents remain private.
|
||
|
||
**Q: How do I share the group key?**
|
||
A: After creating a group, the owner can share the key via copied text, QR code, or key file. Use a trusted channel to avoid MITM interception.
|
||
|
||
**Q: Does ChaosCryptChat require a public IP?**
|
||
A: No. Use P2P for LAN; for cross‑network, the central server (`server.py`) relays traffic to handle NAT.
|
||
|
||
---
|
||
|
||
## Project Structure
|
||
|
||
```
|
||
chaoscrypt/
|
||
├── chaoscrypt.py # Main program (encrypt/decrypt/key management)
|
||
├── README.md # This document
|
||
├── SECURITY.md # Security details
|
||
└── ChaosCryptChat/ # 💬 Encrypted Chat (v2.0 new)
|
||
├── qtmain.py # PyQt5 chat client (E2E encrypted)
|
||
└── server.py # ☁️ Central server (NAT traversal / message relay)
|
||
```
|
||
|
||
The core is just three files with zero dependencies; ChaosCryptChat is the v2.0 addition.
|
||
|
||
---
|
||
|
||
## Disclaimer
|
||
|
||
> **This system is for educational and research purposes only.**
|
||
> The author assumes no liability for data loss due to key file leakage, password theft, or client‑side compromise.
|
||
> In production, ensure the `.key` file and user password are stored securely, and enforce strong password policies.
|
||
> **ChaosCryptChat** servers do not hold group keys, but they do log login information and relay metadata—choose your server wisely.
|
||
> Group keys are shared by the group owner; transmit them over trusted channels. Even if the server is compromised, historical chat content remains private.
|
||
|
||
---
|
||
|
||
## 📜 License
|
||
|
||
MIT License — you are free to use, modify, and distribute, but please retain the original attribution.
|
||
|
||
---
|
||
|
||
## 🙏 Acknowledgments
|
||
|
||
Thank you to everyone who read this document carefully.
|
||
You are among the few who judge security by **logic**, not by **credentials**.
|
||
|
||
---
|
||
|
||
**"Security should be defined by the difficulty of attack, not by a stamp from an institution."**
|
||
— ChaosCrypt Design Philosophy
|
||
|
||
---
|
||
|
||
**Happy Encrypting! 🔐**
|