TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Small simple explanation to Diffie-Hellman Key Exchange (D-H)

3 点作者 Tomer超过 15 年前

3 条评论

RiderOfGiraffes超过 15 年前
That's a really, really bad explanation. You have<p><pre><code> Bill: Says: 5 Bill: hmm Now I know the key is: 5 Monika: hmm now I know the key is: 5 And they encrypt their communication with this number 5, Hillary does not know that the number they have chosen is 5. </code></pre> But Bill said "5" and Hillary is listening!<p>Really, really bad.<p>I admit that it seems at the beginning that Diffie-Hellman is complicated, but really it's not. You can implement the basics in 3 lots of 8 lines of python. Follow the logic.<p>Using uppercase for secrets and lower case for openly visible information, and we're talking about Y (for you) and M (for me):<p><pre><code> We openly agree b (small prime) and n (large prime). All calculations will be done modulo n. We each pick secrets, Y for you and M for me. We each compute powers: y=b^Y and m=b^M Exchange these powers openly. We each raise the others power to our own secret, y^M and m^Y, and we get the same answer! Use that as a key in blowfish or similar. </code></pre> That's all there is. There are some details about "good" primes versus "bad" primes, but really, that's it.<p>So, a longer explanation:<p>Together, over the phone, you and I pick two numbers, n and b. One's a 500 bit prime, the other is a moderate prime, say, 53. That's not too critical. We agree these openly, everyone can know them.<p>Now you pick a really big secret number, Y, and I pick a secret number M. You compute y = b^Y (modulo n) and I compute m=b^M (mod n).<p>We exchange these, quite openly.<p>Then I compute y^M, and you compute m^Y. The fun part is that the answers we get are the same.<p>Why?<p>You computed m^Y which is (b^M)^Y which is b^(MxY), while I computed y^M, which is (b^Y)^M which is b^(YxM). (using "x" for multiplication, because asterisks change to italic)<p>Modulo n, everything works.<p>Now we share a secret, and we can use that in a symmetric cipher such as blowfish, or whatever.<p>It is believed that no one can deduce the shared secret, or the individual secrets, from the visible numbers.
Nycto超过 15 年前
The run on sentences make this article hard to follow. The last paragraph of the article even says, "not the best explanation..." Isn't the whole point that this is supposed to be a good, simple explanation?<p>Wikipedia offers a much better walk-through of what it is and how it works:<p><a href="http://en.wikipedia.org/wiki/Diffie-Hellman" rel="nofollow">http://en.wikipedia.org/wiki/Diffie-Hellman</a>
newsdog超过 15 年前
It's actually a terrible explanation. I understood it better before.