3 Commits

Author SHA1 Message Date
Alexis Bruneteau
c979f1a760 fix: Comprehensive ElGamal encryption system - DRY & KISS principles
Major improvements applying DRY (Don't Repeat Yourself) and KISS (Keep It Simple, Stupid):

BACKEND CHANGES:
- Fixed public key storage: Store as base64-encoded bytes in LargeBinary column (not double-encoding)
- ElGamal key generation now produces proper "p:g:h" format with colons
- Removed all double base64-encoding issues
- Simplified API responses to decode bytes to UTF-8 strings for JSON serialization

FRONTEND CHANGES:
- Refactored ElGamalEncryption.encrypt() to use extracted helper methods (_decodeBase64, _parsePublicKey)
- Eliminated nested error handling - now uses clear, composable private methods
- Improved error messages with specific format validation
- Simplified cryptographic operations by reducing code duplication

TESTING:
- Verified public key format: "p:g:h" properly encoded as base64
- Full vote submission flow tested and working
- Blockchain integration confirmed functional
- No encryption errors during vote submission

This fixes the original "Invalid public key format" error that was preventing vote submission.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 19:17:24 +01:00
E-Voting Developer
dfdf159198 fix: ElGamal encryption, vote deduplication, and frontend data validation
- Fixed ElGamal class instantiation in votes.py (ElGamalEncryption instead of ElGamal)
- Fixed public key serialization in admin.py (use public_key_bytes property)
- Implemented database migration with SQL-based key generation
- Added vote deduplication endpoint: GET /api/votes/check
- Protected all array accesses with type validation in frontend
- Fixed vote parameter type handling (string to number conversion)
- Removed all debug console logs for production
- Created missing dynamic route for vote history details

Fixes:
- JavaScript error: "can't access property length, e is undefined"
- Vote deduplication not preventing form display
- Frontend data validation issues
- Missing dynamic routes
2025-11-08 00:05:19 +01:00
Alexis Bruneteau
3aa988442f fix: Correct ElGamal public key serialization and .gitignore Python lib paths
- Fix ElGamalEncryption to generate keypair on initialization and provide public_key_bytes property with proper "p:g:h" UTF-8 format
- Add ElGamal alias for backward compatibility with imports
- Improve frontend error handling with detailed base64 decode error messages
- Update .gitignore to specifically ignore backend/lib/ and backend/lib64/ instead of all lib directories, preserving frontend node_modules-style lib/

This fixes the "Invalid public key format" error that was preventing vote submission during testing.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 18:19:48 +01:00