CIA/e-voting-system
Alexis Bruneteau adfec105d8 fix: Correct ElGamal public key base64 encoding consistency
## Issue
ElGamal encryption failed with "Invalid base64: 23:5:9..." error because:
- `/api/votes/setup` stored public key as base64-encoded bytes
- `/api/admin/init-keys` stored public key as raw UTF-8 bytes
- Client received plain "p:g:h" text instead of base64, causing decoding failure

## Root Cause
Inconsistent storage format:
- votes.py line 505: `base64.b64encode(elgamal.public_key_bytes)`
- admin.py line 169: `elgamal.public_key_bytes` (no encoding)
- Return paths decoded base64 as UTF-8, exposing plain format to client

## Fix
1. Both endpoints now consistently store `base64.b64encode(elgamal.public_key_bytes)`
2. Return paths decode base64 to ASCII (which is valid base64 format)
3. Updated validation in admin.py to properly decode base64 before validation
4. Frontend ElGamalEncryption.encrypt() expects base64 input, now receives it correctly

## Files Changed
- backend/routes/votes.py: Lines 505, 513, 550
- backend/routes/admin.py: Lines 159-162, 169, 182

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 19:33:22 +01:00
..

E-Voting System - Post-Quantum Cryptography

Système de vote électronique sécurisé avec cryptographie post-quantique hybride certifiée NIST FIPS 203/204.

🚀 Démarrer

# Lancer tous les services
docker-compose up -d

# Frontend: http://localhost:3000
# API: http://localhost:8000/docs
# Database: localhost:3306

🔐 Sécurité Post-Quantique

  • Signatures: RSA-PSS + ML-DSA-65 (Dilithium) - FIPS 204
  • Chiffrement: ML-KEM-768 (Kyber) + ElGamal - FIPS 203
  • Hachage: SHA-256 (quantum-resistant)
  • Approche hybride: Defense-in-depth

Voir .claude/POSTQUANTUM_CRYPTO.md pour les détails.

📁 Structure

.
├── docker/                 # Configuration Docker
├── src/
│   ├── backend/           # API FastAPI
│   ├── crypto/            # Cryptographie classique + PQC
│   └── frontend/          # Interface web
├── tests/                 # Tests unitaires
├── docker-compose.yml
└── README.md

🧪 Tests

pytest tests/ -v

🔑 Clés Cryptographiques

  • Génération: Clés hybrides RSA + Dilithium + Kyber à l'inscription
  • Stockage: Base de données sécurisée
  • Signatures: RSA-PSS + Dilithium sur chaque vote
  • Chiffrement: ML-KEM-768 (Kyber)

📊 Endpoints API

  • POST /api/auth/register - Inscription avec génération de clés PQC
  • POST /api/auth/login - Authentification JWT
  • GET /api/elections/active - Élection active
  • POST /api/votes/submit - Vote signé avec signatures hybrides
  • GET /api/elections/{id}/results - Résultats

Voir http://localhost:8000/docs pour API interactive.


Production-ready post-quantum e-voting system 🔐 MIT