On Implementing the Symbolic Preprocessing Function over Boolean Polynomial Rings in Gröbner Basis Algorithms Using Linear Algebra

Similar documents
arxiv: v1 [cs.sc] 11 Aug 2013

MutantXL: Solving Multivariate Polynomial Equations for Cryptanalysis

Algebraic Cryptanalysis of MQQ Public Key Cryptosystem by MutantXL

A Generalized Criterion for Signature Related Gröbner Basis Algorithms

MXL2 : Solving Polynomial Equations over GF(2) Using an Improved Mutant Strategy

Computing Minimal Polynomial of Matrices over Algebraic Extension Fields

Key words. Gröbner basis, Buchberger s Algorithm, Syzygy Module, F5 Algorithm, Module

Comparison between XL and Gröbner Basis Algorithms

A (short) survey on signature-based Gröbner Basis Algorithms

On the relation of the Mutant strategy and the Normal Selection strategy

On the Complexity of the Hybrid Approach on HFEv-

A variant of the F4 algorithm

Algebraic Aspects of Symmetric-key Cryptography

Polynomial multiplication and division using heap.

A variant of the F4 algorithm

Sparse Polynomial Multiplication and Division in Maple 14

Cryptanalysis of the Tractable Rational Map Cryptosystem

Gröbner Bases in Public-Key Cryptography

Improved Cryptanalysis of HFEv- via Projection

New candidates for multivariate trapdoor functions

WORKING WITH MULTIVARIATE POLYNOMIALS IN MAPLE

PREMUR Seminar Week 2 Discussions - Polynomial Division, Gröbner Bases, First Applications

Möller s Algorithm. the algorithm developed in [14] was improved in [18] and applied in order to solve the FGLM-problem;

Counting and Gröbner Bases

4 Hilbert s Basis Theorem and Gröbner basis

An Efficient Algorithm for Computing Parametric Multivariate Polynomial GCD

Gröbner Bases & their Computation

Current Advances. Open Source Gröbner Basis Algorithms

Little Dragon Two: An efficient Multivariate Public Key Cryptosystem

Signature-based algorithms to compute Gröbner bases

Modular Algorithms for Computing Minimal Associated Primes and Radicals of Polynomial Ideals. Masayuki Noro. Toru Aoyama

On solving sparse algebraic equations over finite

The Shortest Signatures Ever

On the Complexity of Gröbner Basis Computation for Regular and Semi-Regular Systems

New Directions in Multivariate Public Key Cryptography

An efficient reduction strategy for signature-based algorithms to compute Gröbner basis

The F 4 Algorithm. Dylan Peifer. 9 May Cornell University

Diophantine equations via weighted LLL algorithm

Gröbner Bases. Applications in Cryptology

Quadratic Equations from APN Power Functions

New Gröbner Bases for formal verification and cryptography

ALGORITHM FAUGÈRE'S F 5

Obtaining and solving systems of equations in key variables only for the small variants of AES

Algebraic Cryptanalysis of Curry and Flurry using Correlated Messages

Virtual isomorphisms of ciphers: is AES secure against differential / linear attack?

How Fast can be Algebraic Attacks on Block Ciphers?

SIMPLIFICATION/COMPLICATION OF THE BASIS OF PRIME BOOLEAN IDEAL

Analysis of the MQQ Public Key Cryptosystem

The University of Southern Mississippi ROW REDUCTION OF MACAULAY MATRICES. Lorrin Debenport. A Thesis

arxiv: v1 [math.ag] 13 Oct 2010

Hybrid Approach : a Tool for Multivariate Cryptography

Poly Dragon: An efficient Multivariate Public Key Cryptosystem

The ANF of the Composition of Addition and Multiplication mod 2 n with a Boolean Function

Key Recovery on Hidden Monomial Multivariate Schemes

A variant of the F4 algorithm

CHAPMAN & HALL/CRC CRYPTOGRAPHY AND NETWORK SECURITY ALGORITHMIC CR YPTAN ALY51S. Ant nine J aux

Anatomy of SINGULAR talk at p. 1

Reconstructing Chemical Reaction Networks by Solving Boolean Polynomial Systems

Gröbner Bases. Martin R. Albrecht. DTU Crypto Group

Analysis of Hidden Field Equations Cryptosystem over Odd-Characteristic Fields

Analysis of Some Quasigroup Transformations as Boolean Functions

Signature-based Gröbner basis computation

Lecture 15: Algebraic Geometry II

Cryptanalysis of Patarin s 2-Round Public Key System with S Boxes (2R)

On Generating Coset Representatives of P GL 2 (F q ) in P GL 2 (F q 2)

Characterizations on Algebraic Immunity for Multi-Output Boolean Functions

Zero Decomposition Algorithms for System of Polynomial Equations 1)

Computational and Algebraic Aspects of the Advanced Encryption Standard

Advanced Algebraic Attack on Trivium November 26, 2015 Frank-M. Quedenfeld 1 and Christopher Wolf 2 1 University of Technology Braunschweig, Germany

Multivariate Public Key Cryptography or Why is there a rainbow hidden behind fields full of oil and vinegar?

Multivariate Public Key Cryptography

arxiv: v1 [math.ac] 14 Sep 2016

Efficient variant of Rainbow using sparse secret keys

A Five-Round Algebraic Property of the Advanced Encryption Standard

Inoculating Multivariate Schemes Against Differential Attacks

How to Find the Sufficient Collision Conditions for Haval-128 Pass 3 by Backward Analysis

Elliptic Curve Discrete Logarithm Problem

POLY : A new polynomial data structure for Maple.

Polly Cracker, revisited, revisited

Solving LWE problem with bounded errors in polynomial time

Interval Gröbner System and its Applications

Sparse Polynomial Division Using a Heap

Revisit and Cryptanalysis of a CAST Cipher

ABSTRACT. Department of Mathematics. interesting results. A graph on n vertices is represented by a polynomial in n

From Gauss. to Gröbner Bases. John Perry. The University of Southern Mississippi. From Gauss to Gröbner Bases p.

Jean-Charles Faugère

Sieving for Shortest Vectors in Ideal Lattices:

Differential Fault Analysis of Trivium

Daniel Lazard and Polynomial Systems A Personal View

A new attack on RSA with a composed decryption exponent

arxiv: v3 [cs.sc] 21 Oct 2016

On the Security and Key Generation of the ZHFE Encryption Scheme

On the Relation Between the Mutant Strategy and the Normal Selection Strategy in Gröbner Basis Algorithms

Sparse Boolean equations and circuit lattices

On the Inoue invariants of the puzzles of Sudoku type

POLY : A new polynomial data structure for Maple 17 that improves parallel speedup.

Solving Underdetermined Systems of Multivariate Quadratic Equations Revisited

Solving Quadratic Equations with XL on Parallel Architectures

Computations with Differential Rational Parametric Equations 1)

Algebraic Techniques in Differential Cryptanalysis

Transcription:

On Implementing the Symbolic Preprocessing Function over Boolean Polynomial Rings in Gröbner Basis Algorithms Using Linear Algebra Yao Sun a, Zhenyu Huang a, Dongdai Lin a, Dingkang Wang b a SKLOIS, Institute of Information Engineering, CAS, Beijing 100093, China b KLMM, Academy of Mathematics and Systems Science, CAS, Beijing 100190, China Abstract Linear algebra is introduced by Faugère in F4 to speed up the reduction procedure during Gröbner basis computations. Linear algebra has also been used in fast implementations of F5 and other signature-based Gröbner basis algorithms. To use linear algebra for reductions, an important step is constructing matrices from critical pairs and existing polynomials by the Symbolic Preprocessing function (given in F4). This function can be very costly over boolean polynomial rings when the number of involved polynomials/monomials is huge, because multiplications of monomials and polynomials are contained in the Symbolic Preprocessing function, and moreover, the multiplication of a monomial and a boolean polynomial over a boolean polynomial ring is different from that over a polynomial ring. In this paper, a method of implementing the Symbolic Preprocessing function over boolean polynomial rings is reported. The experimental data show this method is very efficient. Keywords: Gröbner basis, linear algebra, boolean polynomial rings, implementation. 1. Introduction Gröbner basis is a powerful tool of solving systems of polynomial equations as well as many important problems in algebra. Since Gröbner basis was proposed in 1965 (Buchberger, 1965), many improvements have been made to speed up the algorithms for computing Gröbner bases. One important improvement is that Lazard pointed out the strong relation between Gröbner bases and linear algebra (Lazard, 1983). This idea has been implemented in F4 by Faugère(Faugère, 1999), and in XL type algorithms by Courtois et al. (Courtois et al., 2000) and Ding et al. (Ding et al., 2008). Up to now, Faugère s F4 (Faugère, 1999) and F5 (Faugère, 2002) are the most efficient algorithms for computing Gröbner bases, particularly in finite fields. The efficiency of the F4 algorithm mainly comes from the usage of linear algebra for reductions, because the most costly computation in Gröbner basis algorithms is the reduction Email addresses: sunyao@iie.ac.cn (Yao Sun), huangzhenyu@iie.ac.cn (Zhenyu Huang), ddlin@iie.ac.cn (Dongdai Lin), dwang@mmrc.iss.ac.cn (Dingkang Wang) Preprint submitted to Elsevier February 11, 2014

of polynomials. Linear algebra has also been introduced to signature-based algorithms to speed up the efficiency, including F5 in matrix style (Faugère and Rahmany, 2009; Albrecht and Perry, 2010) and the GVW algorithm (Gao et al., 2010b) in matrix style (Sun et al., 2014). One important step in Gröbner basis algorithms that use linear algebra is to convert polynomials to matrices. The matrices are constructed from two kinds of polynomials, polynomials to be reduced and polynomials used to reduce others. When the matrices are constructed, then the elimination of matrices can be done. The procedure of constructing matrices is done by the Symbolic Preprocessing function in F4. There are similar functions in (Albrecht and Perry, 2010; Sun et al., 2014). Since multiplications of monomials and polynomials are involved in the function, constructing matrices may be very costly if the number of polynomials/monomials is huge. This procedure may be even more expensive over boolean polynomial rings, because for monomials m 1, m 2, and t in a boolean polynomial ring, m 1 m 2 does not always imply tm 1 tm 2 w.r.t. orderings on monomials. The Symbolic Preprocessing function in F4 is given in theoretical level, and does not give implementing details. According to the authors knowledge, there are few papers discussing about the implementing details of the Symbolic Preprocessing function, particularly over the finite field GF (2). In this paper, we will report our method of implementing the Symbolic Preprocessing function over boolean polynomial rings. The experimental results show our method is very efficient. This paper is organized as follows. We introduce some notations and give the description of the Symbolic Preprocessing function in Section 2. We report a method for implementing the Symbolic Preprocessing function over boolean polynomial rings in Section 3. Some experimental results are given in Section 4, and concluding remarks follow in Section 5. 2. Preliminaries 2.1. Notations Let F 2 [X] := F 2 [x 1,..., x n ] be a polynomial ring over the finite field F 2 = GF (2) in n variables X = {x 1,..., x n }, and we always require x 1 > x 2 > > x n in this paper. Given a monomial ordering on monomials in F 2 [X], for a polynomial f = x α 1 + +x αt F 2 [X], the leading monomial of f w.r.t. is defined as lm(f) := max {x α i i = 1, 2,..., t}. Let E := {x 2 1 + x 1,..., x 2 n + x n } be a set of polynomials in F 2 [X], and we call these polynomials field polynomials. Then B n := F 2 [X]/ E is a boolean polynomial ring in n variables. Elements in B n are called boolean polynomials. For a boolean polynomial f = [x α 1 ] + + [x αt ] B n where [x α i ] denotes the coset of x α i F 2 [X] in F 2 [X]/ E and x α i is a normal form w.r.t. E, we still write f = x α 1 + + x αt B n in this paper if no confusions occur. Please note that for each monomial in B n, the degree of each variable is at most 1. Let M(X) := {x α α {0, 1} n } be all monomials in B n. Monomial orderings on F 2 [X] can be deduced to orderings on monomials of B n directly. Please note that orderings on M(X) are not real monomial orderings in mathematical senses. With orderings on M(X), leading monomials of boolean polynomials can be defined similarly. 2

Let f be a boolean polynomial in B n. Then M(f) denotes the set of all monomials appearing in f. For a set of boolean polynomials H B n, M(H) denotes the set of all monomials in polynomials in H, i.e. the union of M(f) for all f M. 2.2. The Symbolic Preprocessing function In Gröbner basis algorithm that uses linear algebra for reductions, including F4 (Faugère, 1999), F5 in matrix style (Albrecht and Perry, 2010) and GVW in matrix style (Sun et al., 2014), one important procedure is constructing matrices for eliminations. Constructing a matrix in Gröbner basis algorithms usually contains two steps. The first step is to generate polynomials to be reduced. These polynomials generally come from critical pairs/s-pairs. The second step is to generate polynomials that are used to reduce others. These polynomials are always obtained from a given polynomial set. During these two steps, all involved polynomials are converted to rows of a matrix. When all needed polynomials have been put into this matrix, the elimination of this matrix can then be done. In F4, Faugère gives the following function to construct matrices for eliminations. Notations are slightly different from Faugère s original version. Matrix F5 in (Albrecht and Perry, 2010) and matrix GVW in (Sun et al., 2014) have similar functions. Function Symbolic Preprocessing Input : G, a finite subset of B n ; L = {(t, f) t M(X), f G}, a finite subset of M(X) B n. Output: H, a finite subset of B n. 1 begin 2 H {tf (t, f) L} 3 Done {lm(h) h H} 4 while M(H) Done do 5 m a monomial of M(H) \ Done 6 Done Done {m} 7 if there exists g G such that lm(g) m then 8 H H {(m/lm(g))g} 9 return H In the above function, the input set L are obtained from critical pairs which have been generated earlier, and the polynomials in {tf (t, f) L} are all polynomials to be reduced. Polynomials used to reduce others are obtained from the set G after multiplying proper multipliers at Line 8. This function is straight, but does not contain implementing details. To implement the Symbolic Preprocessing function efficiently over boolean polynomial rings, we need to consider the following two problems. 1. Multiplying t M(X) and f G over a boolean polynomial ring often creates many duplicated monomials, and these duplicated monomials usually will vanish in the product. For example, in the boolean polynomial ring B 4 = F 2 [x 1, x 2, x 3, x 4 ]/ x 2 1 + 3

x 1,..., x 2 4 + x 4, the product of x 1 x 2 and x 1 x 3 + x 2 + x 3 + x 4 is x 1 x 2 x 3 + x 1 x 2 + x 1 x 2 x 3 + x 1 x 2 x 4. The monomial x 1 x 2 x 3 appears twice and should vanish. However, the duplication of monomials is usually not easy to be detected in boolean polynomial rings, because x α x β does not always imply x γ x α x γ x β in boolean polynomial rings, which means monomials in the product are usually not in a sorted order. 2. Finding monomials from M(H)\Done at Line 5 may be very expensive when the size of M(H) is huge. Besides, M(H) needs to be updated frequently because many new polynomials will be appended to H at Line 8. Unfortunately, the size of M(H) is often very large in practical problems. For example, to break HFE challenge 1 (Faugère and Joux, 2003), a 307126 1667009 matrix over F 2 is constructed. This means about 1.7 million distinct monomials will appear, and billions of monomials will be considered when constructing the matrix. So updating M(H) and searching monomials from H(M)\Done should be implemented quite efficiently. 3. On implementing the Symbolic Preprcessing function First, in Subsection 3.1, we discuss about basic data structures used in our implementation. Next, we present our method of implementing the Symbolic Preprocessing function in Subsection 3.2. In the next following two subsections, some related subfunctions are discussed. At last, a toy example is given to illustrate the method in Subsection 3.5. In out implementation, the monomial ordering is the Graded Reverse Lexicographic (GRLex for short) ordering. 3.1. Data structure There are two important data structures will be used: data structures for monomials and for the output of the Symbolic Preprocessing function. First, we use a monomial list to store monomials that will be used during computations. The monomial list is an array of monomials sorted in an ascending order w.r.t. the GR- Lex ordering. The length of this monomial list is dominated by a degree, say Deg Limit. That is, we always store all monomials with degrees smaller or equal to Deg Limit in the monomial list. Positions of monomials in the monomial list become the unique identity numbers of these monomials throughout the computations. For example, monomials in B 4 = F 2 [x 1, x 2, x 3, x 4 ]/ x 2 1 + x 1,..., x 2 4 + x 4 with Deg Limit = 2 are stored in the following list, where x 1 > x 2 > x 3 > x 4 in letters: Identity Number: 0 1 2 3 4 5 6 7 8 9 10 Monomial: 1 x 4 x 3 x 2 x 1 x 3 x 4 x 2 x 4 x 1 x 4 x 2 x 3 x 1 x 3 x 1 x 2. Please note that positions of arrays start from 0 not 1 in this paper. With this monomial list, each monomial can be referred by its identity number, and boolean polynomials can be stored as arrays of identity numbers. For example, the polynomial x 2 x 3 + x 2 + x 4 + 1 can be stored as [8, 3, 1, 0]. 4

Second, we use a sparse matrix in row-compressed form to store all polynomials in the output of the Symbolic Preprocessing function. This sparse matrix contains two arrays. The array startpos stores positions of the first monomial in each polynomial. The array ids stores all identity numbers of the monomials that appear in the output polynomials. For example, assume H = {x 2 x 3 + x 2 + x 4 + 1, x 2 x 4 + x 3, x 3 x 4 + x 1 } is the output set, using the monomial list in the last paragraph, then we can store H by the following two arrays: startpos 0 4 6 8, ids 8 3 1 0 6 2 5 4. The identity numbers of monomials in the i-th polynomials is stored in the array ids from the position startpos[i] to startpos[i + 1] 1. The last element of the array startpos gives the length of the array ids. In practical implementation, more auxiliary information should be stored. The monomial list and the sparse matrix are defined below in C++: monnode t m o n l i s t ; matrix t mat ; In our implementation, the mon list array is unique, and is updated due to the maximal degree of polynomials appearing in computations. We may use several matrices of type matrix t, since several matrices may be constructed. Definition of matrix t is given below: struct matrix t { int num; int s t a r t p o s ; int i d s ; } ; Annotations of members in the above structure is given below: 1. num, gives the number of rows in a row-compressed sparse matrix, and gives the number of columns in a column-compressed sparse matrix. 2. startpos, points to an allocated array of integers that stores the starting position of each row (or column). The starting position of the i-th row (or column) in the array ids is startpos[i], where i = 0, 1,..., num - 1. 3. ids, points to an allocated array of all identity numbers in this matrix. The structure monnode t is presented below: struct monnode t { mon t mon ; 5

} ; char type ; int appeartimes ; int lastrowpos ; int l a s t p o s ; Here are some annotations for the members of monnode t. Assume mat is a matrix to be constructed, i.e. mat will contain all information in the output of the Symbolic Preprocessing function. 1. mon, is a monomial stored in type of mon t. Each monnode t corresponds to one and only one monomial, and the monomial is stored in mon. The position of monnode t in the array mon list is then the unique identity number of the monomial mon. Since there are many methods of storing a monomial in B n, the definition of mon t can be various. Take the monomial x 1 x 3 x 4 B 4 for example, one can either stores exponents of each variable by bits like [1, 0, 1, 1], or only stores the appearing subscripts of x like [1, 3, 4]. Ether method can be used as the definition of mon t. 2. type, shows the status of the monomial mon. type = 0, means mon does not appear in the output matrix mat; type = 1, means mon has appeared in the output mat but is not a leading monomial of some polynomial; type = 2, means mon has appeared in mat and is the leading monomial of some polynomial. type is set to 0 initially. The type of mon is used to decide whether it is necessary to search polynomials from G to eliminate the monomial mon at Line 7 of the Symbolic Preprocessing function. 3. appeartimes, shows how many times the monomial mon has appeared in the output mat. This value is used to check whether mon really appears in mat, and it is also useful when transforming mat to column-compressed form. 4. lastrowpos, shows the position of the row where mon appears in mat for the last time. This value is used to check whether mon appears in the same row twice (or for even times). lastrowpos is set to -1 initially. 5. lastpos, shows where the identity number of mon is stored in mat when mon appears for the last time. The value of lastpos is only used when mon will appear in the same row twice (or for even times). Specifically, if mon has already appeared in some row and the same mon will also be appended to the same row, then both mon should vanish in this row. In practical implementation, the identity number of the second mon will not be appended to mat, and besides, we should also clear the record of first mon in mat. Then lastpos is used. Please note that, memories for the arrays mon list, startpos and ids should be allocated and adjusted during computations. 6

3.2. Implementing the Symbolic Preprocessing function The main algorithm for implementing the Symbolic Preprocessing function is given below. Algorithm 1: Symbolic Preprocessing in Implementation (SPI) Input : G, a finite subset of B n ; L = {(t, f) t M(X), f G}, a finite subset of M(X) B n ; mon list, an array of monnode t; mat, a matrix of type matrix t. Output: The matrix mat. 1 begin 2 rowpos 0 3 id lengh the length of mon list 4 for i from 0 to id lengh 1 do 5 mon list[i].type 0 6 mon list[i].appeartimes 0 7 mon list[i].rowpos -1 8 for each (t, f) L do 9 multplypoly (t, f, mat, rowpos, mon list) 10 rowpos rowpos + 1 11 for i from id lengh 1 to 0 do 12 if mon list[i].type = 1 and mon list[i].appeartimes > 0 then 13 if there exists g G such that lm(g) mon list[i].mon then 14 multplypoly (mon list[i].mon/lm(g), g, mat, rowpos, mon list) 15 rowpos rowpos + 1 16 mat.num rowpos 17 return mat The algorithm SPI contains three steps. In the first step (Line 2-7), the algorithm SPI initializes some data, including the initial position of the row, and the members type, appeartimes, rowpos of each monomial node in the monomial list mon list. In the second step (Line 8-10), the algorithm SPI computes the product of t and f from each pair in L. The product is computed by the procedure multiplypoly, which is given later, and the product tf is appended to the matrix mat. In the last step (Line 11-17), the algorithm SPI traverses all monomials in the monomial list to find monomials that appear in mat but are not leading monomials of polynomials. In this algorithm, for each monomial mon list[i].mon, mon list[i].appeartimes > 0 means mon list[i].mon really appears in mat, and mon list[i].type = 1 means mon list[i].mon is not a leading monomial of some polynomial. If the monomial mon list[i].mon meets the two conditions at Line 12, then the algorithm searches G to find a polynomial g satisfying conditions at Line 13. If such a polynomial g is found, then the product of 7

mon list[i].mon/lm(g) and g is computed by the procedure multiplypoly and appended to mat. Since the algorithm SPI traverses all monomials by a decreasing order on the monomial ordering, when adding a new polynomial (mon list[i].mon/lm(g))g to mat at Line 14, monomials bigger than mon list[i].mon are not affected. In the algorithm SPI, the procedure multiplypoly(t, f, mat, rowpos, mon list) computes the product of t and f, and append the product to mat at the row rowpos. Pseudo codes are given below. Procedure multiplypoly(t, f, mat, rowpos, mon list) Input: t, a monomial in B n ; f, a polynomial in B n ; mat, a matrix of type matrix t; rowpos, an integer shows a position of row in mat; mon list, an array of monnode t. 1 begin 2 nextpos mat.startpos[rowpos] 3 if gcd(t, lm(f)) = 1 then 4 id getid(tlm(f)) 5 mon list[id].type 2 6 for each m in M(f) do 7 id getid(tm) 8 if mon list[id].lastrowpos = rowpos then 9 mon list[id].lastrowpos 1 10 mat.ids[mon list[id].lastpos] 1 11 mon list[id].appeartimes mon list[id].appeartimes 1 12 else 13 mon list[id].lastrowpos rowpos 14 mat.ids[nextpos] id 15 mon list[id].lastpos nextpos 16 nextpos nextpos + 1 17 mon list[id].appeartimes mon list[id].appeartimes + 1 18 if mon list[id].type = 0 then 19 mon list[id].type 1 20 mat.startpos[rowpos + 1] nextpos The procedure multiplypoly does two things. First, if tlm(f) is the leading monomial of tf, then the procedure multiplypoly sets the type of the monomial tlm(f) to be 2. In the algorithm SPI, if the type of a monomial is set to 2, it will never change until the algorithm is over. Please note that if gcd(t, lm(f)) = 1, then we always have lm(tf) = tlm(f), but the converse is not always true in boolean polynomial rings. Second, for each monomial m appearing in f, the procedure multiplypoly computes 8

the product tm, and then check whether the monomial tm has already appeared in the row rowpos in mat, i.e. check whether tm will appear in the same row twice (or for even times). If tm has already appeared at the row rowpos, then the latest appearing record of tm is cleared at Line 10; otherwise, the identity number of tm is appended to mat. A key subroutine in the procedure multiplypoly is the function getid, which gets the identity number of a given monomial. We will discuss this function in the next subsection. Please note that when the algorithm SPI is over, there may exist many -1 s in the array ids of mat. So when reading mat, such -1 s should be skipped directly. 3.3. Getting identity numbers of given monomials In this subsection, we present our method of getting identity numbers of given monomials. The efficiency of function getid is quite important to the whole algorithm, because this function may be called for billions of times in complicated examples. For example, the maximal matrix in computing a Gröbner basis for 25 square polynomials in 25 variables (Courtois, 2013) by F4 has the size of 248, 237 108, 488 with the density 1.6%, and contains totally about 431 million monomials. This means the algorithm SPI will call function getid about 431 million times. A simple method of getting the identity number of a given monomial m, is to search m in the monomial list. However, no matter which searching algorithm is used, this searching procedure will cost O(log(lengh)) comparisons of monomials, where length is the length of the monomial list. After testing many examples, we find this searching method is not very efficient, particularly for complicated examples. Another method of getting the identity number of a given monomial is through a multiplication table suggested by Cabarcas (Cabarcas, 2010). That is, for any monomial represented by its identity number and any variable, we can store the identity number of the product in a table in advance. In our tests, we find this method is very efficient, but the main drawback of this method is that the multiplication table will cost too much memories when the number of variables is large. In our implementation, the identity number of a given monomial is obtained through a hash table. Specifically, let table be an array of integers, table size be the length of table, and φ be a mapping from monomials to integers, then for each monomial m in the monomial list, we set the value table[φ(m) mod table size] to the identity number of m. The values of table should be updated when the monomial list is enlarged. In our implementation, chaining is used for collision resolution (Skiena, 2008). By this hash table, for any given monomial m, we can compute the value of φ(m) mod table size first, and then read the identity number of m from table directly. Experimental results in Section 4 show this method is very efficient. For the hash function φ, there may be many choices. In our implementation, we use the following function. Let x α = x i0 x i1 x il 1, where 1 i 0 < i 1 < < i l n, then we set φ(x i0 x i1 x il ) = i 0 + i 1 (n + 1) + + i l (n + 1) l. Then φ(x α ) 1 for any x α 1, and we define φ(1) = 0. The idea of this hash function 9

is to regard (i 0, i 1,, i l ) as an (n + 1)-adic number. So we have φ(x α ) φ(x β ) whenever x α x β. But please note that φ(x α ) φ(x β ) mod table size may hold for x α x β. Since the time complexity of the above method is dominated by the time of accessing table, the size of table is usually not set very large. 3.4. Transforming row-compressed matrices to column-compressed matrices The output of the algorithm SPI is stored as a row-compressed sparse matrix. Since most elimination algorithms of sparse matrices require matrices are stored as column-compressed forms. In this subsection, we give a function for transforming row-compressed matrices to column-compressed matrices. Similar functions can be found in most books on sparse linear algebra, for example (Davis, 2006). Function Transform(mat, mon list) Input : mat, a matrix of type matrix t in row-compressed form; mon list, an array of monnode t. Output: newmat, a matrix of type matrix t in column-compressed form; column id, an array of integers, showing the identity number of each column. 1 begin 2 pos 0 3 col num 0 4 id lengh the length of mon list 5 for i from id lengh 1 to 0 do 6 if mon list[i].appeartimes > 0 then 7 newmat.startpos[col num] pos 8 pos pos + mon list[i].appeartimes 9 mon list[i].appeartimes newmat.startpos[col num] 10 column id[col num] i 11 col num col num + 1 12 newmat.startpos[col num] pos 13 newmat.num col num 14 for r from 0 to mat.num 1 do 15 for j from mat.startpos[r] to mat.startpos[r + 1] 1 do 16 id mat.ids[j] 17 if id 1 then 18 newmat.ids[mon list[id].appeartimes] r 19 mon list[id].appeartimes mon list[id].appeartimes + 1 20 return newmat, col num In the above function, mon list[i].appeartimes is used to store the starting positions of each column. In the output of the function Transform, columns of newmat are stored by a decreasing order on monomial orderings, and the row numbers in each column of newmat are sorted 10

by an ascending order. The function Transform in fact does a bucket sort to the identity numbers in mat. 3.5. A toy example In this subsection, we give a toy example to illustrate how our method works. Example 3.1. Let B 4 := F 2 [x 1, x 2, x 3, x 4 ]/ x 2 1 + x 1,..., x 2 4 + x 4 be a boolean polynomial ring in {x 1, x 2, x 3, x 4 }, G = {f 1, f 2 } be a subset of B 4 where f 1 = x 1 x 2 + x 3 x 4 + x 2 + x 4 and f 2 = x 2 x 3 + x 2, and L := {(x 3, f 1 ), (x 1, f 2 )}. The monomial ordering is the Graded Reverse Lexicographical ordering with x 1 > x 2 > x 3 > x 4. Next, we construct a matrix from G and L by the algorithm SPI. The initial monomial list used in this example is id 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 mon 1 x 4 x 3 x 2 x 1 x 3 x 4 x 2 x 4 x 1 x 4 x 2 x 3 x 1 x 3 x 1 x 2 x 2 x 3 x 4 x 1 x 3 x 4 x 1 x 2 x 4 x 1 x 2 x 3 type 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 appeartimes 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 lastrowpos 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 lastpos 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0. (1) The output mat is empty initially. After appending x 3 f 1 to mat, we get startpos 0 3, ids 14-1 8. The monomial x 3 x 4 vanishes because it appears twice, and the monomial list becomes id 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 mon 1 x 4 x 3 x 2 x 1 x 3 x 4 x 2 x 4 x 1 x 4 x 2 x 3 x 1 x 3 x 1 x 2 x 2 x 3 x 4 x 1 x 3 x 4 x 1 x 2 x 4 x 1 x 2 x 3 type 0 0 0 0 0 1 0 0 1 0 0 0 0 0 2 appeartimes 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 lastrowpos 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 lastpos 0 0 0 0 0 1 0 0 2 0 0 0 0 0 0. (2) After appending x 1 f 2 to mat, we get startpos 0 3 5, ids 14-1 8 14 10. The monomial list becomes id 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 mon 1 x 4 x 3 x 2 x 1 x 3 x 4 x 2 x 4 x 1 x 4 x 2 x 3 x 1 x 3 x 1 x 2 x 2 x 3 x 4 x 1 x 3 x 4 x 1 x 2 x 4 x 1 x 2 x 3 type 0 0 0 0 0 1 0 0 1 0 1 0 0 0 2 appeartimes 0 0 0 0 0 0 0 0 1 0 1 0 0 0 2 lastrowpos 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 lastpos 0 0 0 0 0 1 0 0 2 0 4 0 0 0 3. 11

(3) Since the type of x 1 x 2 is 1 and appeartimes = 1, the polynomial f 1 is found and appended to mat and we get startpos 0 3 5 9, ids 14-1 8 14 10 10 5 3 1. The monomial list becomes id 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 mon 1 x 4 x 3 x 2 x 1 x 3 x 4 x 2 x 4 x 1 x 4 x 2 x 3 x 1 x 3 x 1 x 2 x 2 x 3 x 4 x 1 x 3 x 4 x 1 x 2 x 4 x 1 x 2 x 3 type 0 1 0 1 0 1 0 0 1 0 2 0 0 0 2 appeartimes 0 1 0 1 0 1 0 0 1 0 2 0 0 0 2 lastrowpos 1 2 1 2 1 2 1 1 0 1 2 1 1 1 1 lastpos 0 8 0 7 0 6 0 0 2 0 5 0 0 0 3. (4) Similarly, since the type of x 2 x 3 is 1 and appeartimes = 1, the polynomial f 2 is found and appended to mat and we get startpos 0 3 5 9 11, ids 14-1 8 14 10 10 5 3 1 8 3. The monomial list becomes id 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 mon 1 x 4 x 3 x 2 x 1 x 3 x 4 x 2 x 4 x 1 x 4 x 2 x 3 x 1 x 3 x 1 x 2 x 2 x 3 x 4 x 1 x 3 x 4 x 1 x 2 x 4 x 1 x 2 x 3 type 0 1 0 1 0 1 0 0 2 0 2 0 0 0 2 appeartimes 0 1 0 2 0 1 0 0 2 0 2 0 0 0 2 lastrowpos 1 2 1 3 1 2 1 1 3 1 2 1 1 1 1 lastpos 0 8 0 10 0 6 0 0 9 0 5 0 0 0 3. So far, no more polynomials will be appended to mat, and mat can be eliminated by linear algebra. 4. Experimental data We implemented an F4 algorithm (called New-F4) over boolean polynomial rings in C++ and the library M4RI (version 20130416) (Albrecht and Bard, 2013) is used for the eliminations of matrices. The M4RI package provides efficient routines for eliminating dense matrices over GF (2), so in our implementation, the outputs of the algorithm SPI are converted to dense matrices. We test our implementation by square polynomial systems generated by Courtois (Courtois, 2013), and HFE systems from (Steel, 2004). In the examples generated by Courtois, n n means that the input square polynomial system has n polynomials with n variables. The computer we used is MacBook Pro with 2.6 GHz Intel Core i7, 16 GB memory. In Table 1, we list the size and density of the maximal matrices generated during the computations of Gröbner bases for given examples. We compare the time for constructing 12

matrices (Const. time in Table 1) and the total time for computing the whole Gröbner bases (Total time in Table 1), and the ratios are also presented (Const./Total in Table 1). Exa. Max matrix Density Const. time Total time Const./Total 16 16 9997 4038 4.8% 0.085 0.170 50.0% 18 18 15174 8107 5.0% 0.259 0.473 54.8% 20 20 22441 14979 4.8% 0.704 1.357 51.9% 21 21 26915 19811 4.6% 1.133 2.524 44.9% 22 22 63631 21865 3.7% 3.377 8.819 38.3% 23 23 37860 33014 4.1% 4.487 13.116 34.2% 24 24 206990 78477 1.5% 29.204 100.499 29.1% 25 25 248237 108488 1.6% 63.317 235.750 26.9% 26 26 298673 148885 0.7% 133.089 567.081 23.5% 27 27 354012 197725 0.3% 229.43 1707.601 13.4% 28 28 420773 261160 0.15% 400.050 5547.582 7.2% HFE 25 96 12478 13679 6.9% 0.749 1.768 42.3% HFE 30 96 19988 29404 6.3% 2.264 7.721 29.3% HFE 35 96 30081 55912 5.6% 5.948 41.161 14.5% Table 1: Constructing time and total time From Table 1, we can see that the ratio of constructing time and total time becomes lower when the example becomes complicated. So we believe that, in the examples from practical cryptosystems, the time of constructing matrices will be much less than the time used for eliminating matrices. This means the proposed method of constructing matrices can be used in practical analysis of cryptosystems. We also test our implementation with intrinsic Gröbner basis functions on Maple (version 17, setting method = fgb ), Singular (version 3-1-6), and Magma (version 2.12-16) 1, and the computing times in seconds are listed in Table 2. 1 Magma 2.12-16 is an old version, and we are trying to buy the latest one. 13

Exam. Maple Singular Magma New-F4 16 16 4.088 5.210 0.484 0.170 17 17 9.891 12.886 0.874 0.318 18 18 22.340 31.590 1.513 0.473 19 19 48.314 84.771 2.792 0.840 20 20 107.064 265.325 5.226 1.357 21 21 218.479 724.886 10.468 2.524 22 22 839.067 > 1h 37.144 8.819 HFE 25 96 121.681 > 1h 7.675 1.768 HFE 30 96 619.745 > 1h 29.172 7.721 HFE 35 96 2229.239 > 1h out mem. 41.161 Table 2: Maple, Singular and Magma vs New-F4 5. Conclusions In this paper, we present a method of implementing the Symbolic Preprocessing function over boolean polynomial rings in Gröbner basis algorithms using linear algebra. A monomial list is introduced to detect duplicated monomials in the products of monomials and polynomials. The monomial list can also record the statuses of monomials, i.e. whether a monomial appears in the matrix and whether a monomial is a leading monomial of some polynomial. When searching polynomials that are used to reduce others, the algorithm SPI only needs to traverse the monomial list once. Another crucial step in our method is to get the identity numbers of given monomials, and this step is done by using a hash table. The experimental results show the proposed method is very efficient. References M. Albrecht and J. Perry. F4/5. Preprint, arxiv:1006.4933v2 [math.ac], 2010. M. Albrecht and G. Bard. The M4RI Library Version 20130416, 2013. http://m4ri.sagemath.org B. Buchberger. Ein Algorithmus zum auffinden der Basiselemente des Restklassenringes nach einem nulldimensionalen Polynomideal. PhD thesis, 1965. D. Cabarcas. An implementation of Faugère s F4 algorithm for computing Gröbner bases. Thesis, 2010. N. Courtois, A. Klimov, J. Patarin, and A. Shamir. Efficient algorithms for solving overdefined systems of multivariate polynomial equations. In Proc. of EUROCRYPT 00, Lect. Notes in Comp. Sci., vol. 1807, 392-407, 2000. N. Courtois. Benchmarking algebraic, logical and constraint solvers and study of selected hard problems, 2013. http://www.cryptosystem.net/aes/hardproblems.html. T.A. Davis. Direct methods for sparse linear systems. Society for Industrial and Applied Mathematics, 2006. J. Ding, J. Buchmann, M.S.E. Mohamed, W.S.A.E. Mohamed, and R.-P. Weinmann. MutantXL. In Proc. SCC 08, 16-22, 2008. J.-C. Faugère. A new effcient algorithm for computing Gröbner bases (F 4 ). J. Pure Appl. Algebra, vol. 139(1-3), 61-88, 1999. J.-C. Faugère. A new effcient algorithm for computing Gröbner bases without reduction to zero (F 5 ). In Proc. ISSAC 02, ACM Press, 75-82, 2002. Revised version downloaded from fgbrs.lip6.fr/jcf/publications/index.html. 14

J.-C. Faugère and A. Joux. Algebraci cryptanalysis of Hidden Field Equation (HFE) cryptosystems using Gröbner bases. In proc. advances in Cryptology - CRYPTO 2003, LNCS, vol. 2729, 44-60, springer Berlin/Heidelberg, 2003. J.-C. Faugère and S. Rahmany. Solving systems of polynomial equations with symmetries using SAGBI- Gröbner bases. In proc. ISSAC 09, ACM Press, New York, USA, 151-158, 2009. S.H. Gao, F. Volny, and M.S. Wang. A new algorithm for computing Gröbner bases. Cryptology eprint Archive, Report 2010/641, 2010. D. Lazard. Gröbner bases, Gaussian elimination and resolution of systems of algebraic equations. In Proc. EUROCAL 83, Lect. Notes in Comp. Sci., vol. 162, 146-156, 1983. S.S. Skiena. The algorithm design manual. Springer, second edition, 2008. A. Steel. Allan Steel s Gröbner basis timings page. 2004. http://magma.maths.usyd.edu.au/~allan/gb/. Y. Sun, D.D. Lin and D.K. Wang. An improvement over the GVW algorithm for inhomogeneous polynomial systems. Submitted to ISSAC 14, 2014. 15