I am having a trouble not knowing how to do a java code that will take user string then encrypt it using Elgamal algorithm as following
Elgamal algorithm Pseudo code:
- Select Q where Q is a prime number
- Select α where α is a primitive root of Q and α < Q.
- Select Random Xa such that Xa < Q -1
- Calculate Ya , such that Ya = αXa mod Q
- Public key = { Q, α, Ya}
- Private key = { Xa}
- Plain Text M < Q
- Select random k0 such that k0 < Q
- Calculate K1 such that K1 = Yak mod Q
- Calculate C1 = αk0 mod Q
- Calculate C2 = K1 * M mod Q
- Cipher = (C1, C2)
- Decryption: Cipher = C1,C2
- Calculate K1 such that K1 = C1 Xa mod Q
- PlainText M = (C2K1-1
) mod Q
How can I do it