# The tangent space attack

## Axel Lemoine

► To cite this version:

Axel Lemoine. The tangent space attack. 2025. hal-05069034

HAL Id: hal-05069034

https://hal.science/hal-05069034v1

Preprint submitted on 15 May 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# THE TANGENT SPACE ATTACK

AXEL LEMOINE

**ABSTRACT.** We propose a new method for retrieving the algebraic structure of a generic alternant code given an arbitrary generator matrix, provided certain conditions are met. We then discuss how this challenges the security of the McEliece cryptosystem instantiated with this family of codes. The central object of our work is the quadratic hull related to a linear code, defined as the intersection of all quadrics passing through the columns of a given generator or parity-check matrix, where the columns are considered as points in the affine or projective space. The geometric properties of this object reveal important information about the internal algebraic structure of the code. This is particularly evident in the case of generalized Reed-Solomon codes, whose quadratic hull is deeply linked to a well-known algebraic variety called the rational normal curve. By utilizing the concept of Weil restriction of affine varieties, we demonstrate that the quadratic hull of a generic dual alternant code inherits many interesting features from the rational normal curve, on account of the fact that alternant codes are subfield-subcodes of generalized Reed-Solomon codes. If the rate of the generic alternant code is sufficiently high, this allows us to construct a polynomial-time algorithm for retrieving the underlying generalized Reed-Solomon code from which the alternant code is defined, which leads to an efficient key-recovery attack against the McEliece cryptosystem when instantiated with this class of codes. Finally, we discuss the generalization of this approach to Algebraic-Geometry codes and Goppa codes.

## INTRODUCTION

**McEliece cryptosystem.** The problem of decoding random linear codes, also known as random decoding problem, is widely regarded as a difficult problem. It was shown in [BMvT78] that this problem is NP-hard, which may be thought of as worst-case hardness. More interestingly, the random decoding problem has also been deeply studied in the average case. After decades of research, the best generic decoding algorithm [BM17] remains exponential, which makes the decoding problem a good candidate for asymmetric cryptography. Moreover, it is generally agreed that the decoding problem is quantum resistant, given that the best known quantum decoding algorithm [KT17] also has exponential complexity. Until very recently, the NIST was still considering several code-based cryptosystems [AAB$^{+22}$, AAB$^{+17}$, ABC$^{+22}$] in the fourth round of its post-quantum standardization competition, whose [AAB$^{+17}$] was eventually declared the winner.

The first code-based public-key cryptosystem was proposed by McEliece back in 1978 [McE78]. The idea is to pick a linear code among a family of codes for which efficient decoding algorithms exist, provided that some secret structure about the code is known. The public key consists of a generator matrix of the code, which appears random, while the private key is represented by an efficient decoding algorithm. To encrypt a message, the sender first encodes it using the public generator matrix, and then deliberately adds a random error vector whose Hamming weight equals the code's decoding capability. Only the owner of the private key can recover the original message using the efficient decoding algorithm.

*Key words and phrases.* McEliece scheme, Alternant codes, Algebraic-geometry codes, Weil restriction.
The security of the scheme strongly relies on the choice of the family of codes, as the latter has to behave like random codes. Under the hypothesis of *indistinguishability* between the family of codes that is being used and random codes, a rigorous security proof was given in [CFS01]. Under such an assumption, breaking the cryptosystem boils down to decoding a random linear code, whose computational intractability has already been discussed. Many families have been considered for this purpose, for instance generalized Reed-Solomon (GRS) codes by Niederreiter in [Nie86], which were proven insecure for such a use case in [SS92] by Sidelnikov and Shestakov, or algebraic-geometry (AG) codes proposed by Janwa and Moreno in [JM96] and attacked by Couvreur, Márquez-Corbella and Pellikaan in [CMCP14]. Interestingly, the family of binary Goppa codes, originally proposed by McEliece, still looks like a relevant proposition nowadays. Despite the existence of distinguishers against Goppa codes, such as those presented in [FGO+11, CMT23] which both handle high-rate Goppa codes in polynomial time, or [Ran24] which handles constant-rate Goppa codes in sub-exponential — but still high — time, no efficient key-recovery or message-recovery attacks exist against McEliece scheme with *binary* Goppa codes. Most notably, the key recovery attack proposed in [BMT24] could only work for generic alternant codes, while [CMT23] treats the case of codes over a large alphabet and thus excludes the binary case.

**Codes and geometry.** A generator matrix of a linear code may be thought of as a collection of points in the affine or projective space, each column of the matrix being seen as a point. The *quadratic hull* of a code with respect to such a matrix is defined as the intersection of all quadrics that pass through each of these points. For generalized Reed-Solomon codes whose dimension does not exceed half the length, the quadratic hull turns out to be a rational normal curve. Using Weil restriction and the strong rigidity of the objects that are derived from it, we wish to provide the same kind of results for generic alternant codes.

**Our contribution.** We propose a new approach for recovering the private structure of a generic alternant code using both algebraic-geometry and Galois theory. Our algorithm has polynomial complexity with respect to the length and dimension of the code, and is able to fully recover the structure of the code provided that the rate of the alternant code is high enough for the square of its dual not to fill the entire ambient space. To achieve this goal, we compute the quadratic hull with respect to the public parity-check matrix of the code. Under some hypotheses, this algebraic variety is the Weil restriction of the affine cone over the rational normal curve, up to an unknown change of basis. Even after this change of basis, this variety keeps an interesting property: its tangent spaces are stabilized by a certain linear operator. One may therefore compute the space of linear operators that stabilize all these tangent spaces, which turns out to have a structure of algebra isomorphic to the extension field over which the underlying GRS code is defined. This enables us to compute another parity-check matrix of the code which directly yields a generator matrix of the underlying GRS code, up to conjugation by the Frobenius automorphism. The final step is to apply [SS92] to recover a support and a multiplier, and thus an efficient decoding algorithm. We eventually study the application of our framework to Goppa codes and algebraic-geometry codes, and investigate some natural generalization of generic alternant codes that are vulnerable to our attack.

**Outline of the paper.** The first section is dedicated to the basic notions of coding theory that we will need throughout the paper. In Section 2 we set up our key-recovery problem, and explain why this naturally leads to the concept of Weil restriction of ideals and affine algebraic varieties. Section 3 introduces the notion of Weil restriction of scalars, and establishes several results such as Lemma 2 which identifies subspaces having the structure of a Weil restriction, or Theorem 3 which explicitly gives the family of linear automorphisms that preserve this structure.
In this section, we also introduce the notion of Weil-properness, that essentially tells us when this framework can be used to analyze the structure of trace codes. Section 4 provides a polynomial-time algorithm for retrieving an efficient decoding algorithm for the subfield-subcode being used in the McEliece cryptosystem, be it a generic alternant code, the subfield subcode of a generic AG code, or even a Goppa code of sufficiently low degree, but provided that the square of the dual code is not the entire ambient space.

# 1. NOTATIONS AND PREREQUISITES

## 1.1. Basic notation.

*Fields.* Throughout the paper, we work with an extension of finite fields $\mathbb{F}_{q^m}/\mathbb{F}_q$, together with a primitive element $\alpha \in \mathbb{F}_{q^m}$, so that $\mathbb{F}_{q^m} = \mathbb{F}_q[\alpha]$. We may sometimes also refer to a generic field as $\mathbb{F}$. The algebraic closure of $\mathbb{F}$ is denoted by $\overline{\mathbb{F}}$.

*Vectors and matrices.* Codewords, i.e. elements of a linear code, are denoted using bold lower-case letters. We use the row-vectors convention for codewords. For geometric points in the affine space, we instead use the column-vectors convention. Matrices are denoted with bold capital letters. If $(\lambda_1, \dots, \lambda_n) \in \mathbb{F}^n$, the notation $\text{Diag}(\lambda_1, \dots, \lambda_n)$ stands for the diagonal matrix with entries given by the $\lambda_i$'s. We freely use this notation to build block-diagonal matrices as well. Finally, $\text{GL}_k(\mathbb{F})$ denotes the general linear group of size $k$ over $\mathbb{F}$, while $\text{GL}(\mathbb{F}^k)$ denotes the group of linear automorphisms of $\mathbb{F}^k$. We have of course $\text{GL}_k(\mathbb{F}) \simeq \text{GL}(\mathbb{F}^k)$.

*Spans and ideals.* If $E$ is any subset of an $\mathbb{F}$-vector space, we denote by $\text{Span}_{\mathbb{F}}(E)$ the $\mathbb{F}$-vector subspace spanned by $E$. Similarly, when $A$ is a subset of a ring $R$, the notation $\langle A \rangle$ stands for the ideal generated by $A$.

*Partial derivatives.* Let $R = \mathbb{F}[x_s | s \in S]$ be a polynomial ring whose variables are indexed by a finite set $S$. For $f \in R$, we write $\partial_s f$ for the partial derivative of $f$ with respect to $x_s$.

*Varieties.* In this paper, the term algebraic variety refers to algebraic subsets of $\mathbb{F}^r$ for some integer $r$ and field $\mathbb{F}$, i.e. the zero locus associated to an ideal $I \subset \mathbb{F}[X_1, \dots, X_r]$ in $\mathbb{F}^r$. When we are given such an ideal $I$, we denote by $V(I)$ its variety, or sometimes $V_{\mathbb{F}}(I)$ when we want to emphasize that the ground field is $\mathbb{F}$. If $I$ is the defining ideal of the variety $V$, the coordinate ring of $V$ is denoted with $\mathbb{F}[V]$ and defined by $\mathbb{F}[X_0, \dots, X_{r-1}]/I$.

## 1.2. Linear codes.
A linear subspace $\mathcal{C} \subseteq \mathbb{F}^n$ of dimension $r$ is called an $[n, k]_{\mathbb{F}}$-linear code. We may talk about $[n, k]_q$-codes when $\mathbb{F} = \mathbb{F}_q$. A generator matrix of $\mathcal{C}$ is a matrix $\mathbf{G}$ with coefficients in $\mathbb{F}$ whose row space equals $\mathcal{C}$. An $[n, k]_{\mathbb{F}}$-code $\mathcal{C}$ may as well be defined by a *parity-check matrix* $\mathbf{H} \in \mathbb{F}^{(n-k) \times n}$ which is such that

$$ \mathcal{C} = \{ \mathbf{x} \in \mathbb{F}^n \mid \mathbf{H}\mathbf{x}^{\top} = 0 \}. $$

As $\mathbb{F}^n$ is endowed with the canonical inner product defined by

$$ \forall \mathbf{x}, \mathbf{y} \in \mathbb{F}^n, \quad \mathbf{x} \cdot \mathbf{y} \stackrel{\text{def}}{=} \sum_{i=1}^{n} x_i y_i, $$

we may define the dual of a code $\mathcal{C}$ as $\mathcal{C}^{\perp} \stackrel{\text{def}}{=} \{ \mathbf{y} \in \mathbb{F}^n \mid \forall \mathbf{x} \in \mathcal{C}, \mathbf{x} \cdot \mathbf{y} = 0 \}$. Note that $\mathbf{H} \in \mathbb{F}^{(n-k) \times n}$ is a *parity-check matrix* of $\mathcal{C}$ if and only if it is a *generator matrix* of $\mathcal{C}^{\perp}$.
1.3. **Componentwise product of codes.** The space $\mathbb{F}^n$ naturally comes with the canonical product algebra structure. The multiplication law will be denoted with the star notation as follows:

$$ \forall \mathbf{x}, \mathbf{y} \in \mathbb{F}^n, \mathbf{x} \star \mathbf{y} \stackrel{\text{def}}{=} (x_1 y_1, \dots, x_n y_n). $$

This immediately gives rise to the notion of product of codes.

**Definition 1.** For any $\mathbb{F}$-linear codes $\mathcal{C}, \mathcal{D} \subset \mathbb{F}^n$, we define

$$ \mathcal{C} \star \mathcal{D} \stackrel{\text{def}}{=} \operatorname{Span}_{\mathbb{F}}\{\mathbf{c} \star \mathbf{d} \mid (\mathbf{c}, \mathbf{d}) \in \mathcal{C} \times \mathcal{D}\}. $$

We also write $\mathcal{C}^{*2} = \mathcal{C} \star \mathcal{C}$.

Note that the componentwise product of codes is associative and may therefore be iterated. We will thus write $\mathcal{C}^{*d}$ for $\mathcal{C} \star \dots \star \mathcal{C}$.
Let $\mathbf{G} \in \mathbb{F}^{r \times n}$ be a generator matrix of $\mathcal{C}$, and let $\mathbf{g}_j$ denote the $j$-th column of $\mathbf{G}$ for all $1 \le j \le n$. Define $\mathbf{R} = \mathbb{F}[X_0, \dots, X_{r-1}]$ together with the natural evaluation map

$$ (1) \qquad \operatorname{ev}_{\mathbf{G}} : \left\{ \begin{array}{l} \mathbf{R} \to \mathbb{F}^n \\ f \mapsto (f(\mathbf{g}_1), \dots, f(\mathbf{g}_n)). \end{array} \right. $$

Alternatively, following the convention of [Ran24], $\operatorname{ev}_{\mathbf{G}}$ can be defined as the only homomorphism of (graded) $\mathbb{F}$-algebras mapping each variable $X_i$ onto the $i$-th row $\mathbf{r}_i$ of $\mathbf{G}$ — here we have $0 \le i < r$ in order to be consistent with the way we enumerate the variables of $\mathbf{R}$. The image of this map, which does not depend on the choice of $\mathbf{G}$, was denoted in [Ran24] by $\bigoplus_{d \ge 0} \mathcal{C}^{*d}$ and referred to as the *homogeneous coordinate ring* of $\mathcal{C}$. On the contrary, the kernel of $\operatorname{ev}_{\mathbf{G}}$ formally depends on the choice of $\mathbf{G}$ and will be denoted by $I(\mathbf{G})$ in this paper. It has a structure of graded ideal, i.e.

$$ I(\mathbf{G}) = \bigoplus_{d \ge 0} I_d(\mathbf{G}), $$

where $I_d(\mathbf{G})$ is the homogeneous component of degree $d$ of $I(\mathbf{G})$, that we will refer to as the vanishing ideal of $\mathbf{G}$ at degree $d$.

**Definition 2** (Quadratic hull [Ran19]). We define the algebraic quadratic hull of $\mathcal{C}$ with respect to $\mathbf{G}$ as the polynomial ideal generated by $I_2(\mathbf{G})$. The algebraic variety induced by the algebraic quadratic hull will be denoted by $V_2(\mathbf{G})$ and referred to as the geometric quadratic hull of $\mathcal{C}$ with respect to $\mathbf{G}$.

**Remark 1.** Hilbert's Nullstellensatz establishes a correspondence between ideals of $\overline{\mathbb{F}}[X_1, \dots, X_r]$ and algebraic subsets of $\overline{\mathbb{F}}^r$, meaning that we can work with either the algebraic or the geometric quadratic hull equivalently. However, most of the time we only have access to the $\mathbb{F}$-rational points of the variety, preventing the Nullstellensatz to hold as $\mathbb{F}$ will always be a finite field in this paper. This will require us to be cautious and to always specify which version of the quadratic hull — algebraic or geometric — we will be working with.

Note that the vector space $I_2(\mathbf{G})$ is the very same object as the *code of quadratic relations* introduced in [CMT23], as we have

$$ I_2(\mathbf{G}) = \left\{ \sum_{i \le j} c_{i,j} X_i X_j \mid \sum_{i \le j} c_{i,j} \mathbf{r}_i \star \mathbf{r}_j = 0 \right\}. $$

Recall that the dimension of $I_2(\mathbf{G})$ is related to that of $\mathcal{C}^{*2}$ by

$$ (2) \qquad \dim I_2(\mathbf{G}) = \binom{r+1}{2} - \dim \mathcal{C}^{*2}, $$
which can be obtained by applying the rank-nullity theorem on the evaluation map $ev_G$ restricted to $R_2$. Although we emphasize the dependence of $I_2(G)$ on the choice of generator matrix, many properties of the algebraic or geometric quadratic hull are actually intrinsic. More precisely, the quadratic hull — be it algebraic or geometric — depends only on the code, at least up to some linear transformation.

**Proposition 1.** Let $G_1, G_2$ be two $r \times n$ generator matrices of an $\mathbb{F}$-linear code $\mathcal{C}$. Denote by $P \in GL_r(\mathbb{F})$ the transition matrix so that $G_2 = P \cdot G_1$. Then

$$ (i) \quad I_2(G_1) = \{f^P | f \in I_2(G_2)\}, \text{ where } f^P = f((X_1 \dots X_r) \cdot P^\top); $$

$$ (ii) \quad V_2(G_2) = \{P \cdot v \mid v \in V_2(G_1)\}. $$

*Proof.* Denote by $g_1, \dots, g_n$ the columns of $G_1$. As the columns of $G_2$ are $P \cdot g_1, \dots, P \cdot g_n$, we see that for any quadratic form $f \in R_2$,

$$ \begin{align*} f \in I_2(G_2) &\iff \forall 1 \le i \le n, f(P \cdot g_i) = 0 \\ &\iff \forall 1 \le i \le n, f^P(g_i) = 0 \\ &\iff f^P \in I_2(G_1), \end{align*} $$

which proves (i). Note that (ii) follows directly from this by definition of the geometric quadratic hull. $\square$

As a result of this proposition, several features such as the dimension of $I_2(G)$, the dimension of the geometric quadratic hull or even its smoothness do not depend on the specific generator matrix we are working with. We may sometimes omit the dependence on the generator matrix when we refer to invariant quantities, and write $I_2(\mathcal{C})$ instead of $I_2(G)$.

**1.4. GRS codes.** Many codes used in the McEliece scheme are derived from generalized Reed-Solomon codes, which we introduce below.

**Definition 3 (GRS codes).** Let $\mathbf{x} = (x_1, \dots, x_n) \in \mathbb{F}^n$ be a vector of pairwise-distinct elements, $\mathbf{y} \in (\mathbb{F}^\times)^n$, and let $r \le n$ be an integer. The generalized Reed-Solomon (GRS) code of degree $r$, support $\mathbf{x}$ and multiplier $\mathbf{y}$ is defined by

$$ \mathbf{GRS}_r(\mathbf{x}, \mathbf{y}) = \{\mathbf{y} \star f(\mathbf{x}) \mid f \in \mathbb{F}[X], \deg f < r\}, $$

where $f(\mathbf{x}) = (f(x_1), \dots, f(x_n))$.

*Remark 2.* A generator matrix of $\mathbf{GRS}_r(\mathbf{x}, \mathbf{y})$ is given by the following truncated Vandermonde matrix:

$$ V_r(\mathbf{x}, \mathbf{y}) = \begin{pmatrix} y_1 & y_2 & \dots & y_n \\ x_1 y_1 & x_2 y_2 & \dots & x_n y_n \\ \vdots & \vdots & \ddots & \vdots \\ x_1^{r-1} y_1 & x_2^{r-1} y_2 & \dots & x_n^{r-1} y_n \end{pmatrix}. $$

A GRS code of degree $r$ has dimension $r$. It follows from the fact that univariate polynomials of degree at most $r-1$ have at most $r-1$ roots that a GRS code is always MDS, meaning that its minimum distance $d$ is equal to $n-r+1$ — the highest possible value by Singleton's bound. Furthermore, the Welch-Berlekamp algorithm [WB86] enables to decode these codes up to half their minimum distance in $O(n^3)$ operations in $\mathbb{F}$. These positive features explain why these codes have been so widely studied by researchers and engineers. However, all these nice properties mean that GRS codes are far from looking like random codes. In particular, their behavior with respect to the componentwise product is very peculiar, as we state below without proof.
**Proposition 2.** $\text{GRS}_r(\mathbf{x}, \mathbf{y})^{*2} = \text{GRS}_{2r-1}(\mathbf{x}, \mathbf{y}^{*2})$.

Hence, the dimension of the square of a GRS code increases linearly. In the random case [CCMZ15], the square of an $[n, k]$-code has dimension $\min\{n, \frac{k(k+1)}{2}\}$ with overwhelming probability, which means a quadratic increase. Equation (2) shows that GRS codes having a small square means they have an unexpectedly large algebraic quadratic hull. It is particularly visible when we look at the quadratic hull of $V_r(\mathbf{x}, \mathbf{y})$.

**Proposition 3.** If $2r-1 \le n$, then $I_2(V_r(\mathbf{x}, \mathbf{y}))$ is spanned by the $2 \times 2$ minors of

$$ (3) \qquad \begin{pmatrix} X_0 & X_1 & \dots & X_{r-2} \\ X_1 & X_2 & \dots & X_{r-1} \end{pmatrix}. $$

*Proof.* See for instance [LMT25, Propositions 1 & 2]. □

<figure><img src="image_2.png" /></figure>

The projective variety defined by the determinantal ideal generated by the minors of (3) is the rational normal curve in $\mathbb{P}^{r-1}$, defined as the image of the Veronese embedding

$$ \nu : \begin{cases} \mathbb{P}^1 & \mapsto \mathbb{P}^{r-1} \\ (u:v) & \mapsto (v^{r-1} : uv^{r-2} : \dots : u^{r-1}). \end{cases} $$

*Remark 3.* We may sometimes denote with a *rational normal curve* any curve which is the image of the projective line through a map $(u:v) \mapsto (f_0(u,v) : \dots : f_{r-1}(u,v))$, where $(f_0, \dots, f_{r-1})$ is a basis of the $r$-dimensional vector space of homogeneous bivariate polynomials of degree $r-1$. Up to projective equivalence, all these curves are actually the same, which is why some authors talk about the rational normal curve.

The link between GRS codes and the rational normal curve provides a lot of insightful information about these codes. For example, as suggested in [MMP14], any generator matrix of a GRS code can be seen as a collection of points in the projective space, through which there passes a unique rational normal curve [GH78]. Computing a parametrization of the latter provides an alternative to the Sidelnikov-Shestakov attack.

**1.5. Alternant codes.** The original proposal of McEliece [McE78] suggested implementing the scheme with binary Goppa codes, which are a subclass of the much broader family of alternant codes.

**Definition 4 (Alternant code).** Let $\mathbf{x}, \mathbf{y} \in \mathbb{F}_{q^m}^n$ be some support and multiplier, and let $r \ge 2$ be an integer. The alternant code of degree $r$, support $\mathbf{x}$ and multiplier $\mathbf{y}$ is defined by

$$ \mathcal{A}_r(\mathbf{x}, \mathbf{y}) = (\text{GRS}_r(\mathbf{x}, \mathbf{y})^{\perp}) \cap \mathbb{F}_q^n. $$

In this paper, we study the structure of alternant codes through their dual code. To this end, we need to introduce the trace map associated to the Galois extension $\mathbb{F}_{q^m}/\mathbb{F}_q$ and defined by

$$ \mathrm{Tr} : \begin{cases} \mathbb{F}_{q^m} & \to \mathbb{F}_q \\ x & \mapsto \sum_{j=0}^{m-1} x^{q^j}. \end{cases} $$

Applying this map coordinatewise to any codeword is a way to construct a $q$-ary linear code given a code defined over $\mathbb{F}_{q^m}$.

**Definition 5 (Trace code).** Let $\mathcal{C}$ be an $[n, k]_{q^m}$-code. The trace code of $\mathcal{C}$ is the $\mathbb{F}_q$-linear code defined by

$$ \mathrm{Tr}(\mathcal{C}) \stackrel{\mathrm{def}}{=} \{\mathrm{Tr}(c) \mid c \in \mathcal{C}\}, $$

where $\mathrm{Tr}(c) \stackrel{\mathrm{def}}{=} (\mathrm{Tr}(c_1), \dots, \mathrm{Tr}(c_n))$.
Another way to construct an $\mathbb{F}_q$-linear code starting from an $\mathbb{F}_{q^m}$-linear code $\mathcal{C}$ consists of merely taking the intersection of $\mathcal{C}$ with the subfield $\mathbb{F}_q^n$, like when we defined alternant codes. The resulting code, denoted by

$$ \mathcal{C}|_{\mathbb{F}_q} \stackrel{\text{def}}{=} \mathcal{C} \cap \mathbb{F}_q^n $$

is referred to as the *subfield-subcode* of $\mathcal{C}$. It turns out that those two constructions are dual to each other as stated by Delsarte's theorem.

**Theorem 1** ([Del75]). $(\mathcal{C}|_{\mathbb{F}_q})^{\perp} = \text{Tr}(\mathcal{C}^{\perp})$, or equivalently $(\mathcal{C}^{\perp})|_{\mathbb{F}_q} = \text{Tr}(\mathcal{C})^{\perp}$.

From this, we immediately get that duals of alternant codes are trace codes of GRS codes.

**Corollary 1.** $\mathcal{A}_r(\mathbf{x}, \mathbf{y})^{\perp} = \text{Tr}(\text{GRS}_r(\mathbf{x}, \mathbf{y}))$.

We may thus study alternant codes as trace codes of GRS codes. In general, for an $\mathbb{F}_{q^m}$-linear code $\mathcal{C}$, the structure of trace code can be used to derive a generator matrix of $\text{Tr}(\mathcal{C})$ given a generator matrix of $\mathcal{C}$, which may be really helpful for establishing a link between the structure of $\mathcal{C}$ and that of the trace code. We start with a generator matrix $\mathbf{G} \in \mathbb{F}_{q^m}^{r \times n}$ of $\mathcal{C}$, and let $\mathcal{D} = (\mathcal{C}^{\perp})|_{\mathbb{F}_q}$, so that

$$ \mathcal{D} = \{\mathbf{h} \in \mathbb{F}_q^n \mid \forall \mathbf{c} \in \mathcal{C}, \mathbf{c} \cdot \mathbf{h} = 0\}. $$

Let us denote with $\mathbf{r}_i = (g_{i,1}, \dots, g_{i,n})$ the $i$-th row of $\mathbf{G}$. By linearity of the dot product, the above condition is equivalent to $\mathbf{h} \cdot \mathbf{r}_i = 0$ for all $0 \le i < r$. Since $\mathbf{h}$ has coefficients in $\mathbb{F}_q$, the equation $\mathbf{h} \cdot \mathbf{r}_i = 0$ yields $m$ equations over $\mathbb{F}_q$. To see this, for all coefficient $g_{i,j}$ of $\mathbf{G}$, write $g_{i,j} = g_{i,j,0} + g_{i,j,1}\alpha + \dots + g_{i,j,m-1}\alpha^{m-1}$, with $g_{i,j,\ell} \in \mathbb{F}_q$, and $\alpha$ being the primitive element in $\mathbb{F}_{q^m}$. Then for any $\mathbf{h} \in \mathbb{F}_q^n$,

$$ \begin{align*} \mathbf{h} \cdot \mathbf{r}_i = 0 &\iff \sum_{j=1}^{n} h_j g_{i,j} = 0 \\ &\iff \sum_{j=1}^{n} \sum_{\ell=0}^{m-1} \alpha^{\ell} h_j g_{i,j,\ell} = 0 \\ &\iff \sum_{\ell=0}^{m-1} \alpha^{\ell} \sum_{j=1}^{n} h_j g_{i,j,\ell} = 0 \\ &\iff \forall \ 0 \le \ell < m, \ \sum_{j=1}^{n} h_j g_{i,j,\ell} = 0. \end{align*} $$

As a result, the $rm \times n$ matrix obtained by taking $\mathbf{G}$ and replacing each coefficient $g_{i,j}$ by the column-vector of its $\mathbb{F}_q$-coordinates is a parity-check matrix of $\mathcal{D}$, i.e. a generator matrix of $\mathcal{D}^{\perp}$. By Delsarte's theorem, $\mathcal{D}^{\perp} = \text{Tr}(\mathcal{C})$, which means that we have obtained a generator matrix of $\text{Tr}(\mathcal{C})$. It is clear from here that $\text{dim}_{\mathbb{F}_q} \text{Tr}(\mathcal{C}) \le m \cdot \text{dim}_{\mathbb{F}_{q^m}} \mathcal{C}$. Subfield-subcodes or trace codes that reach this bound will be called *proper codes*.

## 2. THE PROBLEM OF RECOVERING THE STRUCTURE OF AN ALTERNANT CODE

In the McEliece cryptosystem instantiated with the family of alternant codes, the knowledge of some support and multiplier plays the role of the private key, just as in the case of generalized Reed-Solomon codes. A noisy codeword $\mathbf{y} = \mathbf{c} + \mathbf{e}$ can indeed be interpreted as a noisy codeword of the underlying GRS code of dimension $n - r$. Using a support and a multiplier, one can run the Welch-Berlekamp algorithm and thus recover $\mathbf{c}$, provided that the Hamming weight of $\mathbf{e}$ is strictly less than $r/2$. This is why any information about the support and the multiplier of the alternant code must again be kept secret. Although several algorithms [CGG+13, MMP14, SS92]
can recover such a support and multiplier in polynomial time in the GRS case, this task appears to be more difficult in the generic alternant case.

**2.1. The key-recovery problem.** We formulate the key-recovery problem in the following manner.

**Problem 1.** Given $H_{\text{pub}} \in \mathbb{F}_q^{rm \times n}$ a parity-check matrix of a proper alternant code $\mathcal{A}$, find a support $\mathbf{x}$ and a multiplier $\mathbf{y}$ such that $\mathcal{A} = \mathcal{A}_r(\mathbf{x}, \mathbf{y})$.

Throughout the rest of the paper, we make use of the natural vector space identification:

$$ (4) \qquad \Psi_{\alpha}: \left\{ \begin{array}{ll} \mathbb{F}_{q^m} & \xrightarrow{\sim} \mathbb{F}_q^m \\ x = \sum_{j<m} x_j \alpha^j & \mapsto (x_0, \dots, x_{m-1}). \end{array} \right. $$

By a slight abuse of notation, given a vector $\mathbf{v} = (v_0, \dots, v_{r-1}) \in \mathbb{F}_{q^m}^r$, we write $\Psi_{\alpha}(\mathbf{v}) = (\Psi_{\alpha}(v_0), \dots, \Psi_{\alpha}(v_{r-1})) \in \mathbb{F}_q^{rm}$. Finally, if $\mathbf{G} \in \mathbb{F}_{q^m}^{r \times n}$ is a matrix whose columns are $(\mathbf{g}_1, \dots, \mathbf{g}_n)$, we denote by $\Psi_{\alpha}(\mathbf{G}) \in \mathbb{F}_q^{rm \times n}$ the matrix whose columns are $(\Psi_{\alpha}(\mathbf{g}_1), \dots, \Psi_{\alpha}(\mathbf{g}_n))$.

We explained in the previous section that whenever $\mathbf{G} \in \mathbb{F}_{q^m}^{r \times n}$ is a generator matrix of $\mathcal{C}$, then $\Psi_{\alpha}(\mathbf{G})$ is a parity-check matrix of $\mathcal{C}|_{\mathbb{F}_q}$. In particular, $H_{\text{sec}} \stackrel{\text{def}}{=} \Psi_{\alpha}(V_r(\mathbf{x}, \mathbf{y}))$ is a valid parity-check matrix of the alternant code $\mathcal{A}_r(\mathbf{x}, \mathbf{y})$. Moreover, the knowledge of $H_{\text{sec}}$ directly yields the support $\mathbf{x}$ and the multiplier $\mathbf{y}$, and therefore the private key. If now $H_{\text{sec}} = \Psi_{\alpha}(\mathbf{G})$ for some other generator matrix of $\mathbf{GRS}_r(\mathbf{x}, \mathbf{y})$, then one directly recovers $\mathbf{G}$ by reading the columns of $H_{\text{sec}}$, and it only remains to run [SS92] to recover an efficient decoding algorithm. We just described a whole family of easy instances of Problem 1.

In reality, an attacker would not be given $H_{\text{sec}} = \Psi_{\alpha}(\mathbf{G})$ directly. Instead, the public key consists of $H_{\text{pub}} = \mathbf{P} \cdot H_{\text{sec}}$ where $\mathbf{P}$ is a random $rm \times rm$ nonsingular matrix with entries in $\mathbb{F}_q$. In some sense, the transition matrix $\mathbf{P}$ not only shuffles the basis of the underlying GRS code, but also hides the $\mathbb{F}_{q^m}$-linear structure that is visible in $H_{\text{sec}}$, preventing an attacker from being able to directly recover a generator matrix of the GRS code. However, Proposition 1 tells us that if we look at the quadratic hull of $H_{\text{pub}}$, it has a good chance to share strong properties with that of $H_{\text{sec}}$. This leads us to investigate the state of the art about the algebraic quadratic hull of an alternant code.

**2.2. The quadratic hull of an alternant code.** The dimension of the space of quadratic forms vanishing at all columns of a given parity-check matrix of an alternant code was first studied in [FGO+10]. Equivalently by Equation (2) one can study the dimension of the square of the dual code, as it was first noticed in [MP12] and fully investigated in [MT21].

**Theorem 2 ([MT21], Theorem 19).** Let $\mathcal{C} = \mathcal{A}_r(\mathbf{x}, \mathbf{y})^{\perp}$ be a proper dual alternant code. Then

$$ (5) \qquad \dim I_2(\mathcal{C}) \ge \frac{m}{2}(r-1) \left( (2e_{\mathcal{A}}+1)r - 2 \frac{q^{e_{\mathcal{A}}+1}-1}{q-1} \right), $$

where $e_{\mathcal{A}} = [\log_q(r-1)]$.

Note that we did not specify any generator matrix in the above statement, as the result is independent of such a choice. Even though the above result is an inequality, it turns out that one can confidently predict when equality holds.

**Heuristic 1 ([FGO+10])**. Assume that $\mathbf{x}$ and $\mathbf{y}$ are chosen independently at random. Then equality is reached in Inequality (5) as soon as the right-hand side exceeds $(\binom{rm+1}{2} - n)$.
This is the high-rate regime corresponding to the so called square-distinguishability of (duals of) alternant codes. In general, we say that alternant codes are square-distinguishable when the square of their dual code has dimension lower than $\min\{n, \binom{r m+1}{2}\}$, i.e. when the dimension of the square of the dual code is unexpectedly low compared to what we would obtain from a random code having the same parameters.

When we further assume that $r \le q$, we see that $e_{\mathcal{A}} = 0$ and the dimension of $I_2(\mathcal{C})$ simplifies as

$$ \dim I_2(\mathcal{C}) = m \binom{r-1}{2}, $$

which means that in such a case, the dimension of the vanishing ideal at degree 2 of an alternant code is exactly $m$ times that of the underlying GRS code, which suggests a link between the algebraic quadratic hull of the dual of an alternant code and that of the underlying GRS code. We use the geometric framework to explain this. Let $\mathcal{Y}$ be the geometric quadratic hull of $\mathbf{GRS}_r(\mathbf{x}, \mathbf{y})$ with respect to $\mathbf{V}_r(\mathbf{x}, \mathbf{y})$. Recall that $\mathcal{Y}$, when seen as a projective variety, is the rational normal curve and its defining ideal is generated by the $2 \times 2$ minors of (3). A point $P = (p_0 : \dots : p_{r-1}) \in \mathbb{P}^{r-1}(\mathbb{F}_{q^m})$ belongs to $\mathcal{Y}$ if and only if the vector $(p_0, \dots, p_{r-1})$ satisfies these homogeneous quadratic equations. As we will explain in the following section, this condition boils down to the whole vector of coordinates $\Psi_\alpha(p_0, \dots, p_{r-1}) \in \mathbb{F}_q^{rm}$ satisfying $m$ quadratic relations over $\mathbb{F}_q$. In other words, any quadratic equation satisfied by the columns of $\mathbf{V}_r(\mathbf{x}, \mathbf{y})$ yields $m$ quadratic equations satisfied by the columns of the parity-check matrix $\mathbf{H}_{\text{sec}} = \Psi_\alpha(\mathbf{V}_r(\mathbf{x}, \mathbf{y}))$ of $\mathcal{A}_r(\mathbf{x}, \mathbf{y})$. This phenomenon highlights a link between the quadratic hull of an $\mathbb{F}_{q^m}$-linear code and that of its trace code. This is the concept of *affine Weil restriction*, to which the following section is dedicated.

### 3. AFFINE WEIL RESTRICTION

The idea of Weil restriction is to construct a variety defined over $\mathbb{F}_q$ given a variety defined over $\mathbb{F}_{q^m}$ by splitting the variables of the defining equations according to their $\mathbb{F}_q$-coordinates. An algebraic variety $V \subset \mathbb{F}_{q^m}$ would thus give rise to a variety $W \stackrel{\text{def}}{=} \Psi_\alpha(V) \subset \mathbb{F}_q^{rm}$. Weil restriction is the process through which we obtain the defining ideal of $W$ given the defining ideal of $V$.

**3.1. Definition and first properties.** Let $\mathbf{R} = \mathbb{F}_{q^m}[X_0, \dots, X_{r-1}]$ be the polynomial ring over $\mathbb{F}_{q^m}$ in $r \ge 2$ variables. Besides, consider the two polynomial rings

$$ \mathbf{S} = \mathbb{F}_q[x_{i,j} \mid 0 \le i < r, 0 \le j < m], $$

and

$$ \mathbf{S} \otimes_{\mathbb{F}_q} \mathbb{F}_{q^m} = \mathbb{F}_{q^m}[x_{i,j} \mid 0 \le i < r, 0 \le j < m]. $$

This last ring, of which $\mathbf{S}$ is a subring, enables us to define the following as a homomorphism of graded $\mathbb{F}_{q^m}$-algebras:

$$ (6) \qquad \Phi : \left\{ \begin{array}{rcl} \mathbf{R} & \to & \mathbf{S} \otimes_{\mathbb{F}_q} \mathbb{F}_{q^m} \\ X_i & \mapsto & \sum_{j=1}^r \alpha^j x_{i,j}. \end{array} \right. $$

Applying $\Phi$ corresponds to splitting each variable $X_i$ according to its $\mathbb{F}_q$-coordinates. The resulting polynomial has coefficients in $\mathbb{F}_{q^m}$, so we may again gather its $\mathbb{F}_q$-coordinates. In other words, for any $f \in \mathbf{R}$, there are unique $\Phi_1(f), \dots, \Phi_m(f) \in \mathbf{S}$ such that

$$ \Phi(f) = \sum_{j=0}^{m-1} \alpha^j \Phi_j(f). $$

In particular, each map $\Phi_j : \mathbf{R} \to \mathbf{S}$ is an $\mathbb{F}_q$-linear map.
**Definition 6** (Weil restriction). The Weil restriction of an ideal $I \subset \mathbb{R}$ is defined by

$$ \mathrm{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(I) \stackrel{\mathrm{def}}{=} \langle \Phi_j(f) \mid f \in I, 0 \le j < m \rangle \subset \mathcal{S}. $$

The main property at the core of Weil restriction is the correspondence between rational points.

**Proposition 4.** Let $I \subset \mathbb{R}$ be an ideal, and let $J = \mathrm{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(I)$. Then

$$ V_{\mathbb{F}_q}(J) = \Psi_{\alpha}(V_{\mathbb{F}_{q^m}}(I)). $$

*Proof.* Let $P \in \mathbb{F}_{q^m}$. The following equivalences hold:

$$ \begin{align*} \forall f \in I, f(P) = 0 &\iff \forall f \in I, \Phi(f)(\Psi_{\alpha}(P)) = 0 \\ &\iff \forall f \in I, \forall 0 \le j < m, \Phi_j(f)(\Psi_{\alpha}(P)) = 0 \quad \text{By identification} \\ &\iff \forall g \in J, g(\Psi_{\alpha}(P)) = 0, \end{align*} $$

Hence $P \in V_{\mathbb{F}_{q^m}}(I) \iff \Psi_{\alpha}(P) \in V_{\mathbb{F}_q}(J)$, and thus $\Psi_{\alpha}(V_{\mathbb{F}_{q^m}}(I)) \subseteq V_{\mathbb{F}_q}(J)$. By taking $Q \in \mathbb{F}_q^{rm}$ and reading the above equivalences backwards with $\Psi_{\alpha}^{-1}(Q)$ playing the role of $P$, we obtain the converse inclusion. $\square$

Weil restriction can be defined as a functor from the category of varieties defined over $\mathbb{F}_{q^m}$ to that of varieties defined over $\mathbb{F}_q$. This means that we can define the Weil restriction of a morphism $f: V_1 \to V_2$ as well, where $V_1 \subset \mathbb{F}_{q^m}$ and $V_2 \subset \mathbb{F}_{q^m}$ are algebraic varieties. We will restrict ourselves to the case where $f$ is defined by a collection of polynomials $(f_1, \dots, f_s)$, with each $f_i \in \mathbb{F}_{q^m}[V_1]$. In such a case, one can take any representative of each $f_i$ in $\mathbb{R}$ and apply the map $\Phi$, hence getting polynomials $\Phi_0(f_i), \dots, \Phi_{m-1}(f_i) \in \mathcal{S}$.

**Proposition 5.** The collection of polynomials $(\Phi_0(f_1), \dots, \Phi_{m-1}(f_1), \dots, \Phi_0(f_s), \dots, \Phi_{m-1}(f_s))$ is a well-defined rational function $W_1 \to W_2$, where $W_i \stackrel{\mathrm{def}}{=} \Psi_{\alpha}(V_i)$, $i \in \{1, 2\}$. We refer to it as the Weil restriction of $f$.

*Proof.* Let $I \subset \mathbb{R}$ be the ideal defining $V_1$. By definition of Weil restriction, if $g \in I$, then all the $\Phi_j(g)$'s belong to $J \stackrel{\mathrm{def}}{=} \mathrm{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(I)$. As a consequence, if $f \in \mathbb{F}_{q^m}[V_1]$ is defined up to an element of $I$, then all the $\Phi_j(f)$'s are well-defined up to an element of $J$. This proves that the collection of polynomials given in the proposition define a rational function $W_1 \to W_2$. $\square$

*Remark 4.* This is again the good notion for Weil restriction, as we can easily see that the following

$$ \begin{tikzcd} V_1 \arrow[r, "f"] \arrow[d, "\Psi_\alpha"] & V_2 \arrow[d, "\Psi_\alpha"] \\ W_1 \arrow[r, "\mathrm{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(f)"'] & W_2 \end{tikzcd} $$

is a commutative diagram.

We now investigate the case of $\mathbb{F}_{q^m}$-linear maps, as it will be central in the following. First, let us introduce the matrix $J \in \mathbb{F}_q^{m \times m}$ defined as the matrix of the $\mathbb{F}_q$-linear map

$$ \mu_{\alpha} : \left\{ \begin{array}{l} \mathbb{F}_{q^m} \to \mathbb{F}_{q^m} \\ x \mapsto \alpha x, \end{array} \right. $$

with respect to the monomial basis $(1, \alpha, \dots, \alpha^{m-1})$ of $\mathbb{F}_{q^m}$. Note that $J$ is nothing but the companion matrix of the minimal polynomial $\Pi_{\alpha}$ of $\alpha$ over $\mathbb{F}_q$. Given any field element $x = x_0 + x_1\alpha + \dots + x_{m-1}\alpha^{m-1}$, the matrix $x_0 I_m + x_1 J + \dots + x_{m-1} J^{m-1}$ is the matrix of the
multiplication by $x$ in the monomial basis $(1, \alpha, \dots, \alpha^{m-1})$. We denote it by $\mathrm{Mat}_\alpha(x)$. All in all, the map

$$ \mathrm{Mat}_\alpha : \left\{ \begin{array}{ll} \mathbb{F}_{q^m} & \to \mathbb{F}_q[\mathbf{J}] \\ x & \mapsto \mathrm{Mat}_\alpha(x) \end{array} \right. $$

defines an isomorphism of $\mathbb{F}_q$-algebras. These matrices are the natural way of seeing multiplications in terms of $\mathbb{F}_q$-coordinates, as

$$ (7) \qquad \forall x, y \in \mathbb{F}_{q^m}, \quad \Psi_\alpha(xy) = \mathrm{Mat}_\alpha(x) \cdot \Psi_\alpha(y). $$

Furthermore, one can identify the image of $\mathrm{Mat}_\alpha$ using the following criterion.

**Proposition 6.** Let $B \in \mathbb{F}_q^{m \times m}$. Then $B \in \mathbb{F}_q[\mathbf{J}]$ if and only if $BJ = JB$.

*Proof.* It is clear that a polynomial in $J$ commutes with $J$. Conversely, let $B \in \mathbb{F}_q^{m \times m}$ and assume that $B$ and $J$ commute. The minimal polynomial $\Pi_J$ of $J$ over $\mathbb{F}_q$ is that of $\alpha$, and is therefore irreducible of degree $m$. As $\mathbb{F}_{q^m}/\mathbb{F}_q$ is a Galois extension, $\Pi_J$ splits into linear factors over $\mathbb{F}_{q^m}$. More precisely,

$$ \Pi_J = \prod_{j=0}^{m-1} (X - \alpha^{q^j}). $$

This implies that $J$ is diagonalizable over $\mathbb{F}_{q^m}$, and there exists $P \in \mathbf{GL}_m(\mathbb{F}_{q^m})$ such that

$$ PJP^{-1} = \Delta_{\alpha} \stackrel{\text{def}}{=} \mathrm{Diag}(\alpha, \alpha^q, \dots, \alpha^{q^{m-1}}), $$

the diagonal entries being pairwise distinct. Since $B$ commutes with $J$, we see that $PBP^{-1}$ commutes with $\Delta_\alpha$ and consequently stabilizes its eigenspaces. As the latter are lines, we conclude that $PBP^{-1}$ is also a diagonal matrix and there exists $(\beta_1, \dots, \beta_m) \in \mathbb{F}_{q^m}^m$ such that $PBP^{-1} = \mathrm{Diag}(\beta_1, \dots, \beta_m)$. Now let $f \in \mathbb{F}_{q^m}[X]$ be an interpolating polynomial such that $f(\alpha^{q^j}) = \beta_j$ for all $j$. We see that

$$ f(PJP^{-1}) = P f(J) P^{-1} = \mathrm{Diag}(f(\alpha), \dots, f(\alpha^{q^{m-1}})) = \mathrm{Diag}(\beta_1, \dots, \beta_m) = PBP^{-1}. $$

Thus, $B = f(J)$. By writing $f = f_0 + \alpha f_1 + \dots + \alpha^{m-1} f_{m-1}$, with $f_j \in \mathbb{F}_q[X]$, and then proceeding through identification (which is possible as both $B$ and $J$ lie in $\mathbb{F}_q^{m \times m}$) we see that $B = f_0(J)$ which ends the proof. $\square$

Equation (7) essentially states that $\mathrm{Mat}_\alpha(x)$ is the matrix of the Weil restriction of the multiplication map associated to $x$. This can be naturally generalized to higher dimensions. More specifically, we define below the Weil restriction of a matrix.

**Definition 7.** Let

$$ B = (a_{i,j})_{\substack{1 \le i \le s \\ 1 \le j \le r}} \in \mathbb{F}_{q^m}^{s \times r} $$

be a matrix. We denote by $\mathrm{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(B)$ the matrix of the Weil restriction of the map $v \mapsto Bv$ in the canonical basis, i.e.

$$ \forall v \in \mathbb{F}_{q^m}^r, \quad \Psi_\alpha(B \cdot v) = \mathrm{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(B) \cdot \Psi_\alpha(v). $$

*Remark 5.* By applying Equation (7) coefficient-wise, we see that

$$ \mathrm{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(B) = \begin{pmatrix} \mathrm{Mat}_\alpha(a_{1,1}) & \dots & \mathrm{Mat}_\alpha(a_{1,r}) \\ \vdots & \ddots & \vdots \\ \mathrm{Mat}_\alpha(a_{s,1}) & \dots & \mathrm{Mat}_\alpha(a_{s,r}) \end{pmatrix} \in \mathbb{F}_q^{sm \times rm}. $$
For any non-negative integer $k$, let $J_k = \text{Diag}(J, \dots, J)$. Note that $J_k$ is the Weil restriction of the homothety of $\mathbb{F}_{q^m}^k$ defined by $\alpha$, i.e. the scalar multiplication by $\alpha$. Matrices of the form $\text{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(\mathbf{B})$ can be identified in $\mathbb{F}_q^{sm \times rm}$ using the following algebraic criterion, which may be thought of as a generalization of Proposition 6.

**Proposition 7.** Let $\mathbf{A} \in \mathbb{F}_q^{sm \times rm}$. The following are equivalent:

(i) $\mathbf{A}J_r = J_s\mathbf{A}$;

(ii) there exists $\mathbf{B} \in \mathbb{F}_{q^m}^{s \times r}$ such that $\mathbf{A} = \text{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(\mathbf{B})$.

*Proof.* The existence of $\mathbf{B} \in \mathbb{F}_{q^m}^{s \times r}$ such that $\mathbf{A} = \text{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(\mathbf{B})$ is equivalent to each block $\mathbf{A}_{i,j} \in \mathbb{F}_q^{m \times m}$ being in the image of $\text{Mat}_\alpha$, which by Proposition 6 boils down to the $\mathbf{A}_{i,j}$'s commuting with $J$. Gathering these commutativity conditions is exactly equivalent to (i). $\square$

3.2. **Weil-properness.** We now have introduced the necessary framework for stating as a proposition the link between the quadratic hull of an alternant code and that of the underlying GRS code.

**Proposition 8.** Let $\mathcal{C} \subset \mathbb{F}_{q^m}^n$ be a proper code. Let $\mathbf{G} \in \mathbb{F}_{q^m}^{r \times n}$ be a generator matrix of $\mathcal{C}$ and let $\mathbf{H}_{\text{sec}} = \Psi_\alpha(\mathbf{G})$, which is the secret parity-check matrix of $\text{Tr}(\mathcal{C})$. Then

$$ (8) \qquad \text{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(\langle I_2(\mathbf{G}) \rangle) \subseteq \langle I_2(\mathbf{H}_{\text{sec}}) \rangle, $$
and

$$ (9) \qquad V_2(\mathbf{H}_{\text{sec}}) \subseteq \Psi_{\alpha}(V_2(\mathbf{G})). $$

*Proof.* By Proposition 4, for any polynomial $f \in I_2(\mathbf{G})$, the $\Phi_j(f)$'s all vanish at the columns of $\mathbf{H}_{\text{sec}}$. As a consequence,

$$ \text{Span}_{\mathbb{F}_q}\{\Phi_j(f) \mid f \in I_2(\mathbf{G}), 0 \le j < m\} \subseteq I_2(\mathbf{H}_{\text{sec}}), $$

which is a refinement of (8). Taking the varieties reverses the inclusion, which leads to (9) by Proposition 4. $\square$

The above proposition only states inclusions, while equalities will be needed in the following.

**Definition 8 (Weil-properness).** A linear code $\mathcal{D} = \text{Tr}(\mathcal{C})$ is said to be **Weil-proper** if and only if Inclusion (8) is an equality.

Determining whether a linear code is Weil-proper may sometimes be done by just measuring the dimension of its vanishing ideal at degree 2. For alternant codes, we have the following result.

**Proposition 9.** Under Heuristic 1, when $r \le q$, a generic $q$-ary alternant code of degree $r$ achieving equality in (5) is Weil-proper.

For the proof of Proposition 9 we will need the following lemma. The proof of the lemma is quite technical and not really relevant here, which is why we decided to move it to the appendix.

**Lemma 1.** Let $I \subset \mathbf{R}$ be a homogeneous ideal. If $(f_1, \dots, f_N)$ is a minimal set of generators for $I$, then the sequence $(\Phi_j(f_i))_{i,j}$ is a minimal set of generators of $\text{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(I)$.

In case of Weil-properness, it is indeed clear that if $(f_1, \dots, f_N)$ is a basis of $I_2(\mathbf{G})$, then $(\Phi_j(f_i))_{i,j}$ generates $I_2(\Psi_\alpha(\mathbf{G}))$. What is much less clear however is that there are no linear dependencies between the $\Phi_j(f_i)$'s over $\mathbb{F}_q$.

**Corollary 2.** Let $\mathcal{D} = \text{Tr}(\mathcal{C})$. Then $\mathcal{D}$ is Weil-proper if, and only if

$$ \dim_{\mathbb{F}_q} I_2(\mathcal{D}) = m \dim_{\mathbb{F}_{q^m}} I_2(\mathcal{C}). $$
**Proof.** By Proposition 8 and Lemma 1, the Weil restriction of $I_2(\mathscr{C})$ is an $m \dim_{\mathbb{F}_{q^m}} I_2(\mathscr{C})$-dimensional subspace of $I_2(\mathscr{D})$. Equality therefore holds if and only if $I_2(\mathscr{D})$ has dimension $m \dim_{\mathbb{F}_{q^m}} I_2(\mathscr{C})$. $\square$

Gathering all these results enables us to prove Proposition 9 under Heuristic 1.

**Proof of Proposition 9.** When $r \le q$, the vanishing ideal at degree 2 of a generic alternant code in the square-distinguishable regime equals $m$ times the dimension of the vanishing ideal at degree 2 of the underlying GRS code. By Corollary 2 we get that such an alternant code is Weil-proper. $\square$

Lemma 1 also allows us to derive a necessary condition for a code to be Weil proper in general in terms of regime of parameters.

**Corollary 3.** Let $\mathscr{D} = \mathrm{Tr}(\mathscr{C})$ be a proper linear code, i.e. $\dim_{\mathbb{F}_q} \mathscr{D} = rm$ where $r = \dim_{\mathbb{F}_{q^m}} \mathscr{C}$. If $\mathscr{D}$ is Weil proper, then

$$n \ge \binom{rm+1}{2} - m \dim_{\mathbb{F}_{q^m}} I_2(\mathscr{C}).$$

*Proof.* By Corollary 2, we have

$$\binom{rm+1}{2} - m \dim_{\mathbb{F}_{q^m}} I_2(\mathscr{C}) = \binom{rm+1}{2} - \dim_{\mathbb{F}_q} I_2(\mathscr{D}) = \dim \mathscr{D}^{*2} \le n.$$

$\square$

In the regime where an alternant code is Weil-proper, the Weil restriction structure of the quadratic hull may be visible even if we only have access to $H_{\mathrm{pub}} = P \cdot H_{\mathrm{sec}}$, thanks to Proposition 1. Our goal is to determine which properties of $I_2(H_{\mathrm{sec}})$, related to its Weil restriction structure, are preserved by linear transformation and therefore still detectable in $I_2(H_{\mathrm{pub}})$. This naturally leads to the problem of distinguishing affine varieties that are the Weil restriction of a smaller variety over a larger field.

**3.3. Distinguishing Weil restrictions.** Our strategy for finding a criterion that distinguishes Weil restrictions from other varieties consists in first looking at the case of vector subspaces, and then generalizing to algebraic varieties using tangent spaces.

Let $V \subset \mathbb{F}_{q^m}^r$ be some vector subspace. Intuitively, $\Psi_\alpha(V)$ not only lists the points of $V$ in terms of $\mathbb{F}_q$-coordinates, but also somehow reflects the $\mathbb{F}_{q^m}$-linearity of $V$. More formally, the fact that if $v \in V$, then $\alpha \cdot v \in V$ must be visible in $W$. Indeed, as $J_r$ is the Weil restriction of the scalar multiplication by $\alpha$, we see that

$$(10) \qquad \alpha \cdot v \in V \iff J_r \cdot \Psi_\alpha(v) \in W.$$

The following proposition states that this can be used to identify Weil restriction of vector spaces.

**Lemma 2.** Let $W \subset \mathbb{F}_q^{rm}$ be a vector subspace. The following are equivalent:

(i) $W$ is $J_r$-invariant, i.e. $\forall x \in W$, $J_r x \in W$;

(ii) There exists some subspace $V \subset \mathbb{F}_{q^m}^r$ such that $W = \Psi_\alpha(V)$.

**Proof.** Let $W \subset \mathbb{F}_q^{rm}$ be a vector subspace, and set $V = \Psi_\alpha^{-1}(W)$, which is an $\mathbb{F}_q$-vector subspace of $\mathbb{F}_{q^m}$ a priori. It suffices to prove that $W$ is $J_r$-invariant if and only if $V$ is an $\mathbb{F}_{q^m}$-vector subspace of $\mathbb{F}_{q^m}$. Since $V$ is already an $\mathbb{F}_q$-vector space, it is an $\mathbb{F}_{q^m}$-vector space if, and only if

$$\forall v \in V, \alpha v \in V,$$

which by Equivalence (10) is equivalent to

$$\forall v \in V, J_r \Psi_\alpha(v) \in W.$$
Finally, since $\Psi_{\alpha}$ is a bijection between $V$ and $W$, we see that $V$ is an $\mathbb{F}_{q^m}$-vector subspace if and only if

$$ \forall \mathbf{w} \in W, \mathbf{J}_r \mathbf{w} \in W, $$

which proves the proposition.

<figure><img src="image_3.png" /></figure>

**Remark 6.** Lemma 2 is actually a well-known result from the theory of matrix rank-metric codes. More precisely, given a $k$-dimensional $\mathbb{F}_{q^m}$-linear code $\mathcal{C} \subset \mathbb{F}_{q^m}^n$ endowed with the rank-metric, one can build a code $\mathcal{C}_{\text{mat}}$ from a basis $\{\mathbf{v}_1, \dots, \mathbf{v}_k\}$ of $\mathcal{C}$ by defining

$$ \mathcal{C}_{\text{mat}} = \text{Span}_{\mathbb{F}_q} \{\mathbf{M}_{1,0}, \dots, \mathbf{M}_{1,m-1}, \dots, \mathbf{M}_{k,0}, \dots, \mathbf{M}_{k,m-1}\}, $$

where $\mathbf{M}_{i,j} = (\Psi_{\alpha}(\alpha^j v_{i,1}) | \dots | \Psi_{\alpha}(\alpha^j v_{i,n})) \in \mathbb{F}_q^{m \times n}$, with $\mathbf{v}_i = (v_{i,1}, \dots, v_{i,n})$. As $\mathcal{C}$ is an $\mathbb{F}_{q^m}$-linear code, we have

$$ \forall \mathbf{M} \in \mathcal{C}_{\text{mat}}, \mathbf{J}\mathbf{M} \in \mathcal{C}_{\text{mat}}. $$

More generally, an $\mathbb{F}_q$-vector subspace $\mathcal{M} \subset \mathbb{F}_q^{m \times n}$ is $\mathbb{F}_{q^m}$-linear, i.e. built using the above process, if and only if $\mathbf{J}\mathbf{M} \in \mathcal{M}$ for all $\mathbf{M} \in \mathcal{M}$.

**Definition 9 (Stabilizer).** For any vector space $W \subset \mathbb{F}_q^{rm}$, we denote by $\text{St}(W)$ the set of matrices $\mathbf{A} \in \mathbb{F}_q^{rm \times rm}$ such that $\mathbf{A} \cdot W \subseteq W$. Note that $\text{St}(W)$ is a subalgebra of the $\mathbb{F}_q$-algebra $\mathbb{F}_q^{rm \times rm}$.

**Remark 7.** Lemma 2 amounts to say that a subspace $W$ is a Weil restriction if and only if we have $\mathbb{F}_q[\mathbf{J}_r] \subset \text{St}(W)$.

Distinguishing Weil restrictions is therefore a solved problem when it comes to vector subspaces. In order to generalize our approach for algebraic varieties, we need some linear data associated to varieties. This is exactly the role played by tangent spaces.

**Definition 10.** Let $P \in V \stackrel{\text{def}}{=} V_{\mathbb{F}_{q^m}}(I)$ where $I \subset \mathbf{R}$ is an ideal. The tangent space of $V$ at $P$ is defined by

$$ T_P V = \left\{ \mathbf{h} \in \mathbb{F}_{q^m}^r \mid \forall f \in I, \sum_{i=0}^{r-1} h_i \partial_i f(P) = 0 \right\}. $$

As $I$ is finitely generated, $T_P V$ may be computed as the kernel of the Jacobian matrix of a list of generators.

A vector subspace of $\mathbb{F}_q^{rm}$ is a Weil restriction if and only if it is globally invariant under the action of $\mathbf{J}_r$. When a variety $W$ is the Weil restriction of some other variety $V$, then one can expect that its tangent spaces are also the Weil restriction of some vector subspace of $\mathbb{F}_{q^m}^r$. This would enable us to use our criterion to determine whether a variety is a Weil restriction. It turns out that it is true, thanks to the commutativity between Weil restrictions and tangent spaces.

**Proposition 10.** Let $V = V_{\mathbb{F}_{q^m}}(I) \subset \mathbb{F}_{q^m}^r$ be an algebraic variety of defining ideal $I \subset \mathbf{R}$. Let $W = \Psi_{\alpha}(V)$, $P \in V$ and $Q = \Psi_{\alpha}(P)$. Then

$$ T_Q W = \Psi_{\alpha}(T_P V). $$

*Proof.* First, notice that by the rules of derivation, we have

$$ (11) \qquad \partial_{ij} \Phi(f) = \alpha^j \Phi(\partial_i f), $$
for all $f \in \mathbf{R}$ and indices $0 \le i < r, 0 \le j < m$. Now, let $\mathbf{h} = (h_{i,j}) \in \mathbb{F}_q^{rm}$. We have

$$
\begin{align*}
\mathbf{h} \in \Psi_{\alpha}(T_P V) &\iff \forall f \in I, \sum_{i=0}^{r-1} \left( \sum_{j=0}^{m-1} h_{i,j} \alpha^j \right) \partial_i f(P) = 0 \\
&\iff \forall f \in I, \sum_{i=0}^{r-1} \sum_{j=0}^{m-1} h_{i,j} \alpha^j \Phi(\partial_i f)(Q) = 0 \quad \text{Since } \partial_i f(P) = \Phi(\partial_i f)(Q) \\
&\iff \forall f \in I, \sum_{i=0}^{r-1} \sum_{j=0}^{m-1} h_{i,j} \partial_{ij} \Phi(f)(Q) = 0 \quad \text{By Equation (11)} \\
&\iff \forall f \in I, \forall 0 \le \ell < m, \sum_{i=0}^{r-1} h_{i,j} \partial_{ij} \Phi_{\ell}(f)(Q) = 0 \\
&\iff \mathbf{h} \in T_Q W.
\end{align*}
$$

□

This gives us a necessary condition for an algebraic variety to be a Weil restriction.

**Corollary 4.** Let $W \subset \mathbb{F}_q^{rm}$ be an algebraic variety. If there exists an algebraic variety $V \subset \mathbb{F}_q^{r}$ such that $W = \Psi_{\alpha}(V)$, then for all $Q \in W$, the tangent space $T_Q W \subset \mathbb{F}_q^{rm}$ is $\mathbf{J}_r$-invariant.

Back to linear codes, we obtain the following corollary.

**Corollary 5.** Let $\mathbf{H}_{\text{sec}} = \Psi_{\alpha}(\mathbf{V}_r(\mathbf{x}, \mathbf{y}))$ be the secret parity-check matrix of a Weil-proper alternant code $\mathcal{A}_r(\mathbf{x}, \mathbf{y})$. For all $P \in V_{\text{sec}} \stackrel{\text{def}}{=} V_2(\mathbf{H}_{\text{sec}})$, the tangent space $T_P V_{\text{sec}}$ is $\mathbf{J}_r$-invariant.

**3.4. Weil-preserving transformations.** Corollary 5 establishes a distinguishing property for the quadratic hull of a Weil-proper alternant code $\mathcal{A}_r(\mathbf{x}, \mathbf{y})$ with respect to a secret parity-check matrix $\mathbf{H}_{\text{sec}}$, i.e. of the form $\Psi_{\alpha}(\mathbf{G})$ where $\mathbf{G}$ is a generator matrix of the underlying GRS code. Again, denote by $\mathbf{H}_{\text{pub}}$ the corresponding public key, which is related to the private key by the relation $\mathbf{H}_{\text{pub}} = \mathbf{P}\mathbf{H}_{\text{sec}}$ for some secret nonsingular $rm \times rm$ matrix $\mathbf{P}$, which is nothing but a change of basis. We get the following proposition given how a change of basis acts on linear maps.

**Proposition 11.** If $\mathcal{A}_r(\mathbf{x}, \mathbf{y})$ is Weil-proper, then for all $Q \in V_{\text{pub}} \stackrel{\text{def}}{=} V_2(\mathbf{H}_{\text{pub}})$, the tangent space $T_Q V_{\text{pub}}$ is globally invariant under the action of $\mathbf{P}\mathbf{J}_r\mathbf{P}^{-1}$.

*Proof.* We know from Proposition 1 that $V_{\text{pub}} = \mathbf{P} \cdot V_{\text{sec}}$, which implies that $T_Q V_{\text{pub}} = \mathbf{P} \cdot T_{\mathbf{P}^{-1}Q} V_{\text{sec}}$. Since $T_{\mathbf{P}^{-1}Q} V_{\text{sec}} = \mathbf{J}_r$-invariant, $T_Q V_{\text{pub}}$ is $\mathbf{P}\mathbf{J}_r\mathbf{P}^{-1}$-invariant. $\square$

All tangent spaces of the public variety $V_{\text{pub}}$ share the property of being invariant under the very same linear operator. This will be the first cornerstone of our attack, which we will detail in the following section. The second core idea behind the attack consists in finding another transition matrix than $\mathbf{P}$ that directly leaks a generator matrix of the underlying GRS code — or, as we will see, one of its conjugates. Such a transition matrix would also map the variety $V_{\text{sec}} \stackrel{\text{def}}{=} V_2(\mathbf{H}_{\text{sec}})$ onto another algebraic variety, itself being linked to the quadratic hull of a GRS code through Weil restriction. We then see that the set of such transition matrices are exactly those that map Weil restrictions onto other Weil restrictions. The following theorem is an exhaustive description of such linear transformations.

Weil restrictions of invertible $r \times r$ matrices over $\mathbb{F}_{q^m}$ are natural candidates for such transition matrices. If $\mathbf{A} = \text{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(\mathbf{B})$, then $\mathbf{A}$ indeed maps a Weil restriction $W = \Psi_{\alpha}(V)$ onto that of
$B \cdot V$. Another type of transformations mapping Weil restrictions onto Weil restrictions is given by the Frobenius automorphism. Let $\Theta$ be the matrix of the Frobenius automorphism $\theta: x \mapsto x^q$ in the monomial basis $(1, \alpha, \dots, \alpha^{m-1})$, and define $\Theta_r = \text{Diag}(\Theta, \dots, \Theta) \in \mathbb{F}_q^{rm \times rm}$. Then $\Theta_r$ maps $W = \Psi_\alpha(V)$ onto the Weil restriction of $V^q = \{(v_1^q, \dots, v_r^q) \mid v \in V\}$, which is also an algebraic variety. The following theorem essentially states that these two examples generate all possible matrices mapping Weil restrictions onto Weil restrictions.

**Theorem 3.** Let $\mathcal{G}(\mathbb{F}_{q^m}/\mathbb{F}_q; r)$ be the set of invertible $rm \times rm$ matrices over $\mathbb{F}_q$ that map Weil restrictions of subvarieties of $\mathbb{F}_{q^m}$ onto Weil restrictions of subvarieties of $\mathbb{F}_{q^m}$. Then

$$ \mathcal{G}(\mathbb{F}_{q^m}/\mathbb{F}_q; r) = \{\text{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(\mathbf{B}) \cdot \mathbf{\Theta}_r^j \mid \mathbf{B} \in \mathbf{GL}_r(\mathbb{F}_{q^m}), 0 \le j < m\}. $$

The goal of the attack will be to find a matrix $Q$ such that $QP \in \mathcal{G}(\mathbb{F}_{q^m}/\mathbb{F}_q; r)$, so that the columns of $QH_{\text{pub}} = QPH_{\text{sec}}$ belong to the Weil restriction of some rational normal curve. Before proving Theorem 3, we need to give two auxiliary results. The first gives a better description of the action of the Frobenius automorphism in terms of $\mathbb{F}_q$-coordinates. The matrix $\Theta$ represents the Frobenius map in the following way:

$$ \forall x \in \mathbb{F}_{q^m}, \quad \Psi_\alpha(x^q) = \Theta \cdot \Psi_\alpha(x). $$

Meanwhile, the element $x \in \mathbb{F}_{q^m}$ is also identified with the matrix $\text{Mat}_\alpha(x)$. Since $\text{Mat}_\alpha$ is a field isomorphism, we have

$$ \forall x \in \mathbb{F}_{q^m}, \quad \text{Mat}_\alpha(x^q) = \text{Mat}_\alpha(x)^q. $$

There is a way of expressing the above property using the matrix $\Theta$ as stated in our first lemma.

**Lemma 3.** For all $x \in \mathbb{F}_{q^m}$, $\text{Mat}_\alpha(x)^q = \Theta \cdot \text{Mat}_\alpha(x) \cdot \Theta^{-1}$.

*Proof.* Let $x \in \mathbb{F}_{q^m}$. For all $y \in \mathbb{F}_{q^m}$, we have

$$ \begin{aligned} \Theta \cdot \text{Mat}_{\alpha}(x) \cdot \Psi_{\alpha}(y) &= \Theta \cdot \Psi_{\alpha}(xy) \\ &= \Psi_{\alpha}((xy)^q) \\ &= \Psi_{\alpha}(x^q y^q) \\ &= \text{Mat}_{\alpha}(x^q) \cdot \Psi_{\alpha}(y^q) \\ &= \text{Mat}_{\alpha}(x)^q \cdot \Theta \cdot \Psi_{\alpha}(y), \end{aligned} $$

and this holds for any choice of $y \in \mathbb{F}_{q^m}$. As a result, $\Theta \cdot \text{Mat}_\alpha(x) = \text{Mat}_\alpha(x)^q \cdot \Theta$. $\square$

*Remark 8.* Lemma 3 can be summed up in one sentence, essentially saying that conjugation by the matrix $\Theta$ and Galois conjugation by the Frobenius automorphism boil down to the very same operation.

Lemma 2 states that vector subspaces that are the Weil restriction of another vector space are stabilized by $J_r$, and therefore by any polynomial in $J_r$. Such a matrix is nothing but the Weil restriction of an $\mathbb{F}_{q^m}$-homothety. The second ingredient in the proof of Theorem 3 is the converse: a matrix that stabilizes all vector subspaces that are a Weil restriction is a polynomial in $J_r$.

**Lemma 4.** Let $A \in \mathbb{F}_q^{rm \times rm}$. If $A$ stabilizes all vector subspaces of $\mathbb{F}_q^{rm}$ that are the Weil restriction of a subspace of $\mathbb{F}_{q^m}$, then $A \in \mathbb{F}_q[J_r]$.

*Proof.* Let us introduce the $\mathbb{F}_q$-linear endomorphism $a$ of $\mathbb{F}_{q^m}$ represented by the matrix $A$, i.e. $a$ is defined by

$$ \forall v \in \mathbb{F}_{q^m}^r, \quad a(v) = \Psi_{\alpha}^{-1}(A \cdot \Psi_{\alpha}(v)). $$
Since $\mathbf{A}$ stabilizes vector subspaces that are Weil restrictions, it stabilizes in particular Weil restrictions of $\mathbb{F}_{q^m}$-lines. Equivalently, the $\mathbb{F}_q$-linear endomorphism $a$ maps any vector $v \in \mathbb{F}_{q^m}$ onto some $\lambda_v v$, with $\lambda_v \in \mathbb{F}_{q^m}$. If now we take two vectors $u, v \in \mathbb{F}_{q^m}$, then by $\mathbb{F}_q$-linearity we have

$$a(\mathbf{u} + \mathbf{v}) = \lambda_{\mathbf{u}+\mathbf{v}}(\mathbf{u} + \mathbf{v}) = a(\mathbf{u}) + a(\mathbf{v}) = \lambda_{\mathbf{u}}\mathbf{u} + \lambda_{\mathbf{v}}\mathbf{v}.$$

As $r \ge 2$, we can take $\mathbf{u}$ and $\mathbf{v}$ linearly independent over $\mathbb{F}_{q^m}$, which then implies

$$\lambda_{\mathbf{u}+\mathbf{v}} = \lambda_{\mathbf{u}} = \lambda_{\mathbf{v}}.$$

Finally, by noticing that the same reasoning holds if we replace $\mathbf{v}$ with $\beta\mathbf{v}$ for some nonzero $\beta \in \mathbb{F}_{q^m}$, we conclude that $\lambda_{\beta\mathbf{v}} = \lambda_{\mathbf{v}}$. All in all, there exists a unique $\lambda \in \mathbb{F}_{q^m}$ such that

$$\forall \mathbf{v} \in \mathbb{F}_{q^m}^r, a(\mathbf{v}) = \lambda \mathbf{v},$$

which indeed means that $a$ is an $\mathbb{F}_{q^m}$-linear homothety. In terms of matrices, this implies that $\mathbf{A} = f(\mathbf{J}_r)$, the polynomial $f \in \mathbb{F}_q[X]$ being the one that determines $\lambda$. $\square$

**Remark 9.** The assumption $r \ge 2$ that we made at the very beginning of this section is mandatory here, not only for the proof to work but also for the result to hold. If indeed $r = 1$, then the only $\mathbb{F}_{q^m}$-subspaces of $\mathbb{F}_{q^m}^r$ are $\{0\}$ and $\mathbb{F}_{q^m}$, whose Weil restriction are respectively $\{0\}$ and $\mathbb{F}_q^m$. All matrices $\mathbf{A} \in \mathbb{F}_q^{m \times m}$ stabilize these spaces, and therefore the implication stated by Lemma 4 is untrue in this case.

We are now ready to prove Theorem 3.

**Proof of Theorem 3.** Clearly any matrix $\mathbf{A}$ of the form $\mathrm{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(\mathbf{B}) \cdot \mathbf{\Theta}^j$ is the Weil restriction of some $\mathbb{F}_q$-linear automorphism $a = b \circ \theta^j$. Therefore, if $W = \Psi_\alpha(V)$, then $\mathbf{A}$ maps $W$ onto the Weil restriction of $b(V^{q^j})$.

Now let $\mathbf{A} \in \mathcal{G}(\mathbb{F}_{q^m}/\mathbb{F}_q; r)$. We aim to show that there exists some integer $j$ such that $\mathbf{A}\mathbf{\Theta}^j$ is the Weil restriction of an $\mathbb{F}_{q^m}$-linear automorphism of $\mathbb{F}_{q^m}^r$. Firstly, notice that since $\mathbf{A}$ is a bijection as a linear map, any linear Weil restriction can be seen as the preimage through $\mathbf{A}$ of another linear Weil restriction, and as such is stabilized by both $\mathbf{J}_r$ and $\mathbf{A}^{-1}\mathbf{J}_r\mathbf{A}$. By Lemma 4, we conclude that $\mathbf{A}^{-1}\mathbf{J}_r\mathbf{A}$ is a polynomial in $\mathbf{J}_r$. Furthermore, conjugation by the matrix $\mathbf{A}^{-1}$ is an automorphism of the $\mathbb{F}_q$-algebra $\mathbb{F}_q^{rm \times rm}$, which means that it induces an $\mathbb{F}_q$-linear automorphism of $\mathbb{F}_q[\mathbf{J}_r] \simeq \mathbb{F}_{q^m}$. In other words, conjugation by $\mathbf{A}^{-1}$ defines an element of the Galois group $\mathrm{Gal}(\mathbb{F}_{q^m}/\mathbb{F}_q) = \langle\theta\rangle$. This means that $\mathbf{A}^{-1}\mathbf{J}_r\mathbf{A}$ is actually an $\mathbb{F}_q$-conjugate of $\mathbf{J}_r$, i.e. of the form $\mathbf{J}_r^{q^j}$ for some integer $j$. Equivalently by Lemma 3, there is an integer $j$ such that

$$\mathbf{A}^{-1}\mathbf{J}_r\mathbf{A} = \mathbf{\Theta}^j\mathbf{J}_r\mathbf{\Theta}^{-j},$$

which implies $\mathbf{A}\mathbf{\Theta}^j$ commutes with $\mathbf{J}_r$. By Proposition 7, $\mathbf{A}\mathbf{\Theta}^j = \mathrm{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(\mathbf{B})$ for some $\mathbf{B} \in \mathbf{GL}_r(\mathbb{F}_{q^m})$, which proves the theorem. $\square$

**Corollary 6.** Let $\mathbf{A} \in \mathbf{GL}_{rm}(\mathbb{F}_q)$. Then $\mathbf{A} \in \mathcal{G}(\mathbb{F}_{q^m}/\mathbb{F}_q; r)$ if, and only if there exists some integer $j$ such that $\mathbf{A}\mathbf{J}_r\mathbf{A}^{-1} = \mathbf{J}_r^{q^j}$.

**Proof.** Write $\mathbf{A} = \mathbf{A}_0\mathbf{\Theta}^j$ for some integer $j$. Since $\mathbf{A}_0$ commutes with $\mathbf{J}_r$ by Proposition 7, we see that

$$\mathbf{A}^{-1}\mathbf{J}_r\mathbf{A} = \mathbf{\Theta}^{-j}\mathbf{A}_0^{-1}\mathbf{J}_r\mathbf{A}_0\mathbf{\Theta}^j = \mathbf{\Theta}^{-j}\mathbf{J}_r\mathbf{\Theta}^j = \mathbf{J}_r^{q^m-j},$$

the last equality coming from Lemma 3. Raising the above equality to the power $q^j$ gives

$$\mathbf{A}\mathbf{J}_r\mathbf{A}^{-1} = \mathbf{J}_r^{q^j},$$

as required. The converse can be obtained in the same way by reading the above backwards. $\square$
**Proposition 12.** $\mathcal{G}(\mathbb{F}_{q^m}/\mathbb{F}_q; r)$ is a subgroup of $\mathbf{GL}_{rm}(\mathbb{F}_q)$, and its group structure is given by
$$ \mathcal{G}(\mathbb{F}_{q^m}/\mathbb{F}_q; r) \simeq \mathbf{GL}_r(\mathbb{F}_{q^m}) \times \mathbb{Z}/m\mathbb{Z}. $$

*Proof.* We identify $\mathcal{G}(\mathbb{F}_{q^m}/\mathbb{F}_q; r)$ with the set of $\mathbb{F}_q$-linear automorphisms of $\mathbb{F}_{q^m}$ of the form $b \circ \theta^j$ for $b \in \mathbf{GL}(\mathbb{F}_{q^m})$ and $0 \le j < m$. Then for any $c \in \mathbf{GL}(\mathbb{F}_{q^m})$ and $0 \le k < m$, we see that

$$ (c \circ \theta^k) \circ (b \circ \theta^j) = (c \circ b^{(q^k)}) \circ \theta^{k+j}, $$

where $b^{(q^k)}$ is the $\mathbb{F}_{q^m}$-automorphism whose matrix in the canonical basis is that of $b$ where all coefficients have been raised to the power $q^k$. This is indeed a semi-direct product group structure between $\mathbf{GL}(\mathbb{F}_{q^m}) \simeq \mathbf{GL}_r(\mathbb{F}_{q^m})$ and $\langle\theta\rangle \simeq \mathbb{Z}/m\mathbb{Z}$. $\square$

### 4. AN ATTACK AGAINST GENERIC SQUARE-DISTINGUISHABLE ALTERNANT CODES

Let $\mathcal{C} = \mathcal{A}_r(\mathbf{x}, \mathbf{y})$ be a generic $q$-ary alternant code of extension degree $m$. We assume that we are in the square-distinguishable regime, i.e. that the right-hand side of Inequality (5) is greater than $n - \binom{rm+1}{2}$, so that Inequality (5) is an equality by Heuristic 1. In the following, we denote by $H_{\text{sec}} = \Psi_{\alpha}(V_r(\mathbf{x}, \mathbf{y}))$ the secret parity-check matrix of $\mathcal{C}$, where $V_r(\mathbf{x}, \mathbf{y})$ is the Vandermonde generator matrix of Remark 2. The public key is another parity-check matrix $H_{\text{pub}} = PH_{\text{sec}}$, where $P$ is a secret $rm \times rm$ nonsingular $q$-ary matrix. We also denote by $V_{\text{sec}}$ (resp. $V_{\text{pub}}$) the geometric quadratic hull of $H_{\text{sec}}$ (resp. $H_{\text{pub}}$). By Proposition 1, we have $V_{\text{pub}} = P \cdot V_{\text{sec}}$. We aim to recover the private key, which is an efficient decoding algorithm for $\mathcal{C}$. Our global approach follows a quite natural strategy consisting in retrieving some support $\mathbf{x}'$ and multiplier $\mathbf{y}'$.

4.1. **Case** $r \le q$. In the regime where $r \le q$, Proposition 9 ensures that $\mathcal{C}$ is a Weil-proper alternant code. By Proposition 11, all the tangent spaces of $V_{\text{pub}}$ are stabilized by $\mathbf{P}\mathbf{J}_r\mathbf{P}^{-1}$. These tangent spaces have dimension $2m$, as they are the image through $P$ of the tangent spaces of $V_{\text{sec}}$, themselves being the Weil restrictions of the tangent spaces of the quadratic hull of $V_r(\mathbf{x}, \mathbf{y})$ by Proposition 10, which we know have dimension 2 as tangent spaces of the affine cone over a projective curve. Intuitively, there should not be much more matrices stabilizing all tangent spaces of $V_{\text{sec}}$ than those that stabilize all Weil restrictions. Although this statement is likely to be provable, we state the following result as a heuristic.

**Heuristic 2.** Generally, we have

$$ \bigcap_{Q \in V_{\text{pub}}} \text{St}(T_Q V_{\text{pub}}) = \mathbb{F}_q[\mathbf{P}\mathbf{J}_r\mathbf{P}^{-1}]. $$

*Experimentally, taking the intersection over only*

$$ N \stackrel{\text{def}}{=} \left\lfloor \frac{1}{\rho(1 - \rho)} \right\rfloor $$

points, where $\rho = \frac{2}{r}$, suffices to get $\mathbb{F}_q[\mathbf{P}\mathbf{J}_r\mathbf{P}^{-1}]$.

Let $\mathcal{A} \stackrel{\text{def}}{=} \mathbb{F}_q[\mathbf{P}\mathbf{J}_r\mathbf{P}^{-1}]$. In order to compute $\mathcal{A}$ in practice, one has to compute sufficiently many tangent spaces and then compute the space of matrices that stabilize all of them. Computing tangent spaces of $V_{\text{pub}}$ can be done in polynomial time by merely computing the right kernel of the Jacobian matrix of a basis of the vanishing ideal at degree 2. Recall that computing rational points of $V_{\text{pub}}$ is free, as we already have $n$ points given by the columns of $H_{\text{pub}}$. Finally, computing the stabilizing algebra of all those tangent spaces can be done by simply solving a linear system of $2m \times (rm - 2m)$ equations. Indeed, let $\mathbf{A} = (a_{i,j})$ be an $rm \times rm$ matrix whose entries are unknowns. Let $T = T_g V_{\text{pub}}$ be the tangent space of $V_{\text{pub}}$ at some point $\mathbf{g}$, that we
Remark 10. Essentially, we need to compute sufficiently many equations so that the linear system $S$ is overdetermined. Experimentally, having $S$ overdetermined always suffices to have the solutions space reduced to $\mathcal{A}$. If it is not the case, we just need to add a few more equations by computing some additional tangent spaces. We expect the number of potential additional steps to be negligible, so that it does not change the total complexity of Algorithm 1.

Using Algorithm 1, we get access to $\mathcal{A}$. The next step is to use the field structure of $\mathcal{A}$, which is ensured by the following.

**Proposition 13.** $\mathcal{A} \simeq \mathbb{F}_{q^m}$.

*Proof.* We already have $\mathbb{F}_q[\mathbf{J}_r] \simeq \mathbb{F}_q[\mathbf{J}] \simeq \mathbb{F}_{q^m}$, the last isomorphism being $\mathrm{Mat}_\alpha$. Now, define

$$C_P : \left\{ \begin{array}{ccc} \mathbb{F}_q^{rm \times rm} & \to & \mathbb{F}_q^{rm \times rm} \\ \mathbf{A} & \mapsto & \mathbf{PAP}^{-1}, \end{array} \right.$$

which we refer to as the conjugation map of $P$, and which is known to be an automorphism of the $\mathbb{F}_q$-algebra $\mathbb{F}_q^{rm \times rm}$. Therefore, $\mathcal{A} = C_P(\mathbb{F}_q[\mathbf{J}_r])$ inherits the field structure of $\mathbb{F}_q[\mathbf{J}_r]$, from which we conclude $\mathcal{A} \simeq \mathbb{F}_{q^m}$. $\square$

Conjugation by the matrix $P$ defines an isomorphism from $\mathbb{F}_q[\mathbf{J}_r]$ to $\mathcal{A}$. Even if we know both $\mathcal{A}$ and $\mathbf{J}_r$, we still do not have access to $P$ nor its conjugation map, and not even to the restriction of the latter to $\mathbb{F}_q[\mathbf{J}_r]$. What we can do, however, is draw $\mathcal{A} \in \mathcal{A}$ uniformly at random until we get a generator of $\mathcal{A}$, i.e. an element of degree $m$. There should not be many trials necessary to get such a matrix $\mathcal{A}$. Indeed, it suffices to find a generator of the multiplicative group $\mathcal{A}^\times$, which has the following proportion in $\mathcal{A}$:

$$\pi = \prod_p \left(1 - \frac{1}{p}\right),$$

where the product is taken over all prime divisors $p$ of $q^m - 1$. The probability to need more than $t$ trials to get a generator is thus $(1 - \pi)^t$, which tends towards zero exponentially fast.

Let $\Pi_{\mathcal{A}}$ be the minimal polynomial of such a matrix $\mathcal{A}$ over $\mathbb{F}_q$. This polynomial is irreducible of degree $m$ over $\mathbb{F}_q$. Since $\mathbb{F}_{q^m}/\mathbb{F}_q$ is Galois, it splits into linear factors over $\mathbb{F}_{q^m}$:

$$\Pi_{\mathcal{A}} = \prod_{j=0}^{m-1} (X - \zeta^{q^j}),$$

where $\zeta \in \mathbb{F}_{q^m}$ is therefore a primitive element. As such, there exists some polynomial $f \in \mathbb{F}_q[X]$ of degree at most $m-1$ such that $f(\zeta) = \alpha$. Applying $f$ on $\mathcal{A}$, we get a matrix with the same minimal polynomial as $\mathbf{J}_r$, which enables us to assume that $\Pi_{\mathcal{A}} = \Pi_\alpha$ in the following.

**Lemma 5.** There exists an integer $0 \le j < m$ such that $\mathbf{P}\mathbf{J}_r\mathbf{P}^{-1} = \mathcal{A}^{q^j}$.

*Proof.* The conjugation map $C_P$ preserves minimal polynomials, therefore $\mathbf{P}\mathbf{J}_r\mathbf{P}^{-1}$ has the same minimal polynomial as $\mathbf{J}_r$, which is also that of $\mathcal{A}$. As a result, $\mathbf{P}\mathbf{J}_r\mathbf{P}^{-1}$ is a Galois conjugate of $\mathcal{A}$, i.e. of the form $\mathcal{A}^{q^j}$ for some $j$. $\square$

On the other hand, one can compute some matrix $Q$ satisfying $\mathbf{J}_r = \mathbf{Q}\mathcal{A}\mathbf{Q}^{-1}$, the existence of which is proven below.

**Lemma 6.** There exists $Q \in \mathrm{GL}_{rm}(\mathbb{F}_q)$ such that $\mathbf{J}_r = \mathbf{Q}\mathcal{A}\mathbf{Q}^{-1}$.

*Proof.* The two matrices share the same irreducible minimal polynomial, which implies that their Jordan normal form is the same. They are therefore similar over $\mathbb{F}_{q^m}$. As both of them have coefficients in $\mathbb{F}_q$, they are in fact similar over $\mathbb{F}_q$. $\square$
The matrix $Q$ of the previous lemma is exactly the one that we were looking for, as stated below.

**Theorem 5.** One can compute $Q \in GL_{rm}(\mathbb{F}_q)$ such that $QP \in \mathcal{G}(\mathbb{F}_{q^m}/\mathbb{F}_q; r)$.

*Proof.* Let $Q$ be the matrix of Lemma 6. From Lemma 5 and 6, we get

$$ \begin{cases} PJ_r P^{-1} = A^{q^j} \\ J_r = QAQ^{-1}, \end{cases} $$

from which we get $PJ_rP^{-1} = Q^{-1}J_r^{q^j}Q$, or equivalently $(QP)J_r(QP)^{-1} = J_r^{q^j}$. By Theorem 3, this means $QP \in \mathcal{G}(\mathbb{F}_{q^m}/\mathbb{F}_q; r)$. $\square$

It only remains to explain why this solves our problem.

**Proposition 14.** Let $G' = \Psi_{\alpha}^{-1}(QH_{pub})$. Then $G'$ is a generator matrix of GRS($x^{q^j}, y^{q^j}$).

*Proof.* As $QP \in \mathcal{G}(\mathbb{F}_{q^m}/\mathbb{F}_q; r)$, it preserves Weil restrictions. More precisely, there is some $B \in GL_r(\mathbb{F}_{q^m})$ such that $Q \cdot V_{pub} = QP \cdot V_{sec}$ is the Weil restriction $B \cdot \mathcal{Y}^{q^j}$, where $\mathcal{Y}$ is the geometric quadratic hull of $V_r(x, y)$. This means that the columns of $G'$ are points of $B \cdot \mathcal{Y}^{q^j}$. In other words, there exist polynomials $f_1, \dots, f_r \in \mathbb{F}_{q^m}[X]$ of degree at most $r-1$ such that

$$ G' = \begin{pmatrix} y_1^{q^j} f_1(x_1^{q^j}) & \cdots & y_n^{q^j} f_1(x_n^{q^j}) \\ \vdots & \ddots & \vdots \\ y_1^{q^j} f_r(x_1^{q^j}) & \cdots & y_n^{q^j} f_r(x_n^{q^j}) \end{pmatrix}, $$

which means that the row space of $G'$ is a subspace of GRS($x^{q^j}, y^{q^j}$). Since $QH_{pub}$ has rank $rm$, $G'$ has rank $r$ and is therefore a generator matrix of GRS($x^{q^j}, y^{q^j}$). $\square$

The Sidelnikov-Shestakov attack then suffices to recover a support $x'$ and a multiplier $y'$ in $O(n^{\omega})$ operations in $\mathbb{F}_{q^m}$. The whole algorithm is detailed below.

**Algorithm 2 Recovering a support $x'$ and a multiplier $y'$ for $\mathcal{C}$**

1: **Input:** $H_{pub}$ the public parity-check matrix of $\mathcal{C}$

2: **Output:** $x', y'$ such that $\mathcal{C} = \mathcal{A}_r(x', y')$.

3: Compute $\mathcal{A}$ using Algorithm 1

4: Compute $\mathcal{A} \in \mathcal{A}$ such that $\Pi_{\mathcal{A}} = \Pi_{\alpha}$

5: Compute $Q \in GL_{rm}(\mathbb{F}_q)$ such that $J_r = QAQ^{-1}$

6: Compute $G' = \Psi_{\alpha}^{-1}(QH_{pub})$ and let $\mathcal{D} = \{mG' | m \in \mathbb{F}_{q^m}^r\}$

7: Apply [SS92] on $\mathcal{D}$ to get $x', y'$ such that $\mathcal{D} = \text{GRS}_r(x', y')$

8: **Return** $x', y'$.

**Theorem 6.** Provided that $m = O(\log r)$, Algorithm 2 returns a support $x'$ and a multiplier $y'$ such that $\mathcal{C} = \mathcal{A}_r(x', y')$ at a cost of $O(rn^{\omega})$ operations in $\mathbb{F}_q$.

*Proof.* Firstly, let us prove that $x', y'$ returned by Algorithm 2 are indeed valid support and multiplier. By Proposition 14, we have

$$ \text{GRS}_r(x', y') = \text{GRS}(x^{q^j}, y^{q^j}) $$

for some integer $0 \le j < m$. The GRS codes generated by $x, y$ and $x', y'$ respectively are therefore equal up to Galois conjugation, the latter being erased by the trace map. As a consequence,
the two GRS codes have the same trace codes. By duality, $x, y$ and $x', y'$ generate the same alternant code.

Let us now derive the complexity of Algorithm 2. Step 3 requires $O(rn^\omega)$ operations in $\mathbb{F}_q$ by Theorem 4. Step 4 requires computing matrices $A \in \mathcal{A}$ at random $O(1)$ times, then computing the minimal polynomial and checking its degree. Computing the minimal polynomial of $A$ requires $O((rm)^\omega)$ operations in $\mathbb{F}_q$, so Step 4 is negligible. Computing the similarity matrix $Q$ requires computing the Jordan normal form of $A$ and checking whether it is equal to that of $J_r$ (which can be precomputed). This step requires $O((rm)^\omega)$ operations (possibly in $\mathbb{F}_{q^m}$) and is again negligible. The only remaining costly operation is Step 7 which is known to require $O(n^\omega)$ operations in $\mathbb{F}_{q^m}$, which boils down to $O(mn^\omega)$ operations on $\mathbb{F}_q$. Since $m = O(\log r)$ — which is the natural asymptotic regime in McEliece cryptosystem — we conclude that the overall complexity is bounded by that of Algorithm 1. $\square$

We provide a SageMath implementation of our attack, which is available here.

4.2. **Case $r > q$.** The attack described in the previous section requires the alternant code to be generic, square-distinguishable, and of degree $r \le q$. If we run the exact same algorithm with a generic square-distinguishable alternant code of degree $r > q$ in input, then it turns out that the algorithm does return valid support $x'$ and multiplier $y'$. Although we will not provide a proof of this, we will try to give a partial explanation. To this end we introduce two results.

**Theorem 7 (Weil's theorem).** Let $I \subset \mathbf{R}$ be an ideal and $J = \mathrm{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(I) \subset \mathbf{S}$, where $\mathbf{R}$ and $\mathbf{S}$ are the polynomial rings defined in Section 3. There exists an isomorphism of graded $\mathbb{F}_{q^m}$-algebras

$$ (12) \qquad (S/J) \otimes_{\mathbb{F}_q} \mathbb{F}_{q^m} \cong \bigotimes_{j=0}^{m-1} \mathbf{R}/I^{q^j}, $$

where $I^{q^j} = \{f^{(q^j)} | f \in I\}$, the notation $f^{(q^j)}$ referring to $f$ where the automorphism $\theta^j$ has been applied on the coefficients — the degree is preserved.

*Proof.* This result is [CCG23, Theorem 2.8] in the case of finite fields. $\square$

<figure><img src="image_4.png" /></figure>

This means that we can work equivalently with the Weil restriction or the ideal obtained by extension of scalars. Note that this theorem somehow looks like the following result from coding theory.

**Proposition 15 ([BMT24])**. Let $\mathcal{C} \subset \mathbb{F}_{q^m}^n$ be a proper code. Then

$$ \mathrm{Tr}(\mathcal{C})_{\mathbb{F}_{q^m}} = \bigoplus_{j=0}^{m-1} \mathcal{C}^{q^j}, $$

where $\mathrm{Tr}(\mathcal{C})_{\mathbb{F}_{q^m}}$ denotes the $\mathbb{F}_{q^m}$-linear code spanned by $\mathrm{Tr}(\mathcal{C})$.

To understand why Algorithm 2 still works in the case $r > q$, we can therefore study the quadratic hull of

$$ \mathcal{A}_r (\mathbf{x}, \mathbf{y})_{\mathbb{F}_{q^m}}^{\perp} = \bigoplus_{j=0}^{m-1} \mathrm{GRS}_r (\mathbf{x}, \mathbf{y})^{q^j}. $$
A natural choice for the generator matrix of this code is the matrix whose columns consist of the following list:

$$
\begin{align*}
\mathcal{B} ={}& \{\mathbf{y}, \mathbf{x}\mathbf{y}, \dots, \mathbf{x}^{r-1}\mathbf{y} \\
& \phantom{=} \mathbf{y}^q, (\mathbf{x}\mathbf{y})^q, \dots, (\mathbf{x}^{r-1}\mathbf{y})^q \\
& \phantom{=} \dots \\
& \mathbf{y}^{q^{m-1}}, (\mathbf{x}\mathbf{y})^{q^{m-1}}, \dots, (\mathbf{x}^{r-1}\mathbf{y})^{q^{m-1}}\},
\end{align*}
$$

which was first introduced in [CMT23] and referred to as the canonical basis. For more conve-
nience, we will analyze the quadratic hull of $\mathscr{C}_{\mathbb{F}_{q^m}}$ in the polynomial ring

$$
\mathbf{R} = \mathbb{F}_{q^m} [X_{i,u} \mid 0 \leq i < r, 0 \leq u < m],
$$

the evaluation map sending $X_{i,u}$ onto $(\mathbf{x}^i \star \mathbf{y})^{q^u}$. As recalled in [CMT23], the work that was
done in [FGO+11] shows that, heuristically, the algebraic quadratic hull related to this basis $\mathcal{B}$
is generated by the equations of the form

$$
f_{i,j,k,l,u,v} = X_{i,u}X_{j,v} - X_{k,u}X_{l,v},
$$

for all $0 \le u, v < m$ and $0 \le i, j, k, \ell < r$ such that $iq^u + jq^v = kq^u + \ell q^v$. Denoting by $\mathcal{Y}$ the affine cone over the rational normal curve, we see that these equations define a subvariety of

$$
\mathcal{Y} \times \mathcal{Y}^q \times \dots \times \mathcal{Y}^{q^{m-1}},
$$

which is the variety obtained by extension of scalars of the quadratic hull of $\mathcal{A}_r(\mathbf{x}, \mathbf{y})^{\perp}$ by Weil's theorem. We see that the defining ideal of this product variety is generated by the $f_{i,j,k,l,u,v}$'s with $u=v$. Furthermore, it is the expected quadratic hull of $\mathcal{A}_r(\mathbf{x}, \mathbf{y})_{\mathbb{F}_{q^m}}^{\perp}$ when $r \le q$, i.e. when we have Weil-properness. On the other hand, the crossed equations $f_{i,j,k,l,u,v}$ where $u \ne v$ might be interpreted as field equations. We indeed see the following experimentally.

**Heuristic 3.** Let $\mathbf{H}_{\text{sec}} = \Psi_{\alpha}(\mathbf{V}_r(\mathbf{x}, \mathbf{y}))$. When $r > q$, the algebraic quadratic hull of $\mathbf{H}_{\text{sec}}$ is the Weil restriction of $\langle I_2(\mathbf{V}_r(\mathbf{x}, \mathbf{y})) \cup \{X_i^{q^m} - X_i \mid 0 \le i < r\} \rangle$.

The variety of which the algebraic quadratic hull of $\mathbf{H}_{\text{pub}}$ is the Weil restriction is thus the one-dimensional variety given by the lines passing through the points of the cone over the rational normal curve. The Weil restriction of a line is an $m$-dimensional vector-space, and therefore the arguments of Heuristic 2 still hold in this case. In fact, Weil-properness is not a necessary condition for the attack to succeed. What we need is to have a quadratic hull presenting some algebraic structure over $\mathbb{F}_{q^m}$, so that we get access to sufficiently many vector spaces that are stabilized by $\mathbf{P}\mathbf{J}_r\mathbf{P}^{-1}$. All in all, our attack breaks McEliece scheme with generic square-distinguishable alternant codes, regardless of how $q$ compares to $r$. Our SageMath implementation generates such a generic alternant code, and recovers a support and a multiplier as soon as we are in the square-distinguishable regime.

4.3. What about Goppa codes ? In both [ABC$^{+}$22] and [McE78], McEliece cryptosystem is described with the family of binary Goppa codes.

**Definition 11 (Goppa code).** Let $\mathbf{x} \in \mathbb{F}_{q^m}^n$ be a support and $\Gamma \in \mathbb{F}_{q^m}[X]$ be a polynomial of degree $r$ such that $\Gamma(x_i) \neq 0$ for all $i$. The Goppa code of support $\mathbf{x}$ and Goppa polynomial $\Gamma$ is defined by

$$
\mathcal{G}(\mathbf{x}, \Gamma) = \mathcal{A}_r(\mathbf{x}, \Gamma(\mathbf{x})^{-1}).
$$

A result analogous to Theorem 2 exists also for Goppa codes.
**Theorem 8 ([MT21])**. Let $\mathcal{C} = \mathcal{G}(\mathbf{x}, \Gamma)^{\perp}$ be a proper dual Goppa code. If $r < q - 1$, then

$$ \dim I_2(\mathcal{C}) \geq m \binom{r-1}{2}. $$

When $r \geq q - 1$, we have the following bound:

$$ (13) \qquad \dim I_2(\mathcal{C}) \geq \frac{m}{2}r((2e_{\mathcal{G}} + 1)r - 2(q-1)q^{e_{\mathcal{G}}-1} - 1), $$

$$ \text{where } e_{\mathcal{G}} = \left\lfloor \log_q \left( \frac{r}{(q-1)^2} \right) \right\rfloor + 1. $$

Like in the alternant case, these bounds are tight in the following sense.

**Heuristic 4 ([FGO$^{+}$11])**. As soon as the right-hand side of the inequalities of Theorem 8 exceed $(\binom{r+1}{2} - n$, these inequalities are equalities.

As a direct consequence, we see that Goppa codes essentially behave like alternant codes when $r < q - 1$, which means that Algorithm 2 returns valid support and multiplier in such a case. When $r \geq q - 1$ however, even the previous argument of Heuristic 3 may not apply. This is indeed what we see in practice.

**Heuristic 5.** Let $\mathbf{H}$ be any parity-check matrix of a degree-$r$ Goppa code $\mathcal{G}(\mathbf{x}, \Gamma)$. If $r \geq q - 1$, then the dimension of the geometric quadratic hull of $\mathbf{H}$ is equal to 1.

This is unfortunate, as no algebraic structure over $\mathbb{F}_{q^m}$ is visible in the quadratic hull of such Goppa codes. In particular, binary Goppa codes, be they square-distinguishable or not, are again out of reach. We present in the following table a comparison between our attack and the current state of the art.

<table><caption>FIGURE 1. Comparison</caption><thead><tr><th>Target</th><th>Paper</th><th>r(≥ 3)</th><th>q</th><th>complexity</th></tr></thead><tbody><tr><td>generic square dist. alternant</td><td>[BMT24]</td><td>any</td><td>q ∈ {2, 3}</td><td>rn<sup>ω</sup></td></tr><tr><td>generic square dist. alternant</td><td>[CMT23]</td><td>&lt; q + 1</td><td>any</td><td>n<sup>ω+2</sup></td></tr><tr><td>generic square dist. alternant</td><td>[CMT23] + [BMT24]</td><td>any</td><td>any</td><td>n<sup>ω+2</sup></td></tr><tr><td>generic square dist. alternant</td><td>this paper</td><td>any</td><td>any</td><td>rn<sup>ω</sup></td></tr><tr><td>square dist. Goppa</td><td>[CMT23]</td><td>&lt; q − 1</td><td>any</td><td>n<sup>ω+2</sup></td></tr><tr><td>square dist. Goppa</td><td>this paper</td><td>&lt; q − 1</td><td>any</td><td>rn<sup>ω</sup></td></tr></tbody></table>

**4.4. Generalization to Algebraic-Geometry codes.** Algebraic-Geometry (AG) codes, first introduced by Goppa in [Gop81], are a natural generalization of GRS codes. They have been proposed by Janwa and Moreno in [JM96] for McEliece cryptosystem, but this proposition was eventually proven insecure in [CMCP14]. However, the security of McEliece with subfield sub-codes of AG codes, often referred to as SSAG codes, remains unknown in general. In this last subsection, we aim to show that our algorithm can be applied to attack SSAG codes as well, provided that certain conditions are met.

We first need to recall some notions. In the following, $\mathcal{X}$ denotes a smooth, projective and absolutely irreducible algebraic curve defined over $\mathbb{F}_{q^m}$. We denote by $g$ the genus of $\mathcal{X}$. We also denote by $\mathbb{F}_{q^m}(\mathcal{X})$ the function field of $\mathcal{X}$ with field of constants $\mathbb{F}_{q^m}$. Recall that $\mathrm{Div}(\mathcal{X})$ stands for the divisor group of $\mathcal{X}$, i.e. the free abelian group generated by the points of $\mathcal{X}$ over the algebraic closure of $\mathbb{F}_{q^m}$. A divisor $D \in \mathrm{Div}(\mathcal{X})$ therefore takes the form

$$ D = \sum_{P \in \mathcal{X}} n_P \cdot (P), $$
where all but finitely many $n_P$'s are zero. We write

$$ \mathrm{supp}(D) = \{P \in \mathcal{X} \mid n_P \neq 0\}, $$

and call it the support of $D$. The degree of $D$ is defined by $\deg D = \sum_{P \in \mathcal{X}} n_P \in \mathbb{Z}$. We say that $D$ is an *effective divisor*, and write $D \ge 0$, when $\forall P \in \mathcal{X}$, $n_P \ge 0$. The divisor $D$ is said to be defined over $\mathbb{F}_{q^m}$ when

$$ D^{q^m} \stackrel{\mathrm{def}}{=} \sum_{P \in \mathcal{X}} n_P(P^{q^m}) = D, $$

where $P^{q^m}$ is the point of $\mathcal{X}$ with all coordinates being those of $P$ to the power $q^m$ — this is indeed a point of $\mathcal{X}$ as $\mathcal{X}$ is defined over $\mathbb{F}_{q^m}$. The subgroup of divisors defined over $\mathbb{F}_{q^m}$ will be referred to as $\mathrm{Div}_{\mathbb{F}_{q^m}(\mathcal{X})}$. Note that the points of a divisor defined over $\mathbb{F}_{q^m}$ need not have their coordinates in $\mathbb{F}_{q^m}$. This remark is particularly relevant when we look at principal divisors, which are divisors associated to nonzero rational functions in the following manner. For $f \in \mathbb{F}_{q^m}(\mathcal{X})^\times$ such a nonzero rational function and $P \in \mathcal{X}$, we write $\mathrm{ord}_P(f)$ the valuation of $f$ at $P$. The principal divisor associated to $f$ is defined by

$$ (f) = \sum_{P \in \mathcal{X}} \mathrm{ord}_P(f) \cdot (P). $$

Although the zeros and poles of $f$ may not lie in $\mathcal{X}(\mathbb{F}_{q^m})$, the whole divisor $(f)$ is globally invariant under the Frobenius automorphism and is therefore defined over $\mathbb{F}_{q^m}$. Furthermore, the following holds.

**Theorem 9** ([Sil09], Proposition 3.1 (b)). For all $f \in \mathbb{F}_{q^m}(\mathcal{X})^\times$, we have $\deg(f) = 0$.

Finally, we denote by $\mathcal{L}(D)$ the Riemann-Roch space of $D$, which is defined by

$$ \mathcal{L}(D) = \{f \in \mathbb{F}_{q^m}(\mathcal{X})^\times \mid (f) + D \ge 0\} \cup \{0\}. $$

As stated by the famous Riemann-Roch theorem, this space is a finite dimensional $\mathbb{F}_{q^m}$-vector space whose dimension $\ell(D)$ is related to the degree of $D$. We give the special case of Riemann-Roch theorem for divisors of sufficiently high degree.

**Theorem 10** (Riemann-Roch). If $\deg D > 2g - 2$, then $\ell(D) = \deg D + 1 - g$.

*Proof.* See [Sil09, Corollary 5.5 (c)]. □

We have introduced all the necessary material to define algebraic-geometry codes.

**Definition 12.** Let $\mathcal{P} = (P_1, \dots, P_n) \in \mathcal{X}(\mathbb{F}_{q^m})^n$ be a tuple of pairwise distinct $\mathbb{F}_{q^m}$-rational points of $\mathcal{X}$, and let $D \in \mathrm{Div}_{\mathbb{F}_{q^m}(\mathcal{X})}$ be such that $\mathrm{supp}(D) \cap \{P_1, \dots, P_n\} = \emptyset$. The algebraic-geometry code of support $\mathcal{P}$ and divisor $D$ is defined by

$$ \mathcal{C}_{\mathcal{L}}(\mathcal{X}, \mathcal{P}, D) = \{(f(P_1), \dots, f(P_n)) \mid f \in \mathcal{L}(D)\}. $$

**Remark 11.** When $\mathcal{X} = \mathbb{P}^1$ and $D = (r+1)P_\infty$ where $P_\infty = (1:0)$, the above definition gives Reed-Solomon codes. See [Sti09, Proposition 2.3.5] for further details.

Let $r = \ell(D) - 1$ and $(f_0, \dots, f_r)$ be a basis of $\mathcal{L}(D)$. Since $\mathcal{X}$ is a smooth curve, the rational function $\phi_D = (f_0, \dots, f_r)$ defines a morphism $\mathcal{X} \to \mathbb{P}^r$. If $\deg D > 2g$, then $\phi_D$ defines an isomorphism between $\mathcal{X}$ and $\mathcal{Y} = \phi_D(\mathcal{X})$. Moreover, like in the case of GRS codes, the following matrix

$$ V(\mathcal{P}, \phi_D) = \begin{pmatrix} f_0(P_1) & f_0(P_2) & \dots & f_0(P_n) \\ f_1(P_1) & f_1(P_2) & \dots & f_1(P_n) \\ \vdots & \vdots & \ddots & \vdots \\ f_r(P_1) & f_r(P_2) & \dots & f_r(P_n) \end{pmatrix} $$
is a generator matrix of $\mathscr{C} \stackrel{\text{def}}{=} \mathscr{C}_L(\mathcal{X}, \mathcal{P}, D)$, and each column defines a point on $\mathcal{Y}$. From the work of [MMP14], we know that if $\deg D > 2g+1$, then the quadratic hull of this matrix is equal to $\mathcal{Y}$, which implies that the quadratic hull of $\text{Tr}(\mathscr{C})$ is a subvariety of $\Psi_\alpha(\mathcal{Y})$. In order to adapt our attack to SSAG codes, we need to understand when such a code is Weil-proper. Extensive computations in our SageMath implementation available here have led us to the following quite natural conjecture. We have investigated Weil-properness of generic one point AG codes, i.e. codes of the form

$$ (14) \qquad \mathscr{C} = \{\mathbf{c} \star \mathbf{y} \mid \mathbf{c} \in \mathscr{C}_L(\mathcal{X}, \mathcal{P}, r \cdot (P_\infty))\} $$

where $\mathbf{y} \in (\mathbb{F}_{q^m}^\times)^n$ is chosen uniformly at random.

**Heuristic 6 (Weil-properness of one point generic AG codes).** Let $\mathcal{D} = \text{Tr}(\mathscr{C})$ where $\mathscr{C}$ is as in Equation (14). We make the two following assumptions:

(i) $2g+2 \le r \le q$;

(ii) $n > \binom{(r+1-g)m+1}{2} - m \dim_{\mathbb{F}_{q^m}} I_2(\mathscr{C})$.

Then $\mathcal{D}$ is Weil-proper.

In such a case, one can compute the tangent spaces of the quadratic hull of the public generator matrix of $\mathcal{D}$. The assumption $2g+2 \le r$ ensures that the quadratic hull of $\mathscr{C}$ is a projective variety of dimension 1, therefore the underlying ideal has dimension 2, which means that the quadratic hull of $\mathcal{D}$ has dimension $2m$. All in all, Algorithm 2 eventually retrieves a generator matrix of $\mathscr{C}$, and then [CMCP14] recovers an efficient decoding algorithm. This class of AG codes is therefore vulnerable to our attack.

Like in the case of alternant codes, the attack still succeeds when we no longer have the assumption $r \le q$.

**Heuristic 7.** Let $\mathbf{H}_{\text{sec}} = \Psi_\alpha(\mathbf{G})$ be the secret generator matrix of $\mathcal{D}$, where $\mathbf{G}$ is a generator matrix of $\mathscr{C}$. We still assume $2g+2 \le r$, as well as (ii) of the previous heuristic, but now we also assume $r > q$. Then the algebraic quadratic hull of $\mathbf{H}_{\text{sec}}$ is equal to the Weil restriction of $\langle I_2(\mathbf{G}) \cup \{X_i^{q^m} - X_i \mid 0 \le i \le r-g\} \rangle$.

Our SageMath implementation also provides Algorithm 2 in the case of generic one point AG codes, regardless of how $r$ compares to $q$.

## 5. CONCLUSION AND OPEN PROBLEMS

The geometric analysis of linear codes using the quadratic hull seems to be a prolific approach. Using Weil restriction, we have been able to write an algorithm that recovers the structure of a trace code, provided that the original code has a nontrivial quadratic hull and assuming Weil-properness. This notion turns out to be more powerful than what we actually need for our attack to succeed. We eventually described a polynomial-time attack against the McEliece cryptosystem instantiated with generic alternant codes, generic one-point SSAG codes, or even Goppa codes of sufficiently low degree.

For future work, better understanding what happens when the degree of the alternant code gives rise to field equations even in the high-rate regime will be crucial to see whether we can adapt our framework to the case of binary Goppa codes. It is also still unclear whether other families of codes are vulnerable to our attack.

## ACKNOWLEDGEMENTS

This work was in part funded by the Direction Générale de l'Armement (DGA). The author would also like to thank Jean-Pierre Tillich for his advice and feedback, as well as Alain Couvreur for his insightful discussions.
REFERENCES

[AAB<sup>+17</sup>] Carlos Aguilar Melchor, Nicolas Aragon, Slim Bettaieb, Loïc Bidoux, Olivier Blazy, Jean-Christophe Deneuville, Philippe Gaborit, Edoardo Persichetti, and Gilles Zémor. HQC, November 2017. NIST Round 1 submission for Post-Quantum Cryptography.

[AAB<sup>+22</sup>] Carlos Aguilar Melchor, Nicolas Aragon, Paulo Barreto, Slim Bettaieb, Loïc Bidoux, Olivier Blazy, Jean-Christophe Deneuville, Philippe Gaborit, Santosh Ghosh, Shay Gueron, Tim Güneysu, Rafael Misoczki, Edoardo Persichetti, Jan Richter-Brockmann, Nicolas Sendrier, Jean-Pierre Tillich, Valentin Vasseur, and Gilles Zémor. BIKE. Round 4 Submission to the NIST Post-Quantum Cryptography Call, v. 5.1, October 2022.

[ABC<sup>+22</sup>] Martin Albrecht, Daniel J. Bernstein, Tung Chou, Carlos Cid, Jan Gilcher, Tanja Lange, Varun Maram, Ingo von Maurich, Rafael Mizoczki, Ruben Niederhagen, Edoardo Persichetti, Kenneth Paterson, Christiane Peters, Peter Schwabe, Nicolas Sendrier, Jakub Szefer, Cen Jung Tjhai, Martin Tomlinson, and Wang Wen. Classic McEliece (merger of Classic McEliece and NTS-KEM). https://classic.mceliece.org, November 2022. Fourth round finalist of the NIST post-quantum cryptography call.

[BM17] Leif Both and Alexander May. Optimizing BJMM with Nearest Neighbors: Full Decoding in $2^{2/21n}$ and McEliece Security. In *WCC Workshop on Coding and Cryptography*, September 2017.

[BMT24] Magali Bardet, Rocco Mora, and Jean-Pierre Tillich. Polynomial time key-recovery attack on high rate random alternant codes. *IEEE Trans. Inform. Theory*, 70(6):4492–4511, 2024.

[BMvT78] Elwyn Berlekamp, Robert McEliece, and Henk van Tilborg. On the inherent intractability of certain coding problems. *IEEE Trans. Inform. Theory*, 24(3):384–386, May 1978.

[CCG23] Alessio Caminata, Michela Ceria, and Elisa Gorla. The complexity of solving weil restriction systems. *Journal of Algebra*, 621:116–133, 2023.

[CCMZ15] Ignacio Cascudo, Ronald Cramer, Diego Mirandola, and Gilles Zémor. Squares of random linear codes. *IEEE Trans. Inform. Theory*, 61(3):1159–1173, 3 2015.

[CFS01] Nicolas Courtois, Matthieu Finiasz, and Nicolas Sendrier. How to achieve a McEliece-based digital signature scheme. In *Advances in Cryptology - ASIACRYPT 2001*, volume 2248 of LNCS, pages 157–174, Gold Coast, Australia, 2001. Springer.

[CGG<sup>+13</sup>] Alain Couvreur, Philippe Gaborit, Valérie Gautier, Ayoub Otmani, and Jean-Pierre Tillich. Distinguisher-Based Attacks on Public-Key Cryptosystems Using Reed-Solomon Codes. In *International Workshop on Coding and Cryptography - WCC 2013*, pages 181–193, Bergen, Norway, April 2013.

[CMCP14] Alain Couvreur, Irene Márquez-Corbella, and Ruud Pellikaan. A polynomial time attack against algebraic geometry code based public key cryptosystems. In *Proc. IEEE Int. Symposium Inf. Theory - ISIT 2014*, pages 1446–1450, June 2014.

[CMT23] Alain Couvreur, Rocco Mora, and Jean-Pierre Tillich. A new approach based on quadratic forms to attack the McEliece cryptosystem. In Jian Guo and Ron Steinfeld, editors, *Advances in Cryptology - ASIACRYPT 2023 - 29th International Conference on the Theory and Application of Cryptology and Information Security, Guangzhou, China, December 4-8, 2023, Proceedings, Part IV*, volume 14441 of LNCS, pages 3–38. Springer, 2023.

[Del75] Philippe Delsarte. On subfield subcodes of modified Reed-Solomon codes. *IEEE Trans. Inform. Theory*, 21(5):575–576, 1975.

[Eis06] D. Eisenbud. *The Geometry of Syzygies: A Second Course in Algebraic Geometry and Commutative Algebra*. Graduate Texts in Mathematics. Springer New York, 2006.

[FGO<sup>+10</sup>] Jean-Charles Faugère, Valérie Gauthier, Ayoub Otmani, Ludovic Perret, and Jean-Pierre Tillich. A distinguisher for high rate McEliece cryptosystems. IACR Cryptology ePrint Archive, Report2010/331, 2010. http://eprint.iacr.org/.

[FGO<sup>+11</sup>] Jean-Charles Faugère, Valérie Gauthier, Ayoub Otmani, Ludovic Perret, and Jean-Pierre Tillich. A distinguisher for high rate McEliece cryptosystems. In *Proc. IEEE Inf. Theory Workshop- ITW 2011*, pages 282–286, Paraty, Brasil, October 2011.

[GH78] Phillip Griffiths and Joseph Harris. *Principles of algebraic geometry*. Pure and Applied Mathematics. A Wiley-Interscience Publication. John Wiley & Sons, New York, 1978.

[Gop81] Valerii D. Goppa. Codes on algebraic curves. *Dokl. Akad. Nauk SSSR*, 259(6):1289–1290, 1981. In Russian.

[JM96] Heeralal Janwa and Oscar Moreno. McEliece public key cryptosystems using algebraic-geometric codes. *Des. Codes Cryptogr.*, 8(3):293–307, 1996.
[KT17] Ghazal Kachigar and Jean-Pierre Tillich. Quantum information set decoding algorithms. In *Post-Quantum Cryptography 2017*, volume 10346 of LNCS, pages 69–89, Utrecht, The Netherlands, June 2017. Springer.

[LMT25] Axel Lemoine, Rocco Mora, and Jean-Pierre Tillich. Understanding the new distinguisher of alternant codes at degree 2. Cryptology ePrint Archive, Paper 2025/531, 2025.

[McE78] Robert J. McEliece. *A Public-Key System Based on Algebraic Coding Theory*, pages 114–116. Jet Propulsion Lab, 1978. DSN Progress Report 44.

[MMP14] Irene Márquez-Corbella, Edgar Martínez-Moro, and Ruud Pellikaan. On the unique representation of very strong algebraic geometry codes. *Des. Codes Cryptogr.*, 70(1-2):215-230, 2014.

[MP12] Irene Márquez-Corbella and Ruud Pellikaan. Error-correcting pairs for a public-key cryptosystem. CBC 2012, Code-based Cryptography Workshop, 2012. Available on http://www.win.tue.nl/~ruudp/paper/59.pdf.

[MT21] Rocco Mora and Jean-Pierre Tillich. On the dimension and structure of the square of the dual of a Goppa code. preprint, 2021.

[Nie86] Harald Niederreiter. Knapsack-type cryptosystems and algebraic coding theory. *Problems of Control and Information Theory*, 15(2):159–166, 1986.

[Ran19] Hugues Randriambololona. The quadratic hull of a code and the geometric view on multiplication algorithms. *CoRR*, abs/1912.06627, 2019.

[Ran24] Hugues Randriambololona. The syzygy distinguisher. *CoRR*, abs/2407.15740, 2024.

[Sil09] Joseph H. Silverman. *The Arithmetic of Elliptic Curves*, volume 106 of *Graduate Texts in Mathematics*. Springer, 2009.

[SS92] Vladimir Michilovich Sidelnikov and S.O. Shestakov. On the insecurity of cryptosystems based on generalized Reed-Solomon codes. *Discrete Math. Appl.*, 1(4):439–444, 1992.

[Sti09] Henning Stichtenoth. *Algebraic function fields and codes*, volume 254 of *Graduate Texts in Mathematics*. Springer-Verlag, Berlin, second edition, 2009.

[WB86] Lloyd R Welch and Elwyn R Berlekamp. Error correction for algebraic block codes. December 1986. US Patent 4,633,470.
## 6. APPENDIX

**6.1. Graded free resolutions.** The proof of Lemma 1 involves the notion of minimal graded free resolution of finitely generated graded modules over polynomial rings. Let us define

$$ \mathbf{R} = \mathbb{F}_{q}^{m}[X_{0}, \dots, X_{r-1}] \text{ and } \mathbf{S} = \mathbb{F}_{q}[x_{i,j} \mid 0 \le i < r, 0 \le j < m]. $$

Both $\mathbf{R}$ and $\mathbf{S}$ have a structure of graded rings. More precisely, we can write

$$ \mathbf{R} = \bigoplus_{d \in \mathbb{N}} \mathbf{R}_d \text{ and } \mathbf{S} = \bigoplus_{d \in \mathbb{N}} \mathbf{S}_d, $$

where $\mathbf{R}_d$ and $\mathbf{S}_d$ refer to the vector space spanned by monomials of degree $d$, and we have $\mathbf{R}_a \mathbf{R}_b \subset \mathbf{R}_{a+b}$ for all $a, b \in \mathbb{N}$ — and likewise for $\mathbf{S}$. In the same manner, if $M$ is a module over $\mathbf{R}$, we say that $M$ is a graded $\mathbf{R}$-module if one can write $M = \bigoplus_{d \in \mathbb{Z}} M_d$ and if

$$ \forall a \in \mathbb{N}, \forall b \in \mathbb{Z}, \mathbf{R}_a M_b \subset M_{a+b}. $$

**Definition 13.** Let $M$ be a finitely generated $\mathbf{R}$-module. A free resolution of $M$ is an exact sequence

$$ \dots \to \mathbb{F}_{i+1} \to \mathbb{F}_i \to \dots \to \mathbb{F}_0 \to M \to 0, $$

where each $\mathbb{F}_i$ is a free $\mathbf{R}$-module. We write $\mathbb{F}_\bullet \to M \to 0$ for conciseness. If moreover each $\mathbb{F}_i$ is a graded free $\mathbf{R}$-module, and if the maps $\mathbb{F}_{i+1} \to \mathbb{F}_i$ and $\mathbb{F}_0 \to M$ preserve the degree, then we say that $\mathbb{F}_\bullet \to M \to 0$ is a graded free resolution of $M$.

**6.2. Minimal resolutions.** Let $M$ be a finitely generated $\mathbf{R}$-module. If $(x_1, \dots, x_n) \in M^n$ is a minimal set of generators of $M$, then we have a natural map

$$ \mathbb{F}_0 = \mathbf{R}^n \to M. $$

One can repeat this process inductively by setting $M_1 = \ker(\mathbb{F}_0 \to M)$ and let $\mathbb{F}_1$ be the free module over a minimal set of generators of $M_1$, and so on. This is the notion of minimality of a free resolution, that we define more formally below.

**Definition 14.** Let $\mathbb{F}_\bullet \to M \to 0$ be a free resolution of the finitely generated graded $\mathbf{R}$-module $M$. Define the sequence of $\mathbf{R}$-modules $(M_i)_{i \in \mathbb{N}}$ by $M_0 = M$ and $M_{i+1} = \ker(F_i \to M_i)$. We say that the resolution is minimal if for any $i \in \mathbb{N}$, the cardinality of a minimal set of generators of $M_i$ equals the rank of the free module $\mathbb{F}_i$.

If $N$ is any graded $\mathbf{R}$-module, then for any integer $j$ we denote by $N(j)$ the graded $\mathbf{R}$-module whose degree $d$ component is defined by the degree $d + j$ component of $N$:

$$ \forall d \in \mathbb{Z}, N(j)_d = N_{d+j}. $$

We now assume that $M$ is a graded $\mathbf{R}$-module. By taking into account the degree of the elements of a minimal set of generators of $M$, we get a degree-preserving natural surjective map

$$ \mathbb{F}_0 = \bigoplus_{j \in \mathbb{N}} \mathbf{R}(-j)^{\beta_{0,j}} \to M, $$

where $\beta_{0,j}$ is therefore the number of elements of degree $j$ in a minimal set of generators of $M$. Repeating this construction inductively, we obtain a minimal graded free resolution of $M$. The fact that the numbers of generators of a certain degree in a minimal set of generators does not depend on the choice of generators is a consequence of the following result.

**Theorem 11** ([Eis06], Theorem 1.6). If $\mathbb{F}_\bullet$ and $\mathbb{G}_\bullet$ are minimal graded free resolutions of $M$, then there is a graded isomorphism of complexes $\mathbb{F}_\bullet \to \mathbb{G}_\bullet$ inducing the identity map on $M$.
We can therefore talk about the minimal graded free resolution of the finitely generated graded $R$-module $M$. For any integer $j \in \mathbb{N}$, we can write

$$ \mathbb{F}_i = \bigoplus_{j \in \mathbb{N}} R(-j)^{\beta_{i,j}}, $$

and the $\beta_{i,j} \in \mathbb{N}$ are called the graded Betti numbers of $M$.

**6.3. Minimal set of generators of a Weil restriction.** A homogeneous ideal $I \subset R$ is a graded $R$-module. Since $R$ is a noetherian ring by Hilbert's basis theorem, we know that $I$ is finitely generated. As a result we can apply the framework that we introduced above on the finitely generated graded module $R/I$. Furthermore, if $J = \text{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(I)$, then $J$ is also a finitely generated graded $S$-module, and as such we can also consider the minimal graded free resolution of $S/J$. The Betti numbers of $R/I$ and $S/J$ are related by the following formula.

**Proposition 16.** Let $(\beta_{i,j})_{i,j}$ and $(\gamma_{i,j})_{i,j}$ be the graded Betti numbers of $R/I$ and $S/J$ respectively. Then for all $i$ and $j$, we have

$$ (15) \qquad \gamma_{i,j} = \sum_{\substack{i_1+\dots+i_m=i \\ j_1+\dots+j_m=j}} \prod_{s=1}^{m} \beta_{i_s,j_s}. $$

*Proof.* Let $\mathbb{F}_\bullet$ be a minimal graded free resolution of $R/I$. By [CCG23, Theorem 3.3], we have a minimal graded free resolution

$$ (16) \qquad \mathbb{G}_\bullet \stackrel{\text{def}}{=} \mathbb{F}^{\otimes m} \to (S/J) \otimes_{\mathbb{F}_q} \mathbb{F}_{q^m} \to 0. $$

We thus have for all $i \in \mathbb{N}$,

$$ \mathbb{G}_i = \bigoplus_{i_1+\dots+i_m=i} \mathbb{F}_{i_1} \otimes \dots \otimes \mathbb{F}_{i_m}. $$

Expanding each $\mathbb{F}_{i_s}$ as $\bigoplus_{j_s} R(-j_s)^{\beta_{i_s,j_s}}$ gives

$$ \begin{align*} \mathbb{G}_i &= \bigoplus_{i_1+\dots+i_m=i} \bigotimes_{s=1}^{m} \left( \bigoplus_{j_s} R(-j_s)^{\beta_{i_s,j_s}} \right) \\ &= \bigoplus_{i_1+\dots+i_m=i} \bigoplus_{j_1, \dots, j_m} R(-j_1)^{\beta_{i_1,j_1}} \otimes \dots \otimes R(-j_m)^{\beta_{i_m,j_m}} \\ &= \bigoplus_{i_1+\dots+i_m=i} \bigoplus_{j_1, \dots, j_m} R(-j_1 - \dots - j_m)^{\beta_{i_1,j_1} \times \dots \times \beta_{i_m,j_m}}. \end{align*} $$

Since the map $\Phi: R \to S \otimes_{\mathbb{F}_q} \mathbb{F}_{q^m}$ is an injective homomorphism of graded $\mathbb{F}_{q^m}$-algebras, we get that the Betti numbers of $S/J$ and $(S/J) \otimes_{\mathbb{F}_q} \mathbb{F}_{q^m}$ are the same. Identifying the component of degree $j$ of $\mathbb{G}_i$ eventually gives the desired formula. $\square$

Focusing on $i=1$ gives the number of generators in a minimal set of generators of the ideals $I$ and $J$ respectively. The leads us to a proof of Lemma 1, that we recall below.

**Lemma 1.** Let $I \subset R$ be a homogeneous ideal. If $(f_1, \dots, f_N)$ is a minimal set of generators for $I$, then the sequence $(\Phi_j(f_i))_{i,j}$ is a minimal set of generators of $\text{Res}_{\mathbb{F}_{q^m}/\mathbb{F}_q}(I)$.

*Proof.* Retaking the notations of Proposition 16, it suffices to show that

$$ \forall j \in \mathbb{N}, \quad \gamma_{1,j} = m\beta_{1,j}. $$

Let $j \in \mathbb{N}$. In Equation (15), every index $i_s$ must be equal to zero but one, which must be equal to one. As $\mathbb{F}_0 = R$, we see that for each integer $j_s$, the Betti number $\beta_{0,j_s}$ equals 1 if and only if
$j_s = 0$, and 0 otherwise. Therefore, in the product of Equation (15), we only have Betti numbers of the form $\beta_{0,0}$ and one of the form $\beta_{1,j_s}$, and that $j_s$ must be equal to $j$. All in all, we get

$$ \gamma_{1,j} = \sum_{s=1}^{m} \beta_{0,0} \times \dots \times \underbrace{\beta_{1,j}}_{\text{position } s} \times \dots \times \beta_{0,0} = m\beta_{1,j} $$

as required.

□

INRIA PARIS, FRANCE

DGA, FRANCE

Email address: axel.lemoine@inria.fr