Skip to content

[FEATURE REQUEST] ElGamal Encryption Algorithm #6934

@Shewale41

Description

@Shewale41

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions