Metadata-Version: 2.4
Name: neva256
Version: 0.1.0
Summary: NEVA-256: experimental self-synchronizing cipher (NOT for production secrets)
Author: EWX-AI
License-Expression: MIT
Project-URL: Homepage, https://github.com/ewxai/ewxai
Project-URL: Repository, https://github.com/ewxai/ewxai
Keywords: cipher,experimental,self-synchronizing,educational,ctf
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Education
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: fast
Requires-Dist: neva256-native<0.2,>=0.1.0; extra == "fast"

# neva256 — NEVA-256 for Python

Port bit-exact dari implementasi TypeScript di `src/neva/neva.ts`.
Ciphertext yang dihasilkan **kompatibel lintas bahasa** (diverifikasi lewat
known-answer test + uji silang Python ↔ Node).

> ⚠️ **EKSPERIMENTAL.** NEVA belum pernah dianalisis kriptografer. Jangan pakai
> untuk melindungi data rahasia sungguhan — gunakan AES-256-GCM, libsodium,
> atau `cryptography` untuk produksi. Cocok untuk: belajar, CTF, obfuscation,
> watermark, dan eksperimen.

## Instalasi

```bash
pip install neva256                 # pure Python (jalan di mana saja)
pip install "neva256[fast]"        # + akselerator Rust/PyO3 (~360x lebih cepat)
```

Dari repo ini:

```bash
cd python && pip install -e .              # pure Python
cd python/rust && pip install maturin && maturin develop --release   # + native
```

Backend native dipakai otomatis bila tersedia, dan jatuh kembali ke pure Python
kalau tidak. Eksplisit: `NevaCipher(key, nonce, use_native=True/False)`; cek
`cipher.backend` (`"native"` atau `"python"`) dan konstanta `NATIVE_AVAILABLE`.

## Pemakaian

```python
from neva256 import NevaCipher, generate_key, generate_nonce

key = generate_key()            # simpan ini (32 byte)
nonce = generate_nonce()        # acak per pesan (16 byte)

cipher = NevaCipher(key, nonce)

blob = cipher.encrypt_text("halo dunia 🌪️")   # string base64 (ct || tag)
print(cipher.decrypt_text(blob))             # 'halo dunia 🌪️'

# bytes
data = b"\x00\x01\x02"
sealed = cipher.encrypt_bytes(data)
assert cipher.decrypt_bytes(sealed) == data

# mode toleran kerusakan: 1 byte rusak hanya merusak ~5 byte sekitarnya
partial = cipher.decrypt_bytes(corrupted, verify=False)
```

Salah kunci atau ciphertext yang diubah → `NevaError`
(`integrity check failed`).

## CLI

```bash
neva256 keygen
neva256 enc "rahasia" --key <64-hex>
neva256 dec "<nonceHex>:<base64>" --key <64-hex>
echo "teks dari pipe" | neva256 enc - --key <64-hex>
```

## Test

```bash
cd python
python -m unittest discover -s tests -v
```

Test mencakup known-answer vectors dari implementasi TypeScript, round-trip
(a–4 KB), deteksi tamper, validasi ukuran key/nonce, dan sifat
self-synchronizing.

## Catatan keamanan

Lihat `src/neva/README.md` untuk matriks serangan lengkap: differential per
round, kurva sensitivitas rotasi, hill-climbing, SMT/Z3, dan temuan
equivalent-key pada versi 1-swirl. Ringkasnya: implementasi ini memakai
**4 swirl** dengan margin satu round di atas ambang kebersihan statistik
terukur — tapi statusnya tetap eksperimental.

## Performa (terukur di aarch64)

| Backend | Encrypt 1 MB | Throughput |
| --- | --- | --- |
| Pure Python | 31.3 s | 0.03 MB/s |
| **Native (Rust/PyO3)** | **87 ms** | **11.5 MB/s** |

Native ~360× lebih cepat dan melepas GIL: 4 thread paralel = 2.5× speedup pada
mesin uji. Implementasi TypeScript ~3 MB/s (native Rust ~4× lebih cepat dari itu).
Untuk teks/payload kecil, pure Python sudah cukup.
