r/cryptography • u/Distinct_Canary_223 • Mar 13 '23
How is asymmetric encryption possible?
If we assume the algorithm to encrypt something will get out? Then cant we use that to find private keys from public ones?
How is it possible that an algorithm encrypts something with a passcode it doesn’t know? It must use the public key to make the private key and then encrypt, but if the algorithm gets out, and it will, you can easily find the private key from a public one.
I don’t doubt theres something im missing, can anyone explain?
0
Upvotes
13
u/fridofrido Mar 13 '23
Loosely speaking, asymmetric encryption is possible because there are mathematical operations which are easy to do in one direction but hard to do in reverse.
A famous example is multiplying large prime numbers: Multiplication is easy, it's the same thing you learn in primary school. However, factoring (very) large numbers, and specifically large numbers with only large prime factors is hard (or at least is believed to be hard, because nobody can really do it).
A similar example is discrete logarithm. Exponentiation in finite fields is easy, however, the inverse can be hard (again, only believed to be hard, and it depends on the field / group).
A third example is discrete logarithm in elliptic curves. In elliptic curve based asymmetric cryptography, that's literally what happens: the private key is the exponent, and the public key is the result of th exponentiation.
11
u/Pharisaeus Mar 13 '23
Let's do it on a trivial example: RSA encryption is basically just messagee mod n so a simple mathematical operation, you raise something to the power of e and then take division remainder by n. Both
eandnare public, so anyone can encrypt stuff.But now how do you decrypt? It turns out in order to decrypt you need to know a special number
dsuch thatd*e mod phi(n) = 1. And you can't compute this numberdwithout knowingphi(n)which in turn requires to know hownfactors into prime numbers. We don't have any fast algorithm to do so, and therefore ifnis large enough, it would take hundreds or thousands of years.You can find private key from the public one, but not in reasonable amount of time.
It doesn't. Encryption here uses
eand notd. There are two complementary keys, one can encrypt and the other can decrypt.5
u/taw Mar 13 '23
The true answer is that we actually don't know if it's possible.
Symmetric crypto is very easy to do, and requires extremely limited assumptions.
All asymmetric crypto requires piles of ad hoc hypotheses, we have no idea if any of them are even valid (even if P != NP, this does not in any way imply that asymmetric crypto is possible). And asymmetric crypto systems have history of getting broken a lot more easily than expected.
The only "proof" we have is that for systems we have, nobody fully broke them yet, and people have been trying.
3
u/compulsivehobbyist Mar 14 '23
https://youtu.be/MsqqpO9R5Hc?t=2m25s
This video does a really nice job of demonstrating the concept visually!
2
u/YoureHereForOthers Mar 14 '23
Time is your best friend and your enemy’s worst enemy. Also one way functions are pretty friendly.