given large prime p, some a, some b:
1. A = g^a mod p
2. B = g^b mod p
3. exchange A,B
4. B^a mod p = (g^b)^a mod p = (g^a)^b mod p = A^b mod p is the shared key.
the end
given large prime p, some a, some b:
1. A = g^a mod p
2. B = g^b mod p
3. exchange A,B
4. B^a mod p = (g^b)^a mod p = (g^a)^b mod p = A^b mod p is the shared key.
the end
https://www.comparitech.com/blog/information-security/diffie...
that's just multiplication in Z_r...?
edit: alright i guess technically it uses homomorphism from Z to Z_r but you don't need to be able to write out the proof to intuit/believe it
Even allowing that you meant "programmers" originally, "programming" covers a massive field of knowledge sets. For example, I know what exponentiation and modular arithmetic are, but I can't derive the practical implications from your example without further research. I also have no idea what "g" is.
DH relies on the discrete logarithm problem. That means that if I give you g + g + .. + g, where g is added to itself n times, it will be difficult for you to find out what n is.
Both parties share the same prime p, and the same base point g. Then each of them select a random, secret point. Say Alice's secret is a and Bob's is b. Now each of them create their "public key", which is just g + g + g .. a times, and g + ... b times to create A and B, respectively. The (mod p) simply means divide the result by p and take the remainder as the answer.
Now if I am Alice, my secret is a, my public key is A. Bob sends me B = g^b (mod p). I exponentiate this with my own secret key to get shared secret = (B)^a = (g^b)^a = (g^a)^b = g^(ab) (mod p)
(mod can be deferred to the end of the calculation or done at each step, without changing the answer)
So you can see that, since the order of exponentiation doesn't matter, when Bob does the same calculation (multiplying his private b with alice's public key g^a) he gets the same shared secret.
ECDH has smaller keys because the attacks are (until now) weaker and not because you're using an additive cyclic group.
I think the keys can be smaller because every random coordinate is a valid value (valid key), but in the case of RSA, valid values are more sparse.
I don't think I can explain to a layman without math backround why it is secure. So I have kept it simple.
https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exc...
In the case of DH, g is some such element.