logoalt Hacker News

soon_to_be_sb • yesterday at 6:18 AM • 13 replies • view on HN

Can someone say how proving P=NP will automatically allow us to crack RSA? Like if we have a public key, just by using the proof of P=NP, can we easily get the private key from it?


Replies

Gabriel54 • yesterday at 6:51 AM

It wouldn’t. If P=NP then many problems we think are hard (ie currently require exponential time) would in fact be solvable in polynomial time. But such a polynomial time algorithm might be “galactic” in the sense that the constants are so astronomically large that in practice the algorithm would not be faster than current methods.

Note that this is not widely believed to be likely, because usually if a problem is in P, then usually further work can improve constants considerably, but it is a possibility that there is a certain class of problems in P that are “galacticly” polynomial.

inkysigma • yesterday at 6:51 AM

Depending on the proof of P=NP and what you mean by "easily". In TCS, anything polynomial is considered "easily" so it could easily be the case that some ridiculous polynomial is implied with some ridiculous constants.

Suppose the proof of P=NP were not constructive, then Levin's universal search algorithm automatically gives us an algorithm that finds the factors in polynomial time. This would satisfy some definition of "easily" from above. However, if you take a look at Levin's universal search, it quickly becomes apparent the constants involved are truly galactic and not worth even thinking about in a practical sense.

If the proof of P=NP were constructive but gave some incredibly high degree polynomial or something with incredibly high constants, then we might be more wary. We would be able to get factors in polynomial time but it would still be "hard" in a practical sense to get the private key but it becomes exceedingly difficult to guarantee that there isn't some practically efficient algorithm. Proving fine grained lower bounds like this has been difficult to say the least.

If the proof of P=NP were constructive and efficient, then we would easily be able to get the private key. There is some additional detail here about what NP complete problem was actually solved (and thus how much the polynomial reduction cost but this is typically small) but this is a bit detailed and unclear. We would also probably begin searching for a directly efficient factoring algorithm.

➕ show 1 reply
2143 • yesterday at 6:36 AM

I’m not qualified to answer this.

(Well my qualification is this – I took a semester of Theory of Computation class about a decade ago and barely managed to pass without screwing up my scholarship in the foreign country I was studying in. Today I write PHP during my day job..)

One way to try to get the private key is to try all possibilities. For an RSA key with 4096 bits, there are 2^4096 possible keys, which I’m told is greater than the number of atoms in the universe.

So you see, this is a O(2^n) operation. ie., the algorithm is “exponential”.

You’ll never finish checking all those combinations before the universe ends, or at least not before the Sun explodes and the Earth ceases to exist as we know it.

Unless you’re really really lucky and a key you try during your lifetime happens to be the actual private key. But the likelihood of that happening is practically zero because of the sheer number of possibilities.

The point is, you have to exhaustively check all possible keys. Exponential.

P=NP means there exists a polynomial time (O(n^k)) algorithm to find the private key. ie., it can be found relatively quickly.

This is all I know. I skipped a lot of details. Experts can chime in.

➕ show 4 replies
aleph_minus_one • yesterday at 2:13 PM

> Like if we have a public key, just by using the proof of P=NP, can we easily get the private key from it?

1. Consider an RSA public key (n, e). Keep in mind that by the RSA standard, n=p*q where p,q are prime (for the mathematics behind RSA, this condition can be relaxed, but for simplicity, let's assume that this is the case).

2. Formulate "n=p*q AND p prime AND q prime" as a Boolean circuit where the inputs are bits encoding candidates for p and q.

3. Since P=NP, you can in polynomial time decide whether for a Boolean circuit there exist variable assignment such that the circuit evaluates to 1.

4. We know that our original circuit has such an assignment. To find p,q, set some Boolean variable to 0 or 1 and check whether under this additional condition, the circuit still has an assignment for which it evaluates to 1. If this is the case, do this with another input variable, until you have found p, q.

5. To construct a private key that is able to decrypt the messages encrypted with the public key (n, e), use (n, d) where d*e ≡ 1 mod λ(n). λ(n) is the Carmichael function of n (https://en.wikipedia.org/wiki/Carmichael_function ). If n=p*q where p, q are odd primes, we have λ(n)=lcm(p-1, q-1).

Note that (n, d) is not necessarily equal to the original private key (for example, the original creator could instead have used the formula de ≡ 1 mod φ(n) where φ is Euler's totient function; for n=pq where p,q prime, we have φ(n)=(p-1)*(q-1) , even though this way of creating private keys is prohibited in FIPS 186-4. See https://en.wikipedia.org/w/index.php?title=RSA_cryptosystem&... for a discussion of this topic).*

stingraycharles • yesterday at 2:14 PM

It means that there’s a simple algorithm so solve every problem, rather than having to brute force it.

So basically being able to reverse all crypto algorithms without having to try all possible combinations.

➕ show 1 reply
rmu09 • yesterday at 7:43 AM

Is it even known that factorization is NP? Maybe some new efficient algorithm (like manually calculating a square root) pops up that just yields the largest prime factor of a number? Is that ruled out? That would break RSA without touching all the other P=NP stuff.

➕ show 2 replies
leowoo91 • yesterday at 4:04 PM

To me, it always looked like an invalid question and prolly false, because you can't represent "every problem" to work on the proof. I believe RSA prime factoring problem itself is much more "workable" than this.

habitue • yesterday at 7:03 AM

Depends on if the proof is constructive or non-constructive.

If the proof is constructive, it'll say "here's an algorithm you can use"

If the proof is non-constructive, it'll say "It's not possible for there not to be an algorithm you can use" and... that doesn't really help you find the algorithm

➕ show 1 reply
solyin • yesterday at 6:51 AM

> if we have a public key, just by using the proof of P=NP, can we easily get the private key from it?

There's a couple more steps, but since we have AI, I wouldn't say it would be easy per se, but it goes from being actually impossible to "okay, maybe with a lot of effort". Right now, it's impossible for anybody to snoop or alter the TLS connection to my bank that's encrypted with a 4k RSA key. To go from impossible to "maybe the CIA/NSA if they really cared" would be world changing. Nevermind that me talking to my bank is not that interesting to them, the mere possibility upends a lot of assumptions about the world that computer people have.

It wouldn't be automatic, but a CIA agent with access to Claude and enough tokens could then do it.

cowlevel • yesterday at 1:50 PM

If the proof gives a P algorithm to solve NP problems, we can apply it to many NP problems to find out their solutions.

This won't work if the solution is "only technically in P" like O(n^10¹⁰⁰⁰), or if the proof is nonconstructive (e.g. proof by contradiction) and doesn't give an algorithm.

cantalopes • yesterday at 7:44 AM

Majority of respected professors of theoretical conputer science kind of know and assumes that p is not np. it's possible because not proven but it's extremely unlikely

_heimdall • yesterday at 6:25 AM

Proving P=NP is theoretical, for starters. It would be an important finding, but it wouldn't immediately break RSA encryption.

➕ show 1 reply
NoMoreNicksLeft • yesterday at 6:28 AM

One NP problem can be transformed into another... if you can solve an NP problem, you can solve all NP problems. It's generally trivial to prove that a particular problem is NP, and many classes of problems have been proven to be NP. P problems can be solved in non-exponential time. That is, if you're cracking some crypto and the crypto were P instead of NP, it wouldn't take you 10 billion years or a Matrioshka brain to do it. Crypto is NP by design. Because, for now, we think NP != P. And if we were wrong about that...

➕ show 4 replies