HomeОбразованиеRelated VideosMore From: patrickJMT

Cryptography: The Math of the Public Private Key of RSA

1115 ratings | 36973 views
Thanks to all of you who support me on Patreon. You da real mvps! $1 per month helps!! :) https://www.patreon.com/patrickjmt !! Part 1: https://youtu.be/PkpFBK3wGJc Please consider being a supporter on Patreon! https://www.patreon.com/patrickjmt Twitter: @Patrick_JMT In this video I show mathematically for RSA encryption works by going through an example of sending an encrypted message! If you are interested in seeing how Euclid's algorithm would work, check out this video by Emily Jane: https://www.youtube.com/watch?v=fz1vxq5ts5I A big thanks to the 'Making & Science team at Google' for sponsoring this video! Please like and share using hashtag #sciencegoals
Html code for embedding videos on your blog
Text Comments (130)
邱吉 (12 days ago)
每次看同类的视频都有种“大家都会了就我不会”的挫败感→_→。
Vendel Serke (1 month ago)
So this method relies on having private keys that only the sender and receiver now. But how does those 2 parties agree on the private keys without 3rd parties interfering?
Jaba6798 (2 months ago)
You love eggs
gopro_2027 (3 months ago)
How come you write it so weird? Shouldn't it be like 17mod3=2? The may you wrote it really doesn't make any sense. After figuring that out though, the video was very helpful.
Johnny Rico (3 months ago)
You just made a great video. Very informative and well broken down.
fancy home (5 months ago)
Hello everyone, My name is Andy Walters. Don't believe all this fake video they ain't real, I was so happy when I met ([email protected]) he's a real and legit hacker, after I explained myself to him and he told me not to worry, all he asked if I have a Bank account, Credit Card top up, PayPal account, and I told him YES to my surprise I got $2500 in my account in 48hrs I was so happy, for that reason I must recommend him as much as I can try him today you can also text him here (541)-903-5835. Its new and hot hit up Morgan Hackman for fresh Btc Wallet top ups.... 100$ will generate 500$ in btc . 200$ will generate 1000 in btc 500$ will generate 2000 in btc.
Dave MIlke (5 months ago)
Best description I've found on this - thanks.
Zeeshan Patel (5 months ago)
Do you have a video on SHA256 ?
T1000mileman (5 months ago)
Are there algorithms available to determine if a large number is prime?
David Bristoll (6 months ago)
This is fantastic, thank you! I can't help but to think this is crackable! I know I will be proven wrong, especially when I start upscaling the numbers, but, I will benefit from and learn through trying. It's really helpful to see the underlying concepts. There's enough here to get some concept code together and to begin to understand the enormity of the task at hand. It would be very helpful if it could be explained how these numeric keys become the alphanumeric keys you see in other (over simplified) video examples and how a theoretical decryption key (based on the available public keys) could be tested. Thanks again for your effort in creating this easy to understand video. Not gonna lie, I had to pause, rewind, type-up, recheck my understanding and day-dream on it repeatedly! There's no doubt I'll be back to watch it again too.
Martin (6 months ago)
can you do the math behind ecliptic curve digital sign algo
codna
Miscritz Brotherzz (7 months ago)
relatively prime = their GCD is 1 (greatest common divisor) ??
Derek Lynch (8 months ago)
I have that same edition of Atlas Shrugged on my shelf!
João Massan (9 months ago)
At a first look I thought it would be a boring video. But man, it was amazing. Congrats and thank you.
Chotta Bheem (11 months ago)
Well done Mate..nicely explained, almost the best video on RSA yet. Appreciate your work...Keep it up!!!!
David Parry (11 months ago)
To be honest, ANY replacement to Public-Private Key methods in a post-QC world will be moot and useless. A real solution exists, that defeats the unlimited-crunching problems at source, but sadly _it's not for you._ _The process is more important than the outcome... and only one key is ever needed._ BTW primes are a dead-end because there are ways in, not least because there are patterns and novel 'spiral' approaches often provide valuable short-cuts even in the 8k digit ranges.
Eamon Hannan (11 months ago)
You did not explain how the private key is sent ? If someone has the private key they can decrypt the message . How is the private key transmitted so it is not intercepted . ?
David Rowthorn (11 months ago)
The private key is not sent. The message is encrypted with the public key and decrypted with the private key. So if I send you a message encrypted with your public key, you (and only you) already have the private key to unlock it.
Ramit Inyah (1 year ago)
great example, thanks!
LqIchor (1 year ago)
Thanks! I learned a lot from your video.
Nicholas Peralez (1 year ago)
This is awesome!
Ludo S (1 year ago)
And there comes the NSA and tries do decrypt the message using the private key 103 , or Chinese government with private key 183.. :) 75^23|187 = 75^103|187 = 75^183|187 = 80 in general M = (M^7|187)^23|187 = (M^7|187)^103|187 = (M^7|187)^183|187
AustinDoggie (1 year ago)
Don't quantum computers already exist? Like a DWave?
AustinDoggie DWave is a quantum computer, but it is based on Quantum annealing and not a universal quantum computer; it can't do shores algorithm but it can do stuff like solving optimising problems like for example seat arangement that allows people to easily reach the food they prefer but it can be used for stuff like distribution of resources.
lukeskywalker (1 year ago)
Thanks, finally understand this stuff!
tomctutor (1 year ago)
Thankyou Patrick you once again explain a very complex idea simply- brilliant tutor.
Daniel Cooney (1 year ago)
Hi, can you explain how to get "d" please?
Nain Abbas (1 year ago)
you have'nt explained the main idea... wtf who reciever gets the "d"???
Nain Abbas (1 year ago)
how the recive can find "d" without p and q, to decrypt you have not explained....
Miscritz Brotherzz (7 months ago)
u probably already found out the answer but i am still commenting for others that are also confused lets say that u want to send some message to me u and me both have our own public key and private key u use my public key (anyone can use that) to encrypt your message and send to me ( public and private both can be used to encrypt and decrypt ) then i use my private key (that is only known to me) to decrypt the message and me are done :)
3D Space (1 year ago)
mod is better to understand as 17 mod 3 = 2
Earl Fechter (1 year ago)
this is the weird thing with encryption. suddenly, it makes math relevent and interesting. I've always goofed off in math class, but rsa makes me look forward to it. If I hadnt learned about rsa, I would never be interested in math. you have helped decrypt my interest in math. Congrats.
Earl Fechter (1 year ago)
who said humpty dumpty was an egg?
Formally Informal (1 year ago)
Hey Patrick, can you make good money as a cryptanalyst? My school offers a masters in math with concentration in cryptanalysis.
Ed (11 months ago)
Joel Rodriguez not really, i suggest you to major in cybersecurity
Stanislav Bashkyrtsev (1 year ago)
I think a more important question is why this works.. It would require a deeper dive into the math, but without it the whole thing looks like magic.
Javier Livio (1 year ago)
Great resource. Hours before taken a test on this topic, it really brought light about this topic. Keep up the good work.
ashen madushanka (1 year ago)
I didn't get the part where explaining modulo arithmetic with an example at 9:27 . I thought it should be " 2= 17 mod 3 " or " 17/3 = 5 remainder 2 ". Please explain me where I was wrong.
Dan L. (11 months ago)
The parentheses are important here. 17 = 2 (mod 3) is the same as 2 = 17 (mod 3), just as a = b is equivalent to b = a. On the ring of integers we usually use, you wouldn't say 17 = 2, i.e. mod infinity, since 17 and 2 are clearly different numbers. But, 17 mod 3 = 2 mod 3, so 17 = 2 (mod 3).
Albert John Nguyễn (11 months ago)
I think he made a dyslexic typo.
Ramit Inyah (1 year ago)
That confused me as well. I know it by the format u described also. Suppose he's just using a different way to state the same thing.
alexwhb122 (1 year ago)
Yet another fantastic video.
notker88 (1 year ago)
Can there be multiple private keys for a public key?
notker88 (1 year ago)
why is 80 to 7 equivalent to 75? that makes no sense to me. Do you mean C = 75? at 12:00.
Kai Kunstmann (1 year ago)
9:25 well, I would say 15 o'clock, because that's what we do in non-America.
Miscritz Brotherzz (7 months ago)
lol i dont even bother to look at time myself just show my watch or phone to the person that asks me
Varuna (1 year ago)
It would've been much better to film one shot of the math the way you filmed other videos and film another shot like this horizontally that you could look into the camera for between writing. Then put the shot of you talking into the camera as a picture in picture of the math like YouTuber sentdex does with his tutorials. All this turning around, tape on the walls, you walking in front of the math is no bueno, dude. Picking up what I'm laying down? Two camera shot. Slate it at the beginning so you know where to synch them in Final Cut.
Michael Crookes (11 months ago)
Gah! The focus of that camera wandering in and out! Great video otherwise!
E G (1 year ago)
Patrick, you are unequivocally THE BEST! As an educator myself, you are my role model and my inspiration!
Darren Skerrett (1 year ago)
Thanks good exam prep
Suppose of an account with one user name and multiple one-time password (exactly like crypto card). Lets suppose I have given ID (which is same everytime) and password ( which vary every time). Now my question is, how they verify that this password belongs to the same user ID. If a crypto card can generate over millions of password for a particular ID. Is it mean that there are millions of passwords stored in the server for that particular ID ?
Jeffrey Howell (1 year ago)
Patrick, Excellent video! I'm in a cyber program and have been reading through a mountain of materials on P/P keys and this was by far the best. The Sesame Street example for us non-math guys was excellent. Very well done! Jeff
Aarushi Guptaa (1 year ago)
oh! its complicated
Knight H (1 year ago)
You look handsome...
Hero Man (1 year ago)
That's a huge library in the back ground. BTW Awesome videos.
BABLU KUMAR (1 year ago)
Please make a video on how to find decryption key. Thank you:)
Phillip (1 year ago)
I don 't know. It seems pictures, and diagrams are better way to teach materials.
Creative Force (1 year ago)
Hi Patrick I think the real life math applications videos are cool! Thank you for this!!!!
King Power (2 years ago)
This guy is a freaking genius
DrTomatoSpaghetti (2 years ago)
Hey Patrick, your explanation would be way clearer if you added an annotation explaining what P Q and N E are when you first define those variables.
Danny C. (2 years ago)
Always knew that math was important for decoding stuff but now i know why its important. Had i know this information The Imitation Game would've been so much more enjoyable.
Amir Asghary (2 years ago)
i'm a highschool student and i recently started learning about information security and cryptography. this was really helpful , thanks
patrickJMT (2 years ago)
+Amir Asghary my pleasure! Glad you liked it!
Dominic Illenberger (2 years ago)
Did any one else just come here to see what old pat looks like
patrickJMT (2 years ago)
+Dominic Illenberger just a typical dude, nothing to see here :)
H. Shane (2 years ago)
Aren't quantum computers out yet? I am pretty sure that Google bought one already.
patrickJMT (2 years ago)
i believe there is still some debate but it looks like if they are not here yet, they will be very soon!
Douglas Rocha (2 years ago)
Your videos always help me a lot patrickJMT! You're brilliant :)
Alex G (2 years ago)
so like the person you're sending it to already has p and q? how does the person you're sending it to decrypt the message?
Ramit Inyah (1 year ago)
Your explanation fills in the blanks @Victor Tran. Thanks! So key missing info from this vid to make this whole process make sense is as u said, but also the operation to produce N from p & q must be so complex that it can't easily be reverse engineered to determine p & q if someone intercepts N. Does Bob generate e or Alice?
Hexagon (1 year ago)
oooh I think I get it now :) . so everyone has access to N. Why is there an 'e' then? simply to make the encryption stronger?
darksteel78 (1 year ago)
Texagon Alice uses N and e to encrypt. Bob reverses the encryption using d which comes from P and Q which only he has.
Victor Tran (1 year ago)
+Texagon Bob _generates_ P and Q. Alice uses N to encrypt, which Bob calculates and sends to Alice. :)
Hexagon (1 year ago)
How does Bob get p and q. If it's unique to him then what did Alice use to encrypt?
phatrikk123 (2 years ago)
People might be working on solutions for post-quantum encryption however one thing which is rarely discussed is the time/money/effort required to re-write everything and upgrade everything which is currently using RSA encryption. Consider how slow the transition to IPv6 has been, transitioning absolutely everything to new crypto will be 10x worst.
TripleO et Diou (2 years ago)
Hey Patrick, can you make a video explaining the concept of bitcoins/the math behind it?
LAXEN9003 (30 days ago)
its RSa in bitcoins too
I am great fan of your work patrick thank you for this good work.
patrickJMT (2 years ago)
that is actually an interesting idea
Joseph Thoennes (2 years ago)
Nice. Did I miss something? Where does e=7 come from? I know that the value of e has to meet a rule, but there are multiple numbers that do. Why 7 and not 3 or 11? Is it a random choice from a list?
Joseph Thoennes (2 years ago)
Ah. Found it: http://www.ams.org/samplings/math-awareness-month/06-Kaliski.pdf A very nice step by step... a paper version of your video :)
Joseph Thoennes (2 years ago)
So e can be any number, provided it meets the "relative prime" criteria? Then we're talking about 3 random numbers, 2 of which must be prime, and the third of which must not share factors with the "product of the largest non-prime to each other the first two). This is a bit different then 3 large prime numbers. Why not just use 3 large prime numbers?
patrickJMT (2 years ago)
yep, everyone just picks random numbers, nothing special about those numbers except they were small enough for me to use
aikimark1955 (2 years ago)
"even though those two keys are public" - we had to wait a long time to get to the PRIVATE key(s)
Patrick Kennedy (2 years ago)
check out my spotify https://open.spotify.com/user/patrickmwk45 I like all music except country
Cassandra Cain (1 year ago)
why you posted that?
435iak (2 years ago)
This was a great video! I learned a lot! Thanks Patrick
skillzz (2 years ago)
Very interesting stuff! But I'm wondering, how are the private keys generated?
Roberta Rossi (2 years ago)
incredible how very simple algebra can built a tecnological empire. great lesson btw.
Dangis Congrataway (2 years ago)
I like your new video format
6thmonkey (2 years ago)
Fantastic video, I loved how your applied the math to a real world application. It certainly makes it more relateable and interesting :)
jawbone2000 (2 years ago)
This is is enlightening, thanks
Ross Parlette (2 years ago)
Better than a Playfair square.
CoolAlien 47 (2 years ago)
You're always making some of the most interesting videos. Especially with this one and the Simpsons one.
Stevenisnothere (2 years ago)
he writes his modular arithmetic weird....unless i was taught it was in discrete math...
Stevenisnothere (2 years ago)
is mod not modulus? how does that equal 17..
Windoge 8 (4 months ago)
He is wrong but he is right about how to get the answer... If the question was 17 mod 3 then the answer is 2
kikones34 (2 years ago)
Nope, mod stands for modulo: https://en.wikipedia.org/wiki/Modulo_operation
Sherevan Alhamy (2 years ago)
I feel like I have math homework whenever I hear your voice. it's so weird
Bruce Wayne (2 years ago)
This is so damn hilarious
Hamed Hosseini (2 years ago)
Hey patrick, please do more math tutes :(
Redda (2 years ago)
You didn't talk about why C^d (mod N) reverses M^e (mod N). That's the part I was curious about!
aaa bbb (2 years ago)
it is because d is the inverse of e mod phi(N)
Believe It (2 years ago)
One thing I didn't understand - How does the person who you're sending the message to know what 'd' is? That's they only way they can recover the original message right, and they don't know what p and q are.
Believe It (2 years ago)
You use THEIR public key! Now I get it. Genius idea! I feel that should have been made a little bit clearer in the video. Thanks
Sykander (2 years ago)
You would give out public keys for people to send messages to you. If you were sending an encrypted message to someone you would use their public keys to encrypt your message. They would then use their number d to decrypt the message you sent.
Believe It (2 years ago)
But isn't d specific to what our private key is? It looks to me the first time I'm looking at it now that it is dependent on what p and q and e are. Is this the case? Why does the person who we're sending the message to know what d is but nobody else does? To make the point of my confusion even clearer - Say if I sent a second message to a different person, wouldn't I still be using the same p = 11, q = 17, e = 7 in order to do so? In that case wouldn't d be the same for the second message, meaning d is not unique to the message receiver?
aaa bbb (2 years ago)
the person recieving the message has the d and other stuff originally, the sender only knows the encryption key
Ryth (2 years ago)
How are these two prime numbers assigned to a user? Say I generate a SSH key, I imagine my computer wont just randomly go and find two insanely big primes. I assume every person needs a new set of prime numbers, or the encryption would be easily bruteforced by trying combinations of known primes.
Miscritz Brotherzz (7 months ago)
did u find answer? i am wondering the same thing
litojonny (2 years ago)
hey patrick can you make videos on program languages (python,c,etc)?
AODQ (2 years ago)
+ItsThatMilkshake ; Pick up a good book and you will change your mind. :) Good start: Modern C++ Design by Alexandrescu
ItsThatMilkshake (2 years ago)
+AODQ We can agree to disagree, because I benefit the opposite way.
AODQ (2 years ago)
+ItsThatMilkshake ; Simply not true. Experts write books both for people just starting off programming and for people who have programmed before. Usually a language/tool has a single standard book meant as the official reference and learning material, and then a few others for learning both the language and how to program. I've learned nearly exclusively from books and you simply will never get the scope or breadth of programming from even a hundred youtube videos.
ItsThatMilkshake (2 years ago)
+AODQ Which is exactly why a lot of books are poorly written for beginners. The authors are SO good, they forget the readers are new to it all. Videos are step by step and are explained as they type the code. I learned a lot more watching a video on topic X, THEN reading the text on topic X :)
Applefanboy2012 (2 years ago)
Hey Patrick.

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.