Generating and Exploring S-Box Multivariate Quadratic Equation Systems with SageMath
A new method to derive Multivariate Quadratic equation systems (MQ) for the input and output bit variables of a cryptographic S-box from its algebraic expressions with the aid of the computer mathematics software system SageMath is presented. We consolidate the deficiency of previously presented MQ metrics, supposed to quantify the resistance of S-boxes against algebraic attacks.
đĄ Research Summary
The paper presents a systematic method for automatically deriving multivariate quadratic (MQ) equation systems for cryptographic Sâboxes, focusing on the Rijndael (AES) Sâbox and a newly proposed AffineâInverseâAffine (AIA) variant, using the openâsource computer algebra system SageMath. The authors first recap the algebraic definition of the Rijndael Sâbox: an 8âbit input byte x is represented as a polynomial xâŻ=âŻâ_{i=0}^{7}x_iâŻt^i over GF(2), the inverse transformation I(x)âŻ=âŻx^{254}âŻmodâŻm(t) (with irreducible m(t)=tâ¸+tâ´+tÂł+t+1) is applied, followed by an affine map A(x)=a¡x+b (a=0x1F, b=0x63) to obtain the output byte z = A(I(x)).
The authors then reconstruct the MQ derivation originally described by Cui etâŻal. and CourtoisâPieprzyk, but implement it entirely in SageMath. They create a Boolean polynomial ring for the coefficient variables, extend it to a multivariate polynomial ring, and finally form a quotient ring âByteâ that implements arithmetic modulo the AES irreducible polynomial. By enforcing the relation x¡yâŻ=âŻ1 (modâŻm(t)), where y = I(x), they obtain eight quadratic equations. Substituting the affine transformation yields an additional sixteen equations, for a total of twentyâfour equations; however, one of them holds only with probability 255/256 and is discarded, leaving a system of 23 equations (mq1) that contains 81 distinct monomials.
The paper demonstrates how SageMathâs list and dictionary facilities can automatically extract coefficients, substitute variables, and generate the full MQ without manual transcription errors. The authors then solve the MQ using two approaches: (1) a SAT solver provided by SageMathâs SAT module, and (2) GrĂśbner basis computation. The SAT solver solves the 23âequation system in roughly 0.6âŻseconds on a modest 2.8âŻGHz machine, while GrĂśbner basis computation takes about 14âŻseconds and produces an 8âequation basis of degree 7 with 263 monomials. Remarkably, the reduced 16âequation subsystem (mq2) is sufficient to recover the full Sâbox table, and its SAT solving time (â0.7âŻs) is comparable to that of the larger system, contradicting the claim that more equations automatically imply higher algebraic resistance.
Next, the authors apply the same automated pipeline to the AIA Sâbox, which applies an affine map, then the inverse, then another affine map (AâŻââŻIâŻââŻA). They model the AIA transformation with 253 intermediate variables yââŚyââ â and the output z. The polynomial coefficients of the AIA mapping are entered as hexadecimal strings; SageMath converts them into Boolean variables and constructs the full MQ. Despite the dramatic increase in the number of equations and variables, the SAT solver again solves the system in a time comparable to the original Rijndael MQ, indicating that sheer equation count does not translate into practical hardness.
The paper critically examines two previously proposed metrics for resistance against algebraic attacks (RAA): the CheonâLee metric Î = â(târ)/nâ¡2^{d(târ)/n} and the CourtoisâPieprzyk metric Î_CP = ât/nâ¡2^{d¡t/r}, where r is the number of equations, t the total number of monomials, n the field size, and d the maximal degree. Using the counted values (e.g., for Rijndael: r=23, t=81, d=2, n=8) the authors compute Îâ2^{22} and Î_CPâ2^{13}. For the reduced 16âequation system the metrics explode to Îâ2^{27} and Î_CPâ2^{20}, yet the empirical SAT solving time does not reflect such a dramatic increase. The same discrepancy appears for the AIA Sâbox, leading the authors to conclude that these metrics severely overâestimate actual algebraic difficulty and are therefore unsuitable for evaluating Sâbox security.
Finally, the authors emphasize the practical benefits of SageMath: it provides a free, reproducible environment where researchers can define Boolean rings, construct quotient rings, generate MQs automatically, and invoke SAT or GrĂśbner solvers with a few lines of code. This transparency allowed the authors to spot typographical errors and incorrect coefficient tables in the original Cui etâŻal. publications. They argue that SageMath should become a standard tool for Sâbox design and algebraic cryptanalysis, enabling rapid verification of claimed security properties and facilitating the exploration of more sophisticated algebraic structures. The paper thus contributes both a concrete methodological framework and a critical perspective on existing algebraicâresistance metrics.
Comments & Academic Discussion
Loading comments...
Leave a Comment