Abstract
In 1953, Carlitz showed that all permutation polynomials over \({\mathbb F}_q\), where \(q>2\) is a power of a prime, are generated by the special permutation polynomials \(x^{q-2}\) (the inversion) and \( ax+b\) (affine functions, where \(0\ne a, b\in {\mathbb F}_q\)). Recently, Nikova, Nikov and Rijmen (2019) proposed an algorithm (NNR) to find a decomposition of the inverse function in quadratics, and computationally covered all dimensions \(n\le 16\). Petrides (2023) theoretically found a class of integers for which it is easy to decompose the inverse into quadratics, and improved the NNR algorithm, thereby extending the computation up to \(n\le 32\). In this paper, we extend Petrides’ result, as well as we propose a new number theoretical approach, which allows us to easily cover all (surely, odd) exponents up to 250, at least.
Similar content being viewed by others
Avoid common mistakes on your manuscript.
1 Introduction
Threshold implementations (TI) are a kind of side-channel attack countermeasures, based on secret sharing schemes and techniques from multiparty computation. The idea is to split a variable x into s additive shares \(x_i\) with \(x =\sum _{i=1}^s x_i\). Let \(\textbf{x}=(x_1,x_2,\ldots ,x_s)\). To implement a function \(F(x,y,z,\ldots ,)=a\) from \({\mathbb F}_2^m\) to \({\mathbb F}_{2}^n\), the TI method requires sharing, that is, a set of s functions \(F_i\), which together can compute the output of F. Sharing needs to satisfy some properties, namely, correctness, non-completeness and uniformity [10]:
-
Correctness: \(a=F(x,y,z,\ldots )=\sum _{i=1}^sF_i(\textbf{x},\textbf{y},\textbf{z},\ldots )\), for all \(\textbf{x},\textbf{y},\textbf{z},\ldots ,\) with \(x=\sum _{i=1}^s x_i,y=\sum _{i=1}^s y_i,z=\sum _{i=1}^sz_i\).
-
Non-completeness: Every function is independent of at least one share of the input variables x, y, z (\(F_i\) should be independent of \(x_i,y_i,z_i\)).
-
Uniformity (balancedness): For all \((a_1,a_2,\ldots ,a_s)\) with \(\sum _{i=1}^s a_i=a\), the number of tuples \((\textbf{x},\textbf{y},\textbf{z},\ldots )\in {\mathbb F}_2^{ms}\) for which \(F_j(\textbf{x},\textbf{y},\textbf{z},\ldots )=a_j,1\le j\le s\), is equal to \(2^{(s-1)(m-n)}\) times the number of \((x,y,z,\ldots )\in {\mathbb F}_2^m\), for which \(a=F(x,y,z,\ldots )\). So, if F is a permutation on \({\mathbb F}_2^m\), then the \(F_i\)’s form together a permutation on \(F_2^{ms}\) (sharing preserves the output distribution).
We should mention earlier work on the Gold function, where TI was achieved for all \(3\times 3,4\times 4\) S-boxes [1], and the realization of the inversion in \(\mathbb {F}_{16}\) with 5 shares [10]. One notes that since each \(F_i\) is completely independent of the unmasked values, also the subcircuits implementing them are, even in the presence of glitches. Because of the linearity of the expectation operator, the same holds true for the average power consumption of the whole circuit, or any linear combination of the power consumptions of the subcircuits. This has, as a consequence, the implication that one has perfect resistance against all first-order side-channel attacks [10] (this approach was extended and applied to Noekeon, Keccak, Present, and AES).
Now, in order to share a nonlinear function (S-box) with algebraic degree d, at least \(d+1\) shares are needed. For example, (quadratic) Gold (APN or not) functions can be realized with 3 shares. Since the algebraic degree of a vectorial Boolean function is one of the main parameters driving the cost of its hardware implementation, a natural question is whether we decompose every permutation using affine/quadratics/cubics (especially of those whose shares are investigated).
Prior to this, in [2], Carlitz showed that all permutation polynomials over \({\mathbb F}_q\), where \(q>2\) is a power of a prime, are generated by the special permutation polynomials \(x^{q-2}\) (the inversion) and \( ax+b\) (affine functions, where \(0\ne a, b\in {\mathbb F}_q\)). The smallest number of inversions in such a decomposition is called the Carlitz rank.
Here, we ask whether the inverse in \({\mathbb F}_{2^n}\) (the finite field of dimension n over the two-elements prime field \({\mathbb F}_2\)) can be written as a composition of quadratics, or quadratics and cubics. That is, we ask if there are integers \(r\ge 1\) and \(a_1\ge 0,\ldots ,a_r\ge 0\) such that
Nikova, Nikov and Rijmen [9] proposed an algorithm to find such a decomposition. Leveraging Carlitz’s work [2], they utilized the algorithm to demonstrate that for all \(n\le 16\), any permutation can be decomposed into quadratic permutations, when n is not a multiple of 4, and into cubic permutations, when n is a multiple of 4. In addition to a theoretical result, which we will discuss below, Petrides [11] improved the complexity of the algorithm and presented a computational table of shortest decompositions for \(n\le 32\), allowing also cubic permutations in addition to quadratics. Here, we find a new number theoretical approach that allows us to cover all (surely, odd) exponents up to 250, at least.
2 Heuristics and some conjectures
Let \(\nu _2\) be the 2-valuation, that is, the largest power of 2 dividing the argument. We start with a proposition, extending one of Petrides’ results [11], which states that if n is an odd integer and \(\frac{n-1}{2^{\nu _2(n-1)}}\equiv 2^k\pmod {2^n-1}\), for some k, then
This implies, via Carlitz [2], that for all odd integers (coined good integers, with the counterparts named bad integers in [7]) satisfying the congruence \(\frac{n-1}{2^{\nu _2(n-1)}}\equiv 2^k\pmod {2^n-1}\), one can decompose any permutation polynomial in \({\mathbb F}_{2^n}\) into affine and quadratic power permutations.
The smallest odd positive integer that is not good is \(n=7\). We note however that in that case
and so, any permutation in \({\mathbb F}_{2^7}\) can be decomposed into affine, quadratic and cubic permutations. We are ready to generalize this observation.
Theorem 1
Let n be an odd integer satisfying
for some non-negative integers k, s. Then, the inverse power permutation in \({\mathbb F}_{2^n}\) has a decomposition into affine, quadratic and cubic power permutations of length \(k+s+\nu _2(n-1)\).
Proof
As we have already alluded to above, using the difference of cubes factorization, \(a^3-b^3=(a-b)(a^2+ab+b^2)\), we have
The claim is shown.
Example 1
It is natural to investigate the counting function \(\mathcal {B}(x)\) of superbad integers (that is, integers n such that \(\frac{n-1}{2^{\nu _2(n-1)}}\not \equiv 2^k3^s\pmod {2^n-1}\)), with \(\mathcal {B}(x)=\{n\le x\,:\, n\text { is superbad}\}\), or its complement
As an example, \(|\mathcal {B}(50)|=16\), more precisely,
Petrides [11] noted that 25 integers up to 50 are bad, so our extension surely prunes the integers better. In a recent paper [5], two of us showed that
In the first part of our paper, we restrict our attention to \(n=p\), a prime, and propose some conjectures that will help us in designing our algorithm. Surely, there is no reason why we should not expect the algorithm to work for odd integers, also.
Let \(p\ge 3\) be prime, \(N:=N_p=2^p-1\). It is known that if \(q\mid N_p\), then \(q\equiv 1\pmod {p}\). We ask if we can say anything about the number of distinct prime factors \(\omega (N_p)\) of \(N_p\). We propose the following conjecture.
Conjecture 1
There exists \(p_0\) such that for \(p>p_0\), \(\omega (N_p)<1.36\log p\).
Similar heuristics regarding lower bounds for \(\Omega (2^n-1)\) and \(\omega (2^n-1)\) can be found in [4] and [6].
Our Conjecture 1 is based on statistical arguments originating from sieve methods. The Turán-Kubilius inequality asserts that
So, if \(\delta >0\) is fixed, the set of \(n\le x\) such that \(\omega (n)\ge (1+\delta )\log \log x\) is of counting function \(O_{\delta }(x/\log \log x)\). One can do better using sieves. Indeed, Exercise 04 in [3] shows that for fixed \(\delta >0\) we, in fact, have that
where \(Q(\delta ):=(1+\delta )\log ((1+\delta )/e)+1\). We would like to apply such heuristics to \(N_p=2^p-1\). But note that if \(q\mid N_p\), then \(2^p\equiv 1\pmod q\). In particular, \({\displaystyle {\left( \frac{2}{q}\right) =1}}\), so \(q\equiv \pm 1\pmod 8\). But then the same proof as Exercise 04 in [3] shows that
as \(x\rightarrow \infty \), where \(Q_1(\delta ):=(1+\delta )\log ((1+\delta )/(0.5 e))+1\). Taking \(\delta =0.36\), we get \(Q_1(\delta )=1.00086\ldots \). Thus, the probability that a number having only prime factors congruent to \(\pm 1\pmod 8\) has more than \(1.36\log \log n\) distinct prime factors is
Applying this to \(N_p\), we get
and since the series
is convergent, we are led to believe that maybe there are at most finitely many prime numbers p such that \(\omega (N_p)\ge 1.36\log p\). It has been noted that perhaps infinitely often \(\omega (N_p)\ge 2\). For example, this is the case if \(p\equiv 3\pmod 4\) is such that \(q=2p+1\) is prime. Indeed, then 2 is a quadratic residue modulo q so \(2^{(q-1)/2}\equiv 1\pmod q\), showing that \(q\mid N_p\). Since \(N_p\) is never a perfect power, in particular it cannot be a power of q, we get the desired conclusion that \(\omega (N_p)\ge 2\).
Conjecture 2
There exists \(p_0\) such that if \(p>p_0\), then \(N _p\) is squarefree.
We offer some heuristic evidence for Conjecture 2. Knowing that the prime q divides \(N_p\), the conditional probability that \(N_p\) is divisible by \(q^2\) is 1/q. Thus, the probability that \(N_p\) is not squarefree is bounded above by
and it was shown by Murata and Pomerance in [8] that the above sum is finite under GRH.
So, assuming Conjectures 1 and 2, let \(N_p:=q_1\cdots q_k\) for some distinct primes \(q_1,\ldots ,q_k\) with \(k\le 1.36\log p\). We take numbers of the form \(2^a+1\) with an odd \(a\in [5,p-2]\). We want to compute
This was done by Rotkiewicz in [12]. Namely, write the Euclidean algorithm with even quotients and signed remainders:
where \(\ell :=\ell (a,p)\) is minimal with \(r_{\ell }=1\). Note that \(r_i\) are all odd for \(i=1,\ldots ,\ell \). In particular, \(r_j\ge 3\) for \(j=1,\ldots ,\ell -1\). Then
The right–most equality is clear if \(\varepsilon _1=1\), and if \(\varepsilon _1=-1\), then
The above calculation shows how to transit from the first step to the second step, or more generally from a step with \(2^{r_j}-1\) in the bottom to a step with \(2^{r_j}-1\) in the top. For the next step, we write
The last inequality above is clear if \(\varepsilon _2=1\). If \(\varepsilon _2=-1\), then since \(r_1\ge 3\), we have
At step \(\ell \) we end up with
If \(\ell (a,p)\) is odd, we get
and if \(\ell (a,p)\) is even we get
We thus get that
We select the subset \(\mathcal {A}(p)\) of odd a in the interval \([5,p-2]\) such that \(\ell \equiv 0\pmod 2\). We assume that there are a positive proportion of such, namely that there is a constant \(c_1>0\) such that for large p, there are \(>c_1p\) odd numbers \(a\in [5,p-2]\) such that \(\ell (a,p)\equiv 0\pmod 2\). So, we have
We next conjecture that for such a, the values are
are uniformly distributed among the \(2^k\) vectors \({\underbrace{(\pm 1,\pm 1,\cdots ,\pm 1)}_{k~{\text {times}}}}\). Indeed, if not, then somehow for some a the value of \(2^a+1\) of the Legendre symbol \({\displaystyle {\left( \frac{2^a+1}{p_i}\right) }}\) should be determined in terms of the values of the same symbol for \(b\le a-1\). This can happen for example if:
- (i):
-
\(2^a+1\) is a square. This never happens for \(a\ge 4\).
- (ii):
-
\(2^a+1\) is multiplicatively dependent over \(\{2^b+1: 0\le b\le a-1\}\). This does not happen for \(a\ge 4\) because of the Carmichael’s Primitive Divisor Theorem: \(2^a+1\) has a prime factor \(p_a\) which is primitive in the sense that \(p_a\) does not divide \(2^b+1\) for any \(b\le a-1\).
Well, so we fix \(i\in \{1,\ldots ,k\}\) and search for \(a_i\) such that
where \(\delta _{ij}\) is the Kronecker symbol. That is, \(2^{a_i}+1\) is a quadratic residue modulo \(p_j\) for all \(j\ne i\) but it is not a quadratic residue modulo \(q_i\). Do we expect to find it? Well, let us see. Fix i in \(\{1,\ldots ,k\}\). The probability that \(2^{a_i}+1\) verifies the Legendre conditions given by (2) is \(1/2^k\) so it is \((1-1/2^k)\) that they are not satisfied. Note that since \({\displaystyle {\left( \frac{2^{a_i}+1}{N_p}\right) =-1}}\) we know that an odd number of the \(p=p_j\)’s satisfy that \({\displaystyle {\left( \frac{2^{a_i}+1}{p_j}\right) =1}}\). So, if we assume that this is so for all possible \(a_i\)’s, and assuming that these events are independent, we get that the probability that this be so is
In the above, we used that \(k<1.36\log p\) and \(1.36\cdot \log 2<0.95\). Of course, this is for i fixed and now we sum up over i from 1 to k introducing another logarithmic factor in the above count. Since the series
converges, so we expect that the above event does not occur when \(p>p_0\). So, we have the following conjecture.
Conjecture 3
Assume Conjectures 1 and 2. Write \(2^p-1=q_1\ldots q_k\) for \(p>p_0\) with prime factors \(q_1<\cdots <q_k\) and \(k<1.36\log p\). Then for each \(i=1,\ldots ,k\), there exists an odd \(a_i\in [5,p-2]\) such that equalities (2) hold.
3 Unconditional argument and our decomposition algorithm
The rest of the proof is unconditional. We will show that there exist integers \(x_i\) such that
We will be more precise later, but the idea of our approach is the following. For a prime p below some bound (depending upon the speed of the computer), factor (via the database from the Cunningham project or the computer), \(2^p-1=q_1\cdots q_k\), (\(q_i\) primes), and for each i we search for \(a_i\) in \([5,p-2]\) odd such that for each such, \(2^{a_i}+1\) is a QR (quadratic residue) modulo \(q_j\) for all \(j\ne i\) in \(\{1,\ldots ,k\}\) and a QNR (quadratic non-residue) modulo \(q_i\). We then generate some primitive roots modulo \(q_i\) and compute the invertible matrix \(\mathcal {B}\) and find values for the \(x_i\)’s. There is no reason why we should not expect this to happen to odd integers n (again under some manageable bound) and do the same for \(2^n-1\) (choose a odd with \(\gcd (a,n)=1\)). We now detail this below.
Write \(q_i-1=:2^{\alpha _i} R_i\) for \(i=1,\ldots ,k\), where \(R_i\) is odd. Let
and write \(x_i=y_ iR\) for \(i=1,\ldots ,k\). Let \(\rho _i\) be a primitive root modulo \(q_i\). Write
Conditions (2) show that \(b_{ij}\equiv \delta _{ij}\pmod 2\). Equation (3) holds if and only if it holds one prime \(q_j\) at a time. Thus, we want
which holds provided that
This in turn is equivalent to
Since \(R/R_j\) is odd, it follows that it is invertible modulo \(2^{\alpha _j}\). Writing \((R/R_j)^*\) for the inverse of \((R/R_j)\) modulo \(2^{\alpha _j}\), we get that
Since \((R/R_j)^*\) is odd the left–hand side is just \(2^{\alpha _j-1}\pmod {2^{\alpha _j}}\). Thus,
This is a linear system of modular equations for \(i=1,\ldots ,k\). To see that it is nondegenerate note that the coefficient matrix \(\mathcal {B}=(b_{ij})_{1\le i,j\le k}\) modulo 2 is in fact the identity matrix. Hence, its determinant is an odd integer, so invertible modulo powers of 2, which shows that there exist an integer solution \(y_1,\ldots ,y_k\). To solve it, we can generate for each i, j the number \(b_{i,j}\pmod {2^{\alpha _j}}\) appearing in (4) as an integer in the interval \([0,2^{\alpha _j}-1]\). Having done that, we solve the linear system
This is non-degenerate since the determinant of the coefficient matrix is odd. Thus, \((y_1,\ldots ,y_k)\) are some rational numbers. Now we treat them as residue classes modulo \(2^{\alpha }\), where \(\alpha :=\max \{\alpha _i: 1\le i\le k\}\) (by inverting the odd determinant modulo \(2^{\alpha }\)). These ones are the \(y_i\)’s that we are looking for.
We implemented this and checked it for all primes \(p\le 250\). We present our approach in Algorithm 1.
The factorization of \(2^p-1\) is known for all primes \(p<1000\). Surely, we can use the same algorithm modulo \(2^n-1\) for \(n\le 250\) and odd. Note that if
then we only want to find a relation of the form
Indeed, if we have found the above relation, then
Writing \(Q:=(2^n-1)/(q_1\ldots q_k)\), we then get easily that
Thus,
Thus, we factor \(2^n-1\), take \(q_1,\ldots ,q_k\) to be all its distinct prime factors and attempt to find some numbers \(a_1,\ldots ,a_k\) in \([5,n-2]\) such that the congruences (2) are satisfied. If we are successful, then the argument based on the matrix with an odd determinant will work to find a solution of (5), which in turn can be easily lifted to a solution modulo \(2^n-1\). The factorizations of \(2^n-2\) with weight 2 factors for odd \(33 \le n \le 249\) are given in Table 1, in the appendix.
Remark 1
We have checked that Algorithm 1 works for most primes up to 250. But there are a few primes like 47 for which there is no \(a_j \in [5, p-2]\) such that \(\left( \frac{2^{a_j}+1}{q_i}\right) =(-1)^{\delta _{ij}}\). In these cases, we use the following trick. We first find \(a_i\) and calculate \((\frac{2^{a_j}+1}{q_i})=(-1)^{d_{i,j}}\). Ideally, \(d_{i,j}\) should be Kronecker symbols, but if they are not, we can just record what they are. Because \(d_{i,j}\) are no longer Kronecker symbols, we cannot be certain that the system is solvable because it may have an even determinant and we cannot invert the matrix modulo powers of 2. However, we checked primes (and odd integers) up to 250. We observed that in the case of failure, we can use this trick and always get suitable \(a_i\)’s such that the corresponding matrix has odd determinant, and is therefore invertible.
4 Further comments
One can go further than our choice of bound, namely 250, by using our method. We have yet to encounter an exponent for which we cannot apply Algorithm 1. If there is such an exponent n for which we cannot find \(a_j\), \(d_{i,j}\) as above, then we can involve cubics in the factorization of \(-1\pmod {2^n-1}\). More precisely, we do something similar as above using \(2^{a_i}+2^{b_i}+1\) and check if we can find such powers \(a_i,b_i\) such that the number above is a quadratic nonresidue modulo \(q_i\) and quadratic residue modulo \(q_j\) for all \(j\ne i\). The rest of Algorithm 1 runs unchanged.
While, via Carlitz’ result, we know that any permutation can be decomposed as a composition of inverses and affine functions, it would also be interesting to check whether one can modify our method in this paper to other exponents, other than the inverse and surely, the Gold \(2^k+1\) exponents, to directly find their decomposition in quadratics, or quadratics and cubics, and we leave that for future work and the interested reader.
References
Bilgin, B., Nikova, S., Nikov, V., Rijmen, V., Stütz, G.: Threshold Implementations of All \(3 \times 3\) and \(4\times 4\) S-Boxes. In: Prouff, E., Schaumont, P. (eds.) Cryptographic Hardware and Embedded Systems - CHES 2012, LNCS 7428. Springer, Berlin, Heidelberg (2012)
Carlitz, L.: Permutations in a finite field’. Proc. Amer. Math. Soc. 4, 538 (1953)
Hall, R.T., Tenenbaum, G.: Divisors, Cambridge Tracts in Mathematics, 90. Cambridge University Press, Cambridge (1988)
Kontorovich, A., Lagarias, J.: On toric orbits in the affine sieve. Exp. Math. 30, 575–587 (2021)
Luca, F., Stănică, P.: Asymptotics on a class of \(\cal S\it \)-unit integers. Periodica Math. Hungarica, https://doi.org/10.1007/s10998-023-00551-4
Luca, F.: Stănică, P.: Prime divisors of Lucas sequences and a conjecture of Skałba. Int. J. Number Theory 1(4), 583–591 (2005)
Moree, P.: On the divisors of \(a^k+b^k\). Acta Arith. LXXX.3, 197–212 (1997)
Murata, L., Pomerance, C.: On the largest prime factor of a Mersenne number. In: Number Theory, 209–218, CRM Proc. Lecture Notes 36, Amer. Math. Soc., Providence, RI, (2004)
Nikova, S., Nikov, V., Rijmen, V.: Decomposition of permutations in a finite field. Cryptogr. Commun. 11, 379–384 (2019)
Nikova, S., Rechberger, C., Rijmen, V.: Threshold Implementations Against Side-Channel Attacks and Glitches. In: Ning, P., Qing, S., Li, N. (eds.) Information and Communications Security - ICICS, LNCS 4307. Springer, Berlin, Heidelberg (2006)
Petrides, G.: On decompositions of permutation polynomials into quadratic and cubic power permutations. Cryptogr. Commun. 15, 199–207 (2023)
Rotkiewicz, A.: Applications of Jacobi’s symbol to Lehmer’s numbers. Acta Arith. 42, 163–187 (1983)
Acknowledgements
The authors would like to thank the editor for efficiently handling our paper and the reviewers for their careful reading, beneficial comments and constructive suggestions. The first and the third-named authors worked on this paper during visits to the Max Planck Institute for Software Systems in Saarbrücken, Germany in Spring of 2022 and 2023. They thank Professor J. Ouaknine for the invitation and the Institute for hospitality and support. During the final stages of the preparation of this paper, the first-named author was a fellow at the Stellenbosch Institute for Advanced Study. He thanks this Institution for hospitality and support.
Author information
Authors and Affiliations
Corresponding author
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This is an expanded and vastly improved version of the Extended Abstract, which was presented at the 8th International Workshop on Boolean Functions and their Applications (BFA) in Voss in September 2023.
Appendix
Appendix
Rights and permissions
About this article
Cite this article
Luca, F., Sarkar, S. & Stănică, P. Representing the inverse map as a composition of quadratics in a finite field of characteristic 2. Cryptogr. Commun. (2024). https://doi.org/10.1007/s12095-024-00702-5
Received:
Accepted:
Published:
DOI: https://doi.org/10.1007/s12095-024-00702-5