Abstract
Lattices used in cryptography are integer lattices. Defining and generating a “random integer lattice” are interesting topics. A generation algorithm for a random integer lattice can be used to serve as a random input of all the lattice algorithms. In this paper, we recall the definition of the random integer lattice given by G. Hu et al. and present an improved generation algorithm for it via the Hermite normal form. It can be proven that with probability ≥0.99, this algorithm outputs an n-dim random integer lattice within operations.
Keywords: random integer lattice, Hermite normal form, generation algorithm
1. Introduction
Lattices are discrete subgroups in . Since Ajtai’s discovery of the average-case/worst-case connection in lattice problems [1], lattice-based cryptography has attracted much attention [2,3,4,5]. Up to now, lattice-based cryptographic schemes have been considered to be a promising alternative to more traditional ones based on the factoring and discrete logarithm problems since lattice-based schemes can be resistant to efficient quantum algorithms [6]. Lattice algorithms such as LLL [7] and BKZ [8,9] are commonly used in analyzing these lattice-based schemes’ security. The lattices used in cryptography and lattice algorithms are integer lattices (discrete subgroups of ). Thus, the problem of suitably defining and generating a random integer lattice is a meaningful topic. In [10], P. Q. Nguyen found that for dimensions up to 50, LLL almost outputs the shortest lattice vector, while in theory, LLL’s output is just an approximately short vector. Once we are able to generate a random integer lattice, such a generation algorithm can be used to serve as a random input for all lattice algorithms to obtain their output qualities on average.
In [1], M. Ajtai defined a family of “random integer lattices” in terms of the worst-case to average-case connection and showed how to generate one from this lattice family. For uniform , the lattice family is defined as . In [10], P. Q. Nguyen and D. Stehle gave a definition of the “random integer lattice” in the sense of the Haar measure, which was approximated by the Goldstein–Mayer method [11]. For large number N, this “random integer lattice” is uniformly chosen from the set of all Hermite normal forms with the determinant equal to N. When N is prime, to generate such a random integer lattice, one only needs to set , uniformly and for . This type of “random integer lattice” is used in many cryptographic applications. From the perspective of mathematics, studying whether the requirement that N be a prime can be removed is also a meaningful issue.
In [12], G. Maze studied the probabilistic distribution of the random HNF with a special diagonal structure, where the randomness was derived from a random square matrix whose elements were all chosen uniformly from for large enough B. In [13], G. Hu et al. introduced a different definition of randomness, in which the definition “random integer lattice” means the lattice’s HNF is chosen uniformly from all HNFs whose determinants are upper bounded by a large number M. In the same paper [13], G. Hu et al. also presented a complete random integer lattice generation algorithm. In this algorithm, the first step is to generate a determinant. To make the final output uniform, it is necessary to compute the total number of HNFs with fixed determinant N. Since the total number can be figured out only in the case that the factorization of N is known, a subroutine to factor integers is necessary in this algorithm. In this paper, we improved this algorithm with the help of the diagonal elements’ distribution in the random HNF. This improved algorithm first generates the diagonal elements without computing the total number of HNFs with a fixed determinant, then it uses the reverse sampling method to generate the final diagonal element . Thus, the factorization subroutine is no longer needed in this improved algorithm, which makes it more efficient.
The remainder of the paper is organized as follows. In Section 2, we give some necessary preliminaries. In Section 3, we recall the definition of the random integer lattice given by G. Hu et al. and discuss the distribution of all the diagonal elements in the random integer lattice’s HNF. For the next section, we present our improved algorithm to generate the random integer lattice via the HNF. Finally, we give our conclusion in Section 5.
2. Preliminaries
We denote by the integer ring and the real number field. We use to denote the general linear group over . For convenience, we denote the set of all nonsingular integer matrices by .
Lattice and the HNF
Given a matrix with rank n, the lattice spanned by the rows of B is:
where is the i-th row of B. We call m the dimension of and n its rank. The determinant of , say , is defined as . It is easy to see that when B is full-rank (), its determinant becomes .
Two lattices and are exactly the same when there exists a matrix s.t. . Lattices used in cryptography are usually “integer lattices”, whose basis matrices are over instead of . Thus, the space of all full-rank integer lattices is actually .
The Hermite Normal Form (HNF) is a useful tool to study integer matrices:
Definition 1.
A square nonsingular integer matrix is called in the HNF if:
• H is upper triangular, i.e., for all ;
• All diagonal elements are positive, i.e., for all i;
• All nondiagonal elements are reduced modulo the corresponding diagonal element at the same column, i.e., for all .
There exists a famous result for the HNF [14] (Chapter 2, page 66):
Theorem 1.
For every , there exists a unique matrix (HNF) of the form with .
By this theorem, an integer lattice corresponds to its unique HNF, implying that generating an integer lattice is actually equivalent to generating an HNF.
3. Random Integer Lattice
3.1. Definition
In this part, we refer to [13] to recall some results related to the random integer lattice.
First, for ,
Gruber [15] counted the size of :
Theorem 2.
If N has prime decomposition , then:
There exists an asymptotic estimation for in [13]:
Theorem 3.
For large positive integer M,
H is called an n-dim random nonsingular HNF if for large integer , H is chosen from uniformly, and the lattice generated by such an H is called a random integer lattice.
3.2. Diagonal Distribution
In [13], Hu et al. studied the expectation and variance of every entry and the probability distribution of every diagonal entry:
Theorem 4.
Let be an n-dim random nonsingular HNF with the determinant bounded by and t be an integer in , given an increasing subset of and its increasing complementary subset , for positive integers ; when , we have:
(1)
If we take , a one-element set , and positive integers b, then the increasing complementary subset of T in is . We apply the above theorem and obtain the following corollary:
Corollary 1.
Let be an n-dim random nonsingular HNF with the determinant bounded by , then for and positive integer b, when , we have:
We denote this distribution of by .
Remark 1.
Notice that in Theorem 4, when and , both cases: and are valid conditions, which corresponds to the joint distribution of for or a marginal distribution of the single variable for as in Corollary 1. Considering Theorem 4 and Corollary 1, it can be deduced that when , the first diagonal elements are independent variables.
4. Generating the Random Integer Lattice via the HNF
In this section, we present our random integer lattice generation algorithm via the HNF. Firstly, we introduce the inverse sampling method in probability theory to generate all the diagonal elements. Then, we generate all the nondiagonal elements accordingly.
4.1. Inverse Sampling Method
Given a distribution over some ordered set A, we can use the inverse sampling method to generate a random variable according to the distribution . We present two versions of the inverse sampling method: continuous-ISM and discrete-ISM.
Theorem 5.
(Continuous-ISM) For distribution over interval with cumulative distribution function , choose a random y uniformly from and compute z s.t. , then the resulting variable Z has distribution .
Proof.
Our goal is to prove Z has as its cumulative distribution function. Namely, for any , we have to prove . Since F is a monotonically increasing function, we have:
where the second equality comes from and the last one is a direct result of y’s uniformity in . Thus, the cumulative distribution function of Z is actually , which completes the proof. □
Theorem 6.
(Discrete-ISM) For distribution over finite-ordered set with corresponding density , choose a random number y uniformly from and compute the minimum j s.t. ; then, we let , and Z will have distribution .
Proof.
For any , we need to prove . Since j is the minimum value s.t. , we know that . Then, we have:
which completes the proof. □
4.2. Generating the Random Integer Lattice via the HNF
From Section 3.1, we can generate a random integer lattice by equivalently generating a random nonsingular HNF. To begin with, we generate the first diagonal elements . Then, we generate the last diagonal element . Finally, all the nondiagonal elements are generated, and we output the matrix H as a lattice basis for our random integer lattice.
4.2.1. Generating
From Corollary 1, we know that for an n-dim nonsingular HNF, when , the distribution of is:
| (2) |
Therefore, we generate these diagonal elements according to by discrete-ISM (Theorem 6).
For , we choose y uniformly randomly from and increasingly iterate starting from 1 until it satisfies . Then, we set . By Theorem 6, each diagonal has distribution , which is what we need.
4.2.2. Generating
After generating the first diagonal elements , we set . Since the determinant upper bound is M, the last diagonal element should be in . We point out that is a small number compared to M with high probability. More specifically, the following theorem can be proven.
Theorem 7.
Let be an n-dim random nonsingular HNF with the determinant bounded by ; for , we have:
Moreover, by Markov’s inequality, we find that:
To prove Theorem 7, the following lemma from [13] is needed.
Lemma 1.
Given an integer and a large integer , for any non-negative increasing sequence s.t. and a respective summation:
we have the following Table 1 on asymptotic formulas for .
where is the well-known Riemann zeta function and the constant in the O notation is only relevant to n.
Table 1.
Asymptotic formulas of in different cases.
| If | |
|---|---|
Now, we start to prove Theorem 7.
Proof.
For the expectation of , we find that:
which completes the first part of Theorem 7.
For the second part, recall that for any non-negative random variable X, Markov’s inequality tells us that:
Since is non-negative, we apply Markov’s inequality to it by setting and obtain:
which completes the second part of the proof. □
From Theorem 7, we know that is small compared to M with high probability; thus, is still large enough for us to obtain a similar result for . We think this is a relatively reasonable way to describe the distribution of . Thus, for the random nonsingular HNF with the determinant bounded by M, on the condition that , the distribution of is the following:
| (3) |
Moreover, the corresponding cumulative distribution function is:
| (4) |
Since is still super large, we know that:
As a result, is a rather good estimation for . In fact, if we define the distribution by the cumulative distribution function as follows:
| (5) |
then we have the following theorem.
Theorem 8.
For large enough and positive integer , the statistical distance between and is at most .
Proof.
According to (4), the cumulative distribution function of is , since the cumulative distribution function of is ; denote by , then , and for every , we have:
which implies that the statistical distances and are bounded by . □
Since is still super large, we can generate according to (close enough to ) by continuous-ISM (Theorem 5).
We choose y uniformly randomly from and compute s.t.:
Then, we set . By Theorems 6 and 8, the diagonal has distribution , which is close enough to .
4.2.3. Generating
This part is relatively easier. For , let be chosen from uniformly randomly if and let if .
4.2.4. Correctness
By the discussion above, for large enough , the distribution of the diagonal generated by this algorithm is close enough to its distribution as a random nonsingular HNF. For , since a random nonsingular HNF’s is uniform in and is generated in the same way, we know that the output of this algorithm is also close enough to a real random nonsingular HNF, which implies the correctness of this algorithm.
4.3. Algorithm 1: Generate Random Integer Lattice
Now we present the Algorithm 1 to generate a random integer lattice.
| Algorithm 1: Random Integer Lattice Generation |
| Require: Dimension n, large integer M |
| Ensure: n-dim random integer lattice with |
| Step 1: Generate |
| for to do |
| , |
| choose uniformly |
| while do |
| end while |
| set |
| end for |
| Step 2: Generate |
| choose uniformly |
| set |
| Step 3: Generate |
| for to n do |
| for to do |
| choose uniformly |
| end for |
| for to n do |
| set |
| end for |
| end for |
| Step 4: Set , and output |
4.4. Time Complexity of Algorithm 1
Now, we analyze the time complexity of Algorithm 1. Obviously, the most time-consuming part of Algorithm 1 is the floating-point operations inside the while iteration for each i in Step 1. Denote the number of computing in the i-th while iteration by . Notice that:
since converges to one quite fast as s grows, the majority of will be set to one. In fact, by the numerical results, we have following result:
Fact 1: For any integer ,
By this fact, for , all the are very likely to be set to one, implying that with probability . Then, we consider . If we set the probability bound for each to be , then by accurate numerical results, we have the following Table 2:
Table 2.
Upper bound for with probability.
| T(i) | Upper Bound |
|---|---|
| 0 | |
| 1 | |
| 1 | |
| 1 | |
| 2 | |
| 3 | |
| 6 | |
| 19 | |
| 607 |
Thus, we have the following theorem:
Theorem 9.
The number of floating-point operations performed in Algorithm 1 is bounded by 1300 with probability .
Proof.
By the above table, is bounded by 640 with probability . Since with probability , we know that is bounded by 640 with probability . Notice that each needs two floating-point operations, and it also needs another four floating-point operations to generate in Step 2; thus, with probability , the total number of floating-point operations performed in Algorithm 1 is bounded by , which completes the proof. □
Remark 2.
We point out that the accuracy of the floating-point affects the actual running time of Algorithm 1. By experiments, 150 bit are a suitable option.
It is not hard to see that in Algorithm 1, besides the floating-point operations, the remaining parts of Step 1, Step 2, and Step 3 take , and operations, respectively. Combining this with Theorem 9, we have the following result:
Theorem 10.
Algorithm 1 outputs a random integer lattice within operations with probability .
5. Conclusions
In this paper, we presented an improved algorithm for generating random integer lattices and discussed its time complexity. We proved that with probability , this algorithm outputs an n-dim random integer lattice within operations. We pointed out that there is still space for improvement of our algorithm, and we leave this as an open problem.
Acknowledgments
We thank Yanbin Pan for his wonderful suggestions about this paper, and we thank the referees for putting forward their excellent advice on how to improve the presentation of this paper.
Author Contributions
Conceptualization, G.H.; formal analysis, L.Y.; funding acquisition, G.H. and L.Y.; investigation, G.H.; methodology, G.H.; validation, L.L.; writing—original draft, G.H.; writing—review and editing, L.L., L.H., and H.W. All authors have read and agreed to the published version of the manuscript.
Funding
This research was funded in part by the National Natural Science Foundation of China (No. 61602143, No. 61772166) and in part by the Natural Science Foundation of Zhejiang Province of China (No. LZ17F020002).
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
Not applicable.
Conflicts of Interest
The authors declare no conflict of interest.
Footnotes
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.
References
- 1.Ajtai M. Gennerating hard instances of lattice problems. In: Miller G., editor. Proceedings of the STOC ’96 Twenty-Eighth Annual ACM Symposium on Theory of Computing; Philadelphia, PA, USA. 22–24 May 1996; New York, NY, USA: ACM Press; 1996. pp. 99–108. [Google Scholar]
- 2.Ajtai M., Dwork C. A public-key cryptosystem with worst-case/average-case equivalence. In: Leighton F.T., Shor P., editors. Proceedings of the STOC ’97 Twenty-Ninth Annual ACM Symposium on Theory of Computing; El Paso, TX, USA. 4–6 May 1997; New York, NY, USA: ACM Press; 1997. pp. 284–293. [Google Scholar]
- 3.Hoffstein J., Pipher J., Silverman J.H. NTRU: A Ring-Based Public Key Cryptosystem. In: Buhler J.P., editor. Proceedings of the ANTS-III Third International Symposium on Algorithmic Number Theory; Portland, OR, USA. 21–25 June 1998; Heidelberg, Germany: Springer; 1998. pp. 267–288. [Google Scholar]
- 4.Regev O. On lattices, learning with errors, random linear codes, and cryptography. In: Gabow H.N., Fagin R., editors. Proceedings of the STOC ’05 Thirty-Seventh Annual ACM Symposium on Theory of Computing; Baltimore, MD, USA. 22–24 May 2005; New York, NY, USA: ACM Press; 2005. pp. 84–93. [Google Scholar]
- 5.Gentry C., Peikert C., Vaikuntanathan V. Trapdoors for hard lattices and new cryptographic constructions. In: Ladner R., Dwork C., editors. Proceedings of the STOC ’08 Fortieth Annual ACM Symposium on Theory of Computing; Victoria, BC, Canada. 17–20 May 2008; New York, NY, USA: ACM Press; 2008. pp. 197–206. [Google Scholar]
- 6.Shor P.W. Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM J. Comput. 1997;26:1484–1509. doi: 10.1137/S0097539795293172. [DOI] [Google Scholar]
- 7.Lenstra A.K., Lenstra H.W., Jr., Lovasz L. Factoring polynomials with rational coefficients. Math. Ann. 1982;261:513–534. doi: 10.1007/BF01457454. [DOI] [Google Scholar]
- 8.Schnorr C.P., Euchner M. Lattice basis reduction: Improved practical algorithms and solving subset sum problems. Math. Program. 1994;66:181–199. doi: 10.1007/BF01581144. [DOI] [Google Scholar]
- 9.Chen Y., Nguyen P.Q. BKZ 2.0: Better Lattice Security Estimates. In: Lee D.H., Wang X., editors. Proceedings of the ASIACRYPT 2011 17th International Conference on the Theory and Application of Cryptology and Information Security; Seoul, Korea. 4–8 December 2011; Heidelberg, Germany: Springer; 2011. pp. 1–20. [Google Scholar]
- 10.Nguyen P.Q., Stehle D. LLL on the average. In: Hess F., Pauli S., Pohst M.E., editors. Proceedings of the ANTS-XII 7th International Symposium on Algorithmic Number Theory; Berlin, Germany. 23–28 July 2006; Heidelberg, Germany: Springer; 2006. pp. 238–256. [Google Scholar]
- 11.Goldstein D., Mayer A. On the equidistribution of Hecke points. Forum Math. 2003;15:165–189. doi: 10.1515/form.2003.009. [DOI] [Google Scholar]
- 12.Maze G. Natural density distribution of Hermite normal forms of integer matrices. J. Number Theory. 2011;131:2398–2408. doi: 10.1016/j.jnt.2011.06.010. [DOI] [Google Scholar]
- 13.Hu G., Pan Y., Liu R., Chen Y. On Random Nonsingular Hermite Normal Form. J. Number Theory. 2016;164:66–86. doi: 10.1016/j.jnt.2015.12.004. [DOI] [Google Scholar]
- 14.Cohen H. A Course in Computational Algebraic Number Theory. Volume 138. Springer-Verlag; Berlin/Heidelberg, Germany: 1993. p. 66. [Google Scholar]
- 15.Gruber B. Alternative formulae for the number of sublattices. Acta Cryst. 1997;A53:807–808. doi: 10.1107/S0108767397009781. [DOI] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Data Availability Statement
Not applicable.
