On Tuesday, former COSIC-student Ward Beullens will present his paper “Breaking Rainbow takes a weekend on a laptop” at CRYPTO 2022. In this blog post I will give a brief overview of his attack, which won him this year’s early career researcher award. Since I’m actually a symmetric-key cryptographer, you can rest assured that this post doesn’t assume any prior knowledge about Rainbow or other multivariate public-key cryptosystems.
Rainbow is a signature scheme that was designed to be secure against both classical and quantum attacks (spoiler: it isn’t). The scheme is based on a trapdoored system of multivariate quadratic equations. Without knowing the trapdoor, forging signatures requires solving a random-looking system of equations. The problem of solving actually random systems of multivariate quadratic equations is generally believed to be difficult.
Actually, Rainbow is a variant of another multivariate scheme, called unbalanced oil and vinegar (UOV). At EUROCRYPT 2021, Ward introduced a simplified description of UOV. This description makes it much easier to understand the structure of UOV’s trapdoor, which in turn led to improved attacks. A similarly simplified description is possible for Rainbow. Since it makes the attack easier to explain, I will describe UOV and Rainbow exclusively in this way.
\(\newcommand{\F}{\mathbb F}\)
\(\newcommand{\Lin}[1]{D_{#1}}\)
Unbalanced oil and vinegar
The UOV signature scheme works as follows. The public key is a quadratic function \(P : \F_q^n \to \F_q^m\). By “quadratic function”, I mean that each of the coordinate functions \(P_i\) has degree at most two when represented as a multivariate polynomial over \(\F_q\). The private key is a secret \(m\)-dimensional subspace \(O\) of \(\F_q^n\) such that \(\require{action}\require{color}\color{darkblue}\toggle{P(O) = 0}{\forall x \in O: P(x) = 0}\endtoggle\). Keep in mind that this implies that \(P(0) = 0\).
To sign a message \(m\), first compute a hash \(h = H(m\|t)\) with \(t\) a randomly chosen salt. A signature of \(m\) is a pair \((s, t)\) where \(s \in \F_q^n\) satisfies \(P(s) = h\). The trick is that if you know \(O\), this system is easy to solve. To see why this is true, it’s convenient to introduce the function \(P'(x, y) : \F_q^n \times \F_q^n \to \F_q^m\) defined by $$P'(x, y) = P(x + y) – P(x) – P(y) + P(0)\,.$$ Because \(P\) is quadratic, \(P’\) is bilinear. This means that if you fix either \(x\) or \(y\), you get a linear function in the other argument. For example, if one of the coordinate functions of \(P\) is \(x_1 x_2\), then the corresponding coordinate function of \(P’\) is \(\color{darkblue}\toggle{x_1 y_2 + y_1 x_2}{x_1 y_2 + y_1 x_2 = (x_1 + y_1)(x_2 + y_2) – x_1 x_2 – y_1 y_2}\endtoggle\). For convenience, I will also use the notation \(\Lin{y}(x) = P'(y, x)\) for any \(y \in \F_2^n\). The function \(\Lin{y} : \F_q^n \to \F_q^m\) is linear for any choice of \(y\). Ward calls \(\Lin{y}\) a “differential”, but as a symmetric-key cryptographer I have some psychological difficulties with this terminology so you won’t find it in this post.
To solve \(P(s) = h\) for \(s\), we can now proceed as follows. Choose any \(v \in \F_q^n\) and solve the system \(P(v + x) = h\) for \(x \in O\). In practice, \(v\) is chosen uniformly at random. This system is easy to solve because it can be rewritten as $$\Lin{v}(x) + P(x) + P(v) = h\,.$$ Remember that \(x \in O\), so \(P(x) = 0\), so this is equivalent to $$\Lin{v}(x) = h – P(v)$$ Because \(\Lin{v}\) is a linear function, the above equation is easy to solve (for example with Gaussian elimination). In particular, we get a system with \(m\) equations in \(\color{darkblue}\toggle{m}{m = \dim O}\endtoggle\) variables. There is a small probability that the system is singular, in which case we simply start over with another \(v\). The signature is then \((s, t) = (x + v, t)\).
For UOV to be secure, \(n\) must be much larger than \(m\). Otherwise, it would be easy to find \(O\) by randomly choosing vectors in \(\F_q^n\). The original oil and vinegar scheme (due to Patarin, EUROCRYPT 1997) used \(n = 2m\), but Kipnis and Shamir (CRYPTO 1998) found a polynomial-time attack for these parameters. For this reason, all existing instances use \(n > 2m\) and accordingly are called “unbalanced”. In his EUROCRYPT 2021 paper, Ward obtained better attacks on instances with \(n \le 3m\). I won’t discuss these attacks in this post, but they are easy to understand given the description of UOV from above. I recommend reading Section 4 of Ward’s EUROCRYPT paper.
Rainbow
Rainbow is a kind of “nested” variant of UOV. As for UOV, the public key is a quadratic function \(P : \F_q^n \to \F_q^m\). However, a Rainbow private key consists of a subspace \(W \subseteq \F_q^m\) and two nested subspaces \(O_2 \subset O_1 \subset \F_q^n\). The dimensions of these subspaces satisfy $$m = \dim O_1 > \dim O_2 = \dim W = w\,.$$ In addition, the subspaces satisfy the following three properties:
- Similar to UOV, \(P(O_2) = 0\).
- In addition, \(P(O_1) \equiv 0 \pmod W\), which is a similar requirement to the previous one but weaker: we only require that vectors in \(O_1\) are zero up to addition by a vector in \(W\). This condition is equivalent to \(P(O_1) \subset W\).
- Finally, for any \(v \in \F_q^n\), we should have \(\Lin{v}(O_2) \equiv 0 \pmod W\). Equivalently, \(\Lin{v}(O_2) \subset W\).
These relations are nicely illustrated by the following figure in Ward’s paper.

To sign a message \(m\), first compute \(h = H(m\|t)\) for a salt \(t\). As in UOV, a signature is obtained by solving the system \(P(s) = h\) for \(s\). Also similar to UOV, we begin by choosing an arbitrary \(v \in \F_q^n\) (uniform random in practice). The big difference is that that we will first solve the system modulo \(W\). In particular, we have two steps or layers.
Outer layer (‘UOV modulo \(W\)’)
Here, we solve \(P(v + x_1) \equiv h \pmod W\) for \(x_1 \in O_1\). Rewriting the system, we get $$\Lin{v}(x_1) + P(x_1) + P(v) \equiv h \pmod W\,.$$ Since \(x_1 \in O_1\), we have \(P(x_1) \equiv 0 \pmod W\) by property 2, so the system simplifies to $$\Lin{v}(x_1) \equiv h – P(v) \pmod W\,.$$ This is a linear system, so we can easily solve for \(x_1\). However, this system has \(\color{darkblue}\toggle{m}{m = \dim O_1}\endtoggle\) variables for only \(\color{darkblue}\toggle{m – w}{m – w = \dim \F_q^m / W}\endtoggle\) equations. This is because the solution \(x_1\) is only unique modulo \(O_2\). Indeed, the third property above says that \(\Lin{v}(O_2) \equiv 0 \pmod W\). If we instead consider the system $$\Lin{v}(\bar x_1) \equiv h – P(v) \pmod W\,,$$ for \(\bar x_1 \in O_1 / O_2\), then we have only \(\dim O_1/O_2 = m – w\) variables. In the unlikely event that we don’t obtain a solution, we simply start over with a different choice of \(v\).
Inner layer
Having determined \(\bar x_1\), we choose a particular representative \(x_1 \in \bar x_1\) (in practice uniformly at random) and solve \(P(v + x_1 + x_2) = h\) for \(x_2 \in O_2\). As usual, this can be rewritten as $$\Lin{v + x_1}(x_2) + P(x_2) + P(v + x_1) = h\,.$$ Since \(P(x_2) = 0\) by property 1, we get $$\Lin{v + x_1}P(x_2) = h – P(v + x_1)\,.$$ Both sides of this equation are in \(W\) (the left side because of property 3, the right side because of how we solved the inner layer), so we have \(\dim W = w\) equations in \(w\) variables. Finally, we get \(s = v + x_1 + x_2\).
Attack on Rainbow
The basic strategy of the attack is to find a vector \(x\) in \(O_2\). Such a vector at least needs to satisfy \(P(x) = 0\), but this by itself isn’t enough information to efficiently find such an \(x\). Once a single vector \(x\) in \(O_2\) is found, it is easy to find \(W\) by computing
$$\mathrm{Span}\{\Lin{b_1}(x), \Lin{b_2}(x), \ldots\} \subseteq W\,,$$ for some linearly independent vectors \(b_1, b_2 \ldots\). Given enough such vectors, this is likely to be an equality. Once \(W\) is known, consider the linear system of equations $$\begin{aligned} \Lin{b_1}(x) & \equiv 0 \pmod W \\ \Lin{b_2}(x) & \equiv 0 \pmod W \\ &\vdots\end{aligned}$$ By property 2 of Rainbow, \(\Lin{b_i}(x) \in W\) for \(x \in O_2\). Hence, the solution space of this system contains \(O_2\). Given enough linearly independent vectors, the solution space is in fact likely to equal \(O_2\). Once \(O_2\) and \(W\) have been determined, the outer layer of Rainbow can be unwrapped. The remaining problem is an instance of UOV (“modulo \(W\)”) with \(m – w\) variables and a secret subspace of dimension \(m – w\).
We now turn to the crux of the attack: how to find a vector \(x \in O_2\). Due to property 3 of the Rainbow trapdoor, the restriction \(\Lin{v}|_{O_2}\) of the linear map \(\Lin{v}\) to \(O_2\) is well-defined and has range \(W\). Although \(\dim O_2 = w = \dim W\), it is possible that \(\Lin{v}|_{O_2}\) is singular. In fact, for a random Rainbow key pair, \(\Lin{v}|_{O_2}\) should be a random linear map. Hence, the probability that there exists an \(x \in O_2\) such that \(\Lin{v}(x) = 0\) is approximately \(1/q\) (for very small \(q\), this is less accurate). The attack tries to find such a vector \(x\) by solving the system $$\begin{cases}\Lin{v}(x) &= 0 \\ P(x) &= 0\,.\end{cases}$$ Because the first \(m\) equations are linear, it is easy to eliminate \(m\) variables from the system. The resulting system of equations has only \(n – m\) variables and \(m\) equations.
The total cost of the attack is then the cost of solving the above system \(q\) times (on average), plus the cost of solving the small UOV instance with \(m – w\) variables. When \(n – m\) is small, this approach works really well. For example, for the second round Rainbow parameters (in NIST’s post-quantum cryptography project) with the lowest security level, \(n – m = 32 = m – w\). The attack then takes about 53 hours (“a weekend”) on a laptop. Breaking the final parameters would take a bit over 250 weeks (working only on weekends, of course), or a better laptop.
When (n – m) is large (as for the higher security levels), the attack doesn’t work as well. However, it can be combined with previous attacks on Rainbow from Ward’s EUROCRYPT paper to obtain forgery attacks that violate the security claims of all instances of Rainbow.
Thanks to Christian Eder for pointing out a typo in an earlier version of this blog post.


