Revisiting Multivariate Ring Learning with Errors and Its Applications on Lattice-Based Cryptography

The “Multivariate Ring Learning with Errors” problem was presented as a generalization of Ring Learning with Errors (RLWE), introducing efficiency improvements with respect to the RLWE counterpart thanks to its multivariate structure. Nevertheless, the recent attack presented by Bootland, Castryck and Vercauteren has some important consequences on the security of the multivariate RLWE problem with “non-coprime” cyclotomics; this attack transforms instances of m-RLWE with power-of-two cyclotomic polynomials of degree n=∏ini into a set of RLWE samples with dimension maxi{ni}. This is especially devastating for low-degree cyclotomics (e.g., Φ4(x)=1+x2). In this work, we revisit the security of multivariate RLWE and propose new alternative instantiations of the problem that avoid the attack while still preserving the advantages of the multivariate structure, especially when using low-degree polynomials. Additionally, we show how to parameterize these instances in a secure and practical way, therefore enabling constructions and strategies based on m-RLWE that bring notable space and time efficiency improvements over current RLWE-based constructions.


Introduction
Lattices have become a very promising tool for the development and improvement of new cryptographic constructions, notably those belonging to the field of homomorphic encryption. Instead of directly working with lattice assumptions, it is frequent to deal with assumptions whose underlying security can be based on the hardness of lattice problems. Among them, the family of Learning with Errors (LWE) [1,2] has become the preferred one due to its versatility. Lyubashevsky et al. [3,4] proposed a variant of LWE called Ring-LWE (or RLWE), whose hardness can be reduced from hardness problems over ideal lattices (instead of the general ones used in the LWE version). RLWE has proven to be more practical than LWE, as the underlying primitives can be usually more efficient; e.g., RLWE enables a notable reduction in the size of the public and secret keys in public key cryptosystems.
The RLWE problem enables homomorphic cryptography with a ring homomorphism supporting both addition and multiplication of ciphertexts. Among the possible quotient polynomial rings used for this purpose, the most practical ones are those where the ideal is a cyclotomic polynomial of the form 1 + z n , with n a power of two. They present two advantages: (a) they enable efficient implementations of polynomial operations through fast radix algorithms of the Number Theoretic Transforms (NTTs) [5,6], and (b) the polynomial operations over the used ring correspond to basic blocks in practical applications in Com-in the field [7,[29][30][31]. In particular, RLWE-based cryptosystems show nowadays the best runtime performance.
Most of the efficiency improvements that RLWE has introduced into (somewhat/fully) homomorphic encryption rely on its particular algebraic structure [4], consisting in the use of polynomial cyclotomic rings. Actually, from a practical perspective, most of the recent libraries for homomorphic cryptography, such as the HElib [14,32], PALISADE [33], SEAL [34], Lattigo [35] and NFLlib [5], take advantage of this fact to optimize the runtime of the implemented lattice-based cryptosystems.
We exemplify in Table 1 the use of univariate RLWE for homomorphic encryption. A simple RLWE-based cryptosystem: Let R q be a cyclotomic polynomial ring Z q [x]/(Φ 2n (x)), where Φ 2n (x) = 1 + x n is the 2n-th power-of-two cyclotomic polynomial with a maximum degree φ(2n) = n (by φ(·) we denote the Euler's totient function). We refer the reader to Table 2 for a summary of the notation used in this work. The RLWE assumption states that given a pair (a, b = as + e) where a ← R q is uniformly random and e ← ψ is drawn from an error distribution (usually a discrete Gaussian distribution χ), this sample is very hard to distinguish from the pair (a, u) where u ← R q is also uniformly random. By assuming this indistinguishability assumption, which reduces from hard problems on ideal lattices (see Theorem 2), it is very easy to define a simple cryptosystem based on RLWE. To this aim, the plaintext information can be encoded in the noise term by working with the ring R t = Z t [x]/(1 + x n ).
Let m ∈ R t be the plaintext, it can be encrypted by doing (a = ta, b = a s + te + m), in such a way that the plaintext is encoded in the lower bits of the error term. This cryptosytem also allows for homomorphic operations.
Homomorphic cryptography: Consider two encryptions (a 1 , b 1 = a 1 s + te 1 + m 1 ) and (a 2 , b 2 = a 2 s + te 2 + m 2 ). If q is high enough compared to the maximum value of the noise terms, we can easily obtain a homomorphic addition of the plaintexts by doing (a add = a 1 + a 2 , b add = b 1 + b 2 = a add s + t(e 1 + e 2 ) + (m 1 + m 2 )).
The process for a homomorphic multiplication is slightly more complicated, but it can still be done: (a mult , b mult , c mult ) = (a 1 a 2 , a 1 b 2 + a 2 b 1 , b 1 b 2 ).
Although we skip the details, the triple (a mult , b mult , c mult ) can be seen as an encryption of the polynomial product m 1 m 2 mod (1 + x n ). Efficient homomorphic encryption: This type of cryptosystems brings about some useful features by taking advantage of the plaintext/ciphertext ring structure: • Operations in the ciphertext ring R q can be very efficiently performed by means of NTT/INTT transforms. • If the plaintext ring R t factors into φ(2n) = n linear factors, each ciphertext can directly encrypt vectors of n integers (or slots) and efficient SIMD (Single Instruction, Multiple Data) operations can be homomorphically performed. • The use of the existing automorphisms in both the ciphertext/plaintext rings enables to exchange the contents between different slots. Hence, this is very convenient to homomorphically rotate the components of the encrypted vectors.
As we will show, the use of multivariate rings for both plaintext and ciphertext rings, instead of the conventional choice of univariate cyclotomics, introduces significant efficiency improvements in the above three aspects.

Bivariate RLWE
Let K (T) = K x K y be the tensor product of 2 cyclotomic number fields of dimensions n x = φ(m x ) and n y = φ(m y ), and R = Z[x, y]/(Φ m x (x), Φ m y (y)) the tensor of their corresponding ring of integers (see Table 2 for a summary of the notation used).
We define a Bivariate Ring LWE sample (see Definition 2 for the general formulation of m-RLWE) as the pair (a, b = (a · s)/q + e mod R ∨ ), where a ← R q is uniformly random and e ← ψ comes from the error distribution ψ. They denote, respectively, the polynomial ring Z[x]/( f (x)) and Z q [x]/( f (x)).
R[x 1 , . . . , x l ], R q [x 1 , . . . , x l ] It represents the quotient multivariate polynomial ring with coefficients in Z (resp. Z q ) and the l polynomial functions f i (x i ) with 1 ≤ i ≤ l. For simplicity, if there is no ambiguity, we omit the polynomial variable.
a(x), a The polynomial a(x) is denoted as a when there is no ambiguity. It can also be denoted by a column vector a, whose components are the corresponding polynomial coefficients.
A ⊗ B It denotes the Kronecker product between matrices A and B.
I, I ∨ I is a fractional ideal of K, while I ∨ is its dual. For an integer q ≥ 2 we can have I/qI. Φ m (x) The m-th cyclotomic polynomial.
Φ 2n (x) = 1 + x n The 2n-th cyclotomic polynomial when n is a power of two. For this particular case φ(2n) = n.

η(I )
Smoothing parameter of the lattice generated by I.
λ i (I) It refers to the i-th successive minimum distance in the lattice generated by I.
SVP, SIVP, DGS They refer, respectively, to the Shortest Vector Problem, the Shortest Independent Vectors Problem and the Discrete Gaussian Sampling problem.

Error distributions
ψ A continuous error distribution over K R .
χ A discrete error distribution over R ∨ (also R).
Ψ A family of continuous error distributions over K R .
Υ A distribution over a family of error distributions, each over K R .
Γ(k, θ) Gamma distribution with shape parameter k and scale parameter θ.
e ← ψ, e ← χ They denote an element e drawn, respectively, from the error distribution ψ and the error distribution χ.
a ← A It denotes an element a chosen uniformly at random from the set A.

BCV Attack
Choices of polynomial functions f x (x) = Φ m x (x), f y (y) = Φ m y (y) as f x (x) = x n x + 1, f y (y) = y n y + 1 have been proposed in [10], as this structure presents computational advantages and can be very beneficial for practical applications.
BCV attack is able to exploit common roots on the involved rings to factorize the multivariate RLWE samples into RLWE samples of smaller dimension. For example, consider that n x = n y = n; by applying the substitution x → y, we obtain n RLWE samples of dimension n each, hence decreasing the n 2 lattice dimension of the original m-RLWE sample.
Consequently, by considering instantiations satisfying gcd (m x , m y ) = 1, the bivariate RLWE problem becomes equivalent to the equally sized RLWE problem. However, we would like to search for other instantiations where the polynomial ideals can have a similar form and, if possible, the same degree.
By restricting ourselves to the most common scenario of "power-of-two" cyclotomics (we must clarify here that we refer to polynomials with only two non-zero terms: the leading and the constant coefficient of the polynomial), polynomial ideals of the form (x n x + d x , y n y + d y , z n z + d z , . . .), could avoid BCV attack for some parameters {n x , d x , n y , d y , n z , d z , . . .}. E.g., the rings Z[x]/(x 64 + 1) and Z[y]/(y 27 + 5) do not have common roots, so trivial substitutions such as x → y cannot be applied. Additionally, whenever we reduce modulo q and work over R q , we can impose (for the sake of efficiency) that both polynomials functions x 64 + 1 and y 27 + 5 factor in linear terms enabling the use of variants of the NTT. Additionally, slot encoding and slot manipulations are still possible in the plaintext ring by means of the pre-/post-processing, as presented in [7]. Analogously to the negayclic convolution, these pre-/post-processing steps preserve the properties of the NTT transform over a ring with an α-generalized convolution [36].
This seems to effectively avoid a substitution attack; however, there might be some small ideal divisor for which, modulo some particular q, the noise does not increase substantially, and we can distinguish the resulting sample from uniform. This attack has been extensively studied by Peikert in [37] and we will discuss it in Section 7.1.

The Proposed Solution
The previous strategy preserves most of the advantages of the multivariate constructions while apparently avoiding the effects of BCV attack. However, the security of these instantiations is not based on any specific formulation of the RLWE problem, and there is no trivial way of parameterizing them. This raises the following questions: 1.
Can we find multivariate rings similar to Z[x, y, . . .]/(x n x + d x , y n y + d y , . . .) while (a) still preserving the aforementioned advantages of this structure, and (b) basing its security on the hardness of the RLWE problem (see Definition 7); i.e., without a decrease in the ring dimension due to BCV attack (see Theorem 3)? 2.
If these multivariate rings exist, how can the values {n x , n y , . . .}, {d x , d y , . . .} be chosen to easily define the ring of integers R and its dual R ∨ ?
From this point forward, we focus on answering these two questions. To this aim, we identify number fields whose ring of integers (and their dual) have the sought structure (see Section 4). In particular, we divide this set of fields in two categories:

2.
More general number fields with polynomials functions {x n x + d x , y n y + d y , . . .} (see Section 6). These structures support all the signal processing applications described in [8], and the matrix operations introduced by the original MHEAAN scheme [39] (not based on coprime cyclotomic polynomials [40]) while preserving the equivalent RLWE security.

Rationale on the Security of Our Solution
The weakness of some m-RLWE instantiations is rooted on the existence of (small norm) zero divisors in the tensor product of fields. For example, Q[x, y]/(x 2 + 1, y 2 + 1) has zero divisors as x + y (e.g., (x + y)(x − y) = 0), and hence m-RLWE samples defined on rings Z[x, y]/(x 2 + 1, y 2 + 1) can be easily factored, as the effective degree can be reduced with substitutions {x → y, −x → y}. Additionally, as these roots have small norm, the noise in the reduced samples is not increased enough to preserve security.
Instead of the previously proposed Z[x, y]/(x 2 + 1, y 2 + 1), we work with a quotient bivariate ring with polynomial ideals of the form (x n x + d x , y n y + d y ) (we use Z[x, y]/(x 2 + 1, y 2 + 3) as our example). The use of different polynomials functions avoids a trivial substitution attack. However, we need to rule out the possibility of (small norm) substitution attacks, such as the one from [25], modulo some q; even if they exist, finding them would require solving a hard subset-sum modq (knapsack) problem.
As there is a security reduction from ideal lattices to RLWE defined on general number fields [26], we search for the ring of integers of multivariate number fields. This gives us a way to find secure parameters for the used ring, and also the right error distribution to guarantee that the noise increase after a substitution modulo q is enough to preserve the required security [37]. To exemplify this rationale, we compare the differences between a bivariate cyclotomic ring (which can be seen as a univariate cyclotomic ring), and our proposed solution.
For more general multivariate rings, we can apply a similar idea. In general, for a secure bivariate ring such as Z[x, y]/(x n x + d x , y n y + d y ), we can search for a transformation y → T(y) where the new polynomial function can share at least some roots with x n x + d x . If this transformation can be effectively applied, we could use it to attack multivariate cyclotomic rings.
Thus, this strengthens the belief that an attack on secure m-RLWE instantiations defined on a general number field should provide us with either an attack to RLWE on the product of prime-powers cyclotomic rings, and/or a better understanding on the weaknesses of general cyclotomic rings. For a discussion on the practical security of RLWE on the proposed number fields we refer the reader to Section 7.1.

Division Algebras and Non-Norm Condition
In [41], the authors propose an alternative variant of LWE over cyclic algebras, which they denote as CLWE (Cyclic Algebra LWE). The main difference with respect to RLWE relies on the fact that, instead of adding a ring structure, they incorporate into Module-LWE a cyclic algebra structure, constructing a non-commutative variant of LWE.
The security of CLWE is supported by the hardness of finding short vectors in certain structured lattices induced by ideals in a cyclic algebra A. Additionally, they explicitly address BCV attack by means of the "non-norm" condition (see [42], Proposition 3.5).
Let a cyclic algebra A = (L/K, θ, γ) where K is a number field of degree k and L is a Galois extension of K of degree n such that Gal(L/K) = θ . For a non-zero γ ∈ K, the cyclic algebra is defined as A = L ⊕ uL ⊕ . . . ⊕ u n−1 L where u ∈ A and u n = γ.
The non-norm condition on γ (see [42], Proposition 3.5) avoids BCV attack by stating that the lowest power of γ which appears in N L/K (L) is γ n , where N L/K represents the relative norm of L into K (see [41] for more details).
This defense against BCV attack also relies on avoiding the existence of zero divisors, which are needed for the attack to succeed. In our case, as we already work in a number field, we can adhere to the security conditions established by Peikert [37] to avoid this type of attacks.
It is worth mentioning that we see both approaches as potentially complementary, in such a way that the underlying field K considered in the (cyclic) division algebra could be one of the multivariate fields discussed in Sections 5 and 6.

Contributions
The first contribution of this work is the definition and parameterization of secure instantiations of the multivariate Ring Learning With Errors problem [8,24], supported by the extended reduction [26] of the original proof by Lyubashevsky et al. [3,4]. The proposed instantiations address the vulnerability leveraged on BCV attack to m-RLWE [25], while still preserving all the efficiency improvements that m-RLWE brings. Moreover we show that is possible to securely instantiate the m-RLWE problem, because the canonical embedding of R has a polynomial skewness (λ n /λ 1 ). Our two main results are summarized in Theorem 5 and Corollary 1 for multiquadratic rings (see Section 5), and Theorems 7 and 8 together with Corollaries 2 and 3, which refer to more general multivariate rings (see Section 6). They show valid parameter choices so that the reduction for RLWE over general number fields [26] (Theorem 2) applies to the hardness of multivariate RLWE, and without a reduction in the lattice dimension. More flexible parameter choices require to relax this assumption from RLWE to the Order-LWE assumption (see Section 9.4). Finally, Theorem 3 gives a worst-case security guarantee for RLWE with any multivariate cyclotomic ring, by stating that it is at least as hard as univariate RLWE, but introducing a decrease in the lattice dimension of the univariate RLWE assumption by a factor of L (see Section 4).
The second contribution is to showcase the possible applications. They are numerous and achieve improved space-time tradeoffs in the most critical lattice operations. Therefore enabling more efficient homomorphic processing and closing the gap to the realization of practical fully homomorphic encryption. This is the main list of applications: • We introduce the α-generalized Walsh-Hadamard Transform as the basic block that can replace Number Theoretic Transforms in multivariate rings [43], achieving an improvement on the computational complexity of degree-n polynomial products by a factor log(n) in terms of elemental multiplications, with additional savings in memory usage (see Section 8). It is worth noting that the results of Section 8 were previously introduced in [43], where we also exemplify its use for the implementation of Oblivious Linear function Evaluation. • We enable net improvements in cryptographic primitives built on top of m-RLWE, such as efficient time and space computation of automorphisms, relinearizations, packing, unpacking and homomorphic slot manipulation, and, consequently, bootstrapping, improving on current achievable trade-offs in RLWE (see Section 9). • We instantiate a simple cryptosystem based on m-RLWE (see Section 7.2), and exemplify with it the use of the multivariate structure of m-RLWE to improve on complex number embedding, enabling fully packed complex numbers, compared to the exponentially decreasing packing ratio of current approaches working with multivariate rings [39,40] (see Section 10). This enables applications in homomorphically encrypted approximate arithmetic, complex processing, and efficient multidimensional signal manipulation.

Structure
The rest of the paper is organized as follows: Section 2 describes BCV attack to multivariate RLWE. Section 3 introduces some algebraic number theory notions and the main definitions for the m-RLWE problem. Section 4 describes the followed strategy to achieve secure instantiations of multivariate RLWE, including the well-known tensor of "coprime" cyclotomic rings. Section 5 focuses on the analysis of multiquadratic rings. Section 6 studies a set of more general multivariate rings. Section 7 includes a discussion on the achieved resilience against known attacks together with example instantiations that showcase the practicality of multivariate RLWE, and discusses some practical applications. Additionally, the included Section 8 particularizes the problem to rings enabling an αgeneralized Walsh-Hadamard Transform, and compares its performance with fast NTT algorithms currently used in state-of-the-art RLWE cryptosystems. Section 9 introduces the strategies for homomorphic packing/unpacking and the space/time tradeoffs improving on current RLWE relinearization and bootstrapping operations. Section 10 briefly discusses how to work with complex slots, comparing to current approaches that work with bivariate rings. Finally, Section 11 draws some conclusions.

Worst Case Security of Multivariate RLWE
We first introduce the notation used in this section (see Table 2 for more details on the notation used in this work). Polynomials are denoted with regular lowercase letters, omitting the polynomial variable (i.e., a instead of a(x)) when there is no ambiguity.
We follow a recursive definition of multivariate modular rings: is the quotient bivariate polynomial ring with coefficients belonging to Z q reduced modulo univariate f 1 (x 1 ) and f 2 (x 2 ). In general, R q [x 1 , . . . , x l ] (resp. R[x 1 , . . . , x l ]) represents the quotient multivariate polynomial ring with coefficients in Z q (resp. Z) and the l polynomial functions f i (x i ) with 1 ≤ i ≤ l. The polynomial a can also be denoted by a column vector a whose components are the corresponding polynomial coefficients.
For the sake of clarity, we present the definition of multivariate RLWE with powerof-two cyclotomic polynomials, as originally introduced in [10], but all the results in this section can be generalized to any cyclotomic function: Definition 1 (Multivariate RLWE with power-of-two polynomial functions as x n i i + 1). Given a multivariate polynomial ring R q [x 1 , . . . , x l ] with f j (x j ) = 1 + x n j j for j = 1, . . . , l where n = ∏ j n j (with all n j a power of two) and an error distribution χ[x 1 , . . . , x l ] that generates small-norm random multivariate polynomials in R q [x 1 , . . . , x l ], the multivariate polynomial RLWE problem relies upon the computational indistinguishability between samples (a i , b i = a i · s + e i ) and (a i , u i ), where a i , u i ← R q [x 1 , . . . , x l ] are chosen uniformly at random from the ring R q [x 1 , . . . , x l ]; s, e i ← χ[x 1 , . . . , x l ] are drawn from the error distribution.
The original works of multivariate RLWE [8,10] assume that the search and decision m-RLWE problems (see Definitions 3 and 4) in dimension n = ∏ m i=1 n i are as hard as the corresponding RLWE problems in dimension n. However, Bootland, Castryck and Vercauteren [25] introduced an attack that can exploit polynomial functions that allow repeated "low-norm" roots in the multivariate ring. As a result, when the subrings of the tensor have common roots, this attack is able to factor the m-RLWE samples into RLWE samples of smaller dimension, hence reducing the security of these m-RLWE samples to that of solving a set of independent RLWE samples which are easiest to break. For e.g., the ring Z[x, y]/(x 2n + 1, y n + 1), changes of variable y → x 2i with i ∈ Z * 2n factors the m-RLWE sample into n different RLWE samples with rings of polynomial function x 2n + 1 and an increase in the error variance of n (maximum degree of y n + 1).
The instantiations of (multivariate) RLWE with "coprime" cyclotomic rings are not affected by this attack, as they do not introduce these "common" roots (see Section 4.1).
We now give a more formal description of the attack, particularized for bivariate RLWE (2-RLWE) with power of two cyclotomics (Definition 1). Let (a, b = as + e) ∈ R 2 q [x, y] and R q [x, y] = Z q [x, y]/(x n x + 1, y n y + 1) with n x ≥ n y and k = n x n y without loss of generality. Now we define the mapΘ: This map is a ring homomorphism, and if q is odd it is also invertible (see [25]). This . If we denote each of the components byΘ i , for i = 1, . . . , n y , we have for i = 1, . . . n y . This results in n y different RLWE samples of dimension n x and whose noise has a variance n y times higher than the original 2-RLWE sample (the result of adding n y independent variables). The attack works by trying to break the obtained n y RLWE samples. Once this is done, as the map is invertible, it is possible to reconstruct the original secret key with the different n y smaller keys.
This attack can be generalized to an m-RLWE sample (Definition 1) by recursively applying "versions" of this map (l − 1) times. This recursion converts an m-RLWE sample into n n 1 RLWE samples (assuming, without loss of generality, that n 1 ≥ n 2 ≥ . . . ≥ n l ) with dimension n 1 and an error variance n n 1 times higher.

Multivariate Ring Learning with Errors
This section revisits the main definitions from algebraic number theory and multivariate RLWE, including a generalized version of the multivariate polynomial RLWE problem which admits any type of cyclotomic polynomial as ideals. For the sake of clarity, we particularize to power-of-two cyclotomic functions (Definition 1) when exemplifying some of the results, but this does not affect to the generality of the discussion.

Algebraic Number Theory Background
This section presents the fundamental concepts of lattices and algebraic number theory and extends them to the more general case of a tensor of number fields on which m-RLWE is based.
When dealing with cyclotomic fields, it is useful to work with the subspace H ⊆ R s 1 × C 2s 2 with s 1 + 2s 2 = n, where the tuple (s 1 , s 2 ) ∈ N 2 is called the signature of the number field, and H satisfies The subspace H is composed of vectors from R s 1 × C 2s 2 , whose first s 1 elements (x 1 , . . . , x s 1 ) are real numbers, and the last part is composed of s 2 complex numbers (x s 1 +1 , . . . , x s 1 +s 2 ) together with their complex conjugates (x s 1 +s 2 +1 , . . . , x s 1 +2s 2 ) = (x s 1 +1 , . . . ,x s 1 +s 2 ).
An orthonormal basis {h j } j∈ [n] for H can be defined as where e j are the vectors of the standard basis in R n . Each element a = ∑ j∈[n] a j h j ∈ H (with a j ∈ R) has its own l p norm. For our purposes, we define the subspace H (T) = i∈[l] H i as the tensor product of l subspaces H i (each subspace H i defined as in Equation (3) but with s 1 + 2s 2 = n i ).
In particular, if we see each element belonging to each H i as a different linear transformation, we are actually working with the Kronecker product of the subspaces H i . We can therefore express an orthonormal basis for H

Lattice Background
A lattice in our multivariate setting is defined as an additive subgroup of H (T) . We only consider full rank lattices, obtained as the set of all integer linear combinations of a set of n linear independent basis vectors B = {b 1 , . . . , b n } ⊂ H (T) The minimum distance λ 1 (Λ) of a lattice Λ for the norm ||.|| is given by the length of the shortest non-zero lattice vector, that is, λ 1 (Λ) = min x∈Λ/x =0 ||x||.

Gaussian Measures
The results on nonspherical Gaussian distributions presented in [4] can be extended to our case. Hence, we revisit here some of the concepts for Gaussian measures, adapted to our tensor setting.
We consider the Gaussian function ρ r : H (T) → (0, 1] with r > 0 as ρ r (x) = exp(−π||x|| 2 /r 2 ). A continuous Gaussian probability distribution D r can be obtained by normalizing the previous function to obtain a probability density function as r −n ρ r (x). Extending this to the non spherical Gaussian case, we consider the vector r = i∈[l] r i where r = (r 1 , . . . , r n ) ∈ (R + ) n and r i = (r i,1 , . . . , r i,n i ) ∈ (R + ) n i and whose components satisfy r i,j+s 1 +s 2 = r i,j+s 1 . Finally, a sample from D r is given by ∑ j∈ [n] x j h j where each x j is drawn independently from a Gaussian distribution D r j over R; r j equals ∏ i∈[l] r i,j i (where l is the number of "unidimensional" spaces H i in the tensor, that is n = ∏ i∈[l] n i ) and we are using any invertible mapping between {j} j∈[n] and {j i } j i ∈[n i ],i∈[l] .

Main Definitions for Multivariate Ring-LWE
Let K (T) = i∈[l] K i be the tensor product of l cyclotomic fields of dimension the tensor of their corresponding (dual of the) ring of integers. We have the following definitions: Definition 2 (Multivariate Ring LWE distribution). For s ∈ R ∨ q and an error distribution ψ over K (T),R , a sample from the m-RLWE distribution A s,ψ over R q × T is generated by a ← R q uniformly at random, e ← ψ, and outputting (a, b = (a · s)/q + e mod R ∨ ) (where T = K (T),R /R ∨ and K (T),R = K (T) ⊗ Q R) .

Definition 3 (Multivariate Ring LWE, Search).
Let Ψ be a family of distributions over K (T),R . m-RLWE q,Ψ denotes the search version of the m-RLWE problem. It is defined as follows: given access to arbitrarily many independent samples from A s,ψ for some arbitrary s ∈ R ∨ q and ψ ∈ Ψ, find s. Definition 4 (Multivariate Ring LWE, Average-Case Decision). Let Υ be a distribution over a family of error distributions, each over K (T),R . The average-case decision version of the m-RLWE problem, denoted m-R-DLWE q,Υ , is to distinguish with non-negligible advantage between arbitrarily many independent samples from A s,ψ , for a random choice of (s, ψ) ← U(R ∨ q ) × Υ (where U(R ∨ q ) represents the uniform distribution over R ∨ q ), and the same number of uniformly random and independent samples from R q × T.
For an asymptotic treatment of the m-RLWE problems, we let K (T) come from an infinite sequence of tensors of number fields K = {K (T),n } of increasing dimension n (n = ∏ i φ(m i ) is the number of basis elements that form the integral basis), and let q, Ψ, and Υ depend on n as well.

Error Distributions
We include here two definitions about the error distributions. Definition 6 (extension of Lyubashevsky et al. [4], Definition 3.5). Let K (T) = i∈[l] K i where the K i are the m i -th cyclotomic number field having degree n i = φ(m i ). For a positive real α > 0, a distribution sampled from Υ α is given by an elliptical Gaussian distribution D r (over K (T),R ) whose parameters are r j ∈ [n] using the unidimensional index (see Section 3.1.3), and each r j satisfies r 2 where different x j ,x k that do not correspond to conjugate positions are chosen independently from the distribution Γ(2, 1).
Practical applications [7,9,10] usually deal with variants of the problem: • discrete b: Instead of working with an error distribution ψ over K (T),R , the m-RLWE distribution A s,χ can use χ as a discrete error distribution over R ∨ , so that the element b belongs to R ∨ q . • small key: Instead of a uniform s, s can be a "short key" equivalently sampled from the error distribution (this is known as "normal form" in [13]), with equivalent security. Given a list of l m-RLWE samples, s can be substituted with the error e of any sample (a, b) whose term a is invertible in R q , which occurs with constant probability by Claim 1 below. • power of 2 cyclotomic: Instead of sampling a and s from R q and R ∨ q respectively, both are usually sampled from R q (this is usually known as the non-dual variant). In general, the works which consider s in R q deal with cyclotomic fields where m i is a power of two. It can be shown that for this particular type of cyclotomic fields both definitions are equivalent. • modulus switching: The original definitions of the problem are presented with a prime modulus q that splits the space into small independent coordinates. With the same hardness guarantees, it is possible to modulus-switch to other compute-friendly modulus at the price of a slight increase of the error.
Lyubashevsky et al. [13] show that the variant of RLWE with discrete and short error (R-DLWE q,χ ) is as hard as the original R-DLWE q,ψ , by following the technique from [44]. These results can be adapted to our more general case as follows: Thus, if q ≥ n, this probability is constant.
Proof. Since R q is in bijection with the ring (Z/qZ) n via the tensor embedding mod q, so an element is invertible iff. its image does not contain any zero. Hence, there are (q − 1) n invertible elements out of q n .

Pseudorandomness of m-RLWE
To show that the m-RLWE distribution is pseudorandom (that is, there exists a reduction from the search problem to the decision variant of the hardness problem) we rely on the results from [4], applied to the case of multivariate elements. The main needed properties are those related to the decomposition of (q) into n prime ideals (q ≡ 1 mod m i for all i) and the use of the automorphisms that permute the prime ideals.

Proposed Approach for Secure Multivariate Rings
Despite the efficiency benefits of multivariate RLWE, its security can be much smaller than originally expected for those instances vulnerable to BCV attack [25]. This motivates us to redefine the set of instantiations that preserve the security in the tensor lattice dimension.
This section enumerates those secure instantiations of multivariate RLWE. With this in mind, we first briefly revise the choice of "coprime" order cyclotomics explicitly included in [13]. Afterwards, we discuss the possibility of using a more general set of number fields, enabling other multivariate rings that can be more convenient for practical applications.

Multivariate RLWE as a Subset of RLWE
It is well known that for two cyclotomic number fields Q(ζ a ) and Q(ζ b ) with coprime orders gcd(a, b) = 1, their product is the cyclotomic number field Q(ζ ab ) (see Lemma 11.8 in [45]). For convenience, we include an adapted version of this property ( [13], Equation (1.1)) using the polynomial representation of the cyclotomic number fields.
Theorem 1 (Tensorial decomposition of cyclotomic number fields). The m-th cyclotomic field where m = ∏ i m i is decomposed in its prime-power decomposition with gcd(m j , m k ) = 1 for all j = k.
This fact gives an alternative basis to the power basis {1, x, . . . , It does not coincide with the power basis under the mentioned field isomorphism and considering the map x m m i → x i for i = 1, . . . , l (see [13]). This "powerful" basis has some very nice properties [13] which make it more appealing than the more "conventional" power basis. Additionally the authors of [13] provide a detailed analysis on how the performance of ring operations can be improved by means of this multivariate structure.
Besides [13], the use of the multivariate structure in Equation (4) has been exploited to enhance polynomial operations in both the HElib [14,32] and the MHEAAN [40] libraries. This gives us a first approach to deal with multivariate instantiations which do not suffer a decrease on the underlying lattice dimension. However, this structure is not flexible enough to convey the same benefits that general multivariate structures can achieve; in particular, it cannot preserve the interesting structure of power-of-two cyclotomics (1 + x n ).

More General RLWE Instantiations
We look now beyond cyclotomics, into more general and flexible number fields and their parameterization. We first introduce the definitions of RLWE over any number field [26], and then give the intuition on the properties required to resist the BCV attack. A detailed discussion on the choice of good parameters and the security of RLWE on these number fields follows in Sections 5, 6 and 7.1.

RLWE Over Any Number Field
Peikert et al. [26] have recently generalized the RLWE problem to any number field. Let K be a number field with ring of integers R = O K ; let R ∨ be the fractional codifferent ideal of K, and let T = K R /R ∨ . Let q ≥ 2 be a (rational) integer modulus, and for any fractional ideal I of K, let I q = I/qI (for any fractional ideal I ⊂ K there is a ∈ O K such that aI ⊆ O K is an integral ideal of O K ). We include now the relevant definitions of RLWE over any number field that we use in our formulation.
Definition 7 (Ring-LWE Distribution, Definition 2.14 in [26]). For s ∈ R ∨ q and an error distribution ψ over K R , the R − LWE distribution A s,ψ over R q × T is sampled by independently choosing a uniformly random a ← R q and an error term e ← ψ, and outputting (a, b = (a · s)/q + e mod R ∨ ).
Definition 8 (Ring-LWE, Average-Case Decision, Definition 2.15 in [26]). Let Υ be a distribution over a family of error distributions, each over K R . The average-case Ring-LWE decision problem, denoted R − LWE q,Υ , is to distinguish (with non-negligible advantage) between independent samples from A s,ψ for a random choice of (s, ψ) ← U(R ∨ q ) × Υ, and the same number of uniformly random and independent samples from R q × T. Theorem 2 (Theorem 6.2 from [26]). Let K be an arbitrary number field of degree n, I any fractional ideal of K, and R = O K . Let α = α(n) ∈ (0, 1), and let q = q(n) ≥ 2 be an integer such that αq ≥ 2 · ω(1). There is a polynomial-time quantum reduction from K − DGS γ to (average-case, decision) R − LWE q,Υ α , for any K − DGS γ corresponds to the Discrete Gaussian Sampling (DGS) problem, but restricted to (fractional) ideal lattices in K.
The Υ α distribution considered here is narrower than the one from Theorem 6. We refer the reader to Definition 6.1 from [26] for its concrete expression.
Additionally, it is worth highlighting some observations on the choice of a particular number field in RLWE, as stated in [26]: • The geometry of the dual ideal R ∨ affects the error rate α (chosen to be smaller than the minimum distance λ 1 (R ∨ )). As α decreases, worst-case hardness theorems give weaker guarantees (i.e., larger approximation factors), and known attacks on Ring-LWE become more efficient. • A similar phenomenon arises for rings with large "expansion factors" (see [46]) which imposes smaller α for achieving correct decryption; hence, good rings for practical applications have small expansion factors. • Besides the two previous relations, there is no practical evidence on which particular number field is better in terms of security.

Ad-Hoc Countermeasures to BCV Attack
BCV attack [25] shows that a reduced RLWE sample is at least as hard as an m-RLWE sample. To prove the converse, we can use an oracle for m-RLWE. With access to such oracle and a set of RWLE samples with different keys, we can construct an m-RWLE sample (with a slight increase in the noise variance) by means of the reverse map of BCV attack (i.e.,Θ −1 ). Once this oracle returns the secret key of the m-RLWE sample, the original keys of the RLWE sample can be recovered by means of the mapΘ.
We can therefore express the security of m-RLWE in terms of RLWE, but the decrease of the involved dimension considerably reduces the applicability of the problem with "non-coprime" polynomial functions. The security of and dimension n. We can transform (this transformation is invertible when q is prime) these L samples by means of the (inverse) of BCV attack into one m-RLWE sample with having for the RLWE sample n = . This transformation slightly increases the variance of the error distribution by a factor L.
The decrease in the lattice dimension by a factor L = ∏ j =k φ gcd(m j , m k ) brings about the question of whether we can modify some of the multivariate RLWE constructions where L > 1 to avoid BCV attack.

Followed Strategy
By considering instantiations satisfying gcd (m j , m k ) = 1 for all j = k, we straightforwardly go back again to the RLWE problem defined on univariate cyclotomic rings. On the contrary, we would like to find other instantiations where the polynomial ideals can have a similar form and degree. We will hence focus on polynomial functions as follows: {x n x + d x , y n y + d y , z n z + d z , . . .}, which can avoid BCV attack for certain parameters, while enabling NTT-like fast transforms and preserving the advantages of the originally introduced m-RLWE constructions.
However, the security of these instantiations is apparently not based on any specific formulation of the RLWE problem, so we do not have a clear way of choosing the right parameters.
In the next two sections, we will show that this is not really true and that there are many number fields satisfying Definition 7, and whose ring of integers (and their dual) has the aforementioned structure. In particular, we focus on multiquadratic number fields (Section 5) and more general multivariate rings (Section 6).

Multiquadratic Rings
, according to (see Proposition 1): Let us extend the field to Q( √ d 1 , . . . , √ d l ) (a multiquadratic field), with all d i pairwise coprime, but still sticking to the case d i = 1 mod 4. Taking into account that where F is the compositum over Q (see [48]) of two subfields . This can be generalized to the case of a field with l "coprime" squares, whose resulting ring of integers is Therefore, as all d i are different primes, the discriminants of Q( √ d i ) are also coprime, which implies that the ring of integers can be expressed as the product of the respective univariate rings of integers. However, the definition of RLWE (see Definition 8) works on the dual of the ring of integers, due to its geometric properties. The dual can be obtained through Theorem 4: The dual basis to {1, α, . . . , α n−1 } relative to the trace product is In particular, if K = Q(α) and α ∈ O K then ), being f (x) the corresponding scale factor introduced in the power basis. Particularized to the quadratic case, Theorem 4 says that whenever the ring of integers has a power basis, the basis of the dual is where As dual commutes tensoring, this result can be straightforwardly extended to the compositum case with several d i . Additionally, we see that we can go from the dual to O K by just scaling with √ d i (or multiplying with the polynomial 2x − 1). Following our requirements, we need a ring of the form Z[x 1 , . . . , , which is an order of the field Q( , but not necessarily its ring of integers and a Dedekind domain. Actually, a recent work [51] discusses the hardness of a generalization of Ring-LWE called Order-LWE, which can be leveraged to have more freedom in the choice of the multivariate rings (see Section 9 for more details on the advantages of Order-LWE). We also refer the reader to [52] for a recent study on the connections between several algebraic LWE variants.
However, in this section we only want to base the security on RLWE defined on a number field of the form Q( √ d 1 , . . . , √ d l ) (see Definition 7) and its ring of integers satisfying Z[x 1 , . . . , ). We will therefore show that we can define an invertible map modulo q from the ring O K (and its dual O ∨ K ) to the ring Z[x 1 , . . . , , while still basing its security on the original RLWE formulation from Definition 7. Additionally, this map does not significantly increase the noise; in fact, it also decorrelates it in the coefficient domain, enabling direct sampling of the noise in the coefficient representation with an independent error distribution.
The map, applied to each variable x i , works as follows: • We apply the change of variable x → x+1 2 .
• We multiply the sample by a factor 2.
This mapping can be applied whenever the inverse of 2 exists modulo q. The multiplication by 2 is applied afterwards to avoid the potentially high distortion introduced by the factor 1 2 into the noise. Canonical Embedding: The inverse map E −1 is defined as the product with the matrix

Sampling the error directly in the coefficient domain:
Finally, if we define the noise in the embedding of the dual ring as two independent Gaussian variables e 0 , e 1 with variance σ 2 , we have in the ring 1 x Z[x]/(x 2 − d) after following the whole "processing chain": Hence, the noise is not correlated in the coefficient domain and we can easily sample the error distribution considering an appropriate variance per coefficient.
For simplicity, we have focused on a quadratic field, but the embedding matrix can be extended to the multiquadratic case by means of the Kronecker product.

Multiquadratic RLWE
Let us define the multiquadratic version of m-RLWE, where all the polynomial func- Definition 9 (Multivariate polynomial RLWE with quadratic polynomial ideals). Given a multivariate polynomial ring R ∨ q [x 1 , . . . , x l ] with f j (x j ) = d j + x 2 j for j = 1, . . . , l where l = log 2 n (with n a power of two) and an error distribution χ[x 1 , . . . , x l ] that generates smallnorm random multivariate polynomials in R ∨ q [x 1 , . . . , x l ], the multivariate polynomial RLWE relies upon the computational indistinguishability between samples x l ] are drawn from the error distribution (see Section 5).
Given an adequate parameter setting, the security reduction from Theorem 2 applies to this multiquadratic version of the RLWE problem.
Section 7.1 gives further insights on the security and practicality of the chosen parameterization, and exemplifies it with a concrete instantiation. In particular, Proposition 5 gives a sufficient condition to consider the problem secure against known attacks. It is worth mentioning that even when the Principal Ideal Problem is easy in multiquadratics [53], to the best of our knowledge, this has not been proven enough to solve RLWE.

Comparison with Gaussian Integers
We now compare the multiquadratic RLWE with the particular case of power-of-two cyclotomics m-RLWE (see Definition 1) where all the used polynomial functions have the same form f i ( . . , l where l = log 2 n (with n a power of two) and an error distribution χ[x 1 , . . . , x l ] that generates smallnorm random multivariate polynomials in R q [x 1 , . . . , x l ], the multivariate polynomial RLWE relies upon the computational indistinguishability between samples (a x l ] are chosen uniformly at random from the ring R q [x 1 , . . . , x l ]; and s, e i ← χ[x 1 , . . . , x l ] are drawn from the error distribution. The comparison of our secure multiquadratic RLWE samples with RLWE samples from Definition 10 is specially relevant, as the latter are severely affected by BCV attack. Samples from Definition 10 can be reduced to a dimension of 2, by applying the map Θ a total of (log 2 n − 1) times, yielding n/2 RLWE samples with f (x) = 1 + x 2 and error variance n/2 times higher than the original m-RLWE sample; this can be very easily solved. Consequently, despite of the efficiency of the polynomial operations on the rings instantiated according to Definition 10, they are not valid for cryptographic applications. Meanwhile, the samples from a secure instantiation of multiquadratic RLWE (Definition 9) preserve the lattice dimension n and withstand BCV attack.
Another advantage of the multiquadratic RLWE problem is that it also enables very efficient polynomial operations, without decreasing security. In particular, it is possible to apply a variant of the Fast Walsh-Hadamard Transform (over finite rings instead of the usual real numbers), featuring a convolution property that relates the coefficient-wise representation with the transformed domain. This transform can be very efficiently computed with FFT-like algorithms whose computational cost is only O(n log n) additions and O(n) products, hence considerably speeding up practical implementations [43]. For more details, we refer the reader to Section 8.

More General Multivariate Rings
Let us consider now general fields Q(a 1/n 1 1 , . . . , a 1/n l l ), for which the a i are squarefree and coprime, but for simplicity we will assume that they are independent primes. The results shown in the previous section for multiquadratics cannot be straightforwardly generalized to these fields, as the individual univariate fields Q(a 1/n i i ) can easily have common factors in their discriminants (i.e., be non-coprime), in such a way that finding a basis for the multivariate ring of integers is not trivial. We refer the reader to Section 9 for a discussion on the advantages that Order-LWE [51] brings about with respect to RLWE when choosing a basis for the ring of integers.
We explain the followed path that leads to our definition of valid, secure and easily parameterizable multivariate rings. We start by choosing number fields whose ring of integers O K can be represented as Z[x]/(x n + ax + b), that is, as quotient polynomial rings whose ideal has the form (x n + ax + b). For this to be a valid ring O K for K, it has to be irreducible over Q, for which we use Eisensntein's criterion: Proposition 2 (Eisenstein's criterion [54]). The polynomial p(x) = a n x n + a n−1 x n−1 + . . . + a 1 x + a 0 , where a i ∈ Z for all i = 0, . . . , n and a n = 0 (which means that the degree of p(x) is n) is irreducible if some prime number p divides all coefficients a 0 , . . . , a n−1 , but not the leading coefficient a n and, moreover, p 2 does not divide the constant term a 0 .
Therefore, we impose the following two conditions on f (x) = x n + ax + b: • Both a and b have to be divisible by a prime p and not by p 2 (Eisenstein's criterion). • If we choose b as a prime, a has to be divisible by b.
Now, we can compute the discriminant for this number field by resorting to ([55], Chapter 2.7): Proposition 3 (An example of the calculation of a discriminant [55] ). For the calculation of ∆ K in a number field K = Q(x) being a extension of finite degree n of Q and f (x) = x n + ax + b the minimal polynomial of x over Q, we obtain For n = 2 (respectively, 3) we rediscover the well-known expressions a 2 − 4b (respectively, −27b 2 − 4a 3 ). If we choose values for a and b such that the polynomial discriminant is squarefree, Theorem 6 guarantees that the ring of integers has a power basis of the form {1, α, α 2 , . . .}, with α a root of x n + ax + b. Consequently, Z[x]/(x n + ax + b) is a valid ring of integers.
By including more "univariate" subrings, Z[x 1 , . . . , x l ]/(x n 1 + a 1 x + b 1 , . . . , x n l + a l x + b l ) becomes a valid ring of integers when all the discriminants are coprime [49]. Therefore, this is a feasible strategy to define RLWE over a multivariate ring, as the product of univariate rings with polynomial ideals (x n + a i x + b i ). To define the dual O ∨ K we can make use of Theorem 4 which states that whenever the ring of integers has a power basis, the basis of the dual is the same basis, scaled by 1 f (α) = 1 nα n−1 +a , where α is a root of f (x). Finding valid parameters for f (x) = x n + ax + b: Unfortunately, the two previous conditions (Eisenstein's criterion from Proposition 2 and Theorem 6) cannot be satisfied at the same time

•
To satisfy the Eisenstein's criterion, b and a have to be divisible by at least a prime p (i.e., gcd (a, b) = u · p for some u ∈ Z), this introduces a factor p n−1 in ∆ K (see Equation (9)), in such a way that ∆ K is not squarefree and not satisfying [O K : L ] = 1 in Theorem 6. We could still work with these multivariate rings provided that their discriminants are coprime, but it seems that there is no straightforward way to determine the "powerful" basis of the ring of integers: starting from Proposition 3, it is known that Additionally, Eisenstein's criterion is a sufficient but not necessary condition for irreducibility of the polynomial functions. Without the imposed restrictions, we could search for squarefree and coprime discriminants, but we would have to verify the irreducibility of the involved functions case-by-case. Nevertheless, this is not impossible to find, as it is known that monogenic fields are not scarce [56]; in fact, for random polynomials f , it has been conjectured that Z[x]/( f (x)) of degree ≥ 4 is a ring of integers with probability 0.307 [57].

Transformation Based on Modulus Switching
Let us assume that we have found valid (monogenic) x n i + a i x i + b i functions defining the ring of integers Z[x i ]/(x n i + a i x i + b i ); they do not yet feature the desired x n + d form. In order to achieve this, we consider a map from the original RLWE samples to RLWE samples modulo q, that removes the term ax if q divides a. It is worth noting that this transformation is nothing but a modulus switching to q, and if it were possible to break RLWE modulo q, the original secret key could be recovered or at least the indistinguishability assumption could be broken.
The trick relies on all the polynomial functions having the form Hence, a reduction modulo q converts the polynomial We show the effect of this transformation on the ring qO ∨ K for the univariate case (it extends to the multivariate case, as dual commutes tensoring): After reducing modulo q, we obtain 1 nx n−1 Z q [x]/(x n + b i ); considering that x has inverse modulo q, we can multiply numerator and denominator by x to obtain x nx n = Decodability of the transformed x n + ax + b: Elias et al. [56] use an heuristic perturbation method to bound the spectral norm of the canonical embedding with f (x) = x n + ax + b. As the condition number is stable for most of the random perturbations of the canonical embedding matrix associated to x n + 1, they conjecture that many f functions have a bounded spectral norm in terms of a and b; therefore, we can consider that the spectral norm s 1 (N f ) (N f represents the inverse of the canonical embedding matrix) is likely bounded by max (a, b) · det (N f ) 1/n [58]. Consequently, the same arguments about noise behavior in [37,58] still apply, and in order to guarantee the prevalence of the security reduction (see Proposition 5), the noise wraps around modulo q in some of the polynomial coefficients (max (a, b) ≈ q). This is due to the large q factor introduced in f (x), which requires the use of a high error variance, rendering some of the polynomial coefficients modulo q useless. This makes these RLWE samples harder to use for cryptographic applications.

Valid and Practical Parameterizations for Multivariate Rings
The previous solutions to parameterize multivariate rings with polynomial ideals (x n + d) are not satisfactory, as (a) the search of valid univariate rings is not easy to handle (due to the impossibility to use Eisenstein's criterion) and (b) the obtained samples are not practical for cryptographic applications due to their high noise in some polynomial coefficients.
Here we follow a slightly different approach, releasing the condition on equaldegree polynomial functions; that is, we consider multivariate rings as Z[x 1 , . . . , x l ]/(x n 1 1 + d 1 , . . . , x n l l + d l ). Again, to simplify the explanation we only use an univariate quotient ring with polynomial ideal (x n + d), but all the results can be analogously extended to the multivariate case (see Section 5) by requiring coprime discriminants.
First, for f (x) = x n + d, Equation (9)  Analogously to the multiquadratic rings in Section 5, we can directly map the error distribution in the coefficient domain. In particular, for the ring where r is the parameter of an independent spherical error distribution in the embedding domain [58]. This extends to multivariate rings by means of the Kronecker product.
Finally, we introduce the definition of multivariate RLWE with the proposed polynomial functions f i (x i ) = d i + x n i i : Definition 11 (Multivariate RLWE with polynomial functions as x n i i + d i ). Given a multivariate polynomial ring R q [x 1 , . . . , x l ] with f j (x j ) = d j + x n j j for j = 1, . . . , l where n = ∏ j n j (where all n j are prime powers) and an error distribution χ[x 1 , . . . , x l ] that generates small-norm random multivariate polynomials in R ∨ q [x 1 , . . . , x l ], the multivariate polynomial RLWE relies upon the computational indistinguishability between samples (a i , b i = a i · s + e i ) and (a i , u i ), where a i ← R q [x 1 , . . . , x l ], u i ← R ∨ q [x 1 , . . . , x l ] are chosen uniformly at random from the rings R q [x 1 , . . . , x l ] and R ∨ q [x 1 , . . . , x l ]; s, e i ← χ[x 1 , . . . , x l ] are drawn from the error distribution.
For the ring R ∨ [x 1 , . . . , x l ], we define χ[x 1 , . . . , x l ] as an error distribution generating polynomials belonging to R ∨ [x 1 , . . . , x l ] and whose parameter per coefficient satisfies , where 1 ≤ j i ≤ n i and 1 ≤ i ≤ l, and hence represents the parameter for the coefficient associated to the monomial x . Given an adequate parameter setting, the security reduction from Theorem 2 applies to several multivariate versions of the RLWE problem (see Definition 11). The error distribution satisfies the lower bound αq ≥ 2 · ω(1). . The polynomial-time quantum reduction from Theorem 2 applies to the multivariate RLWE assumption from Definition 11 whenever: • All d i and n i are, respectively, different odd primes and powers of the odd primes u i . • All d i and u i satisfy gcd (d i , u j ) = 1 for all i, j.
Corollary 3 (Parameter setting-hardness of multivariate RLWE with polynomial functions as x n i i + d i , derived from Theorem 7). The polynomial-time quantum reduction from Theorem 2 applies to the multivariate RLWE assumption from Definition 11 whenever:

•
All d i are different primes, and each n i is a power of d i .
Theorem 8 (Parameter setting-hardness of multivariate RLWE with the compositum of rings from Definitions 9 and 11). The polynomial-time quantum reduction from Theorem 2 applies to the multivariate RLWE assumption from Definition 11 whenever: • For all f i (x i ) = d i + x n i i with n i = 2: - The d i are squarefree integers satisfying −d i = 1 mod 4.
• For all f i (x i ) = d i + x n i i with n i > 2 a power of a prime u i : All d i and all n i > 2 satisfy gcd (n i , n j ) = 1, gcd (n i , d j ) = 1 and gcd (d i , The error distribution satisfies the lower bound αq ≥ 2 · ω (1).
Additionally, as both discriminants are coprime, the product is directly the corresponding ring of integers.

Security of Multivariate RLWE and Example Instantiations
This section includes a discussion on several aspects of the proposed solutions in this work, namely their security, the geometric interpretation of the problem, and the feasibility of the proposed parameterizations. With this purpose, we enumerate the known attacks in the literature and include an example instantiation of a simple bivariate RLWE scheme. We refer to next Sections for a description of the applications enabled by our constructions.

Resilience against Known Attacks
The formulation proposed in this work involves working with quotient rings whose polynomial ideal is (x n + d) or, more generally, (x n + ax + b). Some particular instantiations of these rings have already been studied in the literature and we can find specific attacks to "variants" of the RLWE problem (e.g., PLWE together with non-dual and dual RLWE versions) defined over them.
In general, the known attacks can be divided in two main types [37]: • Attacks using a reduction modulo an ideal divisor q of the modulus qR [56,[59][60][61][62][63]. These attacks try to distinguish between the error distribution and the uniform distribution modulo an ideal divisor. • A reduction to errorless LWE [58] which exploits the relation between RLWE and LWE. Expressing RLWE in its LWE form, the error term of some of the equations can be removed by means of a rounding operation, and linear algebra can be used to search for the secret key.
All these attacks have been generalized and studied in depth by Peikert in [37], where he concludes that all the concrete insecure RLWE instantiations made use of error distributions which were insufficiently well spread relative to the rings, meaning that none of the vulnerable instantiations satisfy the conditions from Theorem 2 to have worst-case hardness. In [37], Peikert also gives sufficient conditions to make RLWE secure against the previous attacks. We summarize the main relevant results for our constructions.
The validity of Proposition 5 to resist the previous attacks is shown in the following two theorems: Theorem 9 (for the attack based on reduction modulo an ideal divisor) and Theorem 10 (for the attack based on errorless LWE). Theorem 9 (Theorem 5.2 from [37]). Given a Ring-LWE sample (a, b = s · a + e) ∈ R q × K R /qR ∨ where e ← D r is transformed into n LWE samples (A a , b = s T A a + e T ), where b ∈ (R/qZ) n and e ∈ R n are respectively the coefficient vectors of b ∈ K R /qR ∨ and e ∈ K R (with respect to the chosen basis of R ∨ ), and A a ∈ Z n×n q is the matrix of multiplication by a ∈ R q with any element of R ∨ q (with respect to the chosen bases of R, R ∨ ). Then, for any Z-basis B ∨ = (b ∨ j ) of R ∨ used above, each entry of e is a continuous Gaussian of parameter at least r √ n ≥ 2 √ n (which is the required lower bound to apply the worst-case hardness theorems for plain-LWE).
Theorem 10 (Theorem 5.1 from [37]). Let q ⊆ R be any ideal of norm N(q) ≤ 2 n , and let the error parameter r ≥ 2 satisfy condition (10). Then the reduced error distribution D r mod qR ∨ is within statistical distance 2 −2n of uniform over K R /qR ∨ .

Geometric Interpretation and Examples of Multivariate RLWE
In this section, we give a high level overview of how to instantiate a secure multivariate RLWE sample from Definition 11, exemplifying it in the bivariate case (all rings are defined over variables x, y, omitted when unambiguous).
This example can also be used as a means to showcase complex numbers packing into slots, obtaining a net improvement on the number of available slots per ciphertext when comparing to the recent results in [39] (see Section 10). For the sake of clarity, we introduce a simple SHE scheme which enables homomorphic additions and multiplications without taking into account some of the more advanced techniques typically considered in the literature.

A Multivariate RLWE Sample
For simplicity, we consider a bivariate RLWE sample (a, b = a · s + e) ∈ R q × R ∨ q , where a ∈ R q [x, y], s ∈ R ∨ q [x, y] and e ← χ[x, y], with χ[x, y] generating small-norm random bivariate polynomials in R ∨ [x, y]. We can use a uniformly random s or follow conventional approaches where s is a small key (see Section 3).
Geometry of R, its dual R ∨ and an example for {x 2 + 3, y 2 − 5}: To easily illustrate the geometry of R and R ∨ , we use a simple example R = Z[x, y]/(x 2 + 3, y 2 − 5). By means of the canonical embedding, we know that the substitutions {x → ± √ −3, y → ± √ 5} yield the four different slots in the embedding domain. This clearly shows that λ 1 (R) ≤ √ n = 2 by the embedding of 1, and we can also obtain the embedding of the elements x, y and xy. The term xy can be used to obtain an upper-bound for λ 4 (R), such that λ 4 (R) ≤ 2 √ 15. This is generalizable to any multiquadratic with l = log 2 n variables, by considering the embedding of 1 and ∏ i∈[l] x i , obtaining λ 1 (R) ≤ √ n and λ n (R) ≤ √ n ∏ i∈[l] √ d i . As the l-th prime is asymptotically p l ∼ l log l, a worst-case for l = log 2 n is d l l ∼ l l (log l) l = (log 2 n) log 2 n (log 2 log 2 n) log 2 n . Combining the two previous expressions we have that λ n (R) (and hence also the ratio λ n (R) λ 1 (R) ) is polynomially upper-bounded by n. These bounds are straightforwardly extended to the dual R ∨ by taking into account the corresponding "tweak" factor. For the multiquadratic scenario, the dual only suffers a scaling by the square roots of the d i terms (R is sparser than the dual R ∨ ). However, considering higher degrees in the polynomial functions x n i i + d i , the tweak factor can turn the noise in the non-dual version of RLWE into highly non-spherical.
A very detailed analysis of these effects (including also some enlightening visual examples) can be found in [37].

Parameters' choice:
We show now how to select correct parameters {n x , n y , d x , d y } satisfying the conditions established in Sections 5 and 6 for valid number fields.
As a brief summary, and focusing on n x , n y > 2, this mainly implies that: (1) the discriminants of K x = Q[x]/(x n x + d x ) and K y = Q[y]/(y n y + d y ) are coprime, i.e., gcd (∆ K x , ∆ K y ) = 1, and (2) n x , n y are prime powers satisfying Proposition 4.
This enables the definition of O K = R = Z[x, y]/(x n x + d x , y n y + d y ) as the ring of integers. Analogously, the dual is O ∨ K = 1 n x n y x nx −1 y ny −1 Z[x, y]/(x n x + d x , y n y + d y ) (see Section 6 for some particular choices).
In this bivariate case, the error distribution χ[x, y] samples polynomials in O ∨ K whose coefficients are independently sampled from Gaussian distributions with different standard deviations. In particular, σ is equal to r √ nd nx −jx nx x d ny −jy ny y / √ 2π for the coefficient associated to the monomial x j x −1 y j y −1 with 1 ≤ j x ≤ n x and 1 ≤ j y ≤ n y .
Working on qO K : As it is usually done with power-of-two cyclotomics, we can directly transform the dual into the ring of integers by means of a scaling.
If we have O ∨ K = 1 n x n y x nx −1 y ny −1 Z[x, y]/(x n x + d x , y n y + d y ), we can first multiply the dual by xy xy , to see the simplified relation xy xy O ∨ K = xy nd x d y O K . Finally, analogously to the x n + 1 functions, we can scale the (a, b) sample by n = n x n y and also d x d y . This gives us a sample (a(x, y), b (x, y) = nd x d y xy · b(x, y)) ∈ R 2 q . Consequently, we can directly work on the ring of integers with (a, b = as + e) ∈ R 2 q where a ← R q , s ← R q (or also s ← χ [ The basic example cryptosystem described in Table 3 follows the structure of the SHE version introduced in [64] and implemented in [65]. The main difference relies on the fact that our polynomial elements belong to the multivariate rings R[x, y], R t [x, y] and R q [x, y] (see Definition 11), contrarily to the traditional univariate version Z[x]/(1 + x n ) and its analogous rings modulo t and q. In Table 3 the diagonal of J has the corresponding standard deviations of χ normalized by r (i.e., σ/r) for each coefficient of the bivariate polynomials.
In particular, our plaintext ring R t is basically a bivariate polynomial R t [x, y] = Z t [x, y]/(x n x + d x , y n y + d y ) which is encoded as a sub-module of T = K R /R ∨ (see Definition 7). Our example is based on the scheme introduced in [64], but other choices are possible. Regarding the achieved noise bounds, they are analogous to the computations from [64] by taking into account the expansion factor of the involved rings.
The additional variables of the multivariate structure can bring about some significant advantages: more efficient polynomial operations (see Section 8), better space/efficiency tradeoffs when working with automorphisms (see Section 9), and can also be very useful when working with multidimensional structures (see the works [8,10,39] for more details on practical applications). In particular, in [39,40] the authors present a library called MHEAAN, based on multivariate RLWE, which is optimized to perform homomorphic matrix operations. Table 3. Parameters and primitives of a somewhat homomorphic cryptosystem based on a multivariate version of RLWE (see [8,10]).

Parameters
Let R t [x, y] be the cleartext ring and R q [x, y] the ciphertext ring. The noise distribution χ[x, y] in R q [x, y] takes its coefficients from a multivariate truncated Gaussian N (0, r 2 J 2 ). q is an integer satisfying t < q and is relatively prime to t. All the previous parameters are chosen in terms of the security parameter λ where n = 2 log λ −1

SH.Enc
Input pk = (a 0 , a 1 ) and m ∈ R t [x, y] Process u, f , g ← χ[x, y] and the fresh ciphertext is c = (c 0 , c 1 ) = (a 0 u + tg + m, a 1 u + t f ) Process Using a symbolic variable v their product c can be obtained from

Correctness and Security:
The condition for correct decryption is that the effective noise ||(∑ γ−1 i=0 c i s i ) mod q)|| ∞ remains smaller than q/2. Let us consider a simplified version of Theorem 2 from [64] where only the effect of noise is taken into account, and let max {σ} be the maximum standard deviation of the polynomials sampled from χ[x, y]. Let M be the maximum coefficient of the evaluated degree-D polynomial; if M(t max {σ}d x d y n √ n) D is smaller than q/2, the scheme of Table 3 can evaluate degree-D multivariate polynomials over elements which belong to R t [x, y]. We could also consider a more tight empirical condition for q, as stated in [65].
Regarding the security of this SHE scheme, it relies on the indistiguishability assumption of the polynomial multivariate version of RLWE (with adequately chosen secure parameters χ[x, y], {n x , d x , n y , d y } and q) featured in Definition 11; breaking this assumption implies, as stated in Theorem 2, the existence of a quantum algorithm which solves short vector problems over ideal lattices. For a practical estimation of the bit security, we can apply the LWE security estimator developed by Albrecht et al. [66,67] to the cryptosystems built on multivariate RLWE and also the estimates included in the standards document [68] for a general random lattice with the same dimension (n = ∏ n i ). This is plausible, analogously to what it is typically done with ideal lattices, as a secure instantiation of m-RLWE works with full-rank lattices, for which no substantially faster attacks are known than for general lattices.

Multiquadratic Rings with Fast Walsh-Hadamard Transforms
Copyright of Section 8 by IEEE: ©2021 IEEE. Reprinted, with permission, from Sections 3 and 4 of the conference paper: "Multiquadratic Rings and Walsh-Hadamard Transforms for Oblivious Linear Function Evaluation", 2020 IEEE International Workshop on Information Forensics and Security (WIFS). This section focuses on improving the cost of the underlying polynomial operations for cryptographic primitives based on RLWE, especially polynomial products (convolutions) [43]. We show how the well-known asymptotic cost of O(n log n) for cyclotomic rings with polynomials of n coefficients can be improved by a factor of log n in terms of elemental multiplications when working on m-RLWE (or RLWE over a multivariate number field). To this aim, we particularize the multivariate version to degree-2 polynomials and introduce an (α-generalized) variant of the Walsh-Hadamard Transform (over finite rings instead of the usual real numbers), featuring a convolution property that relates the coefficient-wise representation with the transformed domain. This transform can be very efficiently computed with FFT algorithms (specifically, with a variant of the Fast Walsh-Hadamard Transform) whose computational cost is only O(n log n) additions, hence being much more amenable for a practical implementation. It is worth noting that the effect of the efficiency improvement brought about by our approach goes beyond somewhat homomorphic encryption schemes (including also the NTRU setting [69,70]), also enhancing any cryptographic primitives involving polynomial multiplications, e.g., the candidates of the NIST Post-Quantum challenge [67]. We also exemplify in [43] its use for the efficient implementation of Oblivious Linear Function evaluation.
For this section, we deal with a specific version of m-RLWE where all the used polynomial functions have the same form f i (x i ) = d i + x 2 i (see Definition 9). The security reduction from Theorem 2 applies to this particular version of the m-RLWE problem. To this aim, parameteres d i have to be chosen as indicated in the beginning of Section 5. Additionally, Proposition 5 gives a sufficient condition to make the problem secure against the attacks described in Section 7.1.
We introduce next the (α-generalized) Hadamard transform, that we apply to reach the aforementioned performance gains on polynomial convolutions.

Faster Polynomial Arithmetic over Multivariate Rings
The Hadamard transform over real numbers is usually applied by means of the recursion where i ∈ N and H 0 = 1.
It can be seen that the matrix H i with i ≥ 1 is equivalent to the Kronecker product of i Discrete Fourier Transform (DFT) matrices of size 2 (H 1 equals the DFT matrix of size 2); that is, it can be seen as a 2 × 2 × · · · × 2 i times -DFT transform (defined over i dimensions of length 2 each).
Analogously to the DFT, the Walsh-Hadamard Transform (WHT) of size n possesses a particular fast algorithm called Fast Walsh-Hadamard Transform (FWHT) which can be very efficiently computed with no products and with a cost of O(n log n) additions and subtractions (see [71,72]). Hence, when working over rings satisfying a convolution property with the Hadamard transform, it is possible to efficiently compute the multiplication of elements from these rings with a cost of O(n) elemental multiplications.
Security reasons prevent us from directly working over rings satisfying this convolution property with the Walsh-Hadamard transform (that is, multivariate quotient rings whose polynomial functions are f (x i ) = x 2 i − 1), as they can be easily factored into (x i − 1)(x i + 1) over Z. Therefore, we resort to the type of multivariate rings presented in Definition 9 and apply an (α-generalized) variant of the WHT.
α-generalized convolutions: An α-generalized convolution corresponds to the ring operation defined over polynomials belonging to Z q [z]/(1 − αz n ). For example, with α = −1 we have a negacyclic convolution. In the literature, this convolution operation is also called negative wrapped convolution. Figure 1 shows the realization of an α-generalized convolution between vectors of length N (with l = 0, . . . , N − 1), by means of a cyclic convolution combined with an element-wise pre/post-processing applied before/after [7,36]. As the cyclic convolution can be efficiently computed by means of standard fast algorithms, this means that an α-generalized convolution can be implemented with only a light overhead (O(n) scalar products). It is common to include these additional scalar products inside the butterflies of the FFT algorithms to further enhance the efficiency.

α-generalized Walsh-Hadamard transform:
We are mainly interested in polynomial functions with the form x 2 i + d i . We can rewrite 1 − αx n as −α((−α) −1 + x n ). Hence for For this particular type of polynomial rings we can define the following direct and inverse transforms: where the square-roots (α i ) 1 2 and (α i ) −1 2 have to exist in R q for all i (see Definition 9). Equivalently, if q is an odd prime, we can make use of the Legendre symbol ( −d mod p p ) to check when the multivariate ring factors into linear terms. To this aim we need that ( −d i mod q q ) = 1 for a prime q and for all i. We also redefine H 1 = 1 1 1 −1 without taking into account the normalizing factor 1 2 . Therefore, now we can extend this definition to multivariate quotient rings with polynomial ideals of the form (x 2 i + d i ): we consider the Kronecker product of the matrices W 1 and W −1 , arriving to the following expression: where the normalizing factors are again left outside H i .
Consequently, if we define the vector α = (α 1 , . . . , α l ) T , when working over the multivariate ring R q [x 1 , . . . , x l ] with f j (x j ) = d j + x 2 j for j = 1, . . . , l we can use the transforms W l and W −1 l analogously to the use of negacyclic NTTs in the univariate RLWE. Both W l and W −1 l transforms can be efficiently computed in O(n) (where n = 2 l ) elemental multiplications thanks to the FWHT. This enables the computation of the H l matrix multiplications with only O(n log n) additions and subtractions and no products, which brings a net improvement with respect to the analogous and wide-spread radix implementation of the NTT.

Implementation of the Fast Walsh-Hadamard Transform (FWHT):
Algorithm 1 shows a pseudocode implementation of the (cyclic) Fast Walsh-Hadamard Transform (FWHT) implementation (see [71,72]), computing the Hadamard transform of a length-n vector a. It can be easily seen that this algorithm requires a total of n log 2 n additions (specifically, a ← H i a Finally, the α-generalized version of the direct (inverse) FWHT can be defined by adding a right (left) product by a diagonal matrix, so that the total cost for the α-generalized FWHT on a length-n vector is n elemental multiplications and n log 2 n additions.

Implementation and evaluation:
Polynomial multiplications are the main bottleneck of lattice cryptography, as they are the most time-consuming basic blocks of any cryptographic algorithm, from encryption/decryption to relinearization and bootstrapping. The replacement of the traditional NTTs by FWHT by transitioning from cryptographic constructions built on univariate RLWE to the proposed multivariate version can bring a considerable improvement in terms of computational efficiency. To showcase the achieved gains, we have implemented Algorithm 1 in C++ and compared it with one of the currently most efficient radix-2 implementations of the NTT [6]; this is the algorithm featured in the NFLlib, one of the fastest lattice-based cryptographic libraries available for homomorphic encryption. NFL also off-loads the complexity of the bit-reversal operation to the INTT, in order to speed up the NTT, and makes use of SSE and AVX2 optimizations to further enhance the obtained performance. Figure 2 shows the comparison of the obtained run times for a wide range of practical values of n (vector size or polynomial degree), when using our FWHT implementations, including an SSE/AVX2 vectorized version. It can be seen that we obtain a reduction to about 45-50% of the time of the NTT (38-43% of the INTT) in the nonvectorized implementation of the FWHT with respect to the fast NTT of NFLlib, while the vectorized one further reduces this figure to 22-24% (19-22% of the INTT). Finally, it is worth noting that the memory consumption of the FWHT is much lower, as it does not need to store the tables of the twiddle factors.

Slot Manipulation in Multivariate Rings
In this section we introduce the main improvements that m-RLWE brings to slot manipulation when packing several plaintext inputs into a ciphertext, with applications in relinearization and bootstrapping operations. Packing into slots [73] helps to take advantage of the available space in the plaintext ring, therefore improving cipher expansion. The use of this packing strategy also enables working with homomorphic "slot"-wise additions and multiplications, i.e., Single Instruction, Multiple Data (SIMD) operations with encrypted data. This is usually combined with a mechanism to efficiently move and exchange the plaintext contents across slots, by taking advantage of the properties of the available automorphisms in the used ring. In general, in the ring R t = Z t [z]/(Φ m (z)), we can define a set of automorphisms φ(m) as different transformations ρ i : R t → R t with i ∈ Z * m , which apply a change of variable z → z i over the elements in R t .
Current lattice-based homomorphic cryptosystems leverage automorphisms to perform linear transformations across plaintext slots. Whereas applying an automorphism is a very efficient operation, it produces a ciphertext encrypted under a different secret key, and consequently, a switching key operation is needed to recover a ciphertext under the original secret key. This switching key process has two main drawbacks [74]: (a) a notable computational overhead and (b) an increase in the memory requirements due to the need of adding additional public information ("switching key/relinearization" matrices, a.k.a. evaluation keys).
In general, there is a tradeoff between these two dimensions: when the number of evaluation keys increases, the involved switching key runtime decreases, and conversely, when the number of keys is reduced, a chain of several switching key operations is needed, hence increasing the runtime. In a recent work [74], Halevi and Shoup explore several strategies to optimize this tradeoff, claiming improvements of even 75 times faster runtimes than those of their previous implementation, together with a reduction of up to a half in the required memory space to store the evaluation keys.
This section focuses on two different aspects: (1) We show how the introduced multivariate rings over the RLWE problem (see Sections 5 and 6) enable considerable improvements in the efficiency of the homomorphic packing/unpacking into slots, therefore greatly improving essential blocks for homomorphic encryption, such as bootstrapping, and (2) we analyze the structure of the available set of automorphisms on these rings, also showing that our solution can improve on both the runtime and the memory requirements with respect to the state of the art [74].
It is worth highlighting that some of the exemplified solutions in this section are sketched out with negacyclic rings. For completeness, in Section 9.4 we give some insights on how to extend these results to the more general multivariate rings showcased in this manuscript.

Efficient Slot Packing/Unpacking
The homomorphic packing/unpacking of plaintext values into slots is one of the most important examples of the evaluation of linear transformations on the ciphertexts, bootstrapping being one of the most representative applications [14][15][16]. The way current cryptosystems implement this packing/unpacking is by means of a decomposition of the matrix multiplication into element-wise products between the different diagonals of the matrix and different rotated versions of the ciphertext (hence by adding the result of a set of multiplications between plaintexts and rotated ciphertexts).
The main bottleneck of this process is the number of switching key matrices required to rotate the ciphertexts. Working with n slots, a total of n − 1 rotations, hence n − 1 switching key matrices, is required in the worst case. Available strategies to reduce this number of matrices come at the cost of also increasing the runtimes per automorphism/switching key operation.
To the best of our knowledge, the best strategy for homomorphic packing/unpacking is presented in [75] for the HEAAN cryptosystem. Their method, with an input of n slots and parameterized by a radix r, requires O(r log r n) constant vector multiplications, O( √ r log r n) rotations and a depth of O(log r n).
Thanks to the introduced multiquadratic RLWE with l = log 2 n independent variables, we can also break the need of a number of rotations (automorphisms/switching key operations) equal to the number of slots, and we enable homomorphically packing/unpacking operations with a single switching key operation per independent ring variable.
Homomorphic Packing/Unpacking: Considering a multiquadratic plaintext ring R t [x 1 , . . . , x l ] (see Definition 11), we arrive to the following packing/unpacking matrices: These matrices are similar to the ones introduced in Section 8, but now having and being defined over the plaintext ring, so satisfying α j = −d j mod t for j ∈ [l].
Both packing and unpacking matrices can be decomposed on a matrix of size 2 × 2 over each independent variable. Additionally, these matrices can be very efficiently computed on a quadratic ring.
Once we have extracted a 0 and a 1 , the multiplication with the 2 × 2 matrix can computed. This process can be recursively applied for each independent variable.
Hence, our proposed method enables homomorphic packing/unpacking on an input of n slots which requires log 2 n rotations and depth log 2 n, but now working for BFV-type cryptosytems [76].

Homomorphic Walsh-Hadamard Transform
Consider again a multiquadratic plaintext ring R t [x 1 , . . . , x l ]: by applying the packing method (packed-RLWE) described in [12], we can emulate over a ciphertext composed of multiquadratic rings, a ring homomorphism with a cyclic Walsh-Hadamard ring (i.e., a ring with 1-generalized Walsh-Hadamard transforms, see Section 8).
Then the required matrices for packing and unpacking are respectively:

H l evaluation:
It can be seen that the H l matrix can be homomorphically evaluated by means of recursively applying a shift and an automorphism for each independent variable. That is, if we have encrypted a polynomial a ∈ R t [x 1 , . . . , x i ], we would do: a(x 1 , . . . , x l ) = ∑ i∈ [l] x i a(x 1 , . . . , x i , . . . , x l ) + a(x 1 , . . . , −x i , . . . , x l ).
The above operations can be homomorphically evaluated by means of one shift, one automorphism and two additions per independent variable.

Automorphisms in Multiquadratic Rings and Their Hypercube Structure
We show now how m-RLWE improves on the tradeoffs between space and computational cost when dealing with automorphisms, with respect to the univariate version.
Let A[z]/(1 + z 2 ) be a polynomial ring as the one described by Definition 9, and α be an element α ∈ A[z]/(1 + z 2 ); then, we denote by θ (z) i (α) ∈ A[z]/(1 + z 2 ) the transformation over α which applies the change of variable z → z i with i ∈ Z * 4 . For these particular rings, both transformations are, respectively, the identity z → z and the negation z → −z. Reducing modulo t (the modulo of the plaintext ring), the effect of the latter transformation over the slots would be equivalent to a block shift where each block is composed by one half of the total slots. This shift is graphically illustrated in Figure 3 (also briefly described in Table 4), where ψ is the 4th root of unity modulo t (i.e., ψ 4 ≡ 1 mod t), and the two blocks of slots encoded respectively in α(ψ) and α(ψ 3 ) get shifted by applying z → −z.   Table 4. Rotation between two blocks of slots (description of Figure 3).
To fix ideas, and without loss of generality, in Figure 3 we represent a plaintext α as an element α ∈ A[z]/(1 + z 2 ), where A does not depend on z. By reducing modulo t, and by having a 4-th root of unity ψ, the polynomial α(z) = α 0 + α 1 z mod 1 + z 2 can encode a vector with two different block slots ) ∈ A 2 . The concrete structure of these blocks depends on the ring structure of A modulo t. Figure 3 showcases the effect of applying the transformation z → −z under α(z), i.e., we obtain a new polynomialα(z) = α 0 − α 1 z mod 1 + z 2 . As a result of this automorphism, the polynomialα(z) now encodes a rotated vector of the original block slots (α(ψ),α(−ψ)) = (slot 1 , slot 0 ) ∈ A 2 . Going back to the notation R t [x 1 , . . . , x l ] with f j (x j ) = 1 + x 2 j for our ring, we can then apply combinations of these two transformations with the different variables x j for j ∈ [l]. Analogously to [74], this gives a multidimensional structure on the automorphisms group considering the composition of transformations where α ∈ R t [x 1 , . . . , x l ], t ≡ 1 mod 4 and i 1 , . . . , i l ∈ Z * 4 . This multidimensional structure of the automorphisms group can be seen as an l-tuple with two different values per component (which gives a total of 2 l different automorphisms). Hence, similarly to the shift property of a multidimensional DFT [77], this group satisfies both the abelian and sharply transitive properties required to perform any type of permutation [78].

Logarithmic Increase in Space and Computational Cost (Strategy 1):
The effect of each of the automorphisms over the slots can be visually represented as a hypercube with as many dimensions as independent variables the rings have, that is, with a total of log 2 n dimensions. As a graphical example, Figure 4 shows the slot structure corresponding to a multivariate ring with seven independent variables; in this case, each different vertex of the hypercube represents one of the n = 128 available slots, where the allowed transitions between vertices depend on the chosen strategy, as we describe next (see also A B Figure 4. Representation of the hypercube structure of the group of automorphisms available in the multivariate polynomial RLWE with Φ 4 (·) as polynomial functions and considering 7 independent variables {x 1 , . . . , x 7 }. Table 5. Hypercube structure of the group of automorphisms (description of Figure 4).  In case of storing n switching key matrices (corresponding to all the automorphisms), any vertex transition will be allowed through one single switching key operation. However, it is possible to store less switching key matrices (which, combined, represent the whole set of automorphisms), hence increasing the number of subsequent automorphisms/switching key operations for transitioning from one vertex to another.
Due to the specific structure of our multivariate rings, we propose an optimal strategy with log 2 n switching key matrices, each one corresponding to a different transformation x i → −x i ; with the additional advantage that these transformations are their own inverses. Following this strategy, we can also see the different slots (vertices in Figure 4) as a binary vector of length log 2 n, where the available operations are bit-wise XOR operations with vectors {(1, 0, . . . , 0), (0, 1, 0, . . . , 0), . . . , (0, . . . , 0, 1)} belonging to the standard basis of dimension log 2 n. In the example of Figure 4 (with log 2 n = 7), this method would be equivalent to working with seven independent vectors (of the standard basis) enabling only movements between vertices in the dimension associated to the vector. It can be seen that with this strategy the farthest slot to a given one is always the slot represented as its ones' complement, i.e., the opposite vertex. This implies a total of log 2 n automorphisms/switching key operations. Hence, in the worst case we have an increase in the computational cost by a factor of log 2 n when storing log 2 n switching key matrices and working with n slots. This is a considerable reduction in the memory requirements when compared to the approximately O(D) and O( √ D) factors considered by Halevi and Shoup [74] when working with D slots (in one dimension).
As a quick comparison, for the practical values reported in [74], i.e., n = φ(m) = 16, 384, our strategy achieves an increase factor of 14 on the computational cost, which is not considerably higher than their results, but with huge savings in storage for our case: we store only 14 matrices, compared to the 51 matrices and three automorphisms/switching key operations achieved by [74] for a similar value of φ(m) = 15, 004 and one dimension with D = 682 following a baby-step/giant-step strategy.
Finally, it must be noted that when applying a switching key, noise constraints force the need of decomposing the coefficients of the involved polynomials in some specific base. This is true unless we resort to the strategy of Bajard et al. [79] which takes advantage of the CRT decomposition over the polynomial coefficients. However, this strategy cannot be applied always, as it requires a highly composite modulo with primes of an adequate machine size (see [5]). As this base decomposition does not straightforwardly commute with the NTT/INTT (or CRT over the polynomial function) representation, the inverse and direct transforms have to be applied over the polynomials. Our setting in multivariate rings with FWHT enables a reduction on complexity for these transforms by a factor of O(log n) in terms of elemental products; i.e., this yields a net gain factor of log n in storage while keeping the same order of (multiplicative) computational complexity.
Efficiency/space tradeoffs: In practical scenarios, the tradeoff between used memory and computational cost might require a different balance with less space efficiency than the log 2 n achieved by the described strategy. Consequently, we also cover two additional strategies which lead to an improvement of the computational cost by a factor of 2.
Strategy 2: Our first approach adds to the previous log 2 n matrices those which are associated to "diagonal" vectors in our hypercube representation of the autormorphisms (see Figure 4); that is, we work with automorphisms and i, j ∈ [log 2 n], being i = j. Going back again to the binary representation of the slots, the additional automorphisms could be seen as the result of all pairwise XOR operations of different vectors of the standard basis of length log 2 n. The number of needed switching key matrices is therefore increased to 1 + log 2 n 2 = (1 + log 2 n) log 2 n 2 .
In order to calculate the associated computational cost for this strategy, we resort to induction, working first with the odd natural numbers, and afterwards with the even natural numbers. Let the multivariate ring R t [x 1 , . . . , x l ] with f i (x i ) = 1 + x 2 i where i = 1, . . . , l and l = log 2 n, if we consider only the odd values of l we have: • For l = 1, any transition can be applied with only one automorphism/relinearization operation.
• Assuming that l variables require k automorphisms/relinearization operations, it can be shown that adding two variables (i.e., l + 2), k + 1 automorphisms/relinearization operations are needed. We can graphically see this by resorting to the binary representation: moving between any two slots implies, in the worst case (consider one vector and its ones' complement), one additional XOR operation. • Therefore, by induction, odd values of l require l 2 automorphisms/ relinearization operations.
The argument is analogous for even l. First, we consider l = 2, where with only one automorphism/relinearization operation is enough to move between any of the slots. Next, the same reasoning as before could be applied between l and l + 2 variables, resulting in a total of l 2 automorphisms/relinearization operations for l variables. Taking into account both results, this strategy yields an increase in the number of automorphisms/switching key operations by a factor of log 2 n 2 . Hence, we can reduce by a half the computational cost compared to our previous strategy, with a quadratic increase in the memory requirements of (1+log 2 n) log 2 n 2 instead of log 2 n. For instance, with n = 16, 384 this would give an increase in cost by a factor of seven and a total of 105 stored matrices.
Strategy 3: The incurred increase in space requirements by Strategy 2 might not be acceptable for certain applications; therefore, our next approach preserves the cost improvement, but achieving a negligible increase in the number of required matrices: 1 + log 2 n matrices instead of O((log n) 2 ).
The idea behind this approach is adding to the switching key matrices for transformations of the form {x i → −x i } for i = 1, . . . , log 2 n the following one As a graphical explanation, let us consider again the binary representation of the slots: in addition to working with those XOR operations with vectors belonging to the standard basis of length log 2 n, now we can also apply the ones' complement of every "slot" in one operation (e.g., in Figure 4 we could directly move with one automorphism/switching key operation from point A to point B).
Therefore, the worst case automorphism requiring l = log 2 n 2 matrices with our first strategy can now be computed with just one matrix. Moreover, as we know that l − l 2 ≤ l 2 for any l ∈ N, then the farthest slot position can be achieved by only l 2 = log 2 n 2 automorphisms. Consequently, we can see that with 1 + log 2 n matrices, we only need a maximum of log 2 n 2 automorphism/switching key operations. For instance, with n = 16, 384 this would give an increase in cost by a factor of seven and a total of 15 matrices in terms of use of memory.

Automorphisms in Multivariate Power-of-Two Cyclotomic Rings
It can be useful to expand Definition 9 to also cover more general multivariate rings, which can be leveraged by some applications. Most of these applications consider a general multivariate ring as the R and R q from Definition 1, where each of the polynomial functions are defined as different power-of-two cyclotomic polynomials f i (x i ) = x n i i + 1. Hence, analogously to the procedure we followed with multiquadratics in Section 9.2, we exemplify these results with power-of-two cyclotomics. They can be similarly extended to more general rings of the form x n i i + d i . We refer the reader to Section 9.4 for more details. In this section the discussed efficiency/space tradeoffs achievable with automorphisms on the FWHT-enabled rings will be expanded to these rings (at the cost of lacking the faster FFT algorithms for the negacyclic Hadamard transform).

Tradeoffs in the Size/Efficiency Of Automorphisms
We consider the ring R introduced in Definition 1; particularly, we work with R t [x 1 , . . . , x l ] where t ≡ 1 mod 2n i for i = 1, . . . , l. Analogously to our derivation in Section 9.2, when working with an element α ∈ R t [x 1 , . . . , x l ], we have the transformations 2n j for all j. This multidimensional structure can be seen again as an l-tuple, where each component has n i different values, hence giving a total of n = ∏ l i=1 n i different automorphisms. Strategy 4: Our main strategy works with n i − 1 matrices for each variable x i , where each switching key matrix will correspond to an automorphism {x i → x l i i } for l i ∈ Z * 2n i (except {x i → x i }) and i = 1, . . . , l. This strategy yields a total of ∑ l i=1 n i − l matrices with a computational cost of l automorphism/switching key operations. Let us assume that all the matrices for every "univariate" change of variable have to be stored. However, the number of required matrices per "univariate" change of variable could be further improved [74] (that is, we could work with subsets A i ∈ Z * 2n i in such a way that the corresponding automorphisms would be {x i → x l i i } for l i ∈ A i and i = 1, . . . , l). We consider those n i = n 1 l for i = 1, . . . , l (hence being all n i equal). This gives us several tradeoffs depending on l and n where we have l(n 1 l − 1) matrices and an increase in the computational cost by a factor of l. Table 6 shows the number of required matrices and the increase in computational cost for n = 16384 and several values of l. As n 1 l is not always a valid value (that is, a power of two), the choice of n i can be optimized to achieve the smallest possible number of automorphisms (∑ n i ) such that n = ∏ n i . Conversely, Table 7 summarizes the different tradeoffs we have presented in this section. Table 7. Space/efficiency tradeoffs of automorphisms.

Strategy # Matrices # Calls to Switching Key (Worst-Case)
Strategy 1 from Section 9.2 log 2 n log 2 n Strategy 2 from Section 9.2 (1+log 2 n) log 2 n 2 log 2 n 2 Strategy 3 from Section 9.2 1 + log 2 n It is worth noting that all the solutions exemplified above (Sections 9.2 and 9.3) are sketched out with negacyclic rings. In this section, we give some insights on how to extend these results to the more general multivariate rings showcased in this manuscript.
An alternative set of polynomial ideals: Bernstein et al. [70] propose a different non-cyclotomic ring. The authors argue that with cyclotomic rings it is easy to have non-trivial ring homomorphisms (as the polynomial function usually splits in linear factors to perform FFT algorithms) and a relatively small Galois group. Consequently, the authors propose rings of the form Z q [x]/( f p (x)), with an irreducible polynomial function f p (x) = x p − x − 1 and p prime, where the Galois group is the permutation group S p with p! elements, and the modulo q is inert in the ring. Hence, Z q [x]/(x p − x − 1) is indeed a finite field. See [80] for more details on the properties exhibited by functions of the form f n (x) = x n − x − 1.
These polynomial functions are also interesting for our purposes, but for very different reasons. Let K = Q(α) be a number field with α one of the roots of x n − x − 1. We know that [80] polynomial functions f n (x) = x n − x − 1 with n ≥ 2 are irreducible, and for 2 ≤ n ≤ 100 the discriminant of f n (x) is squarefree. According to Theorem 6, this means that K is monogenic and O K = Z[x]/( f n (x)). Now, from Proposition 3, we have so it is straightforward to find coprime discriminants for different values of n. For example, the discriminants of { f i (x)} i=2,...,7 are coprime. Therefore, we can define a multivariate RLWE sample over the ring of integers for a multivariate number field of degree 5040 and 6 dimensions. In general, this gives an easy way to find multivariate number fields with many variables and a small expansion factor.
Operations over these rings are not as efficient as the ones with polynomial ideal (x n − d), but still acceptable; i.e., in the worst case, multiplications modulo x n − x − 1 can be decomposed in multiplications modulo x n − x and x n − 1, hence requiring two parallel efficient "cyclic" convolutions, and afterwards, adding the obtained results.
Automorphisms for more general multivariate rings: The multivariate rings introduced in Section 6 are, in general, separable but non-Galois field extensions. This implies that the number of available automorphisms is strictly smaller than the degree of the extension (see Corollary 4).

Corollary 4 (Corollary 4.3 from [81]
). If L/K is a finite extension that is either inseparable or not normal then |Aut(L/K)| < [L : K], being [L : K] the degree of the field extension.
Fortunately, this is not a problem in practice as we can make use of Theorem 11 to extend the mentioned separable multivariate number fields in Section 6 to a Galois extension, where we have Gal(L/K) = Aut(L/K) = [L : K]; hence, automorphisms similar to the case of power-of-two cyclotomics (see Section 9.3) can still be applied.
Theorem 11 (Theorem 4.8 from [81]). Every finite separable extension of a field can be enlarged to a finite Galois extension of the field. In particular, every finite extension of a field with characteristic 0 can be enlarged to a finite Galois extension.

A toy example for a prime-degree field extension:
Consider the number field Q(d Even so, we know from Theorem 11 that this field can be extended to a Galois field where we have a Galois automorphism group which enables "rotations" of the slots. It suffices to add the root ζ p by means of a symbolic variable y over the cyclotomic polynomial Φ p (y) = ∑ p−1 i=0 y i , i.e., we enlarge the number field (see Theorem 11) to have Q(d 1 p , ζ p ) with d and p different primes.
For this extended number field and considering a polynomial representation with Q[x, y]/(x p − d, Φ p (y)) (thanks to the field isomorphism d 1 p → x, ζ p → y), we have the chain of transformations {x → xy i , y → y j } with i ∈ Z p and j ∈ Z * p , which enables homomorphic "rotation" of the slots.
As an example, consider the polynomial a(x) = ∑ It is worth noting that the ring Z[x, y]/(x p − d, Φ p (y)) is not, in general, the ring of integers of the field Q(d 1 p , ζ p ), but instead a subring of its ring of integers. This can be easily seen by inspecting the discriminants of x p − d and Φ p (y) which are, respectively, Consequently, when working with rings following Definition 11 in Section 6, if we want to (1) base the security on RLWE over a general number field and also (2) make use of the automorphisms, the reduction from Theorem 2 implies a loss in the lattice dimensionality; in the previous example of Z[x, y]/(x p − d, Φ p (y)), we end up working with a ring of degree p(p − 1), but being the original RLWE sample defined over a number field of degree p. Nevertheless, we can avoid this loss by basing the security in a generalization of RLWE called Order-LWE.
A much wider set of ring choices with Order-LWE: Bolboceanu et al. [51] propose a generalization of RLWE which, instead of considering the ring of integers O K and its dual O ∨ K , relies on the subrings called orders O and their corresponding duals O ∨ to define the underlying ideal lattices.
For a number field K of degree n, an order O in K is a subring of O K containing a Q-basis of full-rank n of K such that O ⊗ Z Q = K. The ring of integers is the maximal order of K.
Order-LWE also presents worst-case hardness with respect to short vector problems, but in the invertible-ideal lattices of the considered order [51].
This result enables a relaxation of many of the restrictions imposed for the rings in Sections 5 and 6, by directly basing their hardness on Order-LWE. The previous example with the field Q(d 1 p , ζ p ) and order Z(d 1 p , ζ p ) can base its hardness on a lattice of dimension p(p − 1) by considering Order-LWE.
The use of the polynomial function Φ p (y) seems to contradict our initial requirements regarding the desired form of the polynomial ideal (see Section 1). However, for efficient polynomial products we can substitute Φ p (y) by y p − 1 by just multiplying both polynomial elements and polynomial function with the term y − 1.
We plan to extend our results and optimizations to the corresponding relaxations offered by Order-LWE. In this direction, this work provides a wide set of concrete ring instantiations which could be considered to analyze the hardness of Order-LWE.

Improving on the Packing Capacity of Complex Numbers
We have addressed packing of integer numbers in Section 9, but complex numbers are more difficult to efficiently pack. Nevertheless, we can also leverage the multivariate structure to represent the complex arithmetic in a much more efficient way than previous recent approaches. Knowing that a total of n/2 complex slots can be packed over the ring Z[z]/(1 + z n ), Cheon et al. [39,82] expand these results to the bivariate case Z[x, y]/(1 + x n x , 1 + y n y ), packing a total of n x 2 n y 2 = n 4 complex slots. Generalizing this strategy to l dimensions, packing is restricted to n 2 l complex slots (where n = ∏ l i=1 n i ) when working over multivariate rings as Z[x 1 , . . . , x l ]/(1 + x n 1 1 , . . . 1 + x n l l ). Consequently, this strategy leaves a huge gap of unused potential slots when transitioning to a multivariate ring. Additionally, while this strategy was introduced for a weak instance of multivariate RLWE (i.e., vulnerable to BCV attack), a similar approach works for rings following Definition 11.
Nevertheless, it is possible to achieve the same number of complex slots as the univariate counterpart (that is, n/2 complex slots), effectively substituting the multivariate complex embedding map (as used in [39]) by its univariate version. Let us consider the ring Z[x 1 , . . . , x l ]/(d 1 + x n 1 1 , . . . , d l + x n l l ), and choose one of the l independent variables to work with the canonical embedding map, x 1 without loss of generality. If we have a total of n/2 complex numbers to pack in one multivariate polynomial plaintext, we organize them as a set of n n 1 complex vectors with length n 1 /2 (n 1 is chosen as a power of two). For each complex vector we use the encoding from [82], defined as the composition of the inverse of the complex embedding map and a discretization. This yields n n 1 polynomials belonging to the ring A = Z t [x 1 ]/(d 1 + x n 1 1 ) for an adequately chosen modulo t. Coming back to the multivariate ring representation, we can consider the new message as a polynomial in the ring Z t [x 1 , . . . , x l ]/(d 1 + x n 1 1 , . . . , d l + x n l l ). Hence, we gather all the polynomials in A as the different coefficients of the ring A[x 2 , . . . , x l ]/(d 2 + x n 2 2 , . . . , d l + x n l l ), and we define encoding/decoding matrices working over d i + x n i i polynomial functions (i.e., α-generalized INTTs/NTTs over t, see Section 8) for i = 2, . . . , l, considering the identity matrix I n 1 of size n 1 × n 1 for x 1 and the polynomial function d 1 + x n 1 1 . Using the vector representation of the plaintext polynomial, the encoding/decoding is performed by means of one matrix multiplication which can be efficiently realized with FFT-like algorithms.
This method can pack a total of n/2 complex slots while preserving the properties for the automorphisms (whenever we enlarge the number field to a Galois extension, see Section 9.4) and also removing the gap of the method used in [39], where the fraction of used slots decreases exponentially with the number of dimensions.
Finally, it is worth looking at the case where the considered multivariate rings are those from Definition 9 in Section 5. In this case, the polynomial ideals have the form (d i + x 2 i ), so the variable x 1 can directly represent the imaginary unit, therefore perfectly mapping the complex arithmetic without the need of applying the canonical embedding map over the polynomials in A.

Conclusions
This work addresses the main security flaw of the multivariate RLWE problem revealed by Bootland et al. For this purpose, we have defined and parameterized practical and secure instantiations of the multivariate Ring Learning With Errors problem, supported by the extended reduction of the original proof by Lyubashevsky et al. [3,4]. The proposed instantiations are resilient against BCV attack to m-RLWE [25], while still preserving all the efficiency improvements that m-RLWE brings. We have shown how to find practical parameters for the proposed instantiations to make them both secure and usable, therefore enabling improved space-time tradeoffs in many practical applications, comprising the most critical fundamental lattice operations (faster polynomial multiplications through α-generalized Walsh-Hadamard Transforms), efficient cryptographic operations such as computation of automorphisms, relinearizations, packing, unpacking and homomorphic slot manipulation, and, consequently, bootstrapping, and optimization of high level applications in encrypted approximate arithmetic, complex processing, and efficient multidimensional signal manipulation.
These contributions, combined, showcase the power and versatility of secure instantiations of the multivariate RLWE problem, and open up new research paths and strategies for realizing efficient (fully) homomorphic encryption. Funding: GPSC is funded by the Agencia Estatal de Investigación (Spain) and the European Regional Development Fund (ERDF) under project RODIN (PID2019-105717RB-C21). Additionally funded by the Xunta de Galicia and the European Union (European Regional Development Fund-ERDF) under projects ED431G2019/08 and Grupo de Referencia ED431C2017/53. EPFL is funded in part by the grant #2017-201 (DPPH) of the Swiss PHRT.