# Diffie-Hellman using a different modulus on both sides

For Diffie-Hellman Key Exchange, the used modulus is the same throughout the process. Is it possible to use 2 different for both sides? For example,

1. $A \gets M^{d_1} \pmod{n_1}$
2. $B\gets M^{d_2} \pmod{n_2}$
3. $m \gets B^{d_1} \pmod{n_1}$
4. $m' \gets A^{d_2} \pmod{n_2}$ <-- I wonder if $m'$ is equal to $m$ as well?

Put 1 into 4; put 2 into 3, then

$$(M^{d_1} \;(\bmod{n_1}))^{d_2} \pmod{n_2} \equiv (M^{d_2} \;(\bmod{n_2}))^{d_1} \pmod{n_1}$$

Please kindly help if my concept is correct? Thanks!

• In 3,4, $m$ should be $M$? Rewrite your equations in terms of arithmetic mod $n_1 n_2$ and see if it works if you assume $gcd(n_1,n_2)=1.$ If that case fails the general case will surely fail. – kodlu Nov 8 '15 at 11:51

I see you use the same generator on both sides (this need not work for any $n_1, n_2$ of course...). But even if this holds (trying a small example):

Let 1 use $n_1 = 11, M=2$, and 2 uses $n_2 = 13, M= 2$. Check that $2$ is a generator for both of the multiplicative groups.

If $d_1 = 7, d_2 = 9$, then $A = 2^7 \bmod 11 = 7$, while $B = 2^9 \bmod 13 = 5$.

But $5^7 \bmod 11 = 3$ which does not equal $7^9 \bmod 13 = 8$.