Is it me or if g=10 and p=307 then g is not a primitive root of p, which is a condition as in: ElGamal Public Key scheme Step 1. Global elements: p a large prime, g primitive root of p.