Section 16.3 ElGamal crypto system
The ElGamal encryption system is a public key encryption algorithm by Taher Elgamal [3] in 1985 that is based on the Diffie-Hellman key exchange. We give an introduction to the ElGamal Encryption System and an example in the video in Figure 16.20.
We assume that the message that Alice encrypts and sends to Bob is an integer. In Chapter 12 we saw how a message can be encoded into integers. We describe the three components of ElGamal encryption, namely key generation, encryption, and decryption.
- Bob: Key Generation
-
To generate his private key and his public key Bob does the following.
- Bob chooses a prime
and and a generator - Bob chooses a random
- Bob computes
in - Bob publishes his public key
in the key directory.
- Alice: Encryption
-
To encrypt a message
Alice does the following.- Alice gets Bob’s public key
from the key directory. - Alice chooses a random
- Alice computes the shared secret
- Alice computes
- Alice encrypts
by computing - Alice sends
to Bob.
- Bob: Decryption
-
The information available to Bob to decrypt a message are his private key
and his public key consisting of the prime the generator and To decrypt a message Bob does the following.- Bob receives
from Alice. - Bob computes the shared secret
- Bob computes the inverse
of in - Bob decrypts the message by computing
Investigate the dependencies of the steps in the ElGamal crypto system in the interactive Example 16.22.
In Checkpoint 16.23 Fill in the blanks to complete the description of key generation, encryption, and decryption following the ElGamal protocol.
Checkpoint 16.23. ElGamal protocol.
When using the ElGamal cryptosystem Bob and Alice do the following.
Bob: Key generation
To generate his public key Bob chooses a prime number and a generator in the group where
In the dropdown menus we write for
Bob chooses an element b in and computes B :=
- select
- g*a
- g*b
- g^a
- g^b
- g^p
- A^b
- B^a
- m*s
- X*t
.
Bob publishes his public key
- select
- (a,X)
- (A,X)
- (B,X)
- (g,b,B)
- (p,g,b)
- (p,g,B)
- (p,b,B)
.
Alice: Encryption
Alice wants to send the secret message m to Bob.
Alice obtains Bob’s public key
- select
- (a,X)
- (A,X)
- (B,X)
- (g,b,B)
- (p,g,b)
- (p,g,B)
- (p,b,B)
from the public key directory.
Alices chooses a in and computes A :=
- select
- g*a
- g*b
- g^a
- g^b
- g^p
- A^b
- B^a
- m*s
- X*t
.
Alice computes the shared secret s :=
- select
- g*a
- g*b
- g^a
- g^b
- g^p
- A^b
- B^a
- m*s
- X*t
.
To encrypt m in Alice computes X :=
- select
- g*a
- g*b
- g^a
- g^b
- g^p
- A^b
- B^a
- m*s
- X*t
Alice sends
- select
- (a,X)
- (A,X)
- (A,m)
- (B,X)
- (s,m)
- (s,X)
to Bob.
Bob: Decryption
Bob receives
- select
- (a,X)
- (A,X)
- (A,m)
- (B,X)
- (s,m)
- (s,X)
from Alice
Bob computes the shared secret
- select
- g*a
- g*b
- g^a
- g^b
- g^p
- A^b
- B^a
- m*s
- X*t
.
Bob computes the inverse t of s in the group
Bob obtains the message m by computing
- select
- g*a
- g*b
- g^a
- g^b
- g^p
- A^b
- B^a
- m*s
- X*t
.
We work through a small example.
Example 16.24. ElGamal with small numbers.
We follow the steps above to generate a private and a public key, encrypt a message, and decrypt a message.
- Bob: Key Generation
-
First Bob chooses the group, the generator, and his private key and computes and publishes his public key.
- Bob chooses the prime
and - Bob chooses
as his private key, - Bob computes
- Bob publishes his public key
in the public key directory.
- Alice: Encryption
-
Alice wants to send the secret message
to Bob.- Alice obtains
from the public key directory. - Alice chooses her secret
- Alice computes the shared secret
- Alice computes
- Alice encrypts the message
as - Alice sends
to Bob.
- Bob: Decryption
-
-
Bob computes the shared secret
- Bob finds the inverse
of in This can be done with the Euclidean algorithm and Bézout’s identity. - Bob decrypts the message by computing
which is Alice’s original message.
-
In Checkpoint 16.25 work through the steps of key generation, encryption, and decryption yourself.
Checkpoint 16.25. ElGamal with small numbers.
Alice and Bob use the ElGamal cryptosystem for their secure communication.
Bob: Key Generation
Bob chooses the prime So he will work in the group where He chooses
Bob chooses his secret key and computes .
Bob publishes and in the public key directory.
Directory of Public Keys
Aaron:
Alice:
Bob: , ,
Sebastian:
Victoria:
Alice: Encryption
Alice wants to send the message to Bob.
Alice gets Bob’s public key from the directory: , ,
Alice chooses her secret
Alice computes the shared secret .
She computes .
Alice encrypts the message by computing .
Alice sends and to Bob.
Bob: Decryption
Bob receives and from Alice.
Bob computes the shared secret .
Bob finds the inverse of in the group
Bob decrypts the message by computing .
Hint:
In we have
Considering only Bob’s side we get:
Problem 16.26. ElGamal decryption.
Bob has published his public key His private key is Alice sends his the encrypted message What is the plain text of the message ?
Solution.
From Alice’s message Bob gets and So the shared secret is The inverse of is since Bob decrypts the message by computing
Checkpoint 16.27. ElGamal: Bob’s perspective.
Alice and Bob use the ElGamal cryptosystem for their secure communication.
Bob: Key Generation
Bob chooses the prime and the generator
Bob chooses his secret key and computes .
Bob publishes and in the public key directory.
Directory of Public Keys Aaron:
Beth:
Bob: , ,
Sebastian:
Victoria:
Bob: Decryption
Bob receives and from Alice.
Bob computes the shared secret .
Bob computes the inverse of in the group
Bob decrypts the message by computing .
Bob finds the expanded base form of namely .
Decoding these numbers with yields the message .
Considering only Alice’s side we get:
Problem 16.28. ElGamal encryption.
Alice and Bob use the ElGamal crypto system for their secure communication. From the key directory Alice obtains Bob’s public key is Alice chooses her secret Alice encrypts the message What does she send to Bob ?
Solution.
Alice computes:
Thus Alice sends to Bob.
Checkpoint 16.29. ElGamal: Alice’s perspective.
Alice and Bob use the ElGamal cryptosystem for their secure communication. Alice sends an encrypted message to Bob.
Directory of Public Keys
Bob:
Nathan:
Thom:
Alice: Encryption
Alice wants to send the message ’ ’ to Bob.
Alice gets Bob’s public key from the directory: , ,
She applies the encoding function with to the characters in message. She obtains , , and .
She encodes this into one number by computing .
Alice chooses her secret
Alice computes the shared secret .
She computes .
Alice encrypts the message by computing .
Alice sends and to Bob.
We end with an example that includes the encoding of a message.
Example 16.30. ElGamal with encoding and decoding.
Alice and Bob use the ElGamal crypto system for their secure communication. In the following we present all steps involved in Alice sending an encrypted message to Bob. For encoding text into numbers we apply the method from Chapter 12.
- Bob: Key Generation
- Bob chooses the prime
and the generator Bob chooses his secret key and computes Bob publishes and in the public key directory. - Directory of Public Keys
Aaron: Beth: Bob: Sebastian: Victoria: - Alice: Encoding and Encryption
-
Alice wants to send the message
to Bob. Alice gets Bob’s public key from the directory: She applies the encoding functionwith to the characters in the message. She obtains and She encodes this into one number by computing - Bob: Decryption and Decoding
-
Bob decrypts the message by computing
Checkpoint 16.31. ElGamal with encoding and decoding.
Alice and Bob use the El Gamal crypto system for their secure communication.
Bob: Key Generation
Bob chooses the prime and the generator
Bob chooses his secret key and computes .
Bob publishes and in the public key directory.
Directory of Public Keys Aaron:
Beth:
Bob: , ,
Sebastian:
Victoria:
Alice: Encryption
Alice wants to send the message ’ ’ to Bob.
Alice gets Bob’s public key from the directory: , ,
She applies the encoding function with to the characters in message. She obtains , , and .
She encodes this into one number by computing .
Alice chooses her secret
Alice computes the shared secret .
She computes .
Alice encrypts the message by computing .
Alice sends and to Bob.
Bob: Decryption
Bob receives and from Alice.
Bob computes the shared secret .
Bob computes the inverse of in the group
Bob decrypts the message by computing .
Bob finds the expanded base form of namely .
Decoding these numbers with yields the message .
In real world applications is chosen much larger.