Cryptography
Nov 12, 2025
Constructing and Breaking SIDH
Explore a detailed, hands-on walkthrough of supersingular isogeny cryptography (SIDH), from elliptic curve preliminaries and kernel-based is...
Cryptography
Mar 24, 2026

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.
The starting point is to make precise what we mean by a system of polynomial equations and its solution set.
Definition. Let be a field and indeterminates. A monomial in is a product of the form
The total degree of is . A polynomial in with coefficients in is a finite -linear combination of monomials:
The set of all such polynomials, equipped with the usual addition and multiplication, forms a commutative ring denoted , called the polynomial ring in variables over .
The solution set of a system of polynomial equations is the fundamental geometric object we need.
Definition. Let . The affine variety defined by is the set of all common zeros:
Example. In , the variety is the unit circle. The variety is the finite set .
A system of polynomial equations can be described by many different collections of polynomials. Multiplying any by an arbitrary polynomial , or replacing with , 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 is an ideal if:
Definition. Given , the ideal generated by is
This is the smallest ideal containing .
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 , then .
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 , the ideal of is
The ideal captures every polynomial relation that vanishes on and is in general strictly larger than any particular generating set used to define .
To compute with polynomials in , 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 is a total ordering on the set of monomials satisfying:
Condition 2 implies that 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). if the leftmost nonzero entry of is positive.
Example. In : . The variable dominates unconditionally, regardless of the degrees of and . 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 , then only , allowing us to solve the system one variable at a time.
Definition (Graded Lexicographic Order, grlex). if , or if and .
Example. In : since . Total degree is compared first; lex breaks ties.
Definition (Graded Reverse Lexicographic Order, grevlex). if , or if and the rightmost nonzero entry of is negative.
Example. In , among degree-2 monomials: .
With a monomial ordering fixed, we can designate the distinguished term of each polynomial.
Definition. Fix a monomial ordering and let .
Example. For under : , , , .
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 -tuple . Then every can be written as
where , no monomial of is divisible by any , and whenever . The polynomial is the remainder on division of by , written .
The algorithm proceeds greedily: at each step, if the current leading term is divisible by some , 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 need not be unique: reordering can produce a different remainder for the same . Second, and more critically, does not imply . 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.
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 has a finite generating set.
The proof uses the ascending chain condition: any chain 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 , the leading term ideal is
The leading term ideal collects the leading terms of every element of , not just those of a generating set. The gap between and is precisely what causes the division algorithm to fail. A Gröbner basis closes this gap.
Definition. A finite set is a Gröbner basis for if
Equivalently, for every nonzero , there exists such that divides .
Every nonzero ideal has a Gröbner basis, and every Gröbner basis is a generating set for . The following two lemmas confirm that Gröbner bases fix both defects identified previously.
Lemma. Let be a Gröbner basis for . Then every has a unique remainder , independent of the ordering of elements of in the division algorithm. This remainder is called the normal form of with respect to , written .
Lemma. Let be a Gröbner basis for . Then
Together, these lemmas say that once we have a Gröbner basis, ideal membership becomes a deterministic single computation. Since we know that , we can replace any generating set with a Gröbner basis and solve the resulting system instead.
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 be nonzero, with and . Set , where . The S-polynomial of and is
The leading terms of and 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 , witnessing that is not yet a Gröbner basis.
Example. Let and in under . Then , and
Theorem (Buchberger's Criterion). A generating set for an ideal is a Gröbner basis if and only if
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:
Output: A Gröbner basisSet
Repeat:
Set
For each pair :
Compute
If , set
Until
Return
Termination follows from the ascending chain condition: each nonzero remainder strictly enlarges , and this chain must stabilise.
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 is minimal if every is monic and .
Definition. A Gröbner basis is reduced if every is monic and no monomial of is divisible by for any other .
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 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.
We now have all the pieces. The following procedure solves a system of polynomial equations over a field .
Step 1: Form the ideal. Collect the system into . Finding is equivalent to finding .
Step 2: Add field equations. If , every element of satisfies . Adding the field equations for each variable to the generating set restricts the variety to and ensures the ideal is zero-dimensional, meaning 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 generates the same ideal and satisfies .
Step 4: Read off the univariate polynomial. Because lex order forces earlier variables to be eliminated as aggressively as possible, the Gröbner basis will contain an element involving only the last variable. Its roots over are the only possible values of in any solution.
Step 5: Back-substitute. For each root of , substitute into the remaining elements of and repeat: find the univariate polynomial in , extract its roots, substitute, and continue until all variables are determined. The full solution set is recovered.
Consider the following system over in variables :
Computing the Gröbner basis. We apply Buchberger's algorithm, processing S-polynomials until all reduce to zero.
S-polynomial of and . Both have leading term , so and:
This does not reduce to zero modulo , so we add to the basis.
S-polynomial of and . Here and , so and:
We reduce this modulo the current basis . The leading term is divisible by , so we subtract :
The leading term is again divisible by , so we subtract :
The leading term is divisible by , so we subtract :
Dividing through by gives . The leading term is now , divisible by . Subtracting :
Subtracting :
Subtracting :
No element of the current basis has a leading term dividing , so this remainder is a new generator: .
Verifying the remaining S-polynomials. At this point the basis is . 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 . We have , so:
Reducing by three times to eliminate terms:
Reducing by three times to eliminate terms:
All S-polynomials reduce to zero, confirming the basis is a Gröbner basis.
Reducing to minimal form. The current basis is with leading terms . Since is divisible by , and is also divisible by , both and are redundant and are removed. Making monic by dividing by 7 gives . The minimal basis is:
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 : the monomial is divisible by , so we subtract :
No remaining monomial is divisible by or , so this is fully reduced.
For : no monomial is divisible by or . No change.
For : no monomial is divisible by or . No change.
The reduced Gröbner basis in lex order is:
The triangular structure is the polynomial analogue of row echelon form. The variable has been eliminated from the second and third equations, and has been eliminated from the third. This is the Elimination Theorem in action.
Step 4: Solve the univariate polynomial. The third equation involves only :
giving or .
Step 5: Back-substitute. For each value of , substitute into the second equation to find , then into the first to find .
Case :
Solution: .
Case :
Solution: .
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.