What happens if P = NP?

@DanHollick
Dan Hollick@DanHollick
55 views Nov 27, 2026 ~6 min read
Advertisement

A lot of crazy shit is happening in mathematics lately but for us normies it’s a little difficult to a) understand and b) care. That’s largely because there’s no practical ramifications to a lot of these proofs - we have been operating under the assumption these things were true for decades.

Media image

But there are some rumours floating around that there is a P versus NP proof on the way and the practical implications of this are much bigger. The way we communicate securely online is built on the assumption that there is a category of problem that computers can verify quickly but can't solve in a reasonable time, otherwise phrased as P ≠ NP.

The best way to explain P and NP problems is through some examples. Imagine we have a phone book and we need to find someone’s number. Because the list is structured, searching it is pretty fast even if the phone book is massive.

Media image

This is a P category problem because it can be solved in polynomial time. A polynomial is just an expression where the input size n sits in the base and gets raised to a fixed constant power (n, n^2, n^3) so as the list size increases the work multiplies by some fixed, predictable multiplier.

Media image

If we are given a number in the phone book and need to find the name associated with it, it gets a lot harder. The only way to do this is check every entry because there’s no structure we can exploit to speed things up. It’s still a P problem but it’s getting harder to solve, even though it’s trivial to verify the solution.

Media image

Now imagine we need to solve a Sudoku puzzle. It’s quite difficult to find a solution because the number of possibilities make the search space large. The interesting thing is its very easy to check if a solution is correct, and we can do the checking in polynomial time.

Media image

A 9×9 Sudoku is tiny for a computer, so imagine scaling it up to a 100×100 or 1,000×1,000 grid — checking a finished board is still quick, but finding the solution explodes exponentially. This is an NP (Nondeterministic polynomial time) problem, which basically means it’s hard to solve but easy to verify where P problems are both easy to solve and verify.

All P problems exist inside NP because they can be verified in polynomial time. But the open question is if all of NP exists within P (P = NP), so being easy to verify means it is also easy to solve and we just haven't figured out the optimal solutions to these problems yet.

Media image

So why does this matter? We’ll we’ve been relying on the assumption that P ≠ NP to encrypt traffic over the internet. One of the biggest challenges in cryptography is sending secure messages between two parties over an open network.

One way we do this is by generating two mathematically linked keys, a public and private one. If you want to send me a message, I send my public key over the open network and you use it to encrypt a message that you send back. Because they operate as a linked pair, only someone with my private key will be able to decrypt the message.

Media image

Simple in theory but for this to work the private key needs to have the property of being able to reverse the public key without leaking it. To do this we depend on what we’ve always believed to be a mathematical one way door: large prime factorisation.

The first step is to pick two prime numbers p and q and compute their product n. In practice these are very, very large to make it harder to reverse.

Media image

Next we need to calculate φ (phi), which is the count of numbers between 1 and n that are coprime with n. Basically, how many numbers are there between 1 and n where the only number that can be used to divide both that number and n evenly is 1.

Media image

Now we are going to use φ to derive a public and private exponent. For the public exponent e it just needs to be a number that's coprime with φ. For the private exponent d it needs to be a multiple of e that is equal to a multiple of φ + 1 .

Media image

Complicated, I know. We encrypt a message by raising it to the power of e and we decrypt it by raising it to the power of d. This whole thing only works because d is the inverse of e which means it can be used to cancel out e but d is never shared over the wire.

Media image

These are called RSA keys and the whole thing depends on the fact that for large keys, the search space is so large that it would take thousands of years to be able to figure out the original p and q values given you only know the product n and the public exponent e. You’d need to check every combination of primes from 1 to n.

Media image

If P = NP it implies that there is a polynomial time method for working out p and q and every RSA key can be cracked potentially dissolving the concept of privacy on the internet. It wouldn't just be RSA keys but almost every cryptographic method (including post-quantum techniques) because there would be no such thing as a one-way function.

We might not be fucked

Even if the proof hands us an explicit algorithm, "polynomial" just means some fixed exponent (n^k) — it says nothing about k being small. In fact, it is possible for a polynomial algorithm to be slower than brute force for certain key sizes so it all depends on where the crossover point is.

What happens if we prove that P ≠ NP? Well, it would suck in a different way because we’d know that there is some fundamental speed limit to computing and any speed ups come from clever pattern exploitation, like Shor’s algorithm.

It also wouldn’t prove that our cryptography techniques are safe so there's not much upside. Factoring (RSA) and discrete log (Diffie-Hellman) algorithms aren't currently proven to be NP, they could be P which would be equally as destabilising.

In fact, the current rumours indicate that one of the labs might have factorisation down to polynomial time. Which means something we long believed to be NP is actually P and the P = NP question remains open.

Anyway, if you want to dive deeper into any of these things they come from the chapters in makingsoftware.com on cryptography, time complexity and quantum computing.

Actions
What You Can Do
  • Export as PDF or Markdown
  • Batch Export to Notion
  • Bookmark & Highlight
  • Screenshot Tweet
Create Free Account

Includes 7-day Premium trial

Advertisement