Simple ElGamal operation
When using ElGamal designers have two choices. Prime p and primitive element
of modp (generator) g may be parts of the system, thus common
for all the users, or they may be different for every user. In this simple example
the first approach is taken for clarity:
p= and g=
Example: p= 11, g= 2
Some other good values for p with g equal to 2:
-1073741827
-2147483658
-9223372036854775907
If p and g are written common in a given system, then public keys consist of y values
calculated just like the y values in Diffie-Hellman protocol. Let assume that Bob
wants to send a message to Alice. Then he will need her public key yB.
This kay is created by Alice in the following way:
xA is choosen randomly from the range
(0, p - 1)
yA is calculated yA
= (g^xA)modp
Example:
xA= 5
yA = 2^5mod11
= 32mod11 = 10
Press the generate button to generate this values.
xA becomes Alice's secret
key, and yA becomes her public
key:
Now Bob can use Alice's public key to send her a message m (), where 0 ≤
m ≤ p - 1. The encryption is berformed in the following way:
k is choosen randomly from the range (0, p - 1), new key should be choosen
for every block of message
Example: m = 9, k = 3
K is calculated K = (yA^k)modp
Example: K = 10^3mod11 = 10
The ciphertext is then the pair (c1; c2),
where:
c1 = (g^k)modp
c2 = (K * m)modp
[ElGamal suggest other invertible operation may be userd e.g addition modulo p]
Example:
c1 = 2^3mod11 = 8mod11 = 8
c2 =
10*9mod11 = 90mod11 = 2
Press the button below to calculate the ciphertext
In order to decrypt the ciphertext (c1;c2) alice performs the following steps:
-Calulates (c1^p-1-xA)modp=(c1^(-xA))modp
-calculates m
m=(c1^(-xA)*c2)modp
Example:
c1^(p-1-xA)mod11
= 8^(11-1-5)mod11 = 8^5mod11 = 32768mod11=10
m = 10*2mod11 = 20mod11 = 9
|