{'fraction_non_alphanumeric': 0.04905613253689096, 'fraction_numerical': 0.011676067184215455, 'mean_word_length': 3.678936605316973, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Folding Alternant and Goppa Codes with Non-Trivial Automorphism Groups

The main practical limitation of the McEliece public-key encryption scheme is probably the size of its key. A famous trend to overcome this issue is to focus on subclasses of alternant/Goppa codes with a non trivial automorphism group. Such codes display then symmetries allowing compact parity-check or generator matrices. For instance, a key-reduction is obtained by taking quasi-cyclic (QC) or quasi-dyadic (QD) alternant/Goppa codes. We show that the use of such symmetric alternant/Goppa codes in cryptography introduces a fundamental weakness. It is indeed possible to reduce the key-recovery on the original symmetric public-code to the key-recovery on a (much) smaller code that has not anymore symmetries. This result is obtained thanks to a new operation on codes called folding that exploits the knowledge of the automorphism group. This operation consists in adding the coordinates of codewords which belong to the same orbit under the action of the automorphism group. The advantage is twofold: the reduction factor can be as large as the size of the orbits, and it preserves a fundamental property: folding the dual of an alternant (resp. Goppa) code provides the dual of an alternant (resp. Goppa) code. A key point is to show that all the existing constructions of alternant/Goppa codes with symmetries follow a common principal of taking codes whose support is globally invariant under the action of affine transformations (by building upon prior works of T. Berger and A. D{\"{u}}r). This enables not only to present a unified view but also to generalize the construction of QC, QD and even quasi-monoidic (QM) Goppa codes. All in all, our results can be harnessed to boost up any key-recovery attack on McEliece systems based on symmetric alternant or Goppa codes, and in particular algebraic attacks.


I. INTRODUCTION
Some significant research efforts have been put recently in code-based cryptography to reduce by a large factor the public key sizes. This has resulted in keys which are now only a few times larger than RSA keys (see [1], [2] for instance). This is obtained by focusing on codes having symmetries, that is to say, codes having a non-trivial automorphism group. Such codes have the advantage of admitting a compact parity-check or generator matrix [3], [4], [5], [1], [6]. Quasi-cyclic (QC) codes represent a good example of the use of symmetries in cryptography to build public-key encryption schemes with short keys [3], [4]. It was then followed by a series of papers proposing alternant and Goppa codes with different automorphism groups like quasi-dyadic (QD) Goppa or Srivastava codes [5], [6] and quasi-monodic (QM) codes [1]. The rationale behind this is the fact that the additional structure does not A preliminary version of this paper will be presented at ISIT'14 under the title "Structural Weakness of Compact Variants of the McEliece Cryptosystem". deteriorate the security of the cryptographic scheme. This hope was eroded by the apparition of specific attacks [7], [8] and algebraic attacks [9], [10], [11] against QC/QD alternant/Goppa codes. Despite these preliminary warning signals, the design of compact McEliece schemes remains a rather popular topic of research e.g. [12], [1], [6], [13], [14]. Besides these cryptographic motivations, the search for Goppa codes, and more generally alternant codes, with non-trivial automorphisms is in itself an important issue in coding theory. Several papers focused on the problem of constructing quasi-cyclic Goppa codes [15], [16], or identifying alternant and Goppa codes invariant under a given permutation [17], [18], [19].

Main Results
All the constructions of symmetric alternant/Goppa codes presented in previous works might look at first glance unrelated, like ad hoc constructions designed for a very specific goal. In [5] symmetric QD Goppa codes are constructed by using the narrower class of separable Goppa codes which have all their roots of multiplicity one in the field over which the coefficients of the Goppa polynomial are taken and by choosing these roots in an appropriate manner; the same approach is followed to obtain more general QM Goppa codes in [1], whereas in [4] the authors rely on the larger class of alternant codes to obtain a large enough family of QC codes in a McEliece like scheme. Building upon the work of [20], [19], [18], we show in this paper that all the QC, QD and QM alternant/Goppa codes which are constructed in [4], [5], [1] rely actually on a common principle (Proposition 3). They are all equipped with non-trivial automorphism groups that involve some affine transformations leaving globally invariant their support. This property imposes on the non-zero scalars defining the alternant codes the constraint of being built from a root of unity. In the case of Goppa codes, this constraint is translated into a functional equation of the form αΓ(az + b) = Γ(z) that the Goppa polynomial Γ(z) has to satisfy, where α is a root of unity and a, b belong to the underlying finite field on which the support is defined. We fully characterize polynomials satisfying such equation in Proposition 4. This enables not only to present a unified view but also to generalize the construction of QC, QD and QM Goppa codes (Proposition 5). In particular, there is no need to use separable polynomials like in [5] for getting QD Goppa codes. Notice that this will also show that it is in principle not compulsory to take the larger family of alternant codes instead of Goppa codes as in [4] to obtain a large enough family of QC codes in a McEliece scheme: in fact there is nothing special with respect to QD Goppa codes instead of QC Goppa codes because there are roughly as many QD Goppa codes as there are QC Goppa codes (for a same size of automorphism group) with our way of constructing them. The major contribution of our paper is to prove that alternant and Goppa codes with symmetries can be seen as an inflated version of a smaller alternant code without symmetries. We call this latter a folded code because we show that it can be obtained easily by adding the coordinates which belong to the same orbit under the action of a permutation of the automorphism group. More importantly, we can also express precisely the relationship between the supports and the non-zero scalars defining the alternant/Goppa with symmetries and their associated folded codes. These links are so explicit for the non-zero scalars that knowing those of the folded code is sufficient for knowing those of the original symmetric alternant/Goppa codes. These results have an important impact in cryptography. First the length and the dimension of the folded code is generally divided by the cardinality of the automorphism group. It means in particular that the use of compact alternant/Goppa codes introduces a fundamental weakness: decreasing the size of the public-key as in [4], [5], [1] necessarily implies a deterioration of the security. Furthermore, since the non-zero scalars of the folded code bear crucial information, it then allows in the context of algebraic attacks as proposed in ( [9], [10], [21]), to reduce a key-recovery attack on the original public-code to the one on a smaller code, that is to say with less variables in the polynomial system. For instance, we can reduce the key-recovery of a quasi-dyadic Goppa code of length 8192 and dimension 4096 to the key-recovery on a Goppa code of length 64 and dimension 32. Interestingly enough, the folded code, if used in a McEliece-like encryption scheme, would have the same key size as the original scheme but without symmetries. In other words, the very reason which allowed to reduce the key size in [4], [5], [1], [13] can be used to derive a reduced McEliece scheme whose key-recovery hardness and key size is equivalent to the original system.
Comparison with "Structural Cryptanalysis of McEliece Schemes with Compact Keys" [21] This paper is a companion paper of [21] which has been submitted separately. In [21], we mainly focused on the cryptanalysis of QM Goppa codes. That is, we [21] developed new algebraic tools for solving the algebraic systems arising in the cryptanalysis QM Goppa codes, reported various experimental results and prove in addition partial results on folded QM Goppa codes. In this submission, we present a much deeper and more systematic treatment of the the folding process. In [21], the folding was performed directly over QM Goppa codes and it was proved there that it results in a subcode of a Goppa code of reduced length. Using a slightly different approach (by considering the dual of the codes), we obtain here a much stronger result which holds in a more general setting. Namely, we prove that if we perform folding on the dual of QC, QD or QM affine induced Goppa/alternant codes (this applies for instance to all the codes constructed in [4], [5], [13], [1]) we obtain a reduced dual Goppa or alternant code where the reduction factor can be as large as the size of the cyclic or monodic blocks of a symmetric parity-check matrix attached to these codes. Folding preserves here the structure of the dual code: if we start with the dual of an alternant code we end up with the dual of an alternant code and if we start with the dual of a Goppa code we end up with the dual of a Goppa code.

II. ALTERNANT AND GOPPA CODES
In this section we introduce notation which is used in the whole paper and recall a few well known facts about alternant and Goppa codes. Throughout the paper, the finite field of q elements with q being a power of a prime number p is denoted by F q . Vectors are denoted by bold letters like x and the notation x = (x i ) 0 i<n or x = (x i ) n−1 i=0 will be used in some cases. The ring of polynomials with coefficients in a finite field F is denoted by F[z], while the subspace of F[z] of polynomials of degree less than t (resp. less than or equal to t) is denoted by . . , Q(x n−1 )). In particular for any vector u = (u 0 , . . . , u n−1 ) and for all a, b ∈ F then au + b stands for the vector (au 0 + b, . . . , au n−1 + b).

Definition 1 (Generalized Reed-Solomon code)
Let q be a prime power and k, n be integers such that 1 k < n q. Let x and y be two n-tuples such that the entries of x are pairwise distinct elements of F q and those of y are nonzero elements in F q . The generalized Reed-Solomon code GRS k (x, y) of dimension k is the k-dimensional vector space: A useful property of these codes is given in [22,Chap. 12,§2]. Proposition 1 Keeping the notation of Definition 1, there exists a vector z ∈ F n q such that GRS k (x, y) ⊥ = GRS n−k (x, z).
This leads to the definition of alternant codes. Definition 2 (Alternant code, degree, support, multiplier) Let x, y ∈ F n q m be two vectors such that the entries of x are pairwise distinct and those of y are all nonzero, and let r and m be positive integers. The alternant code A r (x, y) defined over F q is the subfield subcode over F q of GRS r (x, y) ⊥ ⊂ F n q m : The integer r is the degree of the alternant code, x is a support and y is a multiplier of the alternant code.
The dual of a subfield subcode is known to be a trace code [23]. From this it follows that Lemma 1 The dual A r (x, y) ⊥ of the alternant code A r (x, y) of degree r and extension m over F q is given by: where Tr is the trace map from F q m to F q defined by Tr(z) = z + z q + · · · + z q m−1 .
Let us remark that an alternant code has many equivalent descriptions as shown by the following proposition whose proof can be found in [22,Chap. 10,p. 305].
Proposition 2 For all a ∈ F q m \ {0}, b ∈ F q m , and c ∈ F q m \ {0}, it holds that: A r (x, y) = A r (ax + b, cy).
We introduce now Goppa codes which form an important subfamily of alternant codes.
Definition 3 (Classical Goppa codes) Let x = (x 0 , . . . , x n−1 ) be an n-tuple of distinct elements of F q m and choose Γ(z) ∈ F q m [z] of degree r such that Γ(x i ) = 0 for all i ∈ {0, . . . , n − 1}. The Goppa code G (x, Γ) of degree r over F q associated to Γ(z) is the alternant code A r (x, y) with .
Γ(z) is called the Goppa polynomial and x is the support of the Goppa code.

III. CONSTRUCTION OF SYMMETRIC ALTERNANT AND GOPPA CODES
The purpose of this section is to recall how quasi-cyclic (QC), quasi-dyadic (QD) and quasi-monoidic (QM) alternant/Goppa codes [5], [13], [1] and more generally any symmetric alternant/Goppa code can be constructed from a common principle which stems from Dür's work in [20] about the automorphism group of (generalized) Reed-Solomon codes. This has been applied and developed in [19], [18] to construct large families of symmetric alternant or Goppa codes. It should be emphasized that this way of constructing symmetric Goppa codes is more general than the constructions proposed for QD or QM Goppa in a cryptographic context by [5], [13], [1]. In particular, it is required in [5], [13], [1] to choose Goppa codes with a separable Goppa polynomial. We will prove in the following that this constraint is unnecessary. In order to recall these results we need a few definitions. An automorphism of a code of length n defined over F q is an isometry of the Hamming space F n q i.e. a linear transform of F n q which both preserves the Hamming weight and leaves the code globally invariant. A well-known fact about such isometries is that they consist of permutations and/or non-zero multiplications of the coordinates.
In this paper, we will be interested only in isometries that are permutations. This action is denoted, given a permutation σ of the symmetric group on {0, . . . , n − 1} and a vector x = (x 0 , . . . , x n−1 ), by x σ def = (x σ(0) , . . . , x σ(n−1) ). For a code C and a permutation σ, we define: A permutation automorphism of C is then any permutation σ such that c σ is in C whenever c belongs to C . Symmetric codes are then codes with a non-trivial automorphism group.
We have seen in Proposition 2 that alternant codes may have several identical descriptions thanks to affine transformations. Actually, symmetric Goppa codes and alternant codes can easily be constructed by looking at the action of the projective semi-linear goup on the support of these codes as shown in [19], [18]. By projective semi-linear group, we mean here transformations of the form: Basically when the support of the alternant code is invariant by the action of such a transformation and under a certain condition on the multiplier, it turns out that such a transformation induces a permutation automorphism of the alternant code. However, this action on the support may transform a coordinate of the support into ∞ and a slightly more general definition of generalized Reed-Solomon codes and of alternant codes is required to cope with this issue. This is why A. Dür introduced Cauchy codes in [20] which are in essence a further generalization of generalized Reed-Solomon codes. This construction allows to have ∞ in its support. To avoid such a technicality (and also to simplify some of the statements and propositions obtained here) we will only consider the subgroup of affine transformations of the projective semi-linear group. It should be noted however that this simplification permits to cover all the constructions of symmetric alternant or Goppa codes used in a cryptographic context [4], [5], [13], [1], [6] and in some cases even to generalize them. Namely, we will deal with the following cases: Definition 4 Let C be an alternant or Goppa code defined over a field F of length n, with an automorphism group G. Given a nonnegative integer λ n, we say that C is: Let us now reformulate some corollaries of the results obtained in [19], [18] in this particular case. The symmetric alternant or Goppa codes that will be obtained here correspond to permutation automorphisms of alternant or Goppa codes based on the action of affine maps x → ax + b on the support (x 0 , x 1 , . . . , x n−1 ) of the Goppa code or the alternant code. If this support is globally invariant by this affine map (and a is not equal to 0), then this induces a permutation σ of the code positions {0, 1, . . . , n − 1} by defining σ(i) as the unique integer in In such a case, we say that σ is the permutation induced by the affine map x → ax + b.
Restricting Theorem 1 of [18] to affine transformations yields immediately Proposition 3 Let a = 0 and b be elements of F q m . Let x ∈ F n q m be a support which is globally invariant by the affine map x → ax + b. Let σ be the permutation of S n induced by this affine map. Let ℓ be the order of σ. Assume that y ∈ (F q m ) n is an n-tuple of nonzero elements such that ∃ α ∈ F q m an ℓ-th root of unity such that y σ(i) = αy i , for all i ∈ {0, 1, . . . , n − 1}. Then σ is a permutation automorphism of the alternant code A t (x, y) for any degree t > 0.
If we want to obtain Goppa codes, we can apply this result and we just have to check that the conditions on the support x σ(i) = ax i + b and multiplier y σ(i) = αy i are compatible with the definition of the Goppa code, namely is the Goppa polynomial. These considerations yield immediately the following corollary of Proposition 3.

Corollary 1
Let a = 0 and b be elements of F q m with b = 0 when a = 1. Let x ∈ F n q m be a support which is globally invariant by the affine map x → ax + b. Let σ be the permutation of S n induced by this affine map and let ℓ be its order. Assume that there exists a polynomial Γ(z) and an ℓ-th root of unity α in F q m which is such that In such a case, σ is a permutation automorphism of the Goppa code G (x, Γ).
This proposition allows to obtain easily Goppa codes or alternant codes with a non trivial automorphism group that is cyclic.

Remark 1 One might wonder whether it is possible to characterize polynomials which satisfy Equation (1).
In [19,Theorem 4] a slightly more general polynomial equation is considered, namely Γ(az q s + b) = αΓ(z) q s . It is the particular case of s = m of Theorem 4 of [19] which is of interest to us here. However, since it deals with the classification of cyclic alternant codes (there is therefore a restriction on the order compared to the length which trivializes the solutions of this problem in many cases which are of interest to us) and since for further purposes it will be convenient for us to remove the assumption on Γ(z) to have no roots in {x 0 , . . . , x n−1 } which is done implicitly in Theorem 4 (and also in Lemma 2 of [19] that is used to prove Theorem 4) we can not use it in our case directly.
The characterization of the solution set to (1) we will use is the following.

Proposition 4
Let F be a field of finite characteristic p and let a, b, α be elements of F, such that (i) a = 0 and (ii) b = 0 when a = 1. All the polynomials Γ(z) ∈ F[z] satisfying Γ(az + b) = αΓ(z) have the following form The proof of this proposition can be found in Appendix A. By taking polynomials P in this proposition which are such that the resulting Γ(z) has no zeros in the support (x 0 , . . . , x n−1 ) we obtain Goppa codes with a cyclic permutation automorphism group. To obtain automorphism groups which are isomorphic to (Z/pZ) λ , for some λ 1, we need a slightly more general statement which is the following: Proof: All the shifts z → z + α i give rise to a permutation automorphism of the alternant code by Proposition 3 and they generate a group of order p λ from the independence assumption on the α i 's. The statement about Goppa codes follows by observing that the polynomial Γ(z) = Q (Π g∈G (z − g)) is invariant by all the shifts z → z + α i and by using Corollary 1.

Remark 2 1)
A support (x 0 , . . . , x n−1 ) satisfying the conditions of Proposition 5 is easily obtained by taking unions of cosets of G and getting a QD or a QM Goppa code is obtained by arranging the support as follows. We define The remaining x i 's are chosen as follows: It is readily checked that all the QD or QM constructions of Goppa codes of [5], [13], [1] are just special cases of this construction. It should be observed that the construction presented here is more general. In particular, Γ(z) does not need to split over F q m as in [5], [13], [1]. It may even be irreducible as shown by the example p = q = 2, G = F 2 , m odd and γ(z) = 1 + z.

2) By using our proof technique of Proposition 4 it can actually be shown that all polynomials Γ(z) invariant
by the shifts z → z + α i are actually polynomials of the form Q (Π g (z − g)).
From now on, we will say that the permutation automorphism group of an alternant code or a Goppa code that is obtained by such affine maps (be it a single affine map or a collection of them) is the permutation group induced by such affine maps. As observed in [18], an alternant code or a Goppa code can be invariant by a permutation which is not induced by an affine map or more generally by an element of the projective semilinear group. However, there is no general way of constructing this kind of permutation and it should also be noted that in the case of GRS or Cauchy codes, the whole permutation group is actually induced by the projective linear group, i.e. the set of transformations of the kind z → az+b cz+d (this is actually a consequence of Theorem 4 of [20]).

IV. AFFINE-INVARIANT POLYNOMIALS
The key ingredient which allows to reduce to smaller alternant codes or Goppa codes when these are either quasimonoidic or quasi-cyclic is a fundamental result on the form taken by polynomials which are invariant by an affine map. These polynomials will arise as sums of the form: where P is a polynomial, σ an affine map of order ℓ and α an ℓ-th root of unity. Such polynomial sums clearly satisfy polynomial Equation (1), since: Proposition 4 characterizes all solutions of the polynomial Equation (1). Conversely, and this will be crucial in our context, it turns out that all these solutions are of the form (3). To formalize this point, we introduce the following notation be the set of polynomials of degree t which satisfy (1), i.e. which satisfy P σ(z) = αP (z). When α = 1 we will simply write I σ t [z]. Finally, when t < 0 we adopt the convention that We will first consider the case when α = 1 and σ(x) = x + b.

Lemma 2
Let F be a field of characteristic p. Let b be a non zero element of F and denote by σ the shift σ : x → x + b. Denote by S the mapping defined by: We have for every nonnegative integer t: The proof of this lemma can be found in Appendix B. A similar result holds for affine maps of the form σ(x) = ax+b where a = 1.
If we denote by z 0 the unique fixed point of σ, we have: The proof of this lemma can be found in Subsection C of the appendix. 8 V. REDUCING TO A SMALLER ALTERNANT OR GOPPA CODE

A. Folded codes
Alternant codes and Goppa codes in particular with a certain non-trivial automorphism group (as considered in Proposition 3) meet a very peculiar property. Namely it is possible to derive a new alternant (or a Goppa code) with smaller parameters by simply summing up the coordinates. To define this new code more precisely, we introduce the following operator.
where c ranges over C . When G is generated by a single element σ, that is G =< σ >, we will simply write C σ instead of C <σ> and c σ instead of c <σ> .
This folded code is related to constructions which were considered in the framework of decoding codes with nontrivial automorphism group [24], [25]. The approach there was to consider for a code C with non-trivial permutation automorphism σ of order ℓ (which was supposed to be of order ℓ = 2 in [24], [25], but their approach generalizes easily to other orders) the σ-subcode C σ obtained as follows: If we denote by c σ def = c + c σ + · · · + c σ ℓ−1 then it turns out that c σ takes on a constant value on the orbit i, σ(i), σ 2 (i), . . . of any code position i that is precisely the term ℓ−1 t=0 c σ t (i) which appears in the definition of the folded code. Stated differently, the words of C σ are nothing but the words of C σ where each code coordinatec σ i of the latter code is repeated as many times as the size of the orbit of i under σ. These two codes have therefore the same dimension, but their lengths are different : the first one has the same length as C whereas the latter has length s (the number of orbits under σ). The point of considering such a code for decoding C lies in the fact that C σ is a subcode of C which is typically of much smaller dimension than C . Under mild assumptions, it can be shown that the dimension gets reduced by the order of σ. More precisely: Proposition 6 Let C be a code of length n that has a permutation automorphism group G of size ℓ and a generator matrix G such that if g i is a row of G then g σ i is also a row of G for any σ ∈ G. Denote by {g 0 , . . . , g k−1 } the set of rows of G. Consider the group action of G on the set {g 0 , . . . , g k−1 } of rows of G where σ acts on g j as g j → g σ j for σ ∈ G. Assume that the size of each orbit is equal to ℓ. Then, the dimension C G is equal to dim(C ) ℓ . This is also the dimension of C G and the length of this code is equal to n ℓ .
Proof: This follows at once from the fact that C G is generated by the set of g i G def = σ∈G g σ i where the g i 's are representatives of each orbit of G acting on {g 0 , . . . , g k−1 }. These vectors are clearly independent and there are dim(C ) ℓ such representatives. This implies that the dimension of C G is equal to dim(C ) ℓ . This is also clearly the dimension of C G and the length of the latter code is equal to n ℓ . [4], [5], [1], [13], [6].

Remark 3 A generator matrix of this form is precisely what is achieved by all the constructions of monoidic alternant/Goppa/Srivastava codes proposed in
This can be used to decode a word y by decoding instead y σ in C σ . The point is that this decoding can be less complex to perform than decoding y directly and that the result of the decoding can be useful to solve the original decoding problem, see [25].

B. Folding alternant codes with respect to a cyclic group
If we consider the monoidic alternant or Goppa codes constructed in [4], [5], [1], [13] they have typically length of the form n = n 0 ℓ, degree of the form r = r 0 ℓ and dimension of the form k = n − rm = ℓ(n 0 − r 0 m) where m is the extension degree of the alternant/Goppa code and ℓ is the size of the automorphism group of the code. The automorphism group of these codes satisfies the assumptions of Proposition 6 and therefore the folded code has length n 0 and dimension n 0 − r 0 m. This could suggest that these codes are alternant or Goppa codes of length n 0 and degree r 0 . In all our experiments we have noticed that this was indeed the case. We have proved in [21] a slightly weaker result, namely that in the case of a Goppa code obtained from the constructions of [5], [1], [13], the folded code is included in a Goppa code of length n 0 and degree r 0 . We will prove a significantly stronger result here, by considering instead the dual of these codes. It will turn out that the folded dual of those alternant or Goppa codes will be duals of alternant or Goppa codes and this even if the degree is not of the form r 0 ℓ. More precisely, we have:

Proof:
The case a = 1: remark first that the order ℓ of the permutation σ, which is the shift x → x + b in this case, is necessarily the characteristic p of F q m . Since the order of the multiplicative group of F q m , which is q m − 1, is coprime with the characteristic of F q m it follows that α is necessarily equal to 1 when a = 1. This implies that y is constant over each orbit {i, σ(i), . . . , σ ℓ−1 (i)}. From Lemma 1, the dual C of A t (x, y) is: The folded code of C can now be described as: . . , x n/ℓ−1 are representatives of each of the n/ℓ orbits {u, σ(u), . . . , σ ℓ−1 (u)} (they have all the same size ℓ). By using Lemma 2, we obtain: By using Lemma 1 again, we see that C σ = A r (x ′ , y ′ ) ⊥ with r = t−p p + 1 and for any j ∈ {0, 1, . . . , n/ℓ − 1}, The case a = 1: the difference with the previous situation lies in the fact that now the y j 's are not necessarily constant over an orbit. As previously, we consider representatives x i0 , x i1 , . . . , x n/ℓ−1 of the n/ℓ orbits {u, σ(u), . . . , σ ℓ−1 (u)} (they have here again all the same size ℓ because the support x does not contain the fixed point of σ). We obtain that the folded code of C can now be described as follows.
By introducing the fixed point u 0 of σ, we obtain: We necessarily have α ℓ = 1. Since a is a primitive ℓ-root of unity, there exists an integer d in {0, . . . , ℓ − 1} such that α = a d . This yields: By using Lemma 3, we deduce that: Finally, by Lemma 1 again we see that

Remark 4 In essence, we have proved here that folding a GRS code with a non trivial automorphism group obtained from affine transformations yields again a GRS code. Indeed, the dual of an alternant code is the trace of a GRS code. When we choose the extension degree to be equal to 1 we really prove here that folding such a symmetric GRS code yields again a GRS code. Taking the trace preserves this property : the folding of a trace of a symmetric GRS code is again the trace of a GRS code. The crucial point which explains why such a property holds is the fact that the ring of polynomial in F[x] invariant by an affine transformation σ is a ring of the form F[Q(x)]
for some polynomial Q which is invariant by σ. This is what allows to write a sum of the form ℓ−1 i=0 P (σ i (x)) as a polynomial of the form R(Q(x)).
One might wonder whether folding a subfield subcode of a GRS code (i.e. an alternant code) also yields a subfield subcode of a GRS code. While the proof technique used here obviously allows to prove that a folded subfield subcode of a symmetric GRS code lies in a subfield subcode of a certain subcode, proving equality of both codes seems to be more delicate here. This point can be explained as follows. Consider an alternant code A r (x, y) defined over F q and of extension degree m where x is globally invariant by some σ and y is constant on the orbits on σ (we make this assumption to simplify the discussion). To prove equality that the folded alternant code is still an alternant code we should be able to express a polynomial Q(z) in F q m [z] which is invariant by σ and which is such that y i Q(x i ) belongs to F q for any i as a sum Q(x) = ℓ−1 j=0 P (σ j (x)) where all the y i P (σ j (x i )) belong to F q for any i and j and where P is some polynomial which depends on Q.

C. Folding alternant codes with respect to non-cyclic groups
We have treated the case of folding an alternant code with respect to a group generated by a single element. The group of automorphism might not be cyclic. This happens in particular in the case of the Goppa codes in [5], [1], [13]: in such a case the automorphism group is isomorphic to (Z/pZ) λ . Treating the general case of a subgroup of the affine subgroup is beyond the scope of this article, we will just consider the case of a subgroup which is isomorphic to (Z/pZ) λ . This follows at once from Theorem 1 by noticing that we may fold iteratively the code with respect to λ generators of the subgroup and end up with an alternant code. We use here the straightforward fact Lemma 4 Consider a code C and a group of permutations G acting on the positions of C and assume that this permutation group has a subgroup G 0 and an element σ of G which does not belong to G 0 such that: 2) σ commutes with any element of G 0 .
Then σ induces a permutation on the set of positions of C G0 that we callσ which is defined as follows. We view a code position i of C G0 as an orbit {τ (u), τ ∈ G 0 } for some code position u of C andσ(i) is given by the orbit {τ (σ(u)), τ ∈ G 0 }. If the order ofσ is equal to the order ℓ of σ and for an appropriate order on the choices of the representatives for the orbits under <σ >, G 0 and G, we have Proof: First we have to check that the definition ofσ(u) makes sense, i.e. that it does not depend on the choice of u in the orbit {τ (u), τ ∈ G 0 }. This follows from the fact that σ commutes with any element of G 0 . Indeed assume that we have: then we clearly have u = τ 0 (v) for a certain τ 0 in G 0 . From that we deduce: This shows thatσ is well-defined. We let i 0 , i 1 , . . . , i s−1 be a set of representatives of each orbit of the code positions of C under G 0 (we assume that there are s orbits) and we assume that the set of code positions 0, 1, . . . , s − 1 of C G0 corresponds to i 0 , i 1 , . . . , i s−1 in this order. Consider now an element c in C and let c ′ be the folding of c with respect to G 0 , that is: If we fold c ′ with respect toσ we obtain an element c ′′ defined by: where i ′ 0 , i ′ 1 , . . . , i ′ t−1 are the representatives of the orbits of the code positions of C G0 underσ. Notice that we have used here the fact that the order ofσ is equal to the order of σ. By observing that the code position i ′ j of C G0 corresponds to some orbit {τ (u), τ ∈ G 0 } and putting (8) and (9) together with the characterization of the action ofσ, we obtain: This implies that c ′′ j is equal to some coordinate of c G .
It remains to show that there is a one-to-one and onto mapping from the set of coordinates of c ′′ and those of c G . In order to do so we are going to prove that there is a one-to-one mapping between the orbits underσ and the orbits under G. This is a straightforward consequence of the following observation. Consider an orbit O = {τ (s), τ ∈ G} under G. It decomposes as a union of orbits These orbits O h form a single orbit underσ and we are done. A straightforward consequence of this is the following Corollary 2 Consider a code C which is the dual of an alternant code with an affine-induced permutation group G isomorphic to (Z/pZ) λ where p is the characteristic of the field over which the alternant code is defined. Then C G is the dual of an alternant code.
Proof: In such a case, there exists g 1 , . . . , g λ of order p that generate G. We proceed by induction and assume that this property holds for λ = h. When h = 1, this is just Theorem 1. Consider now a group G isomorphic to (Z/pZ) h+1 . We observe that G 0 def =< g 1 , . . . , g h > and σ = g h+1 satisfy the assumptions of Lemma 4, so we can apply it to this case and obtain that: Since by induction hypothesis C G0 is the dual of an alternant code and sinceσ is clearly an affine induced permutation automorphism of C G0 we can apply Theorem 1 to it and obtain that the result of the folding of C G0 byσ gives an alternant code again. All the duals of the codes used in the following variants of the McEliece cryptosystem, namely the dyadic Goppa codes of [5], [13], the monoidic Goppa codes of [1] or the dyadic Srivastava codes of [6] are instances of alternant codes which have an affine induced permutation group isomorphic to (Z/pZ) λ and this corollary can be applied to reduce attacks on the key to a much smaller key recovery problem (namely on the dual of the code obtained by folding). One might also wonder when we fold certain subfamilies of duals of alternant codes with respect to an affine-induced permutation automorphism group, such as duals of Goppa codes, we stay in the subfamily, i.e. do we still obtain the dual of a Goppa code? This turns out to be the case as shown by the next subsection.

D. Folding Goppa codes
Folding the dual of a Goppa code with an affine-induced automorphism group yields the dual of an alternant code by using Corollary 2. It turns out that a stronger statement holds: we actually obtain the dual of a Goppa code, both in the cyclic case as shown by the following theorem and when the group is isomorphic to (Z/pZ) λ as shown later on.
Theorem 2 Consider a Goppa code C = G (x, Γ(z)) of length n associated to the support x = (x i ) 0 i<n ∈ F n q m which has a cyclic affine induced automorphism group generated by σ(x) def = ax + b where a, b ∈ F q m . We assume that a = 0, b = 0 if a = 1, and that the fixed point u 0 of σ does not belong to {x 0 , . . . , x n−1 }. Let ℓ be the order of σ. In such a case: 1) ℓ divides n and let s def = n/ℓ. There are exactly s orbits for the action of σ on the code positions. We denote by i 0 , i 1 , . . . , i n/ℓ−1 a set of representatives for each orbit; 2) (C ⊥ ) σ is the dual of the Goppa code G (x ′ , γ(z)) with: where d, in the last case, is the unique integer in {0, . . . , ℓ − 1} such that α = a d and α is the element of F q m which satisfies the polynomial identity Γ(az + b) = αΓ(z).
Proof: We will distinguish between a = 1 and a = 1. In both cases, notice that we can apply Theorem 1 to C which is an alternant code A t (x, y) where t is the degree of Γ and y i = 1 Γ(xi) . This is a consequence of the definition of a Goppa code with an affine induced automorphism σ(x) = ax + b : this is a Goppa code obtained from the construction of Proposition 3 and this is precisely what is needed (together with the fact that the support does not contain the fixed point of σ) for applying Theorem 1 to it. In all cases, folding the dual of C gives the dual of an alternant code of the form A t ′ (x ′ , y ′ ) for some integer t ′ and some x ′ , y ′ in F s q m . Moreover in both cases, there exists an ℓ-th root of 1 that we denote by α which is such that the Goppa polynomial satisfies the identity Γ(az + b) = αΓ(z).
Case a = 1 : ℓ is equal to the characteristic p of the field F q m , α is necessarily equal to 1, Γ(z) is of degree a multiple of p and is of the form Γ(z) = γ(z p − b p−1 z). Notice that y satisfies: = y i and using Theorem 1 gives that y ′ j = y ij and therefore: Case a = 1 : there exists a unique integer d in the range [0, . . . , ℓ − 1] such that α = a d and Γ(z) is of the form Notice that in such a case: We use Theorem 1 and obtain: When the group is isomorphic to (Z/pZ) λ we have the following statement Theorem 3 Consider a Goppa code C = G (x, Γ) with an affine induced automorphism group G isomorphic to (Z/pZ) λ where p is the characteristic of the field over which the Goppa code is defined, then the folding (C ⊥ ) G is the dual of a Goppa code G (x ′ , γ(z)) where the degree deg(γ) of γ is equal to deg(Γ) p λ .
Proof: We proceed similarly to the proof of Corollary 2. First we notice that there exists g 1 , . . . , g λ of order p that generate G. We proceed by induction and assume that this property holds for λ = h. When h = 1, this is just Theorem 2 (since g 1 is necessarily induced by an affine transformation of the form x → x + β which has no fixed point in the extension field in which the coordinates of the multiplier live). Consider now a group G isomorphic to (Z/pZ) h+1 . We observe that G 0 def =< g 1 , . . . , g h > and σ = g h+1 satisfy the assumptions of Lemma 4, so we can apply it to this case and obtain that: Since by induction hypothesis C G0 is the dual of a Goppa code of degree deg(Γ) p h and sinceσ is clearly an affine induced permutation automorphism of C G0 we can apply Theorem 2 to it and obtain that the result of the folding of C G0 byσ gives the dual of a Goppa code of degree deg(Γ) p h+1 .

VI. CONCLUSION -CRYPTOGRAPHIC IMPLICATIONS
The results presented on this paper have some significant consequences on a recent research trend which consists in devising McEliece schemes with reduced public key size. This is achieved by relying on QD/QM Goppa codes or QC alternant codes [4], [5], [13], [1]. Some of them were attacked by the algebraic attack introduced in [9], [11] where it was proved that the QD or the QC structure allowed to set up an algebraic system which could be solved by Gröbner bases techniques thanks to the reduction of unknowns obtained in this case compared to an unstructured McEliece scheme. Our result actually explains where this reduction in the number of unknowns comes from: there is in fact a smaller hidden Goppa (or alternant) code behind the public generator or parity-check matrix of the scheme. Moreover it is shown in [21] that a key recovery attack on the reduced cryptosystem can be used to recover the secret key of the original cryptosystem. This implies that a key-recovery on QD and QM schemes is not harder than a key-recovery on a reduced McEliece scheme where all parameters have been scaled down by a factor of p, which is the compression factor allowed by the QC, QD or QM structure. For instance, we can reduce the key-recovery of a QD Goppa code of length 8192 and dimension 4096 (parameters suggested in [5]) to the key-recovery on a QD Goppa code of length 64 and dimension 32. In other words, the very reason which allowed to design compact variants of McEliece can be used to attack such schemes much more efficiently.
Our result does not rule out the possibility of devising alternant or Goppa codes with a non trivial automorphism group for which folding does not produce an alternant or a Goppa code: it only applies to such codes with an affine induced automorphism group. Symmetric codes of this kind could be obtained from the action of the semi-linear projective group on the support instead of the affine group (see Section III).
It is an open question to understand if folding such symmetric codes yields again Goppa or alternant codes, but obviously even treating the case of the linear projective group (obtained from the transformations of the kind z → az+b cz+d ) needs much more general tools than those that have been considered here and is beyond the scope of this paper. It should also be added that this result does not mean that all compact key McEliece cryptosystems based on alternant or Goppa codes with an affine induced automorphism group are weak. It just means that the key security is not better than the key security of a reduced scheme obtained from the folding process. Since key recovery attacks are generally more expensive that message recovery attacks it might be possible to choose secure parameters for which we still obtain a good reduction of the key size where key recovery attacks on the folded key are of the same complexity as message recovery attacks on the original scheme. However this thread of research requires great care since there has been some recent progress on key recovery attacks, see [21], [26] for instance.

A. Proof of Proposition 4
We will first characterize the solutions to Equation (1) in the case where α = 1. In some sense, this characterization generalizes a classical result about even polynomials, i.e. polynomials P (z) which satisfy P (z) = P (−z). It is namely well known that a polynomial is even if and only if there exists a polynomial Q such that P (z) = Q(z 2 ). Lemma 5, which uses the notation I σ t [z] that is defined in Section IV, will generalize this result to any polynomial invariant under a finite order affine map.

Lemma 5
Let σ(z) = az + b be an affine map of finite order ℓ (with ℓ > 1) defined over a field F. We have In other words, the ring of polynomials invariant by an affine map is generated by a single element and the lemma provides this generator explicitly. This result follows from classical results in invariant theory and we derive it from scratch here to keep the paper self-contained. Also, we treat the case where the order ℓ of the group generated by σ is divisible by the characteristic of F. This is precisely what happens when a = 1, and that is commonly avoided in invariant theory (see for instance [ . If a = 1, consider a polynomial P of degree t of the form P (z) = Q(z ℓ − b ℓ−1 z) for some polynomial Q. We have: We just used the fact that ℓ is the characteristic of F and therefore (z + b) ℓ = z ℓ + b ℓ . In the case a = 1, if we consider a polynomial P of degree t of the form P (z) = Q (z − z 0 ) ℓ for some polynomial Q of degree deg P/ℓ we obtain: We used the fact that ℓ is also the order of a. Let us prove now the reverse inclusion. Let P be a polynomial which is invariant by σ. Consider now a non constant polynomial R of smallest degree which is invariant by σ. Such a polynomial necessarily exists since the set of polynomials which are non constant and which are invariant by σ is non empty (since z ℓ − b ℓ−1 z in the case a = 1 and (z − z 0 ) ℓ in the case a = 1, belong to it). Perform the division of P by R. We can write P (z) = R(z)P 1 (z) + P 2 (z) with deg P 2 < deg R. Observe now that P (az + b) = R(az + b)P 1 (az + b) + P 2 (az + b).
Since P (az + b) = P (z) and R(az + b) = R(z) we deduce by subtracting the second equation to the first one, that we have R(z) (P 1 (az + b) − P 1 (z)) = P 2 (z) − P 2 (az + b) Since the degree of S(z) def = P 2 (z) − P 2 (az + b) is less than the degree of R, this can only happen if P 1 is invariant under σ and therefore also P 2 . Since R is a non constant polynomial of smallest degree which is invariant under σ and since deg P 2 < deg R, this implies that P 2 is constant. By carrying on this process (i.e. dividing P 1 by R) we eventually obtain that P is a polynomial in R. We finish the proof by proving that R can be chosen to be R(z) = z ℓ − b ℓ−1 z in the case a = 1 and R(z) = (z − z 0 ) ℓ otherwise.
Let us first prove this for a = 1. We can add any constant to R, it will still be invariant under σ. We may therefore assume that R(0) = 0. We can also assume that R is monic. Let us observe now that 0 = R(0) = R(b) = R(2b) = . . . = R (ℓ − 1)b by the invariance of R under z → z + b. This implies that R is a multiple of z(z − b) · · · (z − b(ℓ − 1)). R is therefore of degree greater than or equal to ℓ. The polynomial z ℓ − b ℓ−1 z is of degree ℓ, is invariant under σ and is a multiple of z(z − b) . . . (z − b(ℓ − 1)). Therefore R(z) = z ℓ − b ℓ−1 z.
Consider now the case a = 1. Without loss of generality (by adding a suitable constant as in the case a = 0) we may assume that R(c) = 0, where c is some element of F such that the orbit of c under σ is of size ℓ. By the invariance of R under σ this implies that 0 = R(c) = R(σ(c)) = · · · = R σ ℓ−1 (c) . This implies that R(z) is divisible by (z − c)(z − σ(c)) · · · z − σ ℓ−1 (c) . Therefore R is of degree ℓ at least. Since (z − z 0 ) ℓ is of degree ℓ and is invariant by σ we can choose R(z) = (z − z 0 ) ℓ . This proves Proposition 4 when α = 1. Let us prove now this proposition in general.
Proof of Proposition 4: Denote by σ the affine map z → az + b. First of all, let us notice that if there exists some polynomial P (z) satisfying the equation P (σ(z) = αP (z) for some α, then necessarily such an α satisfies α ℓ = 1. This follows at once from the fact that we have P (z) = P σ ℓ (z) = α d P (z). This also implies that the order of α divides ℓ. There are now two cases to consider. Case a = 1: then the order ℓ of σ is necessarily equal to the characteristic of F and there is no element, apart from 1, whose order divides ℓ. In this case, Lemma 5 implies Proposition 4. Case a = 1: in such a case the order of a is equal to ℓ and a is a primitive ℓ-th root of unity. Since α is an ℓ-th root of unity, there exists in this case an integer d in the range [0, . . . , ℓ − 1] such that α = a d . Consider now a polynomial which is such that P (σ(z)) = αP (z).
Putting both equations together, we obtain P 1 (az + b) = a d−1 P 1 (z) If d = 1 we can carry on this process on P 1 , deduce from the previous equation that P 1 (z 0 ) = 0 and deduce by induction on d that P (z) has a zero of order at least d at z 0 and that the polynomial P d (z) defined by P d (z) = P (z) (z−z0) d satisfies the equation P d (az + b) = P d (z).
We apply Lemma 5 to P d and derive from it that P should be of the form This together with (14) implies that S(F t ) = I t−p+1 p p [x], which concludes the proof.

C. Proof of Lemma 3
Proof: Let us calculate This sum is equal to 0 as long as d + t ≡ 0 (mod ℓ) and is equal to (ℓ mod p) (z − u 0 ) t when d + t ≡ 0 (mod ℓ).
The polynomial S P (z) is therefore a polynomial of degree ℓ − d + deg P −ℓ+d ℓ ℓ of the form when deg P ℓ−d and is equal to zero otherwise. We conclude the proof by noting that the term ⌊ deg P −ℓ+d ℓ ⌋ i=0 a i (z− u 0 ) iℓ is a polynomial which is invariant by σ by Lemma 5.