Gröbner Bases in Cryptanalysis Part 1: The Underlying Algebra

Cryptography

Mar 24, 2026

groebner-basis-part1-image

A Gröbner basis is a canonical generating set for a polynomial ideal with powerful computational properties. Given a system of polynomial equations, computing a Gröbner basis with respect to a lexicographic monomial order reduces it to a sequence of univariate polynomials that can be solved by standard root-finding.

This is Part 1 of a two-part article that develops a Gröbner basis attack on arithmetization-oriented ciphers, a class of hash functions designed for use inside zero-knowledge proof systems. Part 1 builds the necessary algebraic machinery: what a Gröbner basis is, how it is computed, and why it solves polynomial systems. Part 2 will show how a hash function becomes a polynomial system and how that machinery breaks it.

The definitions and theorems in this post follow Cox, Little, and O'Shea, Ideals, Varieties, and Algorithms (4th ed., Springer, 2015). Chapters 1 and 2 cover all the material in this post.

Polynomial Rings and Affine Varieties

The starting point is to make precise what we mean by a system of polynomial equations and its solution set.

Definition. Let kk be a field and x1,,xnx_1, \ldots, x_n indeterminates. A monomial in x1,,xnx_1, \ldots, x_n is a product of the form

xα=x1α1x2α2xnαn,α=(α1,,αn)Z0n.x^\alpha = x_1^{\alpha_1} x_2^{\alpha_2} \cdots x_n^{\alpha_n}, \qquad \alpha = (\alpha_1, \ldots, \alpha_n) \in \mathbb{Z}_{\geq 0}^n.

The total degree of xαx^\alpha is α=α1++αn|\alpha| = \alpha_1 + \cdots + \alpha_n. A polynomial ff in x1,,xnx_1, \ldots, x_n with coefficients in kk is a finite kk-linear combination of monomials:

f=αcαxα,cαk.f = \sum_{\alpha} c_\alpha x^\alpha, \qquad c_\alpha \in k.

The set of all such polynomials, equipped with the usual addition and multiplication, forms a commutative ring denoted k[x1,,xn]k[x_1, \ldots, x_n], called the polynomial ring in nn variables over kk.

The solution set of a system of polynomial equations is the fundamental geometric object we need.

Definition. Let f1,,fsk[x1,,xn]f_1, \ldots, f_s \in k[x_1, \ldots, x_n]. The affine variety defined by f1,,fsf_1, \ldots, f_s is the set of all common zeros:

V(f1,,fs)={(a1,,an)knfi(a1,,an)=0 for all i=1,,s}.V(f_1, \ldots, f_s) = \{ (a_1, \ldots, a_n) \in k^n \mid f_i(a_1, \ldots, a_n) = 0 \text{ for all } i = 1, \ldots, s \}.

Example. In R2\mathbb{R}^2, the variety V(x12+x221)V(x_1^2 + x_2^2 - 1) is the unit circle. The variety V(x1x2,x121)V(x_1 - x_2,\, x_1^2 - 1) is the finite set {(1,1),(1,1)}\{(1,1),(-1,-1)\}.

Ideals

A system of polynomial equations can be described by many different collections of polynomials. Multiplying any fif_i by an arbitrary polynomial hh, or replacing f1f_1 with f1+hf2f_1 + h \cdot f_2, does not change the solution set. This suggests that the solution set depends not on the particular generators chosen, but on a larger algebraic object they generate. That object is an ideal.

Definition. A subset Ik[x1,,xn]I \subseteq k[x_1, \ldots, x_n] is an ideal if:

  1. 0I0 \in I,
  2. f,gIf+gIf, g \in I \Rightarrow f + g \in I,
  3. fIf \in I, hk[x1,,xn]hfIh \in k[x_1, \ldots, x_n] \Rightarrow hf \in I.

Definition. Given f1,,fsk[x1,,xn]f_1, \ldots, f_s \in k[x_1, \ldots, x_n], the ideal generated by f1,,fsf_1, \ldots, f_s is

f1,,fs={i=1shifi  |  hik[x1,,xn]}.\langle f_1, \ldots, f_s \rangle = \left\{ \sum_{i=1}^{s} h_i f_i \;\middle|\; h_i \in k[x_1, \ldots, x_n] \right\}.

This is the smallest ideal containing f1,,fsf_1, \ldots, f_s.

The key observation is that different generating sets for the same ideal define the same variety. This is not obvious from the definition of a variety, but it follows immediately from the ideal structure.

Lemma. If f1,,fs=g1,,gt\langle f_1, \ldots, f_s \rangle = \langle g_1, \ldots, g_t \rangle, then V(f1,,fs)=V(g1,,gt)V(f_1, \ldots, f_s) = V(g_1, \ldots, g_t).

This lemma means we are free to replace any generating set for an ideal with any other generating set, including a Gröbner basis, without changing the variety. Solving the system with a convenient generating set is equivalent to solving it with the original one.

We also record the ideal associated to a given variety, which will appear in the construction of the field equations.

Definition. Given an affine variety VknV \subseteq k^n, the ideal of VV is

I(V)={fk[x1,,xn]f(a)=0 for all aV}.I(V) = \{ f \in k[x_1, \ldots, x_n] \mid f(a) = 0 \text{ for all } a \in V \}.

The ideal I(V)I(V) captures every polynomial relation that vanishes on VV and is in general strictly larger than any particular generating set f1,,fs\langle f_1, \ldots, f_s \rangle used to define VV.

Monomial Orderings

To compute with polynomials in k[x1,,xn]k[x_1, \ldots, x_n], we need a notion of leading term: the term we try to cancel first when performing polynomial division. In the univariate case, the leading term is simply the one of highest degree. In the multivariate case, there is no single natural choice, and different choices lead to Gröbner bases with different properties.

Definition. A monomial ordering on k[x1,,xn]k[x_1, \ldots, x_n] is a total ordering >> on the set of monomials satisfying:

  1. if xα>xβx^\alpha > x^\beta then xαxγ>xβxγx^\alpha \cdot x^\gamma > x^\beta \cdot x^\gamma for all γZ0n\gamma \in \mathbb{Z}_{\geq 0}^n,
  2. >> is a well-ordering: every nonempty set of monomials has a least element.

Condition 2 implies that 1=x(0,,0)1 = x^{(0,\ldots,0)} is the smallest monomial under any monomial ordering, and together with condition 1 it guarantees that any sequence of reductions eventually terminates.

There are three orderings used in practice. Their computational and structural properties differ significantly, and the choice of ordering is central to the efficiency of the attack.

Definition (Lexicographic Order, lex). xα>lexxβx^\alpha >_{\mathrm{lex}} x^\beta if the leftmost nonzero entry of αβZn\alpha - \beta \in \mathbb{Z}^n is positive.

Example. In k[x1,x2,x3]k[x_1, x_2, x_3]: x12x3>lexx1x25>lexx24x32x_1^2 x_3 >_{\mathrm{lex}} x_1 x_2^5 >_{\mathrm{lex}} x_2^4 x_3^2. The variable x1x_1 dominates unconditionally, regardless of the degrees of x2x_2 and x3x_3. This makes lex order behave like a dictionary, and it is precisely this property that makes it suitable for elimination: a lex Gröbner basis will contain elements involving only x2,x3x_2, x_3, then only x3x_3, allowing us to solve the system one variable at a time.

Definition (Graded Lexicographic Order, grlex). xα>grlexxβx^\alpha >_{\mathrm{grlex}} x^\beta if α>β|\alpha| > |\beta|, or if α=β|\alpha| = |\beta| and xα>lexxβx^\alpha >_{\mathrm{lex}} x^\beta.

Example. In k[x1,x2,x3]k[x_1, x_2, x_3]: x1x2x3>grlexx12x3x_1 x_2 x_3 >_{\mathrm{grlex}} x_1^2 x_3 since α=3>2=β|\alpha| = 3 > 2 = |\beta|. Total degree is compared first; lex breaks ties.

Definition (Graded Reverse Lexicographic Order, grevlex). xα>grevlexxβx^\alpha >_{\mathrm{grevlex}} x^\beta if α>β|\alpha| > |\beta|, or if α=β|\alpha| = |\beta| and the rightmost nonzero entry of αβ\alpha - \beta is negative.

Example. In k[x1,x2,x3]k[x_1, x_2, x_3], among degree-2 monomials: x12>grevlexx1x2>grevlexx1x3>grevlexx22>grevlexx2x3>grevlexx32x_1^2 >_{\mathrm{grevlex}} x_1 x_2 >_{\mathrm{grevlex}} x_1 x_3 >_{\mathrm{grevlex}} x_2^2 >_{\mathrm{grevlex}} x_2 x_3 >_{\mathrm{grevlex}} x_3^2.

With a monomial ordering fixed, we can designate the distinguished term of each polynomial.

Definition. Fix a monomial ordering >> and let f=αcαxα0f = \sum_\alpha c_\alpha x^\alpha \neq 0.

  • The multidegree of ff is multdeg(f)=max>{αcα0}\mathrm{multdeg}(f) = \max_>\{\alpha \mid c_\alpha \neq 0\}.
  • The leading monomial is LM(f)=xmultdeg(f)\mathrm{LM}(f) = x^{\mathrm{multdeg}(f)}.
  • The leading coefficient is LC(f)=cmultdeg(f)k\mathrm{LC}(f) = c_{\mathrm{multdeg}(f)} \in k.
  • The leading term is LT(f)=LC(f)LM(f)\mathrm{LT}(f) = \mathrm{LC}(f) \cdot \mathrm{LM}(f).

Example. For f=4x12x2+3x23x1Q[x1,x2]f = 4x_1^2 x_2 + 3x_2^3 - x_1 \in \mathbb{Q}[x_1, x_2] under >lex>_{\mathrm{lex}}: multdeg(f)=(2,1)\mathrm{multdeg}(f) = (2,1), LM(f)=x12x2\mathrm{LM}(f) = x_1^2 x_2, LC(f)=4\mathrm{LC}(f) = 4, LT(f)=4x12x2\mathrm{LT}(f) = 4x_1^2 x_2.

The Multivariate Division Algorithm

With a notion of leading term in hand, we can generalise polynomial long division to the multivariate setting.

Theorem. Fix a monomial ordering >> and an ordered ss-tuple F=(f1,,fs)F = (f_1, \ldots, f_s). Then every fk[x1,,xn]f \in k[x_1, \ldots, x_n] can be written as

f=a1f1++asfs+rf = a_1 f_1 + \cdots + a_s f_s + r

where ai,rk[x1,,xn]a_i, r \in k[x_1, \ldots, x_n], no monomial of rr is divisible by any LT(fi)\mathrm{LT}(f_i), and multdeg(f)multdeg(aifi)\mathrm{multdeg}(f) \geq \mathrm{multdeg}(a_i f_i) whenever aifi0a_i f_i \neq 0. The polynomial rr is the remainder on division of ff by FF, written fF\overline{f}^F.

The algorithm proceeds greedily: at each step, if the current leading term is divisible by some LT(fi)\mathrm{LT}(f_i), it is cancelled; otherwise it is moved to the remainder.

This generalisation, however, has two serious defects that do not appear in the univariate case.

First, the remainder fF\overline{f}^F need not be unique: reordering f1,,fsf_1, \ldots, f_s can produce a different remainder for the same ff. Second, and more critically, fF=0\overline{f}^F = 0 does not imply ff1,,fsf \in \langle f_1, \ldots, f_s \rangle. A polynomial can be a member of an ideal yet fail to reduce to zero when divided by a generating set, simply because the right cancellations do not happen in the right order.

These two defects are not minor inconveniences. They mean that arbitrary generating sets are computationally useless for ideal membership testing and system solving. Gröbner bases are defined as exactly the generating sets for which both defects disappear.

Gröbner Bases

Before defining a Gröbner basis, we need to know that every ideal has a finite generating set to begin with, without this, the notion of a "basis" would be ill-defined. This is the content of the Hilbert Basis Theorem.

Theorem (Hilbert Basis Theorem). Every ideal Ik[x1,,xn]I \subseteq k[x_1, \ldots, x_n] has a finite generating set.

The proof uses the ascending chain condition: any chain I1I2I_1 \subseteq I_2 \subseteq \cdots of ideals must eventually stabilise. This will also guarantee that Buchberger's algorithm, which enlarges a generating set step by step, always terminates.

Definition. For an ideal Ik[x1,,xn]I \subseteq k[x_1, \ldots, x_n], the leading term ideal is

LT(I)=LT(f)fI,f0.\mathrm{LT}(I) = \langle \mathrm{LT}(f) \mid f \in I,\, f \neq 0 \rangle.

The leading term ideal collects the leading terms of every element of II, not just those of a generating set. The gap between LT(f1),,LT(fs)\langle \mathrm{LT}(f_1), \ldots, \mathrm{LT}(f_s) \rangle and LT(I)\mathrm{LT}(I) is precisely what causes the division algorithm to fail. A Gröbner basis closes this gap.

Definition. A finite set G={g1,,gt}IG = \{g_1, \ldots, g_t\} \subset I is a Gröbner basis for II if

LT(g1),,LT(gt)=LT(I).\langle \mathrm{LT}(g_1), \ldots, \mathrm{LT}(g_t) \rangle = \mathrm{LT}(I).

Equivalently, for every nonzero fIf \in I, there exists giGg_i \in G such that LT(gi)\mathrm{LT}(g_i) divides LT(f)\mathrm{LT}(f).

Every nonzero ideal has a Gröbner basis, and every Gröbner basis is a generating set for II. The following two lemmas confirm that Gröbner bases fix both defects identified previously.

Lemma. Let GG be a Gröbner basis for II. Then every fk[x1,,xn]f \in k[x_1, \ldots, x_n] has a unique remainder fG\overline{f}^G, independent of the ordering of elements of GG in the division algorithm. This remainder is called the normal form of ff with respect to GG, written NF(f,G)\mathrm{NF}(f, G).

Lemma. Let GG be a Gröbner basis for II. Then

fI    fG=0.f \in I \iff \overline{f}^G = 0.

Together, these lemmas say that once we have a Gröbner basis, ideal membership becomes a deterministic single computation. Since we know that V(G)=V(I)V(G) = V(I), we can replace any generating set with a Gröbner basis and solve the resulting system instead.

The S-Polynomial and Buchberger's Algorithm

To compute a Gröbner basis, we need a criterion that detects whether a given generating set is already one. The key observation is that the only way a generating set can fail to be a Gröbner basis is if some combination of its elements produces a polynomial whose leading term is not divisible by any of the generators' leading terms. The S-polynomial is designed to expose exactly these combinations.

Definition. Let f,gk[x1,,xn]f, g \in k[x_1, \ldots, x_n] be nonzero, with α=multdeg(f)\alpha = \mathrm{multdeg}(f) and β=multdeg(g)\beta = \mathrm{multdeg}(g). Set xγ=lcm(LM(f),LM(g))x^\gamma = \mathrm{lcm}(\mathrm{LM}(f), \mathrm{LM}(g)), where γi=max(αi,βi)\gamma_i = \max(\alpha_i, \beta_i). The S-polynomial of ff and gg is

S(f,g)=xγLT(f)fxγLT(g)g.S(f,g) = \frac{x^\gamma}{\mathrm{LT}(f)} \cdot f - \frac{x^\gamma}{\mathrm{LT}(g)} \cdot g.

The leading terms of ff and gg cancel by construction, producing a polynomial of strictly lower degree. If this polynomial reduces to zero modulo the current generating set, it contributes nothing new to the ideal and no new generator is needed. If it does not reduce to zero, its remainder is a new ideal element whose leading term is missing from LT(G)\langle \mathrm{LT}(G) \rangle, witnessing that GG is not yet a Gröbner basis.

Example. Let f=x132x1x2f = x_1^3 - 2x_1 x_2 and g=x12x22x22+x1g = x_1^2 x_2 - 2x_2^2 + x_1 in Q[x1,x2]\mathbb{Q}[x_1, x_2] under >lex>_{\mathrm{lex}}. Then lcm(LM(f),LM(g))=x13x2\mathrm{lcm}(\mathrm{LM}(f), \mathrm{LM}(g)) = x_1^3 x_2, and

S(f,g)=x2fx1g=2x1x22x12+2x23.S(f,g) = x_2 \cdot f - x_1 \cdot g = -2x_1 x_2^2 - x_1^2 + 2x_2^3.

Theorem (Buchberger's Criterion). A generating set G={g1,,gt}G = \{g_1, \ldots, g_t\} for an ideal II is a Gröbner basis if and only if

S(gi,gj)G=0for all ij.\overline{S(g_i, g_j)}^G = 0 \quad \text{for all } i \neq j.

This criterion directly yields an algorithm: start with the given generators, compute all pairwise S-polynomials, add any nonzero remainder as a new generator, and repeat until no new generators appear.

Buchberger's Algorithm.

Input: F={f1,,fs}F = \{f_1, \ldots, f_s\}
Output: A Gröbner basis GFG \supseteq F

Set G:=FG := F
Repeat:
\quad Set G:=GG' := G
\quad For each pair {p,q}G\{p, q\} \subseteq G':
\quad\quad Compute r:=S(p,q)Gr := \overline{S(p,q)}^{G'}
\quad\quad If r0r \neq 0, set G:=G{r}G := G \cup \{r\}
Until G=GG = G'
Return GG

Termination follows from the ascending chain condition: each nonzero remainder strictly enlarges LT(G)\langle \mathrm{LT}(G) \rangle, and this chain must stabilise.

Minimal and Reduced Gröbner Bases

Buchberger's algorithm terminates with a Gröbner basis, but typically one containing redundant elements. We shrink it in two steps.

Definition. A Gröbner basis GG is minimal if every pGp \in G is monic and LT(p)LT(G{p})\mathrm{LT}(p) \notin \langle \mathrm{LT}(G \setminus \{p\}) \rangle.

Definition. A Gröbner basis GG is reduced if every pGp \in G is monic and no monomial of pp is divisible by LT(q)\mathrm{LT}(q) for any other qGq \in G.

A reduced Gröbner basis is obtained from any Gröbner basis by first removing redundant elements to make it minimal, then fully reducing each remaining element modulo the others. The result is unique.

Theorem. Fix a monomial ordering. Every nonzero ideal Ik[x1,,xn]I \subseteq k[x_1, \ldots, x_n] has a unique reduced Gröbner basis.

This uniqueness means the reduced Gröbner basis is a canonical invariant of the ideal and the chosen ordering. Two polynomial systems generate the same ideal if and only if their reduced Gröbner bases coincide. For our purposes, it guarantees that the computation is deterministic: no matter how Buchberger's algorithm processes the S-polynomials, the final reduced basis is always the same.

Solving a Polynomial System with a Gröbner Basis

We now have all the pieces. The following procedure solves a system of polynomial equations f1==fs=0f_1 = \cdots = f_s = 0 over a field kk.

Step 1: Form the ideal. Collect the system into I=f1,,fsk[x1,,xn]I = \langle f_1, \ldots, f_s \rangle \subset k[x_1, \ldots, x_n]. Finding V(I)V(I) is equivalent to finding V(f1,,fs)V(f_1, \ldots, f_s).

Step 2: Add field equations. If k=Fpk = \mathbb{F}_p, every element of Fp\mathbb{F}_p satisfies apa=0a^p - a = 0. Adding the field equations xipxix_i^p - x_i for each variable to the generating set restricts the variety to Fpn\mathbb{F}_p^n and ensures the ideal is zero-dimensional, meaning V(I)V(I) is a finite set.

Step 3: Choose a monomial ordering and compute a Gröbner basis. Apply Buchberger's algorithm with lex order, placing the variable of primary interest first. The resulting basis GG generates the same ideal and satisfies V(G)=V(f1,,fs)V(G) = V(f_1, \ldots, f_s).

Step 4: Read off the univariate polynomial. Because lex order forces earlier variables to be eliminated as aggressively as possible, the Gröbner basis GG will contain an element gk[xn]g \in k[x_n] involving only the last variable. Its roots over kk are the only possible values of xnx_n in any solution.

Step 5: Back-substitute. For each root ana_n of gg, substitute xn=anx_n = a_n into the remaining elements of GG and repeat: find the univariate polynomial in xn1x_{n-1}, extract its roots, substitute, and continue until all variables are determined. The full solution set V(I)V(I) is recovered.


Example

Consider the following system over Q\mathbb{Q} in variables x>y>zx > y > z:

{f1=x+y+z6=0f2=x+2yz3=0f3=x2+y2+z214=0\begin{cases} f_1 = x + y + z - 6 = 0\\ f_2 = x + 2y - z - 3 = 0\\ f_3 = x^2 + y^2 + z^2 - 14 = 0 \end{cases}

Computing the Gröbner basis. We apply Buchberger's algorithm, processing S-polynomials until all reduce to zero.

S-polynomial of f1f_1 and f2f_2. Both have leading term xx, so lcm(LM(f1),LM(f2))=x\mathrm{lcm}(\mathrm{LM}(f_1), \mathrm{LM}(f_2)) = x and:

S(f1,f2)=f1f2=(x+y+z6)(x+2yz3)=y+2z3.S(f_1, f_2) = f_1 - f_2 = (x + y + z - 6) - (x + 2y - z - 3) = -y + 2z - 3.

This does not reduce to zero modulo {f1,f2,f3}\{f_1, f_2, f_3\}, so we add g1=y2z+3g_1 = y - 2z + 3 to the basis.

S-polynomial of f1f_1 and f3f_3. Here LM(f1)=x\mathrm{LM}(f_1) = x and LM(f3)=x2\mathrm{LM}(f_3) = x^2, so lcm=x2\mathrm{lcm} = x^2 and:

S(f1,f3)=xf1f3=xy+xz6xy2z2+14.S(f_1, f_3) = x \cdot f_1 - f_3 = xy + xz - 6x - y^2 - z^2 + 14.

We reduce this modulo the current basis {f1,f2,f3,g1}\{f_1, f_2, f_3, g_1\}. The leading term xyxy is divisible by LT(f1)=x\mathrm{LT}(f_1) = x, so we subtract yf1y \cdot f_1:

xy+xz6xy2z2+14y(x+y+z6)=xz6x2y2yz+6yz2+14.xy + xz - 6x - y^2 - z^2 + 14 - y(x + y + z - 6) = xz - 6x - 2y^2 - yz + 6y - z^2 + 14.

The leading term xzxz is again divisible by LT(f1)\mathrm{LT}(f_1), so we subtract zf1z \cdot f_1:

xz6x2y2yz+6yz2+14z(x+y+z6)=6x2y22yz+6y2z2+6z+14.xz - 6x - 2y^2 - yz + 6y - z^2 + 14 - z(x + y + z - 6) = -6x - 2y^2 - 2yz + 6y - 2z^2 + 6z + 14.

The leading term 6x-6x is divisible by LT(f1)\mathrm{LT}(f_1), so we subtract 6f1-6 \cdot f_1:

6x2y22yz+6y2z2+6z+14(6)(x+y+z6)=2y22yz+12y2z2+12z22.-6x - 2y^2 - 2yz + 6y - 2z^2 + 6z + 14 - (-6)(x + y + z - 6) = -2y^2 - 2yz + 12y - 2z^2 + 12z - 22.

Dividing through by 2-2 gives y2+yz6y+z26z+11y^2 + yz - 6y + z^2 - 6z + 11. The leading term is now y2y^2, divisible by LT(g1)=y\mathrm{LT}(g_1) = y. Subtracting yg1y \cdot g_1:

y2+yz6y+z26z+11y(y2z+3)=3yz9y+z26z+11.y^2 + yz - 6y + z^2 - 6z + 11 - y(y - 2z + 3) = 3yz - 9y + z^2 - 6z + 11.

Subtracting 3zg13z \cdot g_1:

3yz9y+z26z+113z(y2z+3)=9y+7z215z+11.3yz - 9y + z^2 - 6z + 11 - 3z(y - 2z + 3) = -9y + 7z^2 - 15z + 11.

Subtracting 9g1-9 \cdot g_1:

9y+7z215z+11(9)(y2z+3)=7z233z+38.-9y + 7z^2 - 15z + 11 - (-9)(y - 2z + 3) = 7z^2 - 33z + 38.

No element of the current basis has a leading term dividing z2z^2, so this remainder is a new generator: g2=7z233z+38g_2 = 7z^2 - 33z + 38.

Verifying the remaining S-polynomials. At this point the basis is G={f1,f2,f3,g1,g2}G = \{f_1, f_2, f_3, g_1, g_2\}. We must check all remaining pairs. Seven of them can be dismissed immediately by the coprimality criterion: if the leading monomials of two polynomials are coprime, their S-polynomial always reduces to zero.

The only non-trivial remaining pair is (f2,f3)(f_2, f_3). We have lcm(LM(f2),LM(f3))=x2\mathrm{lcm}(\mathrm{LM}(f_2), \mathrm{LM}(f_3)) = x^2, so:

S(f2,f3)=xf2f3=2xyxz3xy2z2+14.S(f_2, f_3) = x \cdot f_2 - f_3 = 2xy - xz - 3x - y^2 - z^2 + 14.

Reducing by f1f_1 three times to eliminate xx terms:

2yf1xz3x3y22yz+12yz2+14\xrightarrow{-2y \cdot f_1} -xz - 3x - 3y^2 - 2yz + 12y - z^2 + 14

+zf13x3y2yz+12y6z+14\xrightarrow{+z \cdot f_1} -3x - 3y^2 - yz + 12y - 6z + 14

+3f13y2yz+15y3z4.\xrightarrow{+3 \cdot f_1} -3y^2 - yz + 15y - 3z - 4.

Reducing by g1g_1 three times to eliminate yy terms:

+3yg17yz+24y3z4\xrightarrow{+3y \cdot g_1} -7yz + 24y - 3z - 4

+7zg124y14z2+18z4\xrightarrow{+7z \cdot g_1} 24y - 14z^2 + 18z - 4

24g114z2+66z76=2(7z233z+38)=2g2+2g20.\xrightarrow{-24 \cdot g_1} -14z^2 + 66z - 76 = -2(7z^2 - 33z + 38) = -2g_2 \xrightarrow{+2 \cdot g_2} 0.

All S-polynomials reduce to zero, confirming the basis is a Gröbner basis.

Reducing to minimal form. The current basis is {f1,f2,f3,g1,g2}\{f_1, f_2, f_3, g_1, g_2\} with leading terms x,x,x2,y,7z2x, x, x^2, y, 7z^2. Since LT(f2)=x\mathrm{LT}(f_2) = x is divisible by LT(f1)=x\mathrm{LT}(f_1) = x, and LT(f3)=x2\mathrm{LT}(f_3) = x^2 is also divisible by LT(f1)=x\mathrm{LT}(f_1) = x, both f2f_2 and f3f_3 are redundant and are removed. Making g2g_2 monic by dividing by 7 gives z2337z+387z^2 - \frac{33}{7}z + \frac{38}{7}. The minimal basis is:

{x+y+z6,y2z+3,z2337z+387}.\left\{ x + y + z - 6, \quad y - 2z + 3, \quad z^2 - \tfrac{33}{7}z + \tfrac{38}{7} \right\}.

Reducing to reduced form. We fully reduce each element modulo the others, ensuring no monomial in any element is divisible by the leading term of another.

For f1=x+y+z6f_1 = x + y + z - 6: the monomial yy is divisible by LT(g1)=y\mathrm{LT}(g_1) = y, so we subtract g1g_1:

f1g1=(x+y+z6)(y2z+3)=x+3z9.f_1 - g_1 = (x + y + z - 6) - (y - 2z + 3) = x + 3z - 9.

No remaining monomial is divisible by yy or z2z^2, so this is fully reduced.

For g1=y2z+3g_1 = y - 2z + 3: no monomial is divisible by LT(f1)=x\mathrm{LT}(f_1) = x or LT(g2)=z2\mathrm{LT}(g_2) = z^2. No change.

For z2337z+387z^2 - \frac{33}{7}z + \frac{38}{7}: no monomial is divisible by xx or yy. No change.

The reduced Gröbner basis in lex order is:

{x+3z9=0y2z+3=0z2337z+387=0\begin{cases} x + 3z - 9 = 0\\ y - 2z + 3 = 0\\ z^2 - \tfrac{33}{7}z + \tfrac{38}{7} = 0 \end{cases}

The triangular structure is the polynomial analogue of row echelon form. The variable xx has been eliminated from the second and third equations, and yy has been eliminated from the third. This is the Elimination Theorem in action.

Step 4: Solve the univariate polynomial. The third equation involves only zz:

z2337z+387=0    7z233z+38=(7z19)(z2)=0z^2 - \tfrac{33}{7}z + \tfrac{38}{7} = 0 \implies 7z^2 - 33z + 38 = (7z - 19)(z - 2) = 0

giving z=2z = 2 or z=197z = \tfrac{19}{7}.

Step 5: Back-substitute. For each value of zz, substitute into the second equation to find yy, then into the first to find xx.

Case z=2z = 2:

y2(2)+3=0    y=1.y - 2(2) + 3 = 0 \implies y = 1.

x+3(2)9=0    x=3.x + 3(2) - 9 = 0 \implies x = 3.

Solution: (x,y,z)=(3,1,2)(x, y, z) = (3, 1, 2).

Case z=197z = \tfrac{19}{7}:

y2 ⁣(197)+3=0    y=177.y - 2\!\left(\tfrac{19}{7}\right) + 3 = 0 \implies y = \tfrac{17}{7}.

x+3 ⁣(197)9=0    x=67.x + 3\!\left(\tfrac{19}{7}\right) - 9 = 0 \implies x = \tfrac{6}{7}.

Solution: (x,y,z)=(67,177,197)(x, y, z) = \left(\tfrac{6}{7}, \tfrac{17}{7}, \tfrac{19}{7}\right).


The theory developed in this part will be applied directly in Part 2 to a problem in cryptanalysis. A class of cryptographic hash functions called arithmetization-oriented ciphers is designed to have a compact algebraic description, which makes their internal computation expressible as a low-degree polynomial system over a prime field. The variety of that system is the set of inputs consistent with a known output. Part 2 will show how to construct that system, compute its Gröbner basis, and recover the input, with a working implementation in SageMath.