Skip to main content

Cryptographie Algébrique Géométrique par Ondes et Logique Entrelacée

Project description

CAGOULE v1.1

Python Version Tests License GitHub Actions Code style z Cryptographie Algébrique Géométrique par Ondes et Logique Entrelacée

Système de chiffrement symétrique hybride fusionnant des primitives cryptographiques modernes avec des structures mathématiques issues du Concours Général Sénégalais 2025 (CGS2025).


Architecture

Plaintext
  │
  ▼  PKCS7 pad → blocs de 16 octets → Z/pZ
  ▼
┌─────────────────────────────────────────┐
│  CBC-like interne                       │
│  1. v = m + prev_cipher mod p           │  ← mixing
│  2. w = P × v mod p                     │  ← diffusion Vandermonde
│  3. u = S-box(w)                        │  ← confusion x³+cx
│  4. c = u + round_key_Ω mod p          │  ← clé de ronde ζ(2n)
└─────────────────────────────────────────┘
  │
  ▼  ChaCha20-Poly1305 (RFC 8439) — AEAD
  │
Format CGL1 : Magic(4) | Version(1) | Salt(32) | Nonce(12) | CT | Tag(16)

Paramètres dérivés depuis le mot de passe

Paramètre Dérivation Rôle
n HKDF ∈ [4, 65536] paramètre de ζ(2n) pour les round keys
p HKDF → nextprime(≈2⁶⁴) corps de travail Z/pZ
µ racine de x⁴+x²+1 dans Z/pZ ou Fp² nœud de la matrice Vandermonde
c HKDF → S-box x³+cx constante de confusion
K_stream HKDF → 256 bits clé ChaCha20
Round keys ζ(2n) → coefficients de Fourier → HKDF 64 clés de ronde

Constantes CGS2025

  • ζ(8) = π⁸/9450 (identité vérifiée à 60 décimales)
  • x₀ = 3π (solution de cos(π/4 − x/3) = −√2/2)
  • ρ = (1+√5)/2 (nombre d'or)

Installation

pip install .
# Avec dépendances de développement :
pip install ".[dev]"

Dépendances

  • cryptography ≥ 42 — ChaCha20-Poly1305, HKDF, Scrypt
  • mpmath ≥ 1.3 — précision arbitraire pour ζ(2n)
  • argon2-cffi ≥ 23 — KDF principal (fallback Scrypt si absent)

Utilisation

Python API

from cagoule import encrypt, decrypt, CagouleAuthError

# Chiffrement
ct = encrypt(b"Message secret", b"mon_mot_de_passe")

# Déchiffrement
plaintext = decrypt(ct, b"mon_mot_de_passe")

# Mauvais mot de passe → exception typée
try:
    decrypt(ct, b"mauvais")
except CagouleAuthError:
    print("Authentification échouée")

CLI

# Chiffrer un fichier
cagoule encrypt secret.txt -p "MonMotDePasse"

# Déchiffrer
cagoule decrypt secret.txt.cgl1 -p "MonMotDePasse"

# Inspecter (sans déchiffrer)
cagoule inspect secret.txt.cgl1

# Benchmark
cagoule bench -n 5

# Version
cagoule version

Format CGL1

Offset Taille Champ
0–3 4 Magic : CGL1 (0x43474C31)
4 1 Version : 0x01
5–36 32 Salt Argon2id (inclus dans AAD)
37–48 12 Nonce ChaCha20 (96 bits)
49–N variable Ciphertext ChaCha20
N–N+16 16 Tag Poly1305

Overhead fixe : 65 octets.


Structure du projet

cagoule/
├── pyproject.toml
├── README.md
└── cagoule/
    ├── __init__.py          # API publique
    ├── __version__.py       # version
    ├── cipher.py            # chiffrement CBC-like + AEAD
    ├── decipher.py          # déchiffrement inverse
    ├── params.py            # dérivation complète des paramètres
    ├── omega.py             # pilier Ω : ζ(2n) → round keys
    ├── sbox.py              # S-box x³+cx et fallback x^d
    ├── matrix.py            # matrices Vandermonde / Cauchy mod p
    ├── mu.py                # racine de x⁴+x²+1 (Z/pZ ou Fp²)
    ├── fp2.py               # extension quadratique Fp²
    ├── constants.py         # constantes CGS2025
    ├── format.py            # parsing / sérialisation CGL1
    ├── cli.py               # interface ligne de commande
    └── kat_vectors.json     # Known Answer Tests v1.1

Tests

pytest
pytest --cov=cagoule

Sécurité

  • KDF : Argon2id (t=3, m=64 MB, p=1) — fallback Scrypt (n=2¹⁷)
  • AEAD : ChaCha20-Poly1305 RFC 8439 — authentification + confidentialité
  • Entropie supplémentaire : n ∈ [4, 65536] secret → les round keys sont mathématiquement irrécupérables sans n
  • Tag invalideCagouleAuthError sans fuite d'information

⚠️ Ce projet est à but académique et expérimental. Ne pas utiliser en production sans audit de sécurité indépendant.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cagoule-1.2.0.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cagoule-1.2.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file cagoule-1.2.0.tar.gz.

File metadata

  • Download URL: cagoule-1.2.0.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cagoule-1.2.0.tar.gz
Algorithm Hash digest
SHA256 25e81e850b086fe744777fecce4701e30bb7ab4360b9280789ec7e4bfc115f13
MD5 a00169bea75aa855577503c9adc200c2
BLAKE2b-256 c736d864f55c9f3dc94326747f9c24f50c99b1e0b06aa00e312dc4d3c2842904

See more details on using hashes here.

File details

Details for the file cagoule-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: cagoule-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cagoule-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b61c4c8fe9f941184072c6f3e0bb7085a9036c078ea727a92e5acbd79ba5a9ef
MD5 2ea1c3f4892aa9cb1674965e2b08887b
BLAKE2b-256 c1bb288c1a854fc87c17141f7c56cd98a9161d7b2da0018ddea87dfc410a8090

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page