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.
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:
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.
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:
Moreover, the corresponding cumulative distribution function is:
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:
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:
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 .