ElGamal is used for digital signature. The signature information is m. First, choose a random number k and calculate the coprime of k and p- 1:
G k (Ministry of national defense)
Then use the extended Euclidean algorithm to solve the following equation b:
m xa+kb(mod p- 1)
The signature is (a, b). The random number k must be discarded.
When verifying, please verify the following formula:
Y^a * a^b (Ministry of National Defense) G M (Ministry of National Defense)
At the same time, be sure to check whether it meets the requirements of 1
ElGamal is used for encryption. The encrypted information is m. First, choose a random number k, k and p- 1 coprime, and then calculate it.
G k (Ministry of national defense)
Y^k M (Ministry of national defense p)
(a, b) is ciphertext, which is twice as long as plaintext. Calculation at decryption time
United Kingdom/a^x (Ministry of Defence)
The security of ElGamal signature depends on the calculation of discrete logarithm on multiplication group (IFp)*. The prime number p must be large enough, and p- 1 contains at least one large prime number.