Path: blob/master/Digital-Signatures/ElGamal-Signatures/README.md
1402 views
ElGamal Signature Scheme
Prerequisites:
Cyclic Groups
ElGamal Signature Scheme is a Signature Authentication Algorithm, with the security level as same as that of Discrete Logarithm (DLP), we will see this as we move forward.
For illustrative purposes, we will consider Alice
as the signer and Bob
as the verifier.
There are different steps involved while signing or verifying data/signatures respectively with ElGamal, let's list them first and then study each of them in detail:
Key Generation: Alice generates a pair of public and private keys. Shares the public key
(g, y, p)
.Signature Generation: Alice uses her private key to generate the signature of a message
m
with the help of another variabler
(r
is public). Shares signatures
,r
, andm
.Signature Verification: Bob then uses Alice's public key to do computation on
s
and checks if it matches withHash(m)
, if yes then the signature is valid, otherwise it isn't.
Key Generation
This step is done by the signer- Alice. Alice's Public and Private keys are generated using the following steps:
Selects a Cyclic Group
G
of orderp
and generatorg
Chooses a random integer
x
such that1 < x < p-2
.x
is the private key.Calculates
Shares
y
,p
,g
as public key
Here is a python-2.7 implementation of the above step:
Signature Generation
In this step, Alice does the following:
Selects a random integer
k
such that1 < k < p-2
andGCD(k, p-1) = 1
Calculates
r
as:Calculates hash of the message
m
to be signed asH(m)
, whereH()
is a secure hashing algorithm agreed upon by both signer and verifier.Calculates signature
s
asShares
r
,s
,m
Here is a python-2.7 implementation of the above step: (Please note that the below example is only for illustrative purposes; md5 should not be used as a hash function)
Signature Verification
Bob, after receiving public key and signature values, computes the following for verification:
Computes H(m)
Checks if
, if it is True, then the signature is successfully verified, if not, then the oracle throws an Exception
Proof
Step-2 is true for valid signatures because
We have from Fermat's Little Theorem that when
GCD(g, p) == 1
:Therefore we can write:
And hence
Here is a python-2.7 implementation of the above step:
Check out a trivial implementation/example of ElGamal Signature signing and verification here- example.py