Math philosophy: Why polynomials won’t stop showing up
Brian asked me to give a math-for-engineers talk on why polynomials keep on reappearing over and over in cryptography. I’m going to try my best, but this is going to be really a math philosophy talk.
I don’t know if I’m able to give the reason why polynomials, because that’s above my pay-grade, so I’m content to try to explain one reason why polynomials appear. The overall assertion is the following pseudo-theorem.
Proposition 1. Whenever you are trying to do linear algebra, the “best” choice of coefficients are given by polynomials.
To try to stake this claim, I’m going to do a dive into one particular protocol, Shamir secret-sharing. I’m going to phrase it entirely in terms of linear algebra at first, and then show how polynomials arise “organically” as the best fit by several criteria.
Secret-sharing
Let’s say we want to do a -of- secret sharing scheme, which means we give each of people a secret share such that any two of them can reconstruct the secret, but no single one of them.
The typical way to do this is to let be a number corresponding to the secret and a random “noise” number. Then
- Send person 1 the value of
- Send person 2 the value of
- …
- Send person the value of .
Then each individual person has no information, but any two can solve a two-variable system of equations to extract . For example, if person is told that while person is told that , then each of them alone doesn’t know anything about , but together they can solve to get .
What if you want to do -of-? If you want to keep buying the linear algebra idea, then the general principle is that we want to choose some functions , , such that
- Send person 1 the value of
- Send person 2 the value of
- …
- Send person the value of .
In the two-variable example, we just used and . For three functions, what would we pick? Well, let’s first make a wish-list of properties that we would want to satisfy:
-
For every three indices , we want there to be a unique solution to the linear algebra task
This is equivalent to
-
Ideally, for practical reasons, we’d like , , to not grow too quickly and be pretty easy to calculate.
-
Ideally, for practical reasons, we’d like inverting to be easy to implement. That is, actually solving the system shouldn’t be too expensive.
Now, the thing I want to communicate is that the first property is “easy” to satisfy, in the sense that I pull random numbers out of a hat, the chance that the determinant happens to be zero is vanishingly small. The issue with random garbage is that the second and third properties become harder to check, and anyway we want a deterministic promise that , not just a “probably”.
Vandermonde determinant
Up until now I’ve made no mention of polynomials yet, and that’s on purpose, because my thesis is that even in pure linear-algebra contexts there are good reasons to want polynomials. Now we’ll bring them in.
If you know how Shamir’s secret-sharing works already, you know what the functions , , should be: it uses , , .
To convince you there is something special about this choice, let me show you a magic trick, which is how you can calculate the determinant
completely in your head. The idea is that this determinant has got to vanish when , because then the first two rows of the matrix will coincide. Therefore, the determinant is a multiple of . For the same reason, it must be a multiple of and . In other words, the determinant should be a multiple of .
However, the determinant is also a polynomial of degree . So there’s no more “room” left for any additional factors! In other words, the determinant has to be equal to for some constant . And so all you need to is look at any particular monomial to determine ; for example, if you look at the determinant you can see a on the diagonal, which isn’t cancelled out by anything else, while also has an term, ergo .
In summary, we have the following result:
Theorem 2 (Vandermonde determinant). We have The obvious generalization to more than three variables (with the same proof) is also valid, e.g. and so on.
This theorem provides an affirmative answer to the first criteria, and gives a reason to believe this is “pretty good” for the second criteria. The point is that is always going to equal zero if any of the variables are equal. That means we expect will always at least have to be “divisible” by , depending on what you mean by “divisible”. The fact that the Vandermonde determinant has no additional “garbage” factors means, philosophically, we can’t compress the sizes of , , in a meaningful further way.
Lagrange interpolation
What about the last criteria — actually solving the system quickly? Let’s specialize again to three-variables, and in fact let’s specialize to , , so we have fewer symbols. That means we’d like to rapidly solve equations of the form
The case where just one is zero
Linear algebra means that it suffices to do the case where all but one of the ’s is zero. Let’s try , , that is: I’m going to show you yet another magic trick: how you can solve for in your head, too.
The idea is to consider the polynomial whose roots are and , namely Now the trick is that this polynomial has by definition, and so will actually satisfy the second two equations! Indeed, But it doesn’t satisfy the first equation, because instead of . But that’s no problem, because you can just scale by a factor of : so the answer is
So in fact, solving the system of equations when all but one is zero is really equivalent to just expanding the polynomial whose roots are the other numbers, and then adding a scaling factor to get the last equation right. And then solving a general system can be done by adding them all together.
A full general example
Let’s put some flesh on this example by doing it fully explicitly for some numbers.
We first solve the three “basic” systems using the procedure we described earlier Again, to reiterate, the numerators are the coefficients you get when you expand a quadratic polynomial, and the denominator is the scaling factor you throw in to make sure the last equation comes out to (by plugging in the final input into the polyonmial).
Then the answer to the general system will just be
This process, which works equally well in any number of variables, is known in mathematics as Lagrange interpolation.
Afterthought: random challenges
You might remember the following fundamental theorem about polynomials:
Theorem 3. A polynomial of degree has at most roots.
Fun fact: this theorem is secretly a linear algebra fact, too.
In fact, we’ve basically already proven this, and I’ll just point it out. Suppose is a quadratic polynomial, and has three roots . The claim is that must then be the zero polynomial. If you actually plug in the numbers, this just saying has only the solution , which is what we showed earlier by calculating the determinant .
As a consequence, we get the following corollary.
Corollary 4. Whenever and are two different polynomials of degree at most , then there will be at most points at which they give different outputs, because is a nonzero polynomial of degree at most , and hence has at most roots.
This key fact is used in a lot of cryptographic protocols, where whenever a prover wants to show two polynomials and are equal to each other, it’s enough for them to receive a random challenge and show . This works because if , a cheating prover would be exposed unless the verifier was so unlucky they picked one of the roots of . As long as the verifier has a lot of numbers to pick from (often ), this is vanishingly small.
And so the same linear algebra idea that let us do Lagrange interpolation is also quietly pulling the strings behind all the “random-challenge” protocols that show up ubiquitously.