Brice Minaud
email: brice.minaud@gmail.com

Patrick Derbez
email: patrick.derbez@uni.lu

Pierre-Alain Fouque
email: pierre-alain.fouque@ens.fr

Pierre Karpman
email: pierre.karpman@inria.fr

la diffusion de documents scientifiques de niveau

Keywords: ASASA, Algebraic Cryptanalysis, Multivariate Cryptography, LPN

recherche, publiés ou non, émanant des établissements d'enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

Introduction

The idea of creating a public-key cryptosystem by obfuscating a secret-key cipher was proposed by Diffie and Hellman in 1976, in the same seminal paper that introduced the idea of public-key encryption [START_REF] Diffie | Multiuser cryptographic techniques[END_REF]. While the RSA cryptosystem was introduced only a year later, creating a public-key scheme based on symmetric components has remained an open challenge to this day. The interest of this problem is not merely historical: beside increasing the variety of available public-key schemes, one can hope that a solution may help bridge the performance gap between public-key and secret-key cryptosystems, or at least offer new trade-offs in that regard.

Multivariate cryptography is one way to achieve this goal. This area of research dates back to the 1980's [START_REF] Matsumoto | Public Quadratic Polynomial-Tuples for Efficient Signature-Verification and Message-Encryption[END_REF][START_REF] Fell | Analysis of a Public Key Approach Based on Polynomial Substitution[END_REF], and has been particularly active in the late 1990's and early 2000's [Pat95, Pat96, RP97, FJ03, . . . ]. Many of the proposed public-key cryptosystems build an encryption function from a structured, easily invertible polynomial, which is then scrambled by affine maps (or similarly simple transformations) applied to its input and output to produce the encryption function.

This approach might be aptly described as an ASA structure, which should be read as the composition of an affine map "A", a nonlinear transformation of low algebraic degree "S" (not necessarily made up of smaller S-boxes), and another affine layer "A". The secret key is the full description of the three maps A, S, A , which makes computing both ASA and (ASA ) -1 easy. The public key is the function ASA as a whole, which is described in a generic manner by providing the polynomial expression of each output bit in the input bits (or group of n bits if the scheme operates on F 2 n ). Thus the owner of the secret key is able to encrypt and decrypt at high speed (provided that S admits an efficient expression). The downside is slow public key operations, and a large key size.

The ASASA construction. Historically, most attempts to build public-key encryption schemes based on the above principle have been ill-fated [FJ03, BFP11, DGS07, DFSS07, WBDY98, . . . ] 1 . However several new ideas to build multivariate schemes were recently introduced by Biryukov, Bouillaguet and Khovratovich at Asiacrypt 2014 [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF]. The paradigm federating these new ideas is the so-called ASASA structure: that is, combining two quadratic mappings S by interleaving random affine layers A. With quadratic S layers, the overall scheme has degree 4, so the polynomial description provided by the public key remains of reasonable size. This is very similar to the 2R scheme by Patarin [START_REF] Patarin | Asymmetric Cryptography with S-Boxes[END_REF], which fell victim to several attacks [Bih00, DFKYZD99], including a powerful decomposition attack [START_REF] Ding-Feng | Cryptanalysis of "2R" Schemes[END_REF][START_REF] Faugère | Cryptanalysis of 2R-Schemes[END_REF] (later developed in a general context by Faugère et al. [START_REF] Faugère | Decomposition of Generic Multivariate Polynomials[END_REF][START_REF] Faugère | An Efficient Algorithm for Decomposing Multivariate Polynomials and its Applications to Cryptography[END_REF][START_REF] Faugère | High Order Derivatives and Decomposition of Multivariate Polynomials[END_REF]). The general course of this attack is to differentiate the encryption function, and observe that the resulting polynomials in the input bits live in a "small" space entirely determined by the first ASA layers. This essentially allows the scheme to be broken down into its two ASA sub-components, which are easily analyzed once isolated. A later attempt to circumvent this and other attacks by truncating the output of the cipher proved insecure against the same technique [FP06] -roughly speaking truncating does not prevent the derivative polynomials from living in too small a space.

In order to thwart attacks including the decomposition technique, the authors of [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF] propose to go in the opposite direction: instead of truncating the cipher, a perturbation is added, consisting in new random polynomials of degree four added at fixed positions, prior to the last affine layer2 . The idea is that these new random polynomials will be spread over the whole output of the cipher by the last affine layer. When differentiating, the "noise" introduced by the perturbation polynomials is intended to drown out the information about the first quadratic layer otherwise carried by the derivative polynomials, and thus foil the decomposition attack.

Based on this idea, two public-key cryptosystems are proposed. One uses random quadratic expanding S-boxes as nonlinear components, while the other relies on the χ function, most famous for its use in the SHA-3 winner Keccak. However the first scheme was broken at Crypto 2015 by a decomposition attack [START_REF] Gilbert | Key-Recovery Attack on the ASASA Cryptosystem With Expanding S-Boxes[END_REF]: the number of perturbation polynomials turned out to be too small to prevent this approach. This leaves open the question of the robustness of the other cryptosystem, based on χ, to which we answer negatively.

Black-box ASASA. Besides public-key cryptosystems, the authors of [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF] also propose a secretkey ("black-box") scheme based on the ASASA structure, showcasing its versatility. While the structure is the same, the context is entirely different. This black-box scheme is in fact the exact counterpart of the SASAS structure analyzed by Biryukov and Shamir [START_REF] Biryukov | Structural Cryptanalysis of SASAS[END_REF]: it is a block cipher operating on 128-bit inputs; each affine layer is a random affine map on F 128 2 , while the nonlinear layers are composed of 16 random 8-bit S-boxes3 . The secret key is the description of the three affine layers, together with the tables of all S-boxes.

In some sense, the "public key" is still the encryption function as a whole; however it is only accessible in a black-box way through known or chosen-plaintext or ciphertext attacks, as any standard secret-key scheme. A major difference however is that the encryption function can be easily distinguished from a random permutation because the constituent S-boxes have algebraic degree at most 7, and hence the whole function has degree at most 49; in particular, it sums up to zero over any cube of dimension 50. The security claim is that the secret key cannot be recovered, with a security parameter evaluated at 128 bits.

White-box ASASA. The structure of the black-box scheme is also used as a basis for several whitebox proposals. In that setting, a symmetric (black-box) ASASA cipher with small block (e.g. 16 bits) is used as a super S-box in a design with a larger block. A white-box user is given the super S-box as a table. The secret information consists in a much more compact description of the super S-box in terms of alternating linear and nonlinear layers. The security of the ASASA design is then expected to prevent a white-box user from recovering the secret information.

Our contribution

Algebraic attack on the secret-key and χ-based public-key schemes. Despite the difference in nature between the χ-based public-key scheme and the black-box scheme, we present a new algebraic key-recovery attack able to break both schemes at once. This attack does not rely on a decomposition technique. Instead, it may be regarded as exploiting the relatively low degree of the encryption function, coupled with the low diffusion of nonlinear layers. Furthermore, in the case of the public-key scheme, the attack applies regardless of the amount of perturbation. Thus, contrary to the attack of [START_REF] Gilbert | Key-Recovery Attack on the ASASA Cryptosystem With Expanding S-Boxes[END_REF], there is no hope of patching the scheme by increasing the number of perturbation polynomials. As for the secret-key scheme, our attack may be seen as a counterpart to the cryptanalysis of SASAS in [START_REF] Biryukov | Structural Cryptanalysis of SASAS[END_REF], and is structural in the same sense.

While the same attack applies to both schemes, their respective bottlenecks for the time complexity come from different stages of the attack. For the χ scheme, the time complexity is dominated by the need to compute the kernel of a binary matrix of dimension 2 13 , which can be evaluated to 2 39 basic linear operations4 . As for the black-box scheme, the time complexity is dominated by the need to encrypt 2 63 chosen plaintexts, and the data complexity follows.

This attack actually only peels off the last linear layer of the scheme, reducing ASASA to ASAS. In the case of the black-box scheme, the remaining layers can be recovered in negligible time using Biryukov and Shamir's techniques [START_REF] Biryukov | Structural Cryptanalysis of SASAS[END_REF]. In the case of the χ scheme, removing the remaining layers poses non-trivial algorithmic challenges (such as how to efficiently recover quadratic polynomials

A, B, C ∈ F 2 [X 1 , . . . , X n ]/ X 2 i -X i , given A + B • C),
and some of the algorithms we propose may be of independent interest. Nevertheless, in the end the remaining layers are peeled off and the secret key is recovered in time complexity negligible relative to the cost of removing the first layer.

We view the attack above as our main result. In addition, we offer two secondary contributions.

LPN-based attack on the χ scheme. As a second contribution, we present an entirely different attack, dedicated to the χ public-key scheme. This attack exploits the fact that each bit at the output of χ is "almost linear" in the input: indeed the nonlinear component of each bit is a single product, which is equal to zero with probability 3/4 over all inputs. Based on this property, we are able to heuristically reduce the problem of breaking the scheme to an LPN-like instance with easy-to-solve parameters. By LPN-like instance, we mean an instance of a problem very close to the Learning Parity with Noise problem (LPN), on which typical LPN-solving algorithms such as the Blum-Kalai-Wasserman algorithm (BKW) [START_REF] Blum | Noise-tolerant learning, the parity problem, and the statistical query model[END_REF] are expected to immediately apply. The time complexity of this approach is higher than the previous one, and can be evaluated at 2 56 basic operations. However it showcases a different weakness of the χ scheme, providing a different insight into the security of ASASA constructions. In this regard, it is noteworthy that the security of another recent multivariate scheme, presented by Huang et al. at PKC 2012 [START_REF] Huang | Public-Key Cryptography from New Multivariate Quadratic Assumptions[END_REF], was also reduced to an easy instance of LWE [START_REF] Regev | On Lattices, Learning with Errors, Random Linear Codes, and Cryptography[END_REF], which is an extension of LPN, in [AFF + 14]5 .

Heuristic attack on the white-box scheme. Finally as a side result, we describe a key-recovery attack on white-box ASASA. The attack technique is unrelated to the previous ones, and it relies on heuristics rather than a theoretical model. On the other hand it is very effective on the smallest white-box instances of [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF] (with a security level of 64 bits), which we break under a minute on a laptop computer. Thus it seems that the security offered by small-block ASASA is much lower than anticipated.

Related Work.

The first attack on an ASASA scheme from [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF] was a decomposition attack targeting the expanding public-key scheme [START_REF] Gilbert | Key-Recovery Attack on the ASASA Cryptosystem With Expanding S-Boxes[END_REF], as mentioned in the introduction. Our techniques are entirely different, and target all ASASA schemes from [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF] except the one already broken in [START_REF] Gilbert | Key-Recovery Attack on the ASASA Cryptosystem With Expanding S-Boxes[END_REF].

Another attack on white-box schemes was found independently by Dinur, Dunkelman, Kranz and Leander [START_REF] Dinur | Decomposing the asasa block cipher construction[END_REF]. Their approach focuses on small-block ASASA instances, and is thus only applicable to the white-box scheme of [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF]. Section 5 of [START_REF] Dinur | Decomposing the asasa block cipher construction[END_REF] is essentially the same attack as ours, minus the heuristic improvements from our Section 6.3, which allow us, for instance, to break the 20bit instance in practice with very limited means using this approach. On the other hand, the authors of [START_REF] Dinur | Decomposing the asasa block cipher construction[END_REF] present other methods to attack small-block ASASA instances that are less reliant on heuristics, but as efficient as our heuristically improved variant, and thus provide a better theoretical basis for understanding small-block ASASA, as used in the white-box scheme of [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF].

A very interesting follow-up work by Alex Biryukov and Dmitry Khovratovich shows that our attack on black-box ASASA can be extended to longer structures, even SASASASAS for some parameters [START_REF] Biryukov | Decomposition attack on SASASASAS[END_REF]. The main obstacle is the degree of the overall function, which is bounded using results by Boura and Canteaut on the degree of composite functions [START_REF] Boura | On the influence of the algebraic degree of on the algebraic degree of. Information Theory[END_REF].

Structure of the article

Section 3 provides a brief description of the three ASASA schemes under attack. In Section 4, we present our main attack, as applied to the secret-key ("black-box") scheme. In particular, an overview of the attack is given in Section 4.1. The attack is then adapted to the χ public-key scheme in Section 5.1, while the LPN-based attack on the same scheme is presented in Section 5.2. Finally, our attack on the white-box scheme is presented in Section 6.

Implementation

Implementations of our attacks have been made available at:

http://asasa.gforge.inria.fr/

Notation and preliminaries

The sign = denotes an equality by definition. |S| denotes the cardinality of a set S. The log() function denotes logarithm in base 2. Binary vectors. We write F 2 for the finite field with two elements. The set of n-bit vectors is denoted interchangeably by {0, 1} n or F n 2 . However the vectors are always regarded as elements of F n 2 with respect to addition + and dot product •|• . In particular, addition should be understood as bitwise XOR. The canonical basis of F n 2 is denoted by e 0 , . . . , e n-1 . For any v ∈ {0, 1} n , v i denotes the i-th coordinate of v. In this context, the index i is always computed modulo n, so v 0 = v n and so forth. Likewise, if F is a mapping into {0, 1} n , F i denotes the i-th bit of the output of F . For a ∈ {0, 1} n , F |a is a shorthand for the function x → F (x)|a . For any v ∈ {0, 1} n , v k denotes the truncation (v 0 , . . . , v k-1 ) of v to its first k coordinates. For any bit b, b stands for b + 1.

Derivative of a binary function.

For F : {0, 1} m → {0, 1} n and δ ∈ {0, 1} m , we define the derivative of F along δ as ∂F/∂δ = x → F (x)+F (x+δ). We write ∂ d F/∂v 0 . . . ∂v d-1 = ∂(. . . (∂F/∂v 0 ) . . . )/∂v d-1 for the order-d derivative along v 0 , . . . , v d-1 ∈ {0, 1} m . For convenience we may write F instead of ∂F/∂v when v is clear from the context; likewise for F . The degree of F i is its degree as an element of F 2 [X 0 , . . . , X m-1 ]/ X 2 i -X i in the binary input variables. The degree of F is the maximum of the degrees of the F i 's.

Cube. A cube of dimension d in {0, 1} n is simply an affine subspace of dimension d. The terminology comes from [START_REF] Dinur | Cube Attacks on Tweakable Black Box Polynomials[END_REF]. Note that summing a function F over a cube C of dimension d, i.e. computing c∈C F (c), amounts to computing the value of an order-d differential of F at a certain point: it is equal to ∂ d F/∂v 0 . . . ∂v d-1 (a) for a, (v i ) such that C = a + span{v 0 , . . . , v d-1 }. In particular if F has degree d, then it sums up to zero over any cube of dimension d + 1.

Bias. For any probability p ∈ [0, 1], the bias of p is |2p -1|. Note that the bias is sometimes defined as |p -1/2| in the literature. Our choice of definition makes the formulation of the Piling-up Lemma more convenient:

Lemma 1 (Piling-up Lemma [START_REF] Matsui | Linear Cryptanalysis Method for DES Cipher[END_REF]). For X 1 , . . . , X n independent random binary variables with respective biases b 1 , . . . , b n , the bias of X =

X i is b = b i .
Learning Parity with Noise (LPN). The LPN problem was introduced in [BKW03], and may be stated as follows: given (A, As + e), find s, where:

-s ∈ F n 2 is a uniformly random secret vector. -A ∈ F N ×n 2 is a uniformly random binary matrix. -e ∈ F N
2 is an error vector, whose coordinates are chosen according to a Bernoulli distribution with parameter p.

Description of ASASA schemes

Presentation and notations

ASASA is a general design scheme for public or secret-key ciphers (or cipher components). An ASASA cipher is composed of 5 interleaved layers: the letter A represents an affine layer, and the letter S represents a nonlinear layer (not necessarily made up of smaller S-boxes). Thus the cipher may be pictured as in Fig. 1. We borrow the notation of [START_REF] Gilbert | Key-Recovery Attack on the ASASA Cryptosystem With Expanding S-Boxes[END_REF] and write the encryption function F as: Moreover, x = (x 0 , . . . , x n-1 ) is used to denote the input of the cipher; x is the output of the first affine layer A x ; and so on as in Fig. 1. The variables x i , y i , etc., will often be viewed as polynomials over the input bits (x 0 , . . . , x n-1 ). Similarly, F denotes the whole encryption function, while F y = S x •A x is the partial encryption function that maps the input x to the intermediate state y, and likewise

F = A z • S y • A y • S x • A x x x y y z z A x S x A y S y A z
F x = A x , F y = A y • S x • A x , etc.
One secret-key ("black-box") and two public-key ASASA ciphers are presented in [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF]. The secret-key and public-key variants are quite different in nature, even though our main attack applies to both. We now present, in turn, the black-box construction, and the public-key variant based on χ.

Description of the black-box scheme

It is worth noting that the following ASASA scheme is the exact counterpart of the SASAS structure analyzed by Biryukov and Shamir [START_REF] Biryukov | Structural Cryptanalysis of SASAS[END_REF], with the affine layer taking the place of the S-box one and vice-versa. Black-box ASASA is a secret-key encryption scheme, parameterized by m, the size of the S-boxes and k, the number of S-boxes. Let n = km be the block size of the scheme (in bits). The overall structure of the cipher follows the ASASA construction, where the layers are as follows:

-A x , A y , A z are a random invertible affine mappings F n 2 → F n 2 .
Without loss of generality, the mappings can be considered purely linear, because the affine constant can be integrated into the preceding or following S-box layer. In the remainder we assume the mappings to be linear. -S x , S y are S-box layers. Each S-box layer consists in the application of k parallel random invertible m-bit S-boxes.

All linear layers and all S-boxes are chosen uniformly and independently at random among invertible elements.

In the concrete instance of [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF], each S-box layer contains k = 16 S-boxes over m = 8 bits each, so that the scheme operates on blocks of n = 128 bits. The secret key consists in three n-bit matrices and 2k m-bit S-boxes, so the key size is 3 • n 2 + 2k • m2 m -bit long. For this instance, this amounts to 14 KB.

It should be pointed out that the scheme is not IND-CPA secure. Indeed, an 8-bit invertible S-box has algebraic degree (at most) 7, so the overall scheme has algebraic degree (at most) 49. Thus, the sum of ciphertexts on entries spanning a cube of dimension 50 is necessarily zero. As a result the security claim in [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF] is only that the secret key cannot be recovered, with a security parameter of 128 bits.

Description of the white-box scheme

As another application of the symmetric ASASA scheme, Biryukov et al. propose its use as a basis for designing white-box block ciphers. In a nutshell, their idea is to use ASASA to create small ciphers of, say, 16-bit blocks and to use them as super S-boxes in e.g. a substitution-permutation network (SPN). Users of the cipher in the white-box model are given access to super S-boxes in the form a table, which allows them to encrypt and decrypt at will. Yet if the small ciphers used in building the super S-boxes are secure, one cannot efficiently recover their keys even when given access to their entire codebook, meaning that white-box users cannot extract a more compact description of the super S-boxes from their tables. This achieves weak white-box security as defined by Biryukov et al. [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF]:

Definition 1 (Key equivalence [BBK14]). Let E : {0, 1} κ × {0, 1} n → {0, 1} n be a (symmetric) block cipher. E(k) is called the equivalent key set of k if for any k ∈ E(k) one can efficiently compute E such that ∀ p E(k, p) = E (k , p).

Definition 2 (Weak white-box T -security [BBK14]). Let

E : {0, 1} κ × {0, 1} n → {0, 1} n be a (symmetric) block cipher. W(E)(k, •) is said to be a T -secure weak white-box implementation of E(k, •) if ∀ p W(E)(k, p) = E(k, p) and if it is computationally expensive to find k ∈ E(k) of length less than T bits when given full access to W(E)(k, •).
Example 1. If S 16 is a secure cipher with 16-bit blocks, then the full codebook of S 16 (k, •) as a table is a 2 20 -secure weak white-box implementation of S 16 (k, •).

For their instantiations, Biryukov et al. propose to use several super S-boxes of different sizes, among others:

-A 16-bit ASASA 16 where the nonlinear permutations S are made of the parallel application of two 8-bit S-boxes, with conjectured security of 64 bits. -A 24-bit ASASA 24 where the nonlinear permutations S are made of the parallel application of three 8-bit S-boxes, with conjectured security of 128 bits.

Description of the χ-based public-key scheme

The χ mapping was introduced by Daemen [Dae95] and later used for several cryptographic constructions, including the SHA-3 competition winner Keccak. The mapping χ : {0, 1} n → {0, 1} n is defined by:

χ i (a) = a i + a i+1 a i+2
The χ-based ASASA scheme presented in [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF] is a public-key encryption scheme operating on 127-bit inputs, the odd size coming from the fact that χ is only invertible on inputs of odd length. The encryption function may be written as:

F = A z • (P + χ • A y • χ • A x )
where:

-A x , A y , A z are random invertible affine mappings F 127 2 → F 127 2 .
In the remainder we will decompose A x as a linear map L x followed by the addition of a constant C x , and likewise for A y , A z . χ is as above.

-P is the perturbation. It is a mapping {0, 1} 127 → {0, 1} 127 . For 24 output bits at a fixed position, it is equal to a random polynomial of degree 4. On the remaining 103 bits, it is equal to zero.

Since χ has degree only 2, the overall degree of the encryption function is 4. The public key of the scheme is the encryption function itself, given in the form of degree 4 polynomials in the input bits, for each output bit. The private key is the triplet of affine maps (A x , A y , A z ).

Due to the perturbation, the scheme is not actually invertible. To circumvent this, some redundancy is required in the plaintext, and the 24 bits of perturbation must be guessed during decryption. The correct guess is determined first by checking whether the resulting plaintext has the required redundancy, and second by recomputing the ciphertext from the tentative plaintext and checking that it matches. This is not relevant to our attack, and we refer the reader to [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF] for more information.

Structural attack on black-box ASASA

Our goal in this section is to recover the secret key of the black-box ASASA scheme, in a chosen-plaintext model. For this purpose, we begin by peeling off the last linear layer, A z . Once A z is removed, we obtain an ASAS structure, which can be broken using Biryukov and Shamir's techniques [START_REF] Biryukov | Structural Cryptanalysis of SASAS[END_REF] in negligible time. Thus the critical step is the first one.

Attack overview

Before progressing further, it is important to observe that the secret key of the scheme is not uniquely defined. In particular, we are free to compose the input and output of any S-box with a linear mapping of our choosing, and use the result in place of the original S-box, as long as we modify the surrounding linear layers accordingly. Thus, S-boxes are essentially defined up to linear equivalence. When we claim to recover the secret key, this should be understood as recovering an equivalent secret key; that is, any secret key that results in an encryption function identical to the black-box instance under attack.

In particular, in order to remove the last linear layer of the scheme, it is enough to determine, for each S-box, the m-dimensional subspace corresponding to its image through the last linear layer. Indeed, we are free to pick any basis of this m-dimensional subspace, and assert that each element of this basis is equal to one bit at the output of the S-box. This will be correct, up to composing the output of the S-box with some invertible linear mapping, and composing the input of the last linear layer with the inverse mapping; which has no bearing on the encryption output.

Thus, peeling off A z amounts to finding the image space of each S-box through A z . For this purpose, we will look for linear masks a, b ∈ {0, 1} n over the output of the cipher, such that the two dot products F |a and F |b of the encryption function F along each mask, are each equal to one bit at the output of the same S-box in the last nonlinear layer S y . Let us denote the set of such pairs (a, b) by S (as in "solution").

In order to compute S, the core property at play is that if masks a and b are as required, then the binary product F |a F |b has degree only (m -1) 2 over the input variables of the cipher, whereas it has degree 2(m -1) 2 in general. This means that F |a F |b sums to zero over any cube of dimension (m -1) 2 + 1.

We now define the two linear masks a and b we are looking for as two vectors of binary unknowns. Then f (a, b) = F |a F |b may be expressed as a quadratic polynomial over these unknowns, whose coefficients are F |e i F |e j for (e i ) the canonical basis of F n 2 . Now, the fact that f (a, b) sums to zero over some cube C gives us a quadratic condition on (a, b), whose coefficients are c∈C F (c)|e i F (c)|e j .

By computing n(n -1)/2 cubes of dimension (m -1) 2 + 1, we thus derive n(n -1)/2 quadratic conditions on (a, b). The resulting system can then be solved by relinearization. This yields the linear space K spanned by S.

However we want to recover S rather than its linear combinations K. Thus in a second step, we compute S as S = K ∩ P , where P is essentially the set of elements that stem from a single product of two masks a and b. While P is not a linear space, by guessing a few bits of the masks a, b, we can get many linear constraints on the elements of P satisfying these guesses, and intersect these linear constraints with K.

The first step may be regarded as the core of the attack; and it is also its bottleneck: essentially we need to encrypt plaintexts spanning n(n -1)/2 cubes of dimension (m -1) 2 + 1. We recall that in the actual black-box scheme of [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF], we have S-boxes over m = 8 bits, and the total block size is n = 128 bits, covered by k = 16 S-boxes, so the complexity is dominated by the computation of the encryption function over 2 13 cubes of dimension 50, i.e. 2 63 encryptions.

Description of the attack

We use the notation of Section 3.1: let

F = A z • S y • A y • S x • A x
denote the encryption function. We are interested in linear masks a ∈ {0, 1} n such that F |a depends only on the output of one S-box.

Since F |a = S y • A y • S x • A x |(A z ) T a
, this is equivalent to saying that the active bits of (A z ) T a span a single S-box.

In fact we are searching for the set S of pairs of masks (a, b) such that (A z ) T a and (A z ) T b span the same single S-box. Formally, O t = span{e i : mt ≤ i < m(t + 1)} be the span of the output of the t-th S-box, then:

S = {(a, b) ∈ {0, 1} n × {0, 1} n : ∃t, (A z ) T a ∈ O t and (A z ) T b ∈ O t }
The core property exploited in the attack is that if (a, b) belongs to S, then F |a F |b has degree at most (m -1) 2 , as shown by Lemma 2 below. On the other hand, if (a, b) ∈ S, then F |a F |b will look like the product of two independent random polynomials of degree (m -1) 2 , and reach degree 2(m -1) 2 with overwhelming probability.

Lemma 2. Let G be an invertible mapping {0, 1} n → {0, 1} n with n > 2. For any two n-bit linear masks a and b, H = G|a G|b has degree at most n -1.

Proof. It is clear that the degree cannot exceed n, since we depend on only n variables (and we live in F 2 ). What we show is that it is less than n -1, as long as n > 2. If a = 0 or b = 0 or a = b, this is clear, so we can assume that a, b are linearly independent. Note that there is only one possible monomial of degree m, and its coefficient is equal to x∈{0,1} n H(x). So all we have to show is that this sum is zero.

Because G is invertible, G(x) spans each value in {0, 1} n once as x spans {0, 1} n . As a consequence, the pair ( G|a , G|b ) takes each of its 4 possible values an equal number of times. In particular, it takes the value (1, 1) exactly 1/4 of the time. Hence G|a G|b takes the value 1 exactly 2 n-2 times, which is even for n > 2. Thus x∈{0,1} n H(x) = 0 and we are done.

In the remainder, we regard two masks a and b as two sequences of n binary unknowns (a 0 , . . . , a n-1 ) and (b 0 , . . . , b n-1 ).

Step 1: kernel computation. If a, b are as desired, F |a F |b has degree at most (m -1) 2 . Hence the sum of this product over a cube of dimension (m -1) 2 + 1 is zero, as this amounts to an order-(m -1) 2 + 1 differential of a degree (m -1) 2 function. Let then C denote a random cube of dimension (m -1) 2 + 1 -that is, a random affine space of dimension (m -1) 2 +1, over {0, 1} n . We have:

c∈C F (c)|a F (c)|b = c∈C i<n a i F i (c) j<n b j F j (c) = i,j<n c∈C F i (c)F j (c) a i b j = i<j<n c∈C F i (c)F j (c) (a i b j + a j b i )
To deduce the last line, notice that c∈C F i F i = 0 since F has degree less than dim C. Since the equation above really only says something about a i b j + a j b i rather than a i b j (which is unavoidable, since the roles of a and b are symmetric), we define E = F n(n-1)/2 2 , see its canonical basis as e i,j for i < j < n, and define λ(a, b) ∈ E by: λ(a, b) i,j = a i b j + a j b i . By convention we set λ j,i = λ i,j and λ i,i = 0. The previous equations tells us that knowing only the n(n -1)/2 bits c∈C F i (c)F j (c) yields a quadratic condition on (a, b), and more specifically a linear condition on λ(a, b). Whence we proceed with Alg. 1.

Algorithm 1: GenerateCondition

Input: A random cube C of dimension (m -1) 2 + 1 over {0, 1} n 1 Let sum = (0, . . . , 0) ∈ E 2 for c ∈ C do 3 (x0, . . . , xn-1) ← F (c) 4 t ← (xixj for i < j < n) ∈ E 5 sum = sum + t 6 return sum
Let M be a binary matrix of size (n 2 /2) × (n(n -1)/2), whose rows are separate outputs of Alg. 1. Let K be the kernel of this matrix. Then for all (a, b) ∈ S, λ(a, b) is necessarily in K. Thus K contains the span of the λ(a, b)'s for (a, b) ∈ S. Because M contains more than n(n -1)/2, with overwhelming probability K contains no other vector6 . This is confirmed by our experiments.

Complexity analysis. Overall, the dominant cost is to compute 2 (m-1) 2 +1 encryptions per cube, for n 2 /2 cubes, which amounts to a total of n 2 2 (m-1) 2 encryptions. With the parameters of [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF], this is 2 63 encryptions. In practice, we could limit ourselves to dimension-(m -1) 2 + 1 subcubes of a single dimension-(m -1) 2 + 2 cube, which would cost only 2 (m-1) 2 +2 encryptions. However we would still need to sum (pairwise bit products of) ciphertexts for each subcube, so while this approach would certainly be an improvement in practice, we believe it is cleaner to simply state the complexity as n 2 2 (m-1) 2 encryption equivalents.

Beside that, we also need to compute the kernel of a matrix of dimension n(n -1)/2, which incurs a cost of roughly n 6 /8 basic linear operations. With the parameters of [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF], we need to invert a binary matrix of dimension 2 13 , costing around 2 39 (in practice, highly optimized) operations, so this is negligible compared to the required number of encryptions.

Step 2: extracting masks. Let:

P = {λ ∈ E : ∃a, b ∈ {0, 1} n , λ = λ(a, b)}
Clearly we have λ(S) ⊆ K ∩P . In fact, we assume λ(S) = K ∩P , which is confirmed by our experiments. We now want to compute K ∩P , but we do not need to enumerate the whole intersection K ∩P directly: for our purpose, it suffices to recover enough elements of λ(S) such that the corresponding masks span the output space of all S-boxes. Indeed, recall that our end goal is merely to find the image of all k S-boxes through the last linear layer. Thus, in the remainder, we explain how to find a random element in K ∩ P . Once we have found km linearly independent masks in this manner, we will be done.

The general idea to find a random element of K ∩ P is as follows. We begin by guessing the value of a few pairs (a i , b i ). This yields linear constraints on the λ i,j 's. As an example, if (a 0 , b 0 ) = (0, 0), then ∀i, λ 0,i = 0. Because the constraints are linear and so is the space K, finding the elements of K satisfying the constraints only involves basic linear algebra. Thus, all we have to do is guess enough constraints to single out an element of S with constant probability, and recover that element as the one-dimensional subspace of K satisfying the constraints.

More precisely, assume we guess 2r bits of a, b as:

a 0 , . . . , a r-1 = α 0 , . . . , α r-1 b 0 , . . . , b r-1 = β 0 , . . . , β r-1
We view pairs (α i , β i ) as elements of F 2 2 . Assume there exists some linear dependency between the (α i , β i )'s: that is, for some (µ i ) ∈ {0, 1} r :

r-1 i=0 µ i (α i , β i ) = (0, 0)
Then for all j < n, we have:

r-1 i=0 µ i λ i,j = b j r-1 i=0 µ i a i + a j r-1 i=0 µ i b i = 0 (1)
Now, since F 2 2 has dimension only 2, we can be sure that there exist r -2 independent linear relations between the (α i , β i )'s, from which we deduce as above (r -2)n linear relations on the λ i,j 's. In Appendix A.1, we prove that at least (r -2)(n -r) of these relations are linearly independent. Now, the cardinality of S is k(2 m -1)(2 m -2) ≈ k2 2m . Hence if we choose r = log(|S|)/2 ≈ m + 1 2 log k, and randomly guess the values of (a i , b i ) for i < r, then we can expect that with constant probability there exists exactly one element in S satisfying our guess. More precisely, each element has a probability (close to) 2 -2 |S|/2 ≈ 2 -|S| of fitting our guess of 2r bits, so this probability is close to |S| |S| -1 (1 -|S| -1 ) |S|-1 ≈ 1/e. Thus, if we denote by T the subspace of E of vectors satisfying the linear constraints induced by our guess, with probability roughly 1/3, λ(S) ∩ T contains a single element.

On the other hand, K is generated by pairs of masks corresponding to distinct bits for each S-box in S y . Hence dim K = km(m -1)/2 = n(m -1)/2. As shown earlier, from our 2r guesses, we deduce (at least) (r -2)(n -r) linear conditions on the (λ i,j )'s, so codim T ≥ (r -2)(n -r). Since we chose r = m + 1 2 log k, this means:

codim T ≥ (m -2 + 1 2 log k) • (n -m - 1 2 log k) dim K = (m -1) • (n/2)
Thus, having 1 2 log k ≥ 1, i.e. k ≥ 4, and m + 1 2 log k ≥ n/2, which is easily the case with concrete parameters m = 8, k = 16, n = 128, we have codim T ≥ dim K, and so K ∩ T is not expected to contain any extra vector beside the span of λ(S) ∩ T . This is confirmed by our experiments.

In summary, if we pick r = m + 1 2 log k and randomly guess the first r pairs of bits (a i , b i ), then with probability close to 1/e, K ∩ T contains only a single vector, which belongs to λ(S) ∩ T and in particular to λ(S). In practice it may be worthwhile to guess a little less than m + 1 2 log k pairs to ensure K ∩ T is nonzero, then guess more as needed to single out a solution. Once we have a single element in λ(S), it is easy to recover the two masks (a, b) it stems from7 .

In the end, we recover two masks (a, b) coming from the same S-box. If we repeat this process n = km times on average, the masks we recover will span the output of each S-box (indeed we recover 2 masks each time, so n tries is more than enough with high probability). Furthermore, checking whether two masks belong to the same S-box is very cheap (for two masks a, b, we only need to check whether λ(a, b) is in K), so we recover the output space of each S-box.

Complexity analysis. In order to get a random element in S, each guess of 2r bits yields roughly 1/3 chance of recovering an element by intersecting linear spaces K and T . Since K has dimension n(m -1)/2, the complexity is roughly (n(m -1)/2) 3 per try, and we need 3 tries on average for one success. Then the process must be repeated n times. Thus the complexity may be evaluated to roughly 3 8 n 4 (m -1) 3 basic linear operations. With the parameters of [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF], this amounts to 2 36 linear operations, so this step is negligible compared to Step 1 (and quite practical besides).

Before closing this section, we note that our attack does not really depend on the randomness of the S-boxes or affine layers. All that is required of the S-boxes is that the degree of z i z j vary depending on whether i and j belong to the same S-box. This makes the attack quite general, in the same sense as the structural attack of [START_REF] Biryukov | Structural Cryptanalysis of SASAS[END_REF].

Attacks on the χ-based public-key scheme

In this section, our goal is to recover the private key of the χ-based ASASA scheme, using only the public key. For this purpose, we peel off one layer at a time, starting with the last affine layer A z . We actually propose two different ways to achieve this. The first attack is our main algebraic attack from Section 4, with some adjustments to account for the specificities of χ and the presence of the perturbation. It is presented in Section 5.1. The second attack reduces the problem to an instance of LPN, and is presented in Section 5.2. Once the last affine layer has been removed with either attack, we move on to attacking the remaining layers one at a time in Sections 5.3 and 5.4.

Algebraic attack on the χ scheme

The χ scheme can be attacked in exactly the same manner as the black-box scheme in Section 4. Using the notations of Sections 3.1 and 3.4, we have:

z i z i+1 = (y i + y i+1 y i+2 ) • (y i+1 + y i+2 y i+3 ) = y i y i+1 + y i y i+2 y i+3
Here the crucial point is that y i+2 is shared by the only degree-4 term of both sides. Thus the degree of z i z i+1 is bounded by 6. Likewise, the degree of z i+1 (z i + z i+2 ) = z i z i+1 + z i+1 z i+2 is also bounded by 6, as the sum of two products of the previous form. On the other hand, any product of linear combinations ( α i z i )( β i z i ) not of the previous two forms does not share common y i 's in its higher-degree terms, so no simplification occurs, and the product reaches degree 8 with overwhelming probability.

As a result, we can proceed as in Section 4. Let n = 127 be the size of the scheme, p = 24 the number of perturbation polynomials. The positions of the p perturbation polynomials are not defined in the original paper; in the sequel we assume that they are next to each other. Other choices of positions increase the tedium of the attack rather than its difficulty. A brief discussion of random positions for perturbation polynomials is offered in Appendix B. Due to the rotational symmetry of χ, the positions of the perturbed bits is only defined modulo rotational symmetry; for convenience, we assume that perturbed bits are at positions z n-p to z n-1 .

The full attack presented below has been verified experimentally for small values of n.

Step 1: kernel computation. We fill the rows of an n(n -1)/2 × n(n -1)/2 matrix with separate outputs of Algorithm 1, with the difference that the dimension of cubes in the algorithm is only 7 (instead of (m -1) 2 + 1 = 50 in the black-box case). Then we compute the kernel K of this matrix.

Since n(n -1)/2 ≈ 2 13 the complexity of this step is roughly 2 39 basic linear operations.

Step 2: extracting masks. The second step is to intersect K with the set P of elements of the form λ(a, b) to recover actual solutions (see Section 4, step 2). In Section 4 we were content with finding random elements of K ∩ P . Now we want to find all of them. To do so, instead of guessing a few pairs (a i , b i ) as earlier, we exhaust all possibilities for (a 0 , b 0 ) then (a 1 , b 1 ) and so forth along a tree-based search. For each branch, we stop when the dimension of K intersected with the linear constraints stemming from our guesses of (a i , b i )'s is reduced to 1. Each branch yields a solution λ(a, b), from which the two masks a and b can be easily recovered.

Step 3: sorting masks. Let a i = ((L z ) T ) -1 e i be the linear mask such that z i = F |a i (for the sake of clarity we first assume C z = 0; this has no impact on the attack until step 4 in Section 5.3 where we will recover C z ). At this point we have recovered the set S of all (unordered) pairs of masks {a i , a i+1 } and {a i , a i-1 + a i+1 } for i < n -p, i.e. such that the corresponding z i 's are not perturbed. Now we want to distinguish masks a i-1 + a i+1 from masks a i . For each i such that z i-1 , z i , z i+1 are not perturbed, this is easy enough, as a i appears exactly three times among unordered pairs in S: namely in the pairs {a i , a i-1 }, {a i , a i+2 } and {a i , a i-1 + a i+1 }; whereas masks of the form a i-1 + a i+1 appear only once, in {a i-1 + a i+1 , a i }.

Thus we have recovered every a i for which z i-1 , z i , z i+1 are not perturbed. Since perturbed bits are next to each other, we have recovered all unperturbed a i 's save the two a i 's on the outer edge of the perturbation, i.e. a 0 and a n-p-1 . We can also order all recovered a i 's simply by checking whether {a i , a i+1 } is in S. In other words, we look at S as the set of edges of a graph whose vertices are the elements of pairs in S; then the chain (a 1 , . . . , a n-p-2 ) is simply the longest path in this graph. In fact we recover (a 1 , . . . , a n-p-2 ), minus its direction: that is, so far, we cannot distinguish it from (a n-p-2 , . . . , a 1 ). If we look at the neighbors of the end points of the path, we also recover {a 0 , a 0 + a 2 } and {a n-p-1 , a n-p-3 + a n-p-1 }. However we are not equipped to tell apart the members of each pair with only S at our disposal.

To find a 0 in {a 0 , a 0 + a 2 } (and likewise a n-p-2 in {a n-p-1 , a n-p-3 + a n-p-1 }), a very efficient technique is to anticipate a little and use the distinguisher from Section 5.2. Namely, in short, we differentiate the encryption function F twice using two fixed random input differences δ 1 = δ 2 , and check whether for a fraction 1/4 of possible choices of (δ 1 , δ 2 ), ∂ 2 F/∂δ 1 ∂δ 2 |x is equal to a constant with bias 2 -4 : this property holds if and only if x is one of the a i 's. This only requires around 2 16 encryptions for each choice of (δ 1 , δ 2 ), and thus completes in negligible time. Another more selfcontained approach is to move on to the next step (in Section 5.3), where the algorithm we use is executed separately on each recovered mask a i , and fails for a 0 + a 2 but not a 1 . However this would be slower in practice.

Regardless of which solution was chosen, we now assume that we know the whole ordered chain (a 0 , . . . , a n-p-1 ) of masks corresponding to unperturbed bits. At this stage we are only missing the direction of the chain, i.e. we cannot distinguish (a 0 , . . . , a n-p-1 ) from (a n-p-1 , . . . , a 0 ). This will be corrected at the next step.

As mentioned earlier, we propose two different techniques to recover the first linear layer of the χ scheme: one algebraic technique, and another based on LPN. We have now just completed the algebraic technique. In the next section we present the LPN-based technique. Afterwards we will move on to the remaining steps, which are common to both techniques, and fully break the cipher with the knowledge of (a 0 , . . . , a n-p-1 ), in Sections 5.3 and 5.4.

LPN-based attack on the χ scheme

We now present a different approach to remove the last linear layer of the χ scheme. This approach relies on the fact that each output bit of χ is almost linear, in the sense that the only nonlinear component is the product of two input bits. In particular this nonlinear component is zero with probability 3/4. The idea is then to treat this nonlinear component as random noise. To achieve this we differentiate the encryption function F twice. So the first ASA layers of F yield a constant; then ASAS is a noisy constant due to the weak nonlinearity; and ASASA is a noisy constant accessed through A z . This allows us to reduce the problem of recovering A z to (a close variant of) an LPN instance with tractable parameters.

We now describe the attack in detail. First, pick two distinct random differences δ 1 , δ 2 ∈ {0, 1} n . Then compute the order 2 differential of the encryption function along these two differences. That is, let F = ∂F/∂δ 1 ∂δ 2 . This second-order differential is constant at the output of F y = A y • χ • A x , since χ has degree only two:

(F y ) (x) = ∂F y /∂δ 1 ∂δ 2 = C(δ 1 , δ 2 )
Now if we look at a single bit at the output of F z = χ • F y , we have:

(F z ) i (x) = (F y ) i (x) + F y i+1 F y i+2 (x) + F y i+1 F y i+2 (x + δ 1 ) + F y i+1 F y i+2 (x + δ 2 ) + F y i+1 F y i+2 (x + δ 1 + δ 2 ) (2)
That is, a bit at the output of (F z ) still sums up to a constant, plus the sum of four bit products. If we look at each product as an independent random binary variable that is zero with probability 3/4, i.e. bias 2 -1 , then by the Piling-up Lemma (Lemma 1) the sum is equal to zero with bias 2 -4 . Experiments show that modeling the four products as independent is not quite accurate: a significant discrepancy is introduced by the fact that the four inputs of the products sum up to a constant. For the sake of clarity, we will disregard this for now and pretend that the four products are independent. We will come back to this issue later on. Now a single linear layer remains between (F z ) and F . Let s i ∈ {0, 1} n be the linear mask such that F |s i = F z i (once again we assume C z = 0, and postpone taking C z into account until step 4 of the attack). Then F |s i is equal to a constant with bias 2 -4 . Now let us compute N different outputs of F for some N to be determined later, which costs 4N calls to the encryption function F . Let us stack these N outputs in an N × n matrix A.

Then we know that A • s i is either the all-zero or the all-one vector (depending on (F y ) i ) plus a noise of bias 2 -4 . Thus finding s i is essentially an LPN problem with dimension n = 127 and bias 2 -4 (i.e. noise 1/2 + 2 -5 ). Of course this is not quite an LPN instance: A is not uniform, there are n solutions instead of one, and there is no output vector b (although we could isolate the last column of A and define it as the output vector). However in practice none of this should hinder the performance of a BKW algorithm [START_REF] Blum | Noise-tolerant learning, the parity problem, and the statistical query model[END_REF]. Thus we make the heuristic assumption that BKW performs here as it would on a standard LPN instance8 .

In the end, we recover the masks s i such that z i = F |s i . Before moving on to the next stage of the attack, we go back to the earlier independence assumption.

Dependency between the four products. In the reasoning above, we have modeled the four bit products in Equation 2 as independent binary random variables with bias 2 -1 . That is, we assumed the four products would behave as:

Π = W 1 W 2 + X 1 X 2 + Y 1 Y 2 + Z 1 Z 2
where W i , X i , Y i , Z i are uniformly random independent binary variables. This yields an expectancy E[Π] with bias 2 -4 . As noted above, this is not quite accurate, and we now provide a more precise model that matches with our experiments.

Since F y has degree two, (F y ) is a constant, dependent only on δ 1 and δ 2 . This implies that in the previous formula, we have

W 1 + X 1 + Y 1 + Z 1 = (F y ) i+1 and W 2 + X 2 + Y 2 + Z 2 = (F y ) i+2 .
To capture this, we look at:

E(c 1 , c 2 ) = E[Π | W 1 + X 1 + Y 1 + Z 1 = c 1 , W 2 + X 2 + Y 2 + Z 2 = c 2 ]
It turns out that E(0, 0) has a stronger bias, close to 2 -3 ; while perhaps surprisingly, E(a, b) for (a, b) = (0, 0) has bias zero, and is thus not suitable for our attack. Since G is essentially random, this means that our technique will work for only a fraction 1/4 of output bits. However, once we have recovered these output bits, we can easily change δ 1 , δ 2 to obtain a new value of G and start over to find new output bits.

After k iterations of the above process, a given bit at position i ≤ 127 will have probability (3/4) k of remaining undiscovered. In order for all 103 unperturbed bits to be discovered with good probability, it is thus enough to perform k = -log(103)/ log(3/4) ≈ 16 iterations.

In the end we recover all linear masks a i corresponding to unperturbed bits at the output of the second χ layer; i.e. a i = ((A z ) T ) -1 e i for 0 ≤ i < n -p. The a i 's can then be ordered into a chain (a 0 , . . . , a n-p-1 ) like in Section 5.1: neighbouring a i 's are characterized by the fact that F |a i F |a i+1 has degree 6. We postpone distinguishing between (a 0 , . . . , a n-p-1 ) and (a n-p-1 , . . . , a 0 ) until Section 5.3.

Complexity analysis.

According to Theorem 2 in [START_REF] Levieil | An Improved LPN Algorithm[END_REF], the number of samples needed to solve an LPN instance of dimension 127 and bias 2 -4 is N = 2 44 (attained by setting a = 3 and b = 43). This requires 4N = 2 46 encryptions. Moreover the dominant cost in the time complexity is to sort the 2 44 samples a times, which requires roughly 3 • 44 • 2 44 < 2 52 basic operations. Finally, as noted above, we need to iterate the process 16 times to recover all unperturbed output bits with good probability, so our overall time complexity is increased to 2 56 for BKW, and 2 50 encryptions to gather samples (slightly less with a structure sharing some plaintexts between the 16 iterations).

From ASAS to ASA

The next layer we wish to peel off is a χ layer, which is entirely public. It may seem that applying χ -1 should be enough. The difficulty arises from the fact that we do not know the full output of χ, but only n -p bits. Furthermore, if our goal was merely to decrypt some specific ciphertext, we could use other techniques, e.g. the fact that guessing one bit at the input of χ produces a cascade effect that allows recovery of all other input bits from output bits, regardless of the fact that the function has been truncated [START_REF] Daemen | Cipher and hash function design strategies based on linear and differential cryptanalysis[END_REF]. However our goal is different: we want to recover the secret key, not just be able to decrypt messages. For this purpose we want to cleanly recover the input of χ in the form of degree 2 polynomials, for every unperturbed bit. We propose a technique to achieve this below.

From the previous step, we are in possession of (a 0 , . . . , a n-p-1 ) as defined above. Since by definition z i = F |a i , this means we know z i for 0 ≤ i < n -p. Note that y i has degree only 2, and we know that z i = y i + y i+1 y i+2 . In order to reverse the χ layer, we set out to recover y i , y i+1 , y i+2 from the knowledge of only z i , by using the fact that y i , y i+1 , y i+2 are quadratic.

This reduces to the following problem: given P = A+B •C, where A, B, C are degree-2 polynomials, recover A, B, C. A closer look reveals that this problem is not possible exactly as stated, because P can be equivalently written in several different ways, such as:

A+B •C, A+B +B •C, or A+C +(B +C)•C.
On the other hand, we assume that for uniformly random A, B, C, the probability that P may be written in some unrelated way, i.e. P = C + D • E for C, D, E not in the linear span of A, B, C, 1, is overwhelmingly low. This situation has never occurred in our experiments. Thus our problem reduces to:

Problem 1. Let A, B, C be quadratic polynomials in Q = F 2 [X 0 , . . . , X n-1 ]/ X 2 i -X i . Let P = A + B • C.
The problem is to recover quadratic A , B , C such that P = A + B • C , given only P .

Remark 1. Problem 1 is part of a general family of polynomial decomposition problems which have very recently been shown to be solvable in polynomial time [START_REF] Bhattacharyya | Algorithmic regularity for polynomials and applications[END_REF]. However our particular instance is much easier than the general case considered in [START_REF] Bhattacharyya | Polynomial decompositions in polynomial time[END_REF][START_REF] Bhattacharyya | Algorithmic regularity for polynomials and applications[END_REF]. This allows us to propose a much simpler and more efficient dedicated algorithm. Our algorithm is unrelated to those used in the general case, which rely on higher-order Fourier analysis.

Our previous assumption says A ∈ span{A, B, C, 1}; B , C ∈ span{B, C, 1}. A straightforward approach to tackle the problem is to write B formally as a generic degree-2 polynomial with unknown coefficients This gives us k = 1 + n + n(n + 1)/2 ≈ n 2 /2 binary unknowns. Then we observe that B • P has degree only 4 (since B 2 = B). Each term of degree 5 in B • P must have a zero coefficient, and thus each term gives us a linear constraint on the unknown coefficients of B. Collecting the constraints takes up negligible time, at which point we have a k × k matrix whose kernel is span{B, C, 1}. This gives us a few possibilities for B , C , which we can filter by checking that A = P -B • C has degree 2. The complexity of this approach boils down to inverting a k-dimensional binary matrix, which costs essentially 2 3k basic linear operations. In our case this amounts to 2 39 basic linear operations. While this is a straightforward approach, and its complexity is reasonable, a much more efficient algorithm is given below.

An Efficient Algorithm for Problem 1. As previously mentioned, A = A, B = B, C = C cannot be the only solution; for instance A = A + C, B = B + C, C = C is also possible. Conceptually, our algorithm will attempt to recover B and C; but in effect it recovers any two linearly independent elements of span{B, C, 1}, which are indistinguishable from (B, C) with knowledge of only P .

H = A y • χ • A x n-p .
Up to now we have always taken advantage of the very simple action of χ when considering only a single output bit. However because A y is truncated, we cannot expect that there exist linear masks on the truncated output of A y that give us access to a single bit at the output of χ. For this reason we switch gear and set out to remove the first layer A x instead.

First, we want to compute the linear component L x of A x . Let ∆ = {(L x ) -1 e i : i < n} denote the set of differences δ that activate only a single bit at the input of χ. Observe that a single bit difference at the input of χ only affects 3 output bits. As a result we have an oracle O that recognizes elements of ∆: namely for δ ∈ ∆, the output of H = ∂H/∂δ has dimension only 3 as x spans {0, 1} n . Furthermore, a closer look reveals that if we remove the constant component in the output of H , then the output of H has dimension only 2. The reason for this is that, while each bit at the input of χ affects 3 bits at the output, only 2 bits are affected in a nonlinear manner; and since we are differentiating H, the linear component of χ only affects the constant component in the output of H .

Let us define an input difference δ as a vector of n binary unknowns. Then we can formally compute the function H . Assume δ ∈ ∆. Per the previous observation, we know that the linear component of H (x) has dimension only two as x spans {0, 1} n . That is, for any pairwise distinct k 0 , k 1 , k 2 < n -p, there exists a nonzero vector (λ 0 , λ 1 , λ 2 ) such that λ i H ki = C(δ) is constant10 . Now observe that H has degree only one in its input variables x i , and the coefficient of each x i is a linear combination of δ i 's, hence the above equality gives us n linear conditions on δ. Since δ lives in a space of dimension n, we can hope that this is enough to recover δ, at the cost of guessing the λ i 's (only 8 possibilities).

In short the algorithm so far sums up to:

1. Pick pairwise distinct k 0 , k 1 , k 2 < n -p arbitrarily. 2. Guess λ = (λ 0 , λ 1 , λ 2 ).
3. Write the polynomial equality λ i H ki = 0. By looking at the coefficient of each x i in this equality, we have n linear conditions on δ.

Let K(k, λ) denote the linear subspace of vectors satisfying these conditions. Then we know that for every δ ∈ ∆, and every choice of k, there exists λ such that δ ∈ K(k, λ).

Note that the cardinality of ∆ is 128 = 2 7 , while λ only contains 3 bits of information. Hence, in order to single out each element of ∆, we repeat the previous algorithm 3 times. This gives us 3 sets of 8 spaces K(k, λ). For every choice of K in each set, we compute the intersection of the spaces (8 3 = 2 9 possibilities). This yields 2 9 intersections. By construction we know that each element of ∆ is in one of the intersections. So we recover ∆ by testing every element in every intersection against the oracle O.

There are 2 9 intersections, so the only remaining question is whether some of the intersections have dimension greater than 0 or 1 (which may considerably slow down the algorithm). Our experiments show that this is in fact the case, but the resulting spaces still have very low dimension. This is due to "false positives" caused by differences δ that activate 2 or 3 differences at the input of δ; but these are quickly weeded out by testing against the oracles O.

We have now recovered the linear component of A x . Thus we have access to A y • χ • (⊕C x ) n-p , where ⊕C x denotes the addition of the constant C x . In order to recover C x , we can use the fact that χ(v) + χ(v + e i ) = e i (where e i is the canonical basis of F n 2 ) if and only if v i-1 = v i+1 = 0. So for each i, we can flip the bits at position i -1 and i + 1 at the input of A y • χ • (⊕C x ) n-p until the previous equality holds. This allows us to recover C x very quickly.

Overall the complexity of this step can be approximated by 2 9 intersections of 3 spaces of dimension 128, which costs around 2 9 • 2 • (2 7 ) 3 = 2 31 , so this step is negligible compared to step 1. In fact we have implemented this step on the full version of the scheme, and it takes only about a minute to complete on a laptop computer.

From SA to A. We know A y • χ n-p , and we want to recover A y n-p . Observe that χ(0) = 0, so C y n-p = F (0). Moreover χ(e i ) = e i so L y (e i ) n-p = A y • χ n-p (e i ) and we are done.

A practical attack on white-box ASASA

In this section we show that the actual security of small-block ASASA ciphers is much lower than was estimated by Biryukov et al.. We describe a procedure to recover the secret components of such schemes, thus breaking their weak white-box security (Definition 2). Our algorithm relies rather heavily on heuristics, and evaluating its efficiency requires actual implementation. We focused on the smallest white-box instance, 16-bit ASASA 16 , whose claimed security level is 64 bits. Our algorithm was able to recover its secret components under one minute on a laptop computer.

Attack overview

Our general black-box attack from Section 4 does not apply, because the block size is too small to allow computing cubes of dimension 50. On the other hand, the small block size makes it possible to compute the distribution of output differences for a single input difference in very reasonable time. In fact, one can compute and store the entire difference distribution table (DDT) of a 16-bit cipher using just a standard PC. For slightly bigger instances such as a 24-bit cipher, computing and storing the entire DDT is still barely possible, even though it would require 3 TB of space and 2 48 invocations of the cipher; computing the distribution of only a few differences on the other hand remains manageable.

Remark 2. Our attack makes use of the full codebook of the ciphers, which in general may be seen as a very strong requirement. This is however only natural in the case of attacking white-box implementations, as the user is actually required to be given the full codebook of the super S-boxes as part of the implementation.

Similarly to the attack of the black box scheme, it is already enough to recover only one of the external affine (or linear) layers in order to break the security of ASASA. Indeed, this allows to reduce the cipher to either of ASAS or SASA, which can then be attacked in practical time [START_REF] Biryukov | Structural Cryptanalysis of SASAS[END_REF]. Thus we focus on removing the first linear layer. In accordance with the opening remarks of Section 4.1, this amounts to finding the image space of each S-box through (A x ) -1 .

The general idea of the attack is to create an oracle able to recognize whether an input difference δ activates one or two S-boxes in the first S-box layer S x . More accurately, we create a ranking function F such that F(δ) is expected to be significantly higher if δ activates only one S-box rather than two.

We present two choices for F which are both heuristic but nonetheless quite efficient as shown by experiments. Both begin by computing the entire output difference distribution D(δ) for the input difference δ, i.e. the row corresponding to δ in the DDT. Then the value of F(δ) is computed from D(δ). Walsh transform. The idea behind this version of the attack is quite intuitive. If δ activates only one S-box, then after the first SA layers, two inner states computed from any two plaintexts with input difference δ are equal on the output of the inactive S-box. Hence after the first ASA layers, they are equal along 2 8 -1 non-zero linear masks. Since these masks only traverse a single S-box layer before the output of the cipher, linear cryptanalysis [START_REF] Matsui | Linear Cryptanalysis Method for DES Cipher[END_REF] tells us that we can expect some linear masks to be biased at the output of the cipher. On the other hand if both S-boxes are active in the first round, no such phenomenon occurs, and linear biases on the output differences are expected to be weaker.

In order to measure this difference, we propose to compute, for every output mask a, the value f (a) = ( x∈{0,1} 16 ∂F ∂δ(x)|a ) -2 15 (where the sum is computed in Z). That is, 2 -15 f (a) is the bias of the output differences D(δ) along mask a. The function f can be computed efficiently, since it is precisely the Walsh transform of the characteristic function of D(δ), and we can use a fast Fourier transform algorithm. Then as a ranking function F we simply choose max(f ), i.e. the highest bias among all output masks 11 . the memory complexity of the order of 2 17 words (about 2 18 bytes in this case), which are respectively quadratic and linear in the size of the domain of ASASA 16 Second step. From the previous step, we know 16 input differences δ i that each activate only one S-box of S x , and we can now use this knowledge to recover the first layer A x . Similarly to the attack of the black-box scheme of Section 4, it is not possible to uniquely determine A x ; but it is enough to recover of the equivalent mappings and later choose the affine equivalent representation of the S-boxes accordingly. The consequence of this is that we only need to identify two groups of 8 linearly independent δ i 's, respectively activating the first and the second S-box. Once this is done, we may assume any value for the images of a group as long as they are linearly independent and indeed activate only one S-box.

In order to achieve our goal, we can use the fact that sums of differences of a single group still activate only one S-box, while if the differences come from two groups they obviously activate two. We can use the same method as in the first step to determine whether a sum activates one or two S-boxes, and thence we may hope to find the correct grouping by ensuring that every linear combination of a group (or equivalently every combination of two differences of a group) only activates a single S-box.

We can conveniently describe the resulting problem with a weighted graph and solve it with a simple greedy algorithm. We define the vertices of the graph as being the differences δ i , and draw an edge between every pair of two (thus making the graph complete); the weight of the edge (δ i , δ j ) is defined as the ranking F(δ i + δ j ) of δ i + δ j . The two partitions of 8 differences are then initialized arbitrarily, with their weight defined as the sum of the weight of edges between vertices belonging to the same partition. Finally, the following process is iterated until a fixed point is reached: for any pair of vertices in different partitions, the pair is swapped if and only if this would result in increasing the weight of the partition. We describe this formally as Algorithm 8. Complexity analysis (Alg. 8). Assuming that the computations of Line 4 have been cached when running Algorithm 7, every individual step can be computed with negligible time and memory. We then only need to estimate how many times the loop of Line 7 is executed before exiting on Line 16. First it is easy to see that the algorithm does indeed eventually terminate, as W(S 1 ) + W(S 2 ) increases every time there is as swap of differences. Then, because there are at most 16 8 = 12870 partitions to consider, we know that the process stops within this number of iterations. In practice, it is unlikely for two S-boxes to be swapped more than once, and the observed time complexity is actually very small.

Experimental results and discussion

We implemented the previous algorithm in C++. The implementation was able to recover the first linear layer of 16-bit ASASA in a minute on average. This strongly invalidates the security level of 64 bits estimated by [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF].

Moreover we implemented a faster but more heuristic algorithm in the Sage formal computation language [Tea]. This variant uses an oracle O that predicts whether a difference δ activates one or two S-boxes, rather than a ranking function. The oracle simply calls the ranking function, and decides that δ activates a single S-box if F(δ) is above a certain threshold. The threshold is determined by comparing values of F for δ's that activate one S-box, versus values obtained when δ activates both S-boxes (this computation only occurs once, by picking a known but random instance and performing the measure).

The algorithm then proceeds by picking random δ's and using the oracle to check whether δ activates a single S-box. Once 16 such linearly independent δ's are found the first step is complete. The second step is identical to the original algorithm. Each δ has probability 2 -8 of activating a single S-box. Hence the expected number of δ's that will need to be tested is 16 • 2 8 = 2 24 , which is lower than the 2 32 DDT row computations incurred by the original algorithm. However this algorithm requires the existence of a clean threshold between the two cases for δ's.

Sage is a high-level interpreted language, which makes it significantly slower than an equivalent implementation in C++. Nonetheless due to its lower complexity, the previous algorithm was also able to succeed in a minute on average, with either choice of the ranking function F.

All of the implementations are publicly available on the Internet with a link provided in Section 1.4.

Remark 3. An interesting observation is that both ranking functions distinguish δ's that activate one or two S-boxes much less efficiently if A y is maximum distance separable (MDS). However the attack still goes through, meaning that relying on such matrices is not a suitable countermeasure.

Adapting the algorithm to larger white-box instances

The algorithm from the previous section can be adapted to larger white-box instances in a straightforwards manner. However the required computational power is higher. Beside the 16-bit instance, we have also successfully run the attack on the 20-bit instance.

Conclusion

We presented a new algebraic attack able to efficiently break both the χ-based public-key cryptosystem and the secret-key scheme of [START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF]. In addition we proposed another attack that heuristically reduces the key-recovery problem on the χ scheme to an easy instance of LPN. In the case of the publickey scheme, both attacks go through regardless of the amount of perturbation. For both schemes, the attacks are quite structural (in the case of the black-box scheme, it is in fact structural in the sense of [START_REF] Biryukov | Structural Cryptanalysis of SASAS[END_REF]), and seem difficult to patch. Finally, although the general attack on the black-box scheme does not carry over to the small-block instances used for white-box designs, we also showed a very efficient dedicated attack on some of the small-block instances, casting a doubt on their general suitability for that purpose.

Fig. 1 .

 1 Fig. 1. The ASASA structure.

Algorithm 8 :S1 := S 1 14 S2 := S 2 15 if

 81415 Computing partitions of D activating the same S-box Input: A set D of 16 linearly independent differences activating only one S-box of S x Output: A partition (S1, S2) of D such that the S-box activated by differences in S1 (resp. S2) is the same for every difference 1 Define W(S) as i,j∈S,i =j W [i][j] 2 for i := 1 to 16 do 3 for j := 1 to 16 do 4 W [i][j] := F(D[i] + D[j]) 5 S1 := {D[i], i := 0. . .7} 6 S2 := {D[i], i := 8. . .15} 7 while ∞ do 8 for δi ∈ S1 do 9 for δj ∈ S2 do 10 S 1 := ((S1 -{δi}) ∪ {δj}) 11 S 2 := ((S2 -{δj}) ∪ {δi}) 12 if W(S 1 ) + W(S 2 ) > W(S1) + W(S2) then 13 Neither S1 nor S2 has been modified then 16 Return (S1, S2)

The HFEvvariant used in Quartz[START_REF] Patarin | Quartz, 128-bit long digital signatures[END_REF] seems to be an exception in this regard.

A similar idea was used in[START_REF] Ding | A New Variant of the Matsumoto-Imai Cryptosystem through Perturbation[END_REF].

Other choices for the number and size of S-boxes are obviously possible, but we focus on the instance proposed byBiryukov et al.

In practice, vector instructions operating on 128-bit inputs would mean that the meaningful size of the matrix is 2 13-7 = 2 6 , and in this context the number of basic linear operations would be much lower. We also disregard asymptotic improvements such as the Strassen or Coppersmith-Winograd algorithms and their variants. The main point is that the time complexity is quite low -well within practical reach.

On this topic, the authors of[START_REF] Biryukov | Cryptographic Schemes Based on the ASASA Structure: Black-Box, White-Box, and Public-Key[END_REF] note that "the full application of LWE to multivariate cryptography is still to be explored in the future".

This point is the only reason we pick n 2 /2 rows rather than only n(n -1)/2; but we may as easily choose n(n -1)/2 plus some small constant. In practice it we can just pick n(n -1)/2 rows, and add more as required until the kernel has the expected dimension km(m -1)/2.

It can be shown that λ is invertible except on its zero output, which is reached only when a = 0, b = 0 or a = b. An inversion algorithm is given in Appendix A.2.

To the best of our knowledge, we have yet to see an LPN-like problem with a matrix A on which BKW underperforms significantly compared to the uniform case, unless the problem was specifically crafted for this purpose. The existence of multiple solutions is also a notable difference in our case. However in a classic application of BKW with a fast Fourier transform at the end, this only means that the Fourier transform will output several solutions. Note that the dimension of the Fourier transform will be close to 127/3 ≈ 42[START_REF] Levieil | An Improved LPN Algorithm[END_REF], and we have only ≈ 2 14 solutions, so they are distinct on their last 42 bits with very high probability.

For instance each degree-4 term in z1 may be written in only 4 2 = 6 ways as a product of two quadratic terms, and so the corresponding equation on the coefficients of y 3 involves only 3 terms on average, and many such equations have only one term, yielding a direct equality.

We always mean "constant" and "non-constant" with respect to the input x of H , and not the difference δ.

Alternatively a less clean but more efficient ranking function in practice is to compute the number of large values of f , where a value is considered large if it is higher than 4σ, for σ the standard deviation in the case where δ activates 2 S-boxes (which needs only be computed once for some fixed random ASASA instance -in fact δ ≈ 250 for ASASA16).

Due to an inefficient representation of polynomials in our implementation, we only performed this step for n = 31. However, we found it to be faster than steps 1 and 2.

Recherche through the BRUTUS project under Contract ANR-14-CE28-0015. Supported by the CORE ACRYPT project from the Fond National de la Recherche, Luxembourg. Partially supported by the Direction Générale de l'Armement and by the Singapore National Research Foundation Fellowship 2012 (NRF-NRFF2012-06).

In fact our algorithm only attempts to recover the homogeneous degree-2 components of B, C. The linear components can then be defined as 2n unknowns and recovered using simple linear algebra from the degree-3 monomials of P . This only involves inverting a matrix in dimension 2n = 254, which has negligible cost. Moreover A = P -B • C. Thus we focus on recovering the degree-2 monomials of B, C. In the remainder we will slightly abuse notation and write B, C to mean the homogeneous degree-2 components of B, C, i.e. we disregard the linear and constant components.

In an effort to reduce notational clutter, we always assume knowledge of P , and do not pass it as parameter to every algorithm. Let n = 127 and [n] = {0, . . . , n -1}. For D ∈ Q, we write D i,j for the coefficient of X i X j in D (we identify elements of Q with their square-free representation in F 2 [X 0 , . . . , X n-1 ]). By convention D i,i = 0. Likewise we define P i,j,k,l as the coefficient of X i X j X k X l in P . Finally, for D ∈ Q, D i, * is the vector (D i,0 , . . . , D i,n-1 ) ∈ F n 2 . Our algorithm makes use of two simple "zero oracles" Z (Alg. 3) and Z (Alg. 2). The oracle Z(i, j) returns True if and only if B i,j = C i,j = 0. It makes use of the oracle Z , which returns True if and only if:

Both oracles attempt to find information on B i,j and C i,j , and in their description above, we describe their output as depending on B and C. But the oracle answers are actually computed without access to either, as we shall see. In both cases there is a small chance of the oracle answer being wrong. However this happens with low probability, and our algorithm is made resilient to such errors at a later point.

Algorithm 2: ZeroTripletOracle Z

Note that we have:

So Eq. 3 implies ∀l, P i,j,k,l = 0. Conversely if Eq. 3 does not hold, then P i,j,k,l = 0 holds for all l = i, j, k with probability close to 2 -(n-3) = 2 -124 . As a result, Z is correct except with negligible probability. Now we use Z to build Z, which returns True if and only if B i,j = C i,j = 0. As with Z , there is

a low probability of incorrect answer for Z , but our algorithm will be made resilient to these errors later on.

Algorithm 4: FindGood

Now we build a function FindGood(i) (Alg. 4), whose purpose will become clear shortly. FindGood picks j, k randomly until Z(i, j) and Z(i, k) hold, but not Z(j, k). This is the case with probability roughly 2 -6 , and there are n(n -1)/2 choices for j, k so the probability of failure is negligible. Now we explain the point of FindGood.

Let (λ, µ) = (B j,k , C j,k ). The point of having the conditions at the output of FindGood is that due to Eq.4, they imply: ∀l, P i,j,k,l = λB i,l + µC i,l so we recover (λB +µC) i,l for all l simply by looking at P i,j,k,l . For simplicity we assume (λ, µ) = (1, 0), and so we are recovering B i,l (other cases correspond to the other two nonzero elements of span{B, C}, which as pointed earlier cannot be distinguished from B). If we view B as an n × n symmetric binary matrix with entries B i,j , this means we recover a row of B, namely B i, * . Now we can naturally define GetSpace(i) (Alg. 5), which recovers span{B i, * , C i, * }:

Algorithm 5: GetSpace

For all i we now know span{B i, * , C i, * }. All that remains to do in order to build B (or C, or B + C) is to choose a nonzero element of GetSpace(i) as the first row; then an element of GetSpace(1) as the second row; and so forth. At each step i, we make sure that our choice of elements is coherent up to this point by checking that the submatrix of rows 0 to i and columns 0 to i is symmetric. If not, we change our choice of element, backtracking if necessary. This is described in Alg. 6.

In the end, span{B, C} is recovered as Solve(0, 0, 0) (where the first two parameters are the zero matrix of F n×n 2 ). Notice that every recursive call to Solve repeats its inner loop twice in case of failure. This is to account for the very rare case where the output of GetSpace might be wrong. Our implementation never returns FAIL and completes within a second for n = 127, which is the actual n value for the χ-based ASASA scheme (see Section 1.4 for a link to our implementation).

Application to ASAS. Note that we only need to go through the previous algorithm for the first unperturbed bit in the chain (z 0 , . . . , z n-p-1 ), namely z 0 . Indeed, we then recover y 0 , y 1 , y 2 , and for the next bit we have z 1 = y 1 + y 2 y 3 , so only y 3 remains to be determined. This can be performed in negligible time, as the system of equations stemming from this equality on the coefficients of y 3 is very sparse 9 . By induction we can propagate this process to all other unperturbed bits.

However in the course of this process we also have to deal with the fact that even from the start, we do not recover y 0 , y 1 , y 2 exactly, but span{y 0 , y 1 , y 2 , 1} and span{y 1 , y 2 , 1}. Thus we need to guess y 0 , y 1 , y 2 from the elements of these two vector spaces, then start the process of rebuilding the rest of the chain (y 0 , . . . , y n-p-1 ) as in the previous paragraph. In our experiments, it turns out that as long as p ≥ 2, there are always exactly 8 solutions for the chain of degree-2 polynomials (y 0 , . . . , y n-p-1 ).

To understand why, we need to look at the last unperturbed bit z n-p-1 . For this bit, we recover span{y n-p-1 , y n-p , y n-p+1 , 1} and span{y n-p , y n-p+1 , 1}. We can recognize y n-p-1 in the first space (or rather span{y n-p-1 , 1}) because it is also one of the factors in the expression of z n-p-2 . We can also identify span{y n-p , 1} for the same reason. However there is fundamentally no way to tell y n-p-1 apart from y n-p-1 , and likewise for y n-p , y n-p , because the necessary information is erased from the public key by the perturbation. For y n-p for instance, we could flip the (n-p)-th bit in the constant C 1 of A y and also flip the perturbed bit z n-p and this would flip y n-p without changing (z 0 , . . . , z n-p-1 ). Thus all 8 solutions for (y 0 , . . . , y n-p-1 ) are valid in the sense that they correspond to equivalent keys, and we are free to choose one of them arbitrarily.

Finally, up to this stage of the attack, we have pretended that C z = 0. This actually has no impact on any algorithm so far, except the one just above. With nonzero C z , we have F |a i = z i + c i for c = (A z ) -1 C z . This merely adds another degree of freedom in the construction of the previous chain: we guess c 0 and attempt to go through the process of building the chain. If our guess was incorrect the algorithm fails after two iterations. Once it goes through for two iterations we guess c 1 and attempt one more iteration, and so forth. Since the chain-building step has negligible complexity, this takes up negligible time.

Overall our algorithm is able to solve Problem 1 for the full n = 127 within a second on a laptop computer. Thus the time complexity of this step is negligible.

Peeling off the remaining ASA layers

From ASA to SA. At the end of the previous step we have recovered the chain (y 0 , . . . , y n-p-1 ) of polynomials at the output of A y . Now we are left with the task of recovering A x , A y n-p from Number of collisions. It turns out that performing the Walsh transform is not truly necessary. Indeed, the number of collisions in D(δ) is higher when δ activates only 1 S-box; where by number of collisions we mean 2 15 minus the number of distinct values in D(δ). This may be understood as a consequence of the fact that whenever δ activates a single S-box, only 2 7 output differences are possible after the first ASA layers; and depending on the properties of the active (random) S-box, the distribution between these differences may be quite uneven. Whereas if both S-boxes are active, 2 15 differences are possible and the distribution is expected to be less skewed. Thus we pick as ranking function F the number of collisions in D(δ) in the previous sense.

Once we have chosen a ranking function F, we simply compute the ranking of every possible input difference, sort the differences, and choose the highest 16 linearly independent differences according to our ranking. Our hope is that these differences only activate a single S-box. In second step, we will group together differences that activate the same S-box.

Attack description

We now describe the attack in detail. We focus on the collision ranking function, which is slightly more efficient in practice.

First step. We wish to recover the individual components of the ASASA

The first step of our attack consists in finding 16 linearly independent input differences to the cipher such that only one of the two S-boxes of S x is active. In other words, we want to find a family of differences δ i such that for all i, A x (δ i ) is zero in its 8 most significant or 8 least significant bits. As A x is invertible, there are 2 × (2 8 -1) non-trivial such differences, but we need an efficient way to test if a given difference is one of them. This can be done by considering the distribution of its corresponding output differences, and counting the number of collisions, as outlined in the previous section.

That is, we attempt to recover 16 suitable differences δ i by computing the entire DDT of ASASA 16 , sorting the input differences by their decreasing number of collisions, and selecting the first 16 linearly independent entries. We describe this formally as Algorithm 7.

Algorithm 7: Finding a basis of differences activating only one S-box of S x at a time Input: An instance of ASASA16 Output: A set D of 16 linearly independent differences activating only one S-box of S x 1 for δ := 1 to 2 16 -1 do 2 F[δ] := 2 15 -# range(∂ASASA16/∂δ) 3 L := sorted differences δ's in decreasing order for F 4 D := ∅ 5 i := 0 6 while # D < 16 do

Complexity analysis (Alg. 7). Computing one iteration of Line 2 requires 2 16 calls to ASASA 16 , each one corresponding to one memory access, and at most 2 16 words of temporary storage. The loop of Line 1 therefore requires 2 32 calls in total and 2 17 words of memory, including R. The sorting of Line 3 can be done in about 2 20 accesses to R and does not require additional memory. The loop of Line 6 has negligible cost. The total time complexity is thus of the order of 2 32 memory accesses and The problem may be formalized as follows. We are given α, β ∈ F r 2 . The set of µ ∈ F r 2 such that µ i (α i , β i ) = (0, 0) is (isomorphic to) the annihilator A of span{α, β} in the dual space (F r 2 ) * . Let M = F n×n 2 denote the space of n×n binary matrices, with basis e i,j . Let D = span({e * i,i }∪{e * i,j +e * j,i }). The space D is isomorphic to the annihilator of E = F n(n-1)/2 2 ; that is, the space of the λ i,j 's in Section 4.2. Let B = span{ µ i e * i,j : µ ∈ A, j > r}. The point of the previous definitions is that the linear relations on E obtained from Eq. 1 for j > r are exactly the vectors of the space B ∩ D.

First, we prove that dim B ≥ (r -2)(n -r). Clearly the projection of B on C j = span{e * i,j : i < n} (which may be seen as looking at a column in the space M ) has dimension dim A for j > r. Since C j ⊆ B and the C j 's are disjoint, we have dim B ≥ (n -r) dim A ≥ (r -2)(n -r) since A is the annihilator of a space of dimension 2. Now it remains to show that dim(B ∩ D) = dim B. To see this, it suffices to observe that every functional e * i,i and e * i,j + e * j,i involves a distinct basis element e * i,j for which i ≤ j, whereas B is entirely disjoint from the span of those elements.

A.2 Inversion algorithm for λ

Recall that λ : As a consequence of the previous properties, by inverting λ, we mean recovering one of {a, b}, {a + b, b}, {a, a + b} given λ(a, b), and provided λ(a, b) = 0 (otherwise any linearly dependent a, b is a preimage). For this purpose we use the following algorithm. Consider the n × n matrix M such that M i,j = λ(a, b) i,j . Let R i denote the i-th row of M , i.e. R i j = a i b j +a j b i . Then observe that R i = a i b+b i a. Thus we see that M has rank 2, and in order to invert λ in the previous sense, we need only pick any two linearly independent rows of M .

B Regarding the location of perturbation polynomials

For the sake of simplicity, in Section 5.1, we assumed that perturbation polynomials are contiguous. In order to increase the security of the scheme one could propose to make the positions of perturbations secret. However this would fail as the scheme would still be broken in practical time. Indeed, according to our experiments, knowing 10 outputs of ASA among the 127 is enough to perform step 5 and quickly recover the first affine layer A x with a probability of 97% (100 trials with n = 127). Thus, as long as there are less than 60 perturbations, one can perform the whole attack to retrieve the first affine layer. Then, in order to retrieve the lines of (A z ) -1 and A y corresponding to unperturbed bits, one need only solve deg(P • G) = 4 where P is an affine combination of the n public polynomials and G is an affine combination of χ. In practice we found this quadratic system to be easily solvable 12 because of the structure of the scheme. The missing lines can take any value as long as the resulting layers are invertible, each choice determining the perturbation layer.