def decipher_elgamal(msg, key):
 (p, r, d) = key
 (c1, c2) = msg
 u = igcdex((c1 ** d), p)[0]
 return ((u * c2) % p)

def decipher_elgamal ( msg , key ) : ( p , r , d ) = key ( c1 , c2 ) = msg u = igcdex ( ( c1 ** d ) , p ) [ 0 ] return ( ( u * c2 ) % p )
decrypt message with private key msg = key = according to extended eucliden theorem .