This post’s ID is 3555430289526188340.
There is a remarkably common misconception (one I’ve personally run into a few times) that quantum computers break cryptography by, essentially, making brute-force search work in polynomial time. I cannot be clear enough when I say this is not true, and this is not how quantum computers work. If it was true, there would no longer be a cryptography. It would also, amusingly, imply that P is NP for quantum computers.
Quantum computers are fundamentally not that different at a mathematical level than classical computers. However, explaining the difference is going to require a bit of mathematical background. I will assume basic familiarity with linear algebra (but not modern algebra, for which I’ll explain concepts).
A field is a mathematical object consisting of a set associated with two operations, conveniently (but not always) referred to as multiplication and addition. These operations must satisfy certain properties:
You might think this is just, like, all numbers, and that I’m pulling your leg, but enterprising young mathematicians should note that these properties do not hold for all subsets of the complex numbers (like, say, the integers !).
This is where things get slightly more fun. See, there are infinite possible fields with infinite members (like the rational numbers ), but there are also infinite possible fields with finite members! These are termed Galois or finite fields, after the 19th-century French mathematician Évariste Galois. We can think of a trivial Galois field right off the bat: , the Galois field with two elements, zero and one (if we assume here that ). You can confirm for yourself that the above properties hold. The number of elements in a Galois field is termed its order, and must be a nonzero power of a prime number.
Why?
Assume that we have a field with order .
Let be equal to adding the element to itself times. Then there exists such that (we call this the characteristic of ). If there are multiple such , then we take the smallest one. At least one such must exist by the pigeonhole principle and the fact that the and elements must be distinct.
If was composite, then we could take any prime factor , and adding to itself times would equal zero: by distributivity, we can equate this to . Doing this for every prime factor (with repetitions), we obtain , of which no (since is specifically the smallest integer with that property). Each of these , being nonzero, has an inverse , and if we multiply , we could arrive at or at by following either the distributivity or identity properties. Both cannot be true, so we have derived a contradiction, so must be prime.
Now we must show that is a power of .
If does not divide , then we would see that , , and indeed covers every element of . Therefore, assuming without loss of generality that , . Setting , we obtain , so , which cannot be true. Thus divides .
Now assume that has some prime factor . We see easily that , and also that . Take to be the absolute value of the difference between and the nearest nonzero multiple of . , so , and . As before, set and observe therefore that , which is a contradiction, so must be a power of .
There are several equivalent models of classical computing, as presented by Alan Turing, Haskell Curry, and others. However, we will presently restrict ourselves to a model that is actually not equivalent to any of these, as it doesn’t allow for unbounded computation (in addition to other things). We can, though, take this model and extend it to a full Turing-complete model of computing.
Brief terminology note
A linear operator is a generalization of a matrix that takes into account only what it “does” to a vector.
Let’s say that a classical computer is a linear operator over a vector space associated with scalar field . The members of this vector space are each of the form , where is a basis vector representing a and is a basis vector representing a . We can then add vectors by adding up their “subvectors” in an elementwise fashion using this handy-dandy table:
So every element is its own inverse. We will see that it does not matter that does not have any physical interpretation for a classical computer. We then define a linear operator such that if and only if the subvector is either or , with otherwise. Essentially, indicates if a subvector corresponds to a physically achievable state. is a linear operator, because for all , but it is not invertible.
We can then clarify that has the restriction that . If we only feed in such that , i.e. all of our input vectors correspond to physically achievable states, then will always give out corresponding physically achievable states. We can thereby represent any bounded classical computation as a linear operator with this property.
Why not just use to represent and to represent ?
Representing and as basis vectors makes it so that all the basic logic gates can be represented using a modification of the Toffoli gate, thus being linear operators with , which means their composition is also a linear operator with this property. This requires some extra machinery when extended to a Turing machine, but it is entirely possible.
We can extend this to be directly equivalent to a Turing machine by assuming that the internal state register of the machine corresponds to a vector such that , the symbols on the tape are (perhaps differently-dimensioned) vectors with the same property, and the output action of the machine is a vector with that property. Then we can describe the state machine as a bounded classical computation, which we represent as a linear operator with , and this gives us a Turing complete model.
Why did I make this so complicated? So as to make quantum computers seem vanishingly simple by comparison.
By taking the previous description and replacing the scalar field with the complex numbers. Now, the vector space is given by . Instead of using , to indicate that a vector corresponds to a physically achievable state, we check that , and we assume that is unitary (i.e., its Hermitian transpose is its inverse and thus the magnitude of its determinant is 1) and thus preserves this property. You can verify that this can compute anything the classical model can on your own time.
Wasn’t that easy?
It turns out to have massive implications, including making possible a couple algorithms that do certain problems that are hard for classical computers very quickly.
But first, a brief diversion.
Finding the logarithm base () of a positive integer is simple and can be done quickly enough using simple bisection:
This algorithm works because increases monotonically as does. Can we generalize logarithms to cases where this isn’t true?
We can. The discrete logarithm assumes is a nonnegative integer and lets us generalize logarithms to groups generally.
What is a group?
A group is like a field as defined above but doesn’t have an addition operation (and thus a zero element) and multiplication doesn’t need to be commutative (though you could equivalently say it doesn’t have multiplication or a one element and addition doesn’t need to be commutative).
To explain briefly why discrete logarithms often aren’t as easy to find as regular logarithms, note that the above algorithm relies on an unstated property of over the reals: it’s continuous in addition to being monotonically increasing for . This means we can apply one of my favorite theorems from my scientific programming class in college, the intermediate value theorem.
Unfortunately, we can’t generally assume that a group even has a concept of continuity to apply. To make things worse (it can always get worse), we cannot assume that exponentials are monotonically increasing or decreasing. Why?
Consider the Galois field . We can represent this really easily as the integers modulo 127: that is, we take the integers and consider any two and to be congruent if and only if there exists an integer such that . If we then consider all congruent integers to be the “same” as each other, we can see that this forms a field.
Now let’s plot out for from 0 to 126 inclusive. You might see where this is going.
Definitely not monotonic. You can check, though, and see that every member of is represented; in fact, since 127 is prime, there is no base whose powers will ever include zero. That all the members are represented is not going to be true of every element of . It isn’t true of 2, for example. The number of unique elements of a group that can be generated by multiplying/adding an element by itself is, confusingly, termed the order of (it helps that this is because those unique elements themselves form a group, and that’s what the order is referring to here).
When are discrete logarithms easy to find?
There are a few notable cases, but in short: division over a Galois field of prime order is a special form of the discrete logarithm, and it’s easy in large part because of Euler’s theorem allowing us to compute for as , which can be done as a series of multiplications.
You will note that I am not giving any rigorous proof that this problem is hard, only that it’s not solvable by the simplest algorithm for solving non-discrete logarithms. This is because we actually don’t really know if this problem is truly hard for classical computers, but we think it is. We do know, however, that it is easy for quantum computers using Shor’s algorithm.
There are two quantum algorithms that cryptographers (generally) care about. One is called Shor’s algorithm (due to mathematician Peter Shor), and the other is Grover’s algorithm (due to mathematician Lov Grover). Note that if you understand how quantum computers work, Wikipedia generally explains these more succinctly and clearly than I could here, so go read that.
The exact details don’t super matter here: just know that Shor’s lets us factor large numbers and compute discrete logarithms quickly on a quantum computer, and that Grover’s lets us reverse an arbitrary function a little less slowly (if there are possibilities, Grover’s needs on the order of steps where classical brute-force search needs steps). They both do this by taking advantage of the expanded number of states a quantum computer allows.
How are factoring and discrete logarithms related?
Shor’s algorithm actually technically solves the hidden subgroup problem, of which factoring integers and computing discrete logarithms are special cases.
You should. The problems solved by Shor’s are the hard problems underlying RSA, Diffie-Hellman key exchange, and (most) elliptic curve cryptography. When cryptographically-relevant quantum computers come around, they will be used to break these primitives and we need to have moved to primitives that aren’t as easily broken by them.
Wait, you mentioned Grover’s algorithm. Is that relevant here?
It’s a long story, but essentially Grover’s is faster than brute-force search, but not enough to actually break any real cryptography (that I know of). The reason we want something in classical cryptography to take around steps or more to break is because usually, those steps can be parallelized, so if it took steps we could throw a supercomputer with CPUs at the problem and crack it in a few years. The way Grover’s works, however, means that if you parallelize it it actually takes more steps overall, to the point where a quantum computer or group of quantum computers will likely never be able to break 128-bit symmetric primitives unless they are also broken classically! There is an excellent blog post by Filippo Valsorda that covers this if you want a more in-depth explanation.
Most (but not all!) elliptic-curve cryptography essentially relies on the discrete log problem over elliptic curves.
What’s an elliptic curve?
For some field , we take an elliptic curve in homogeneous coordinates to be the set of points of the equation for some coefficients . Note that we omit the solution because, in projective geometry, denotes the “point/line at infinity”, which doesn’t have a super intuitive physical meaning but makes the math much nicer and makes each elliptic curve form an abelian group (which is a group where we can assume the group operation is commutative).
An elliptic curve over a Galois field forms an abelian group with a finite order. To add two points and on the curve, we draw a line through them, find the third intersection with the rest of the curve (which may be on the aforementioned line at infinity), and flip that point across the -axis, giving us . By repeatedly adding a point to itself or negating it, we can “multiply” the point by an integer; this is termed scalar multiplication. We can therefore formulate the discrete logarithm problem for elliptic curves: take , being the order of the “base point” , and given , compute . In fact, if is prime, then the group generated by scalar multiplication of is isomorphic to the integers modulo .
Quantum computers are complicated but not that different fundamentally from classical computers. Nevertheless, certain problems that are hard on classical computers and on which we placed several decades of cryptography are easily broken by quantum computers. This includes RSA, Diffie-Hellman key exchange, and scalar multiplication on elliptic curves. I hope this primer was enough to at least generally explain why all this is true.