An open API service indexing awesome lists of open source software.

https://github.com/sethuiyer/chaosencrypt

Deterministic chaos meets encryption. A prime-fueled, keystream-based cipher with stealth key exchange.
https://github.com/sethuiyer/chaosencrypt

Last synced: 2 months ago
JSON representation

Deterministic chaos meets encryption. A prime-fueled, keystream-based cipher with stealth key exchange.

Awesome Lists containing this project

README

        

# CHAOSENCRYPT (PCE-100x)

[![NIST-RNG Pass](https://img.shields.io/badge/NIST--SP800--22-14%2F15%20PASS-green)](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-22r1a.pdf)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Version](https://img.shields.io/badge/version-1.0-orange.svg)](https://github.com/sethuiyer/chaosencrypt/releases)
[![Documentation](https://img.shields.io/badge/docs-available-brightgreen.svg)](./PAPER.md)
[![Demo](https://img.shields.io/badge/demo-live-blue.svg)](https://sethuiyer.github.io/chaosencrypt/index.html)
[![Entropy](https://img.shields.io/badge/entropy-7.98%20bits%2Fbyte-purple.svg)](https://en.wikipedia.org/wiki/Entropy_(information_theory))
[![Cycle Length](https://img.shields.io/badge/cycle%20length-10M%2B%20steps-yellow.svg)](https://en.wikipedia.org/wiki/Cycle_detection)
[![Python](https://img.shields.io/badge/python-3.x-blue.svg)](https://www.python.org/)
[![GitHub](https://img.shields.io/github/stars/sethuiyer/chaosencrypt?style=social)](https://github.com/sethuiyer/chaosencrypt)

> **Author**: Sethu Iyer
> **Last Updated**: 2025-03-29

**CHAOSENCRYPT** (PCE-100x) is an experimental, prime-fueled, keystream-based cipher that marries deterministic chaos with encryption, featuring a unique stealth key exchange mechanism and emergent semantic properties.

## ๐Ÿš€ Core Concepts

- **Prime-Based Chaotic Generator:** Employs the formula `xโ‚™โ‚Šโ‚ = (prime * xโ‚™) mod 1` to generate statistically strong pseudo-random sequences.
- **Dynamic Step Count (`k`):** A variable iteration count that obfuscates the encryption process, adding a layer of security.
- **XOR Keystream:** Protects data integrity and prevents direct correlations between plaintext and ciphertext.
- **Orbit Break Key Exchange:** A novel, covert method for sharing the secret step count `k` without explicit transmission.
- **MAC-Based Integrity:** A simple yet effective Message Authentication Code for tamper detection.
- **Semantic Clustering:** An unexpected emergent property that preserves semantic relationships in ciphertext.

## ๐ŸŽฏ Key Features

- **High-Quality Chaotic PRNG:** Achieves impressive statistical randomness, passing 14/15 NIST SP800-22 tests.
- **Long Cycles:** Exhibits cycle lengths exceeding 10 million steps, reducing repetition risk.
- **Statistical and Cryptographic Strength:** Combines the chaotic nature of the map with dynamic parameters and XOR to create a robust system.
- **Stealth Key Exchange:** Utilizes "Orbit Break" to securely share the step count `k`.
- **Semantic Preservation:** Retains some semantic relationships in ciphertext, enabling potential new applications.
- **Lightweight and Portable:** Implementable in minimal compute environments.

## ๐Ÿงช Experimental Validation

Our research includes rigorous testing:

- **NIST Statistical Tests:** Achieved 14/15 pass rate (SP800-22).
- **Cycle Length Experiments:** 10M+ steps without repetition.
- **Prime-Digit Precision Hypothesis:** Uncovered "Chaotic Harmonics" phenomenon.
- **Entropy Rate Tracking:** Approaching 7.98 bits/byte.
- **MAC Collision Resistance Simulation:** Showed robustness of the MAC.
- **Semantic Clustering Phenomenon:** Documented the preservation of semantic relationships in ciphertext.

## ๐Ÿงฉ Core Mechanisms

### ๐Ÿ”„ Chaotic Map

> `xโ‚™โ‚Šโ‚ = (prime * xโ‚™) mod 1`

- `prime`: Typically `9973`, or a sequence (e.g., `[9973, 9941, 9929]`) for deeper mixing.
- Cycle length: Can exceed millions of steps.

### ๐Ÿ”ข Dynamic Step Count & KDF

- Iterates the map `k` times.
- `k` can be fixed, dynamic (derived), or communicated via Orbit Break.
- KDF: `k_derived = (baseK + secret + chunkIndex) mod 50 + 1`

### ๐Ÿ” XOR Keystream Mode

- `state_k % 256` as keystream bytes.
- `ciphertext = plaintext โŠ• keystream`.

### ๐Ÿ” MAC Computation & Verification

- `MAC = (ฮฃ(ciphertextValues) + secret) mod MAC_PRIME`.
- `MAC_PRIME`: Large prime (e.g., `1e65 + 67`).

### ๐Ÿค Orbit Break Key Exchange

1. Both parties share an initial seed.
2. Bob iterates and sends results.
3. At `k+1`, Bob sends noise.
4. Alice detects the break and infers `k`.

## ๐Ÿ› ๏ธ Command-Line Interface (CLI)

A Python CLI is available for all core features:
```
bash
# Basic encryption
./chaosencrypt_cli.py encrypt --secret "your-secret" "Hello, World!"

# Advanced encryption with all options
./chaosencrypt_cli.py encrypt \
--precision 12 \
--primes "9973,9941,9929" \
--chunk-size 16 \
--base-k 6 \
--dynamic-k \
--xor \
--mac \
--secret "your-secret" \
"Your message here"

# Decryption
./chaosencrypt_cli.py decrypt \
--secret "your-secret" \
--mac-value "MAC_VALUE" \
"CIPHERTEXT_HEX"
```
### CLI Features

- `--precision`: Calculation precision (default: 12).
- `--primes`: Comma-separated list for deeper mixing.
- `--chunk-size`: Chunk size for large messages.
- `--base-k`: Base iteration count.
- `--dynamic-k`: Enable/disable dynamic `k`.
- `--xor`: Toggle XOR mode.
- `--mac`: Enable/disable MAC.
- `--secret`: Shared secret.
- `--mac-value`: MAC value for decryption.

### Example Usage
```
bash
# 1. Encrypt
$ ./chaosencrypt_cli.py encrypt --secret "test123" "Hello, CHAOSENCRYPT!"
Ciphertext (hex): 499015a15ec9096a0ea7b5c9b0
MAC: 804242536103942577353638559904425649505215714466728195510131525952

# 2. Decrypt
$ ./chaosencrypt_cli.py decrypt --secret "test123" --mac-value "804242536103942577353638559904425649505215714466728195510131525952" "499015a15ec9096a0ea7b5c9b0"
Decrypted message: Hello, CHAOSENCRYPT!
```
## ๐Ÿ’ก Advantages

- **Simplicity and Adaptability:** Easy to understand and modify.
- **Long Orbits:** Challenges attackers with long, non-repeating sequences.
- **Covert Key Signals:** Orbit Break provides stealthy key exchange.
- **Portability:** Runs on minimal hardware (JavaScript, Python).
- **Emergent Semantics**: Preserves some semantic relationships.

## โš ๏ธ Limitations

- **Experimental:** Not NIST-approved.
- **Implementation Errors:** Sensitive to coding mistakes.
- **MAC is "Toy":** Use HMAC for production.
- **Seed/Key Management:** Critical for security.
- **CPA Attacks:** Potential weakness with simplistic `k` derivation.

## ๐Ÿ”’ Security Considerations

- **COA:** Challenging unless the attacker can exhaust an enormous parameter space.
- **KPA:** Difficult due to dynamic `k` and separate chunk processing.
- **CPA:** Design your KDF carefully to avoid patterns.
- **MAC Forgery:** Nearly impossible with a hidden secret.
- **Orbit Break Exploit:** Secure if the attacker does not share the prime seed.

## ๐Ÿ“– Table of Contents

1. [Core Concepts](#-core-concepts)
2. [Key Features](#-key-features)
3. [Experimental Validation](#-experimental-validation)
4. [Core Mechanisms](#-core-mechanisms)
- [Chaotic Map](#-chaotic-map)
- [Dynamic Step Count & KDF](#-dynamic-step-count--kdf)
- [XOR Keystream Mode](#-xor-keystream-mode)
- [MAC Computation & Verification](#-mac-computation--verification)
- [Orbit Break Key Exchange](#-orbit-break-key-exchange)
5. [Command-Line Interface (CLI)](#-command-line-interface-cli)
- [CLI Features](#cli-features)
- [Example Usage](#example-usage)
6. [Advantages](#-advantages)
7. [Limitations](#-limitations)
8. [Security Considerations](#-security-considerations)
9. [Further Reading](#-further-reading)

## ๐Ÿ“š Further Reading

- **[1]** Blum, L., Blum, M., & Shub, M., *A Simple Unpredictable Pseudo-Random Number Generator*, SIAM Journal on Computing, 1986.
- **[2]** Shanon, C. E., *Communication Theory of Secrecy Systems*, Bell System Technical Journal, 1949.
- **[3]** NIST SP 800-22, *A Statistical Test Suite for Random and Pseudorandom Number Generators for Cryptographic Applications*.
- **[4]** Menezes, A. J., van Oorschot, P. C., & Vanstone, S. A., *Handbook of Applied Cryptography*, 5th ed.

---

Explore the fascinating world of prime-driven chaos and discover the surprising properties of CHAOSENCRYPT!