Elgamal implementation problems

Torbjorn Granlund tg at gmplib.org
Sun May 1 13:31:46 CEST 2011


Andrew Mattingly <andrew_mattingly at au1.ibm.com> writes:

  I can see two problems with your eg_encryption routine (eg_decryption has 
  no problems):
  
  1.  you should be computing c2 = h^k * M mod p, not c2 = h^k * g^M mod p
  
  2.  even if you disagree with point 1, you should take a modulus after the 
  final multiplication,
  
  ie. after:
  
    mpz_mul(cipherText->c2, tmp2, tmp);
  
  do
  
    mpz_mod(cipherText->c2, cipherText->c2, publicKey->p);
  
  Hope this helps.
  
It is generally a disservice to the society to do student's homework for
them.

Also, please do not use the GMP mailing list for such "help".

-- 
Torbjörn


More information about the gmp-discuss mailing list