# Lenght of the ElGamal cipher

Ok, it's kind of stupid question, but I want to make sure.

What is the length of the ElGamal cipher? It's equal to the size of 2 elements of the cyclic group, right? But lengths of elements are NOT always the same, right?

Toy example:

We pick p = 23, q = 11 (p = 2q+1), our generator is 18, so G = {18,2,13,4,3,8,6,16,12,9,1}. Sekret key x is 6 (a random form {1,q-1}), h = g^x mod p = 8.

Now is the fun part:

1) Encryption of m = 18 with r = 8 is (16,3)

2) Encryption of m = 18 with r = 7 is (6,9)

Am I getting different length ciphers because it's the toy example or what? Padding? All group elements have identical length? I haven't noticed any length difference in the real ElGamal implementation.

• There's about a $\frac{2}{256}$ of one of the parts being a byte shorter. Padding may be applied depending on the encoding. – SEJPM Jan 25 '18 at 12:40