dart_ase 1.0.0
dart_ase: ^1.0.0 copied to clipboard
A Dart package for quantum-secure encryption functionalities.
dart-ASE 🚀🔒 #
Actually Secure Encryption (ASE) #
dart-ASE is a proof‑of‑concept library implementing a hybrid lattice‑based KEM + AES‑GCM scheme in pure Dart.
Warning: This code has never been audited by professional cryptographers or security experts. Not recommended for use in production or for securing real data!
🚀 Features #
-
Post‑Quantum KEM
- Ring‑learning‑with‑errors based key encapsulation
- Modular arithmetic over (q = 3329), polynomial degree (n = 256)
- Noise sampling parameter (eta = 1)
-
Hybrid AEAD
- Derives a 256‑bit AES‑GCM key via HKDF(SHA‑256) from the KEM shared secret
- Authenticated encryption with 96‑bit nonce, 128‑bit tag
-
Pure Dart
- No native extensions
- Zero‑dependency aside from cryptography
-
CLI Tools
gen: generate keypair (pubkey.json & privkey.json)enc: encrypt plaintext → ciphertext.jsondec: decrypt ciphertext.json → prints your message
💻 Quickstart #
-
Clone & install
git clone https://github.com/RafaeloxMC/dart-ASE.git cd dart-ASE dart pub get -
Generate a key pair
dart run main_secure.dart gen # → pubkey.json & privkey.json -
Encrypt a message
dart run main_secure.dart enc pubkey.json "Hello, ASE is cool!" # → ciphertext.json -
Decrypt the message
dart run main_secure.dart dec privkey.json ciphertext.json # → prints: Hello, ASE is cool!
🔍 How It Works #
-
KEM KeyGen
- Generate public matrix $A\in R_q^{k\times k}$ and secret vector $\mathbf{s}\in R_q^k$.
- Compute $\mathbf{b} = A\mathbf{s} + \mathbf{e}$ with small error $\mathbf{e}$.
-
KEM Encapsulation
- Sample ephemeral $\mathbf{r}\in R_q^k$ and noise $\mathbf{e}_1,\mathbf{e}_2$.
- Compute $\mathbf{u} = A^T\mathbf{r} + \mathbf{e}_1$ and encode message bits into $\mathbf{v}$.
-
Shared Secret
-
Decapsulation recovers $\mathbf{r}$ from $\mathbf{u},\mathbf{v}$.
-
Derive a symmetric key via HKDF‑SHA256:
$$\mathrm{AES_Key} = \mathrm{HKDF}(\mathbf{r})$$
-
-
AES‑GCM AEAD
- Encrypt arbitrary plaintext under the derived 256‑bit key.
- Outputs AEAD ciphertext + 128‑bit MAC.
⚠️ Security Disclaimer #
This library is (probably) not production‑safe. No security experts or cryptographers have reviewed or audited this implementation. Use this code for learning and experimentation only — never for real-world confidentiality.
🤝 Contributing #
- Fork the repo
- Create your feature branch (
git checkout -b feature/XYZ) - Commit your changes (
git commit -m "Add XYZ") - Push to the branch (
git push origin feature/XYZ) - Open a Pull Request
📄 License #
This project is licensed under the GNU General Public License v3.