# ElGamal re-encrypts data

I try to learn ElGamal re-encrypts scheme and I have a question about the example: How is a re-encryption done with elGamal?.

• The $$g$$ value of Alice must be the same as $$g$$ value of Bob or not?
• And what about of Prime $$p$$ value for Alice and Bob? Alice.$$p$$ must be the same as Bob.$$p$$ or not?

Thanks!

• Yes, and Yes.${}$ – kelalaka Mar 28 '19 at 10:50
• Ok, thank you! I try test it: 2. Bob reencrypts (x,w) as (x′,w′) with x′=xg^u, w′=wy^u(x′)^b. I use BigInteger. I look that x1>0, ok but w1=0, becourse x1 > p: var x1 = g.modPow(u, p).multiply(x); var tmpB = y.modPow(u, p).multiply(w); var w1 = x1.modPow(b,p).multiply(tmpB); this w1 = 0 Where I mistake? – – Eugene Mar 29 '19 at 13:40
• Eugene, CryptoSO is not programming site. You can ask your programming question with your programming codes in Stackoverflow. – kelalaka Apr 4 '19 at 15:34