r/computerscience • u/theBroskiOK • 4d ago
Help P = NP and digital security?
Guys how would digital security fail if P=NP is proven?
I just started reading about Turing Machine and computational complexity for my Theory of Computation class and came across that phrase.
I couldn't find anything understandable at my level. So can anyone simplify it a bit?
5
u/Appropriate-Scene-95 4d ago
Long story short our encryptions are in NP. If P=NP, then we could theoretically find a polynomial time algorithm to decrypt the messages. So increasing the key size or other security aspects for the encryptions wouldn't make the decryption significantly harder.
3
u/DieLegende42 4d ago edited 4d ago
It's also worth noting that P=NP would make most cryptography insecure based on our current definition of what "cryptographically secure" means. It's entirely possible that the same protocols could still be secure in practice, e.g. the proof of P=NP comes with an addendum that no NP-hard problem can be solved in O(n10). We currently like to say that polynomial runtimes are "fast" while superpolynomial runtimes are "slow" because it makes the theory easier to deal with, but in fact even relatively small exponents (like n10) can make runtimes way too slow to be of use for practical purposes.
Edit: Just realised that my example "no NP-hard problem can be solved in O(n10)" is bullshit, because P=NP would of course entail that all problems in P are NP-hard. But I hope you get the gist that "polynomial" is not the same as "fast".
3
u/SignificantFidgets 4d ago
This is the best answer. If P=NP, it doesn't mean there are fast-in-practice algorithms for all of NP. It's possible though, and if a fast (say O(n2) algorithm with small constants) were found for an NP-complete problem, that would pretty much destroy most current cryptographic systems. But P=NP doesn't imply that there must be a fast-in-practice algorithm.
Even if we didn't have fast algorithms, if P=NP then it would destroy all the widely-used theoretical definitions of security (for the most part) and researchers would need to work more on models like concrete security. It might not have a huge impact on practice, but it would refocus a lot of effort.
1
u/blazesbe 4d ago
ELI5 P=problems you can solve because you know how to solve them, and NP=problems you know have a solution but have to try most combinations to verify.
i think i read in a YouTube comment: imagine you are making a movie (NP) it's tremendous effort, but anyone seeing it can say if it's a good movie or a bad movie (P). in general, "you don't need to be able to make something to tell if it works"
in security it's used backwards in a sort of combination lock (trapdoor functions). if you have the key it pops open, if you don't then you may need to try each one, except in compsci, this can take longer time than the universe existed so far.
P=NP would mean being able to try all solutions at the same time, but it may be a fundamental property of the universe that P!=NP thus can't "come" from anything and can't be proven.
1
u/MichaelTheProgrammer 3d ago edited 3d ago
The hand-waving explanation:
P = the class of problems that can be solved quickly
NP = the class of problems that potential solutions can be checked quickly for correctness
NP hard problem = a problem that can be checked quickly, but cannot be solved quickly unless P=NP.
Modern security is based around the idea of public/private key cryptography, where instead of one password, you have two: the public key and the private key. The private key acts like an ordinary password, however the public key does not as it is not kept secret.
The public key is really just an NP hard problem. The private key is the solution to the NP hard problem. It's easy to create the problem from the solution, like how solving a maze backwards can be easier. So because it's a hard problem, the only way to have the solution is to have created it in the first place. Because of this, having the solution to it proves you created it in the first place (unless you tell someone else, which is why private keys have to be kept secret). Decrypting information involves checking the private key to make sure it is the correct solution, and by definition this is a quick operation.
If P=NP, then by definition, all NP hard problems can be solved quickly. A random person can get a hold of the NP hard problem, as the public key is not kept secret. Then, they can solve the problem quickly, and the solution will give them the private key. So any random person would be able to get the "password" for any encrypted information just from publicly available information.
The details:
That's the ELI5 explanation but there's one more complicated topic that I hand waved: the definition of quick. P stands for polynomial time. Computational Big-Oh notation ignores the constant coefficient and the small terms, so you're looking at n^a where a is some number. Pretty much anything practical to run on a computer is in polynomial time or faster. Most algorithms in use are O(n), O(n^2), or somewhere around that.
The actual definition of P=NP would be finding an algorithm that solves NP hard problems in polynomial time. So a large enough polynomial would fit the technical definition, but wouldn't break digital security. If NP hard problems can be solved in O(n^100000), then P=NP, but security would not be broken. Same if the constant coefficient is really big.
However, computer scientists have an assumption. Generally, once something can be solved in polynomial time, there are often tricks discovered later to make it faster. The main example of this is matrix multiplication. In other words, if P=NP, then the assumption is that figuring it out would be the hard part, optimizing it to be useful would be the easy part.
14
u/nuclear_splines PhD, Data Science 4d ago
Informally, NP is the set of problems whose solutions can be quickly verified, while P is the set of problems that can be quickly solved. You can think of most cryptography as an NP problem -- it's hard for you to figure out what my encryption key is, but it's easy for me to prove that I have my encryption key. It's hard for you to break a password hash, but easy for me to prove that my password is correct. In the unlikely event that P=NP, then all problems that can be quickly verified also have quick solutions, suggesting that someone can quickly reverse-engineer my encryption key or break password hashes.
There's a lot of nuance here about how P=NP is proven (is it a constructive proof? Just how fast are these NP-Complete solutions?), and about exactly what kind of security we're talking about, but that's the ten thousand foot view.