Diffie-Hellman Key Exchange: How to Share a Secret

  Рет қаралды 158,712

Spanning Tree

Spanning Tree

Күн бұрын

Пікірлер: 213
@epicdude1817
@epicdude1817 6 ай бұрын
My favourite thing about this channel is that they take seemingly complex algorithms and break it down so that it’s easy to understand!
@hampus23
@hampus23 6 ай бұрын
💯
@4pmvim
@4pmvim 6 ай бұрын
And with cute renditions of the code at that!
@c2vi_dev
@c2vi_dev 4 ай бұрын
yup, absolutely the best thing ever!!!
@vinniepeterss
@vinniepeterss 3 ай бұрын
yep😮
@NibbyBanana
@NibbyBanana 6 ай бұрын
The problem with DH on its own is that there is no way to verify the calculated public parameters. So an attacker can sit in the middle and perform the handshake with both parties, generate a secret key and maintain the session. The attack decrypts the data from party A, is able to look at it and store it, then encrypt it to party B and vice versa. It does need to be an active attack, because otherwise there would be no way to retrieve the secret key. So you still need PKI for making sure that the public parameters you receive are from the correct party.
@M_1024
@M_1024 6 ай бұрын
Is there a way to counter this?
@NibbyBanana
@NibbyBanana 6 ай бұрын
@@M_1024 Yes. You use certificates on the server side, so you have a means to send the public parameters to the server and back safely. This uses asymmetric encryption, which is a lot slower, so it's only used for the handshake. And if the server later got hacked and the RSA keys are compromised, you still cannot decrypt sessions, because DH achieves perfect forward secrecy. The signing is only neccesary to combat an active attack and verifying the public parameters, otherwise DH is perfect.
@loganhodgsn
@loganhodgsn 6 ай бұрын
The other part of security: authentication!
@M_1024
@M_1024 6 ай бұрын
@@NibbyBanana This only works if you can be sure that some communication is with the right person. For example lets say that Alice tries to verify that Bob is really Bob. If she Has Bobs public verification key, she can do this, but first she has to get that key, which in practice is easy, but in theory could be impossible
@NibbyBanana
@NibbyBanana 6 ай бұрын
@@M_1024 Yes, that's the entire point of the certificates, and why you'd need PKI. To make sure the public paramters are from the right person.
@marvinwaleed
@marvinwaleed 5 ай бұрын
I learned about the DH key exchange back in University and even got the test questions correct without ever really understanding it. This video was fabulous - because NOW I understand. Insanely well done!
@bertik2326
@bertik2326 6 ай бұрын
Wow, this is the second time you have dropped a video with a theme I'm currently learning for an exam in a few days.
@marekkamyk5518
@marekkamyk5518 6 ай бұрын
Good luck!!
@alaminshuvo3815
@alaminshuvo3815 2 ай бұрын
This is exactly what I was looking for! I used to wonder how they create a secured communication channel on a public network. Good job Spanning Tree! Love your channel.
@blackroom-98
@blackroom-98 2 ай бұрын
me too :)
@unvergebeneid
@unvergebeneid 6 ай бұрын
Diffie-Hellman is one of those problems where you could naively swear that it's impossible to solve. And yet!
@kevinscales
@kevinscales 5 ай бұрын
Yeah, the trick is to notice that the problem isn't to find an irreversible operation, that is impossible (when you know the operation and the result nothing can prevent you from, in the worst case, trying every number as input until you find one that gives you the same result), you can make reversing it prohibitively expensive, and that is all you actually need making the problem not as impossible as you initially frame it.
@kevinscales
@kevinscales 5 ай бұрын
As is typical, actually understanding a problem is the hard part of solving a problem.
@unvergebeneid
@unvergebeneid 5 ай бұрын
@@kevinscales Did you read this in a fortune cookie? I mean, you could always define "understanding" in such a way for this sentence to be true but then it's not really a useful statement, is it? Understanding a^n + b^n = c^n is not all that difficult. Understanding it deeply enough to solve it clearly is. So the word "understanding" is doing _a lot_ of heavy lifting here.
@mufaddaldiwan8555
@mufaddaldiwan8555 6 ай бұрын
I think one thing you forgot to mention is why both would get the same key when raising it to their secret number. Operation by person with secret number c = (A^b mod M)^c --- (A^b mod M is what he received from other person) = (A^b)^c mod M --- (property of modular arithmetic) -> 1 = (A^bc) mod M --- (exponent property) = (A^c)^b mod M --- (multiplication is associative) = (A^c mod M) ^ b --- same as eq. 1 = The operation that person with secret number b would do This implies both of them end up with the same output which is the key
@mufaddaldiwan8555
@mufaddaldiwan8555 6 ай бұрын
There is a flaw in this as attacker can become a mediator between two communicating parties. Intercepts communication Creates shared key k1 with A and k2 with B Both A and B think they are communicating well but a mediator attacker sits in middle and reads and manipulates messages xD
@Knirin
@Knirin 6 ай бұрын
@@mufaddaldiwan8555 Thanks for going over a basic version of the proof for why both parties get the same result. Diffie Helman gives you secrecy but not authentication . We use other means to add authentication to the chain.
@santunukaysar
@santunukaysar 4 ай бұрын
"You are the greatest teacher I have ever seen." 😊👍
@CX330Blake
@CX330Blake 10 күн бұрын
This channel really helps a lot, from AES to Diffie-Hellman. Thanks for doing such a nice work.
@ImNetheN
@ImNetheN 6 ай бұрын
a more efficient algorithm to find x^p: the main idea is that a^b * a^b = a^(2 * b) so you can double the exponent in 1 operation instead of increasing it by one. the code of the function would look something like this: function pow(x, p) if (p == 1) return x if (p is even) { int y = pow(x, p / 2); return y * y; } if (p is odd) return x * pow(x, p -1) and you can just take the mod on every step
@dakotaboy80
@dakotaboy80 5 ай бұрын
This concept has been explained to me several times in classroom settings, but this video is the first time it actually made sense to me.
@theAstarrr
@theAstarrr 5 ай бұрын
I recommend Khan Academy's series on it as well
@MAK_007
@MAK_007 29 күн бұрын
i come back to this video very often . great animation great explaination
@thesquatchdoctor3356
@thesquatchdoctor3356 6 ай бұрын
Been wondering this for 15 years
@marcscherzer
@marcscherzer Ай бұрын
3:14 to 6:12 explained what is commonly not taught in colleges, well done!
@tanvirhasanmonir1627
@tanvirhasanmonir1627 3 ай бұрын
Thank you so much. Very easy to understand even though the topic is complex.
@Meghana_Nallamilli
@Meghana_Nallamilli 5 ай бұрын
Just when I needed it! I’m working on understanding AES-GCM encryption and ECDH key exchange for an internship
@Katchi_
@Katchi_ 5 ай бұрын
Or.... or.... you could read the fing man.
@Meghana_Nallamilli
@Meghana_Nallamilli 5 ай бұрын
@@Katchi_ huh??
@RoyNisimov
@RoyNisimov 6 ай бұрын
Great vid as always! I got into cryptography because of your video about AES! I think a video about Shamir's Secret Sharing could be interesting too.
@theAstarrr
@theAstarrr 5 ай бұрын
Great video! Second only to Khan Academy's explanation - they did a really good job on their series. But I'd recommend either one to someone interested in cryptography, security, and that stuff.
@sobevj
@sobevj 5 ай бұрын
It's very concise and you learn a lot in a short time, and if you want to learn the source code, it'll be easier!
@faker7622
@faker7622 3 ай бұрын
Thank you very much to make such simple explenations so people like me can understand it much easier and your animation help a lots. I hope you will make more videos like this for such complicated topic
@Hi2uGaming
@Hi2uGaming 5 ай бұрын
I have an exam on this topic tomorrow and you uploaded this today. Right time ! lucid explanation thanks
@Katchi_
@Katchi_ 5 ай бұрын
Liar.
@fouler3606
@fouler3606 6 ай бұрын
Thank you for the amazing educational content and adorable animations! it helps me as a student studying computer science in university I find your videos a nice and small research video on topics that I don't always encounter in the syllabus so thank you for everything :)
@thefrub
@thefrub 5 ай бұрын
This is a great explanation! I wish I had this when I was taking my cryptography class last year
@SuperLlama88888
@SuperLlama88888 5 ай бұрын
Wow, straightforward and clear explanation! Thank you for this video!
@Guilhem34
@Guilhem34 5 ай бұрын
This protocol is used in SSH, a widely used cryptographic software. However you are susceptible to MITM at first generation. This is why checking the public key is important.
@CultKosmosa
@CultKosmosa 5 ай бұрын
thank you, I have been implementing d-h exchange when communicating with telegram server but this video gave me a much better understanding than reading code or text, I guess I am a visual learner
@The_Pariah
@The_Pariah 5 ай бұрын
You are an absolute nerd. And that's **exactly** why I keep watching your videos. Keep up the fantastic work.
@foobargorch
@foobargorch 6 ай бұрын
worth mentioning that in more modern cryptography the same idea is used on elliptic curves, but the cool thing is this is a pretty black box approach, the higher level key agreement protocol doesn't care about the underlying mathematical structure used so long as it's an Abelian group where reversing the group operation is hard and it turns out that defining an addition operation on the solutions to elliptic curve equations gives a very good tradeoff between efficiency and (presumed) hardness.
@ChristopherOBrienPSU
@ChristopherOBrienPSU 6 ай бұрын
Best explanation of DH that I've ever seen
@WackoMcGoose
@WackoMcGoose 6 ай бұрын
There's another method I like that has a great analogy, but requires a type of cryptography that you can _swap the steps of and still get the same result_ (think A XOR B XOR C == A XOR C XOR B). The analogy is, Alice comes up with a secret, puts it in a box with Padlock A (only she has A's key) and mails it to Bob, who _puts his own Padlock B on it_ and mails it back (the contents are now "double encrypted"). Alice now unlocks Padlock A so the box only has Padlock B on it, and mails it back again to Bob, who unlocks his own padlock and retrieves the secret, that they then share for regular communication. They never unlocked each other's locks, and the box was never in flight without at least one lock on it.
@nidhibiswas9738
@nidhibiswas9738 Ай бұрын
Amazing animation!! thankyou so much it helped with visual understanding
@Valo_iO
@Valo_iO 6 ай бұрын
Well explained, great video!
@mauisstepsis5524
@mauisstepsis5524 4 ай бұрын
I love your content. This is the best intro to DH key exchange
@kebien6020
@kebien6020 6 ай бұрын
One reason for wanting to do this instead of Asymmetric key cryptography is that Symmetric tends to be much more efficient for encription and decription. If you want ALL traffic to be encrypted, it better have a low overhead over sending plaintext.
@mtranchi
@mtranchi 5 ай бұрын
That red robot looks scary.
@k-vn-7
@k-vn-7 5 ай бұрын
Gotta stay alert. Red Guy out there lurkin'.
@mtranchi
@mtranchi 5 ай бұрын
@@k-vn-7 cross-hairs on him
@samueltaylor4989
@samueltaylor4989 4 ай бұрын
It’s the eyes, you know people who squint or have eyebrows turned down are evil.
@CyberGyat-im4bp
@CyberGyat-im4bp 4 ай бұрын
sus
@k-vn-7
@k-vn-7 4 ай бұрын
@@CyberGyat-im4bp 😆
@joshcowan474
@joshcowan474 Ай бұрын
Great explanation! Thank you!
@ShNazem
@ShNazem 3 ай бұрын
You explain very understandable thank you.
@Heyharsh0001
@Heyharsh0001 2 ай бұрын
Very clear and easy good content
@MOOBBreezy
@MOOBBreezy 6 ай бұрын
What a great cryptography lesson! Thank you!
@saksi_mata
@saksi_mata 3 ай бұрын
I am subscribed just because your animation is so cute and the explanation about the problem at hand was really spot on.
@cee2615
@cee2615 4 ай бұрын
I have no interest in the content of the videos, I just absolutely love the little guys in the video and have to watch because of their cuteness … too cute
@lostvayne871
@lostvayne871 6 ай бұрын
That red guy is a masterpiece!!!
@tacuacito6416
@tacuacito6416 5 ай бұрын
I just discovered your channel! Amazing video! 10/10 But what would happen if red guy: 1. Generated his own secret and modular exponent. 2. Intercepted or stopped green's modular exponent from reaching blue. 3. Sent his own modular exponent to blue, pretending it is from green. Wouldn't he be able to read blue's messages now?
@kacper7516
@kacper7516 5 ай бұрын
One of the best explanation
@arpitkumar4525
@arpitkumar4525 5 ай бұрын
Wow! First time I saw the beauty in Maths
@brianarsuaga5008
@brianarsuaga5008 5 ай бұрын
Huh, I knew and studied this, technically, but this made it less "black magic" where the math was concerned. Thanks!
@callisoncaffrey
@callisoncaffrey 5 ай бұрын
Good explanation gets a like.
@lucas-pcs
@lucas-pcs 6 ай бұрын
Thanks for sharing !! Those animations makes so easy to understand the algorithm
@jameslovering9158
@jameslovering9158 5 ай бұрын
Thank you, that was easy to follow !
@jakob5481
@jakob5481 5 ай бұрын
I feel like this would also be a good moment to make a video about the euler phi function since it massively simplifies such calculations
@cdvgter
@cdvgter 5 ай бұрын
This is explained so well!
@Mahm00dM0hanad
@Mahm00dM0hanad 5 ай бұрын
Well explained, thanks a lot
@ricardopassos1180
@ricardopassos1180 5 ай бұрын
It ain't much, but it's my way of saying thanks for your work
@RegulatedNinja
@RegulatedNinja 2 ай бұрын
THANK YOU SO MUCH
@Anythiny
@Anythiny 5 ай бұрын
its always fun to watch ur explaination
@arcanogameplays
@arcanogameplays 5 ай бұрын
Best explanation out there
@tirana.1887
@tirana.1887 5 ай бұрын
Best explanation out there! Came here after watching several videos on the matter. This was the best by far. Thanks!
@official_noself
@official_noself 4 ай бұрын
Could you please explain how can you prevent if red person takes both of the b mod m shared publicly and gives other parties his own version of secret key calculation. Therefore both parties think they agreed on a key but in fact agreed on red person’s keys. Throughout the whole process red person can open the message and encrypt it again to send to receiver as it is coming from other party.
@69k_gold
@69k_gold 6 ай бұрын
Omg, it was this simple! Computerphile did a very poor job in this concept. I love your videos and those cute robots man, you know your stuff really well
@JariNestel
@JariNestel 5 ай бұрын
I need to disagree with this: 1. The Water Color video is just for the non math person: kzbin.info/www/bejne/hJ6want3Z7KEfas 2. The Math behind explains deeper and why exponentiation is safe: kzbin.info/www/bejne/j5vVl6CVpLeCZtk While this video is a mix between, but completely fails to explain why exponentiation is safe, if the communicating parties used the exponentiation iteratively as shown in this video, brute forcing it would be as hard as encrypting it. While multiplying previous powers gives a great benefit to efficiency, reducing your cost to from linear to logarithmic, assuming you know your target exponent. And if you assume the person watching this video knows how exponentiation can be sped up, there would be no need to watch this video in the first place, cause that's literally everything going on.
@69k_gold
@69k_gold 5 ай бұрын
​@@JariNesteloh thanks, I totally missed the second video you mentioned
@foobarf8766
@foobarf8766 5 ай бұрын
You touched on the discrete log problem, so compression functions and their special case of one way hashing next please!
@novmoon5724
@novmoon5724 3 ай бұрын
Congratulations on your upcoming wedding! The lady is so beautiful and wonderful, she would be one of the great breadwinners for the family! congratulate!
@StefanReich
@StefanReich 6 ай бұрын
Diffie-Hellman relies on the same principle (modular exponentiation) that RSA uses to allow asymmetric encryption. Incredible inventions if you think about it
@QualityDoggo
@QualityDoggo 6 ай бұрын
iirc they're often used together -- key exchange versus encryption
@tanmaybora359
@tanmaybora359 6 ай бұрын
You are the best!
@benjaminkpaul
@benjaminkpaul 5 ай бұрын
brian yu is a genius😊😅
@lisakanifer5081
@lisakanifer5081 5 ай бұрын
Small nitpick near the end. TL;DR: You don't have to use primitive roots for your base. It is not sufficient to choose any prime number modulus, as an attacker can use something called the Pohlig-Hellman algorithm if one less than the prime only has small prime factors. Bad prime example: 306557831 is a prime, but 306557831 - 1 = 306557830 = 2 * 5 * 53 * 67 * 89 * 97, and this makes it weak. Good prime example: 489678227 is a prime, and 489678227 - 1 = 489678226 = 2 * 244839113, and this makes it strong. In fact, these primes are called safe primes. Now suppose you've chosen the safe prime modulus in the example. If you avoid a base of 1, 0, or -1, you're guaranteed to go through at least 244839113 values, so pretty much any base works. Pohlig-Hellman makes sure having 489678226 values doesn't make it harder, so there's no need to find a primitive root.
@eyobsolomon4663
@eyobsolomon4663 5 ай бұрын
Really, thank you so much!
@deschia_
@deschia_ 5 ай бұрын
Found your channel from this video. You just earned a sub. Great content.
@fastrobreetus
@fastrobreetus 4 ай бұрын
Great video!
@roborogue_
@roborogue_ 6 ай бұрын
great video!
@AjinGixtas
@AjinGixtas 6 ай бұрын
Cool vid :)
@pbezunartea
@pbezunartea 6 ай бұрын
Great video, thanks!
@guoard
@guoard 5 ай бұрын
Great job!
@ArcherNX1701
@ArcherNX1701 5 ай бұрын
Thanks for making the explanation so simple. Would you make another vid that explians how quantum computing can break this? And any solution post-quantum?
@Stvk
@Stvk 6 ай бұрын
I love video like this, can you do block cipher mode of operation (especially XTS), RSA, ECC and Lattice cryptography?
@clementdato6328
@clementdato6328 5 ай бұрын
The fact that I didn’t turn on all notifications for this channel is mind-blowing
@Krosis_
@Krosis_ 4 ай бұрын
Truly mind blowing
@hvnterblack
@hvnterblack 5 ай бұрын
good material
@DavidNBooth
@DavidNBooth 5 ай бұрын
Amazing video
@Cosmo-ai
@Cosmo-ai 5 ай бұрын
The math just hurts my head. I understand, but at 7:00 I just have a hard time visualizing how you can both end up with the same number after taking answer to exponents of secret number
@Freeethink
@Freeethink 5 ай бұрын
Instead of calculating for example 3^(5) mod 19 in one go, you use the algo shown at 5:00. In this algorithm you use the last solution for the next step in algorithm. So if I want to have the modulo from an exponent of 5 I repeat the steps of the algorithm 5 times. But only the solution of the penultimate step is needed to calculate my final solution (yet we do the rest because the penultimate solution needs the step before and so on and so on). But, if somebody gave us the solution for step 5 for example and want to go to an exponent of 11, we can use the solution of step 5 and just go from there to 11. And that's what this exchange uses. You want to have 5 as your private key and I want to have 6. I take your answer from doing 5 steps and do my 6 steps reaching the answer of the algo after 11 steps. You do the same, take the answer of my 6 steps and do your 5 steps, also reaching 11 steps. We both don't actually know, that 11 steps have been done in total, you only know that my answer plus your number of steps gives the same result as your answer plus my number of steps. So the attacker might intercept your answer, but does not know how many steps to add to get the result we both know have. The attacker can in theory use one of our shared answers plus the information of the base and modulo to invert the operation and find out which exponent one of us used and thus know the number of steps needed to add to the other answer, but that is computationally nigh impossible.
@rhysbaker2595
@rhysbaker2595 6 ай бұрын
Oh hey, this amazing channel that I love uploaded! :D
@TNewton001
@TNewton001 5 ай бұрын
Thanks!
@andreujuanc
@andreujuanc 5 ай бұрын
Brilliant! thanks for such good video
@annantsharma91
@annantsharma91 5 ай бұрын
Keep up the good work, loved it ❤
@melonberry6771
@melonberry6771 5 ай бұрын
I like your content, please make more
@ashb2483
@ashb2483 4 ай бұрын
Great vid!
@Fakyp
@Fakyp 6 ай бұрын
Good video, but it still doesnt solve the question you asked in the old video "How to Send a Secret Message" about MITM
@QualityDoggo
@QualityDoggo 6 ай бұрын
Yes. You need to have some way to secure/verify part of at least one communication -- this could be done with public/private keys which are trusted and setup out of band. The good part is you can then continue the conversation with encryption
@lbqg637
@lbqg637 6 ай бұрын
this video is so good
@mandolinic
@mandolinic 4 ай бұрын
In practice, how many bits should the number base and the modulus be?
@jeanjcl
@jeanjcl 6 ай бұрын
This is way too well explained, thank you!
@cloverberry721
@cloverberry721 5 ай бұрын
Is this method better and/or more common than using asymmetric encryption to establish a symmetric key?
@devr4j
@devr4j 5 ай бұрын
thanks it was helpful
@pjn2001
@pjn2001 5 ай бұрын
Might be a bit simplistic but would like to request a video on hole punching (networking). Maybe if combined with some other networking concept it could be a bit more viable. Thank you
@farnone6166
@farnone6166 6 ай бұрын
what is this timing i have a test on this in a few days
@MichaelDarrow-tr1mn
@MichaelDarrow-tr1mn 6 ай бұрын
clearly this means you win
@hitomi7922
@hitomi7922 6 ай бұрын
Dumb question, since there seems to be a preference for a "good" base and modulus, doesn't that also mean someone building a sort of rainbow table just has to compute all the combinations of the "good" pairings?
@QualityDoggo
@QualityDoggo 6 ай бұрын
that's why the exponent should be massive
@chri-k
@chri-k 5 ай бұрын
The problem is that the numbers involved are MASSIVE. Such a table wouldn't fit into the entire universe even if you managed to compute it. ( the base almost always is 3 )
@alex_zetsu
@alex_zetsu 5 ай бұрын
Is this a follow up to the three pass protocol video?
@freckhard
@freckhard 6 ай бұрын
I assume there are some more or less clever ways to find the primitive root modulo n on each ones side? Or is it just trying until it is "good enough"?
@Laff700
@Laff700 5 ай бұрын
I wonder if there's a symmetric key cryptography algorithm which is unconditionally secure.
@zudwa9280
@zudwa9280 5 ай бұрын
Dustin Hoffman seems to be not only a good actor but a pretty smart guy too.
@g0fher
@g0fher 5 ай бұрын
Can you talk abount quantum key distribution in next videos? Something like bb84, there are a lot of cool things to show in that algorithm.
@VerifyBot
@VerifyBot 6 ай бұрын
This is a great video. This topic is so important yet I haven't found to many great simple to understand resources. Thanks a lot and keep uploading! :)
@madara2887
@madara2887 6 ай бұрын
Hi Brian, it’d be nice if you could make videos about important algorithms like Bellman-Ford, Floyd Warshall, BFS, DFS, Prim etc.
@Katchi_
@Katchi_ 5 ай бұрын
Right... because there are no books on the subject...
Understanding B-Trees: The Data Structure Behind Modern Databases
12:39
Elliptic Curve Diffie Hellman
17:48
Robert Pierce
Рет қаралды 256 М.
小路飞还不知道他把路飞给擦没有了 #路飞#海贼王
00:32
路飞与唐舞桐
Рет қаралды 87 МЛН
this new Linux feature makes hacking IMPOSSIBLE
11:08
Low Level
Рет қаралды 482 М.
Diffie-Hellman Key Exchange and Forward Secrecy
13:00
Practical Networking
Рет қаралды 2,2 М.
AES: How to Design Secure Encryption
15:37
Spanning Tree
Рет қаралды 171 М.
Coding Unbreakable Encryption in C | One-Time Pad
17:42
HirschDaniel
Рет қаралды 4,3 М.
The Algorithm Behind Spell Checkers
13:02
b001
Рет қаралды 418 М.
7 - Cryptography Basics - Diffie-Hellman Key Exchange
8:48
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 1,3 МЛН
Breaking RSA - Computerphile
14:50
Computerphile
Рет қаралды 366 М.
The 3 Laws of Writing Readable Code
5:28
Kantan Coding
Рет қаралды 735 М.
The Most Important Algorithm in Machine Learning
40:08
Artem Kirsanov
Рет қаралды 520 М.