-
Notifications
You must be signed in to change notification settings - Fork 20.7k
Open
Labels
Description
What would you like to Propose?
Title: Add ElGamal Encryption and Decryption Algorithm Implementation
🧠 Overview
I propose implementing the ElGamal encryption scheme, a public-key cryptosystem based on discrete logarithms. It will be a great addition to the ciphers module alongside RSA and other cryptographic algorithms.
🧩 Problem Description
Implement ElGamal key generation, encryption, and decryption in Java using modular arithmetic. Demonstrate how random keys ensure semantic security.
📂 Implementation Details
- Folder:
src/main/java/com/thealgorithms/ciphers/ - Filename:
ElGamalCipher.java - Approach:
- Generate keys
(p, g, x, y)wherey = g^x mod p. - Encrypt message
musing randomk. - Decrypt ciphertext
(c1, c2)usingm = c2 * (c1^x)^-1 mod p.
- Generate keys
✅ Expected Deliverables
- Fully functional implementation with key generation, encryption, and decryption.
- Example in
main()demonstrating encryption/decryption of small integers or strings. - Comments explaining modular arithmetic and randomization.
- Basic test cases and verification of decryption correctness.
🧑💻 Additional Notes
ElGamal is mathematically rich and deepens understanding of asymmetric encryption in the Algorithms repo.
Issue details
🧩 Problem Description
Implement ElGamal key generation, encryption, and decryption in Java using modular arithmetic. Demonstrate how random keys ensure semantic security.
Additional Information
No response