Skip to content
← Writing

On Constraint Satisfiability

Proving STARK constraints that only hold on part of the trace (boundaries, periodic rows, row selectors) by picking subdomains with sparse vanishing polynomials instead of adding selector columns.

· 5 min read · STARKs, Arithmetization

Setup

Let F\mathbb{F} be a finite field of prime order pp such that 2k∣(p−1)2^k \vert (p-1) for some integer k≥1k \geq 1. Set N=2kN = 2^k, and let G=⟨g⟩⊆F∗G = \langle g \rangle \subseteq \mathbb{F}^* be a multiplicative subgroup of order NN. Every subgroup of GG is generated by some power of gg, so we can completely describe the subgroup structure as:

{1}⊂⟨g2k−1⟩⊂⟨g2k−2⟩⊂…⊂⟨g2⟩⊂G,\{ 1 \} \subset \langle g^{2^{k-1}} \rangle \subset \langle g^{2^{k-2}} \rangle \subset \ldots \subset \langle g^{2} \rangle \subset G,

where each subgroup has order 2i2^i, for i=0,1,…,ki=0,1,\ldots,k.

The vanishing polynomial over a set S⊆FS \subseteq \mathbb{F}, denoted VSV_S, is the polynomial whose roots are precisely the elements of XX. For example, it is easy to see that VF∗(X)=Xp−1−1V_{\mathbb{F}^*}(X) = X^{p-1} - 1 and more generally that VG(X)=XN−1V_G(X) = X^N - 1 for any cyclic group GG or order NN.

We say that a polynomial pp of degree nn is sparse if it can be evaluated at any point of F\mathbb{F} in O(log⁡n)O(\log{n}) operations. Vanishing polynomials over any cyclic group are sparse, as well as the vanishing polynomials over sets of size O(log⁡n)O(\log{n}).

Subdomain Constraints

We consider the problem of proving algebraic constraints over a fixed, known evaluation domain. Concretely, given a finite multiplicative group G⊂F∗G \subset \mathbb{F}^* of order NN, we aim to prove the validity of constraints over the entire domain GG, as well as over specific deterministic (non-random) subsets H⊂GH \subset G.

A constraint CC is a multivariate polynomial C∈F[X1,…,Xs]C \in \mathbb{F}[X_1, \dots, X_s], where each variable XiX_i represents a polynomial over F\mathbb{F} of degree strictly less than NN, evaluated over the domain GG. We write deg⁡(C)\deg(C) to denote the degree of CC after substituting each XiX_i with the corresponding polynomial.

From now on, we assume that constraints are non-trivial over GG, i.e. that deg⁡(C)>N\deg(C) > N.

This framework is motivated by the need to efficiently express and enforce common classes of constraints arising in algebraic trace systems, namely trace boundaries, periodic constraints, and row selectors. More precisely:

  • Trace Boundaries. Constraints that are enforced only at specific boundary points of the trace, typically the first and/or last row.
  • Periodic Constraints. Constraints that hold over a periodic subset of the trace, corresponding to a repeating structural pattern.
  • Row Selectors. Constraints that are enforced at a predetermined set of rows within the trace, not necessarily contiguous or periodic.

Subdomain Constraints in STARKs

In STARKs, proving that a constraint is satisfied over GG (i.e., evaluates to zero over GG) is usually done by reducing the problem of constraint satisfiability to a low-degree test as follows. Given a set of constraints {C1,…,Ct}\{C_1, \dots, C_t\}, we compute the following rational function using a verifier-supplied random field element β\beta:

C(X1,…,Xs):=1VG(X)(∑i=1tβi−1⋅Ci(X1,…,Xs)).C(X_1, \dots, X_s) := \frac{1}{V_G(X)}\left( \sum_{i=1}^{t} \beta^{i-1} \cdot C_i(X_1, \dots, X_s)\right).

In the honest setting, VGV_G divides each CiC_i as polynomials, so CC is a polynomial of degree d=max⁡{deg⁡(C1)−N,…,deg⁡(Ct)−N}d = \max\{\deg(C_1) - N, \dots, \deg(C_t) - N\}. The problem reduces to proving that CC is a polynomial of degree at most dd.

Now, what happens when we aim to prove a constraint CC that is satisfied over a subset HH of GG? A common approach is:

  1. Define an auxiliar polynomial ff that “encodes” HH, that is f(x)=1f(x) = 1 if x∈Hx \in H and f(x)=0f(x) = 0 if x∈G\Hx \in G \backslash H.
  2. Define C^:=f⋅C\hat{C} := f \cdot C, transforming the original constraint to one satisfied over GG.
  3. Prove the satisfiability of C^\hat{C} over GG instead of the one of CC over HH.

This process is correct but it incurs in an additional transformation from the natural context of the constraint to a generic one.

The alternative would to define the rational fraction as:

C(X1,…,Xs):=∑i=1tβi−1⋅Ci(X1,…,Xs)VHi(X),C(X_1, \dots, X_s) := \sum_{i=1}^{t} \beta^{i-1} \cdot \frac{C_i(X_1, \dots, X_s)}{V_{H_i}(X)},

where each Hi⊆GH_i \subseteq G is the satisfaction domain of CiC_i. This avoids auxiliary polynomials, but the verifier must evaluate the vanishing polynomials VHiV_{H_i} at some random points. Sparse vanishing polynomials are therefore required for efficient verification.

The optimal strategy is a combination of both approaches, finding subsets H⊆GH \subseteq G that admit sparse vanishing polynomials.

Finding Good Domains

We know show how trace boundaries, periodic constraints and row selectors can be described by a sparse vanishing polynomial, making them amenable to the strategy described in the previous section. We assume that rows are labelled by the exponent of the generating set G=⟨g⟩={g,g2,…,gN}G = \langle g \rangle = \{g, g^2, \dots, g^N\}.

Trace Boundaries

A trace boundary constraint is satisfied at one of:

  1. The first row.
  2. The last row.
  3. All rows except the first.
  4. All rows except the last.

The first two vanishing polynomials are as easy as V1(X)=X−gV_1(X) = X - g and VN(X)=X−gNV_N(X) = X - g^{N}, where we used the shorthand ViV_i for V{gi}V_{\{g^i\}}. The complements are the standard Lagrange polynomials:

VG\g(X)=gN⋅XN−1X−g,    VG\gN(X)=gNN⋅XN−1X−gN,V_{G\backslash g}(X) = \frac{g}{N} \cdot \frac{X^N - 1}{X - g}, \ \ \ \ V_{G\backslash g^N}(X) = \frac{g^N}{N} \cdot \frac{X^N - 1}{X - g^N},

i.e., VG\giV_{G \backslash g^i} is the ii-th Lagrange polynomial.

All of these are sparse.

Periodic Constraints

If we take HH to be a subgroup of GG or order ℓ\ell, then we have VH(X)=Xℓ−1V_H(X) = X^{\ell} - 1. More generally, for a coset H^=gr⟨gN/ℓ⟩\hat{H} = g^r\langle g^{N / \ell}\rangle with gr∈G\Hg^r \in G \backslash H, we have VH^(X)=Xℓ−grℓV_{\hat{H}}(X) = X^{\ell} - g^{r \ell}. These cases correspond to index sets of the form

I={r+k⋅(N/ℓ)∣k=0,…,ℓ−1}, with r∈{0,…,N−1} and ℓ∣N,I = \{r + k\cdot (N/\ell) \mid k = 0,\dots,\ell-1\}, \text{ with } r \in \{0,\dots,N-1\} \text{ and } \ell \vert N,

that is, arithmetic progressions modulo NN whose period ℓ\ell divides NN.

More generally, a union of tt cosets H^=∪i=1tgriHi\widehat{H} = \cup_{i=1}^t g^{r_i}H_i, where each HiH_i is a subgroup of order ℓi\ell_i has vanishing polynomial VH^(X)=∏i=1t(Xℓi−griℓ)V_{\widehat{H}}(X) = \prod_{i=1}^t(X^{\ell_i} - g^{r_i\ell}). As long as O(log⁡N)O(\log{N}), this polynomial is sparse. The corresponding index set is:

I=⋃i=1t{ri+k⋅(N/ℓi)∣k=0,…,ℓi−1}, with ri∈{0,…,N−1} and ℓi∣N,I = \bigcup_{i=1}^t\{r_i + k\cdot (N/\ell_i) \mid k = 0,\dots,\ell_i-1\}, \text{ with } r_i \in \{0,\dots,N-1\} \text{ and } \ell_i \vert N,

Row Selectors

Row selectors correspond to arbitrary predetermined subsets of the trace. Let S⊆{0,…,N−1}S \subseteq \{0, \dots, N-1\} denote the selected rows. The vanishing polynomial is VS(X)=∏i∈S(X−gi)V_S(X) = \prod_{i \in S}(X - g^i).

  • Sparse evaluation is possible if SS can be decomposed as a union of O(log⁡N)O(\log{N}) cosets of power-of-two subgroups, as discussed above.
  • Otherwise, VSV_S is dense and evaluating it requires O(∣S∣)O(|S|) operations, which is inefficient for large SS.

Thus, by carefully choosing subset SS aligned with subgroup structure, we can maintain evaluation efficiency for general row selectors, periodic constraints, and trace boundaries.

Break my circuit

You are the prover. The verifier doesn't run the program; it only checks the constraints. Each circuit here is missing one, which is the most common bug in real ZK systems. Find a witness that fools it.

circuit.circom

Public (verifier sees)

Witness (you choose)

Constraints · everything mod 97