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.1.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.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cagoule-1.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 41dd65c53328d71992316c208adaa7e3585b2c715d71570464f0665d97c49e28
MD5 a4f265371a06980f7b74e0c442c77622
BLAKE2b-256 0baf51f27346dc1e6b62e0b9e830445d1e8932407aaa1f868e7b3058dfb0ce26

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cagoule-1.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 86a69837cfed97e415ac9feeb751ccadf2949feb5a3f97483adb6a3ba3b86fc0
MD5 dfa218986bf4ec9f9074ba507ee2affe
BLAKE2b-256 3a41e427b9dd09543597eb6f23610a96ef2453f423daba16b849e7fbf1764888

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