Java icon indicating copy to clipboard operation
Java copied to clipboard

[FEATURE REQUEST] ElGamal Encryption Algorithm

Open Shewale41 opened this issue 1 month ago • 1 comments

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) where y = g^x mod p.
    • Encrypt message m using random k.
    • Decrypt ciphertext (c1, c2) using m = c2 * (c1^x)^-1 mod p.

✅ 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

Shewale41 avatar Oct 25 '25 13:10 Shewale41