Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

REDEFINING RANDOMNESS

QUANTIS
WHEN RANDOM NUMBERS CANNOT BE LEFT TO CHANCE

ID Quantique

Technical Paper on

Randomness Extractor

Version 1.0
September 2012

ID Quantique SA 1227 Carouge/Geneva T +41 22 301 83 71 info@idquantique.com


Chemin de la Marbrerie 3 Switzerland F +41 22 301 83 79 www.idquantique.com
A randomness extractor for the Quantis device
M. Troyer and R. Renner⇤
September 19, 2012

Abstract any deviation from perfect uniform randomness in


a time longer than the age of the universe. The
This document describes the use of a randomness value of "hash could even be lowered further (e.g.,
extractor to post-process the raw random bits gen- by reducing the size of k, see below) if needed.
erated by the Quantis random number generator. The extractor is a simple bit-matrix-vector mul-
In particular, we detail the implementation of the tiplication with a random matrix m (also called
extractor function as well as the choice of the nec- seed )
essary parameters. The latter depend on the qual- Xn

ity of the raw random bits, which is quantified in yi = mij xj (2)


terms of the entropy per bit. We propose a method j=1

to obtain an estimate for this entropy. performed modulo 2. Multiplication of bits is eas-
iest implemented by a bitwise AND operation, ad-
ditions by a bitwise exclusive OR, and sums by ef-
1 The extractor ficient bit count algorithms.
1.1 Extractor design
1.2 Choice of parameters n and k
The basic idea of the extractor is to compute k
output bits yi with high randomness from n > k When choosing n and k one has to keep in mind
input bits xj with less randomness. Assuming that two conflicting requirements:
each bit of the input sequence has entropy s (s = 1 • Keeping the bound for failure probability "hash
for perfect randomness), the probability that the fixed, the efficiency (in terms of the number
extractor output will deviate from a perfectly uni- of generated bits per input bit), k/n = s
form k-bit string will be strictly bounded by 2 log2 (1/"hash )/n, can be raised by increasing
(sn k)/2 n.
"hash = 2 (1)
• The computational complexity for the matrix-
(see Theorem 1 of Appendix A.4). The value "hash vector multiplication is O(nk), and hence O(n)
can therefore be seen as a measure for the quality operations need to be performed per generated
of the random bits output by the extractor. As random bit.
outlined in Appendix A.1, the quantity "hash has
a direct operational interpretation: it can be seen After study of di↵erent values for n, we find
as the maximum probability by which a deviation that, n = 1024 or n = 2048 are good choices for
from a perfectly random sequence can be noticed. the Quantis and with the implementation of the
While "hash can be made arbitrarily small, a value randomness extractor in Quantis software pack-
of "hash = 0 is generally unachievable. Our aim age. These values gives a good balance between
is to keep "hash below 2 100 or 10 30 , implying extractor efficiency and computational power re-
that even using millions of devices one will not see quirement. Using n = 1024 and k = 768 one loses
⇤ This document has been edited by IDQ to reflect the 25% of the bits, while with n = 2048 and k = 1792
settings actually implemented in the Quantis software pack- one loses only 12.5%. Either is much better than
age. the 75% loss using von Neumann de-biasing, which

1
additionally does not eliminate correlations. Thus, In the Quantis software package, the random bit
from each block of 1024 or 2048 bits the extractor matrix has been generated from multiple Quantis
generates 768 or 1792 bits of provably good random devices.
numbers.
To keep "hash < 2 100 one should choose k <
sn 200. The above choices are thus acceptable 2 Estimating the entropy
as long as for a given device the entropy per raw
bit satisfies s > 0.946 for n = 1024 or s > 0.973 As already indicated above, the quality "hash of the
for n = 2048.1 The entropy of raw sequence gener- final bits depends on the entropy s per bit of the
ated by Quantis is guaranteed to be always above raw randomness generated by the device. In gen-
this value, thanks to continuous monitoring of the eral, the relevant entropy measure in this context is
performance of the device. the min-entropy Hmin . The min-entropy is closely
Others values for n and k can be chosen, but related to the collision entropy H2 (see Lemma 3
we must use multiples of 64 for k for performance in Appendix A.2 for details). For the particular ex-
reasons. tractors we use here (based on two-universal hash-
ing), slightly tighter bounds can be obtained by di-
rect use of the collision entropy. (For other extrac-
1.3 Generating the random matrix tor constructions, e.g., Trevisan’s extractor [Tre01],
The quality of the random bit matrix m is crucial it is however necessary to use the min-entropy.)
for the extractor to work. Fortunately, it needs to In this section, a quick lower bound that can be
be determined only once and can be reused for all used to obtain a rough estimate for the entropy
devices. To simplify the substitution of the random is given. This bound depends on the bias of the
bit matrix by the user, it is hard-coded in a file individual bits only. We will then discuss a more
delivered within the Quantis software package. For elaborate method that can be used to get a better
the two choices above we need 768 kbits or 3584 (higher) bound by running additional tests on a
kbits respectively. device. Besides the generally better bound, a main
To generate these random bits in practice, a advantage of this method is that it relies on weaker
safe (but costly) method is to generate each of the assumptions, as discussed in Appendix A.5.
bits by adding (modulo 2) r (weakly) random bits
from r mutually independent sources. According
2.1 Rough bound for the min-
to Lemma 4 in Appendix A.3, the resulting bits
can be made arbitrarily close to uniform by choos- entropy based on the bias
ing r sufficiently large. (The distance from perfect First a quick way to estimate a lower bound for
uniform bits is exponentially small in r.) H2 is given, incorporating both the bias and auto-
Ideally, the r individual sources used in the de- correlations of an imperfect source of random bits
scribed procedure to generate the matrix m should Xi . The bias b measures the deviation of the dis-
be obtained from di↵erent sources. In addition, we tribution of each bit Xi from uniform, i.e., the val-
recommend to take the following precautions: ues 0 and 1 are taken with probability 1/2 ± b. In
the following we assume that the bias b has been
• take only bits separated by times much longer measured with a statistical error .2 Then, to be
than the autocorrelation time (we recommend on the safe side we choose the probabilities to be
a distance of 100 to 1000 between bits); p0 = 1/2 b 9 0.001 and p1 = 1/2+b+9 +0.001
The term 9 makes sure that the bias estimate has
• use von Neumann de-biasing. an error of less than 10 30 , and the term 0.001 is a
1 The required bound on the entropy s is slightly larger
generous bound on the correlations. With these we
for the case n = 2048 because of the smaller loss of only
can estimate the entropy s = H2 (Xi ) of each bit
12.5%. If one is ready to tolerate a larger loss (25%), one
may choose k = 1536, in which case it is sufficient to have 2 If the bias is determined from N measurements, then
p
s > 0.848. the error is ⇡ 1/(2 N ).

2
produced by the source as statistical error s estimated by standard statisti-
cal methods. The final estimate for s needs to take
s& log2 (p20 + p21 ) into account these statistical errors: the probability
= log2 (1/2 + 2(b + 9 + 0.001)2 ). that the true entropy is below our estimate needs
to be smaller than the bound on the failure prob-
2.2 Accurate determination of the ability "hash that we tolerate. To achieve this we
use
min-entropy
s = s ↵ s, (6)
To determine the min-entropy we have to consider
the asymptotic entropy gain when adding another where the value ↵ is chosen such that the comple-
bit to a bit string C = (X1 , . . . , Xm ) of m bits, and mentary error function erfc(↵) < ".
thus look at the di↵erence of the collision entropy
of bit strings of lengths m and m + 1:3 2.3 Calculating autocorrelations
sm := H2 (X1 , . . . Xm+1 ) H2 (X1 , . . . , Xm ) (3) The histogram h(m) can also be used to calculate
the autocorrelation function
for large values of m, i.e., s = limm!1 sm .
The collision entropy H2 (X1 , . . . Xm ) of bit C(t) = hxi xi+t i hxi ihxi+t i (7)
strings of length m is estimated by recording nor-
malized histograms h(m) (c), counting how often for distances t  m 1. To do so we calculate
each possible bit string c = (x P1 , . . . , xm ) ap- X
pears. After normalizing so that c h(m) (c) = 1, xi = xi h(m) (c) (8)
H2 (X1 , . . . , Xm ) is estimated as c=(x1 ,...,xm )
X X1m Xt h i
H2 (X1 , . . . , Xm ) ⇡ log2 h(m) (c)2 . (4) C(t) ⇡ (xi xi+t xi xi+t )h(m) (c) .
c c
t i=1

To obtain s we thus record histograms h(m) for Statistical errors on C(t) are calculated in the stan-
bit strings of the longest length m to be consid- dard way, or preferably by a jackknife or bootstrap
ered. In our tests we used bit strings of length method to obtain the smallest possible reliable er-
up to m = 16, but found that for the current rors.
Quantis device m = 8 seems sufficient. Longer
m requires exponentially more memory and sam-
pling time. From that histogram, the histograms A Appendix
for shorter bit strings can be obtained by partial
sums: A.1 Statistical distance
1
X
h(m 1)
((x1 , . . . , xm h(m) ((x1 , . . . , xm )). Definition 1. The statistical distance between two
1 )) =
xm =0 probability distributions PX and PX 0 with the same
(5) alphabet is defined as
One can then calculate and plot sm as a function
1
of m, check for convergence and obtain the limiting (PX , PX 0 ) := kPX PX 0 k1 .
value s . We have observed very fast convergence, 2
and for practical purposes it is sufficient to estimate .
s by sm for the largest m considered.
To obtain error estimates this procedure should Proof. A proof of this statement is given in [RK05]
be repeated several times and the mean value s and (see Lemma 1).
3 We use here the collision entropy to simplify the pre-

sentation. To derive rigorous statements, it is advantageous


The statistical distance has an operational inter-
to use the smooth collision entropy, as briefly explained in pretation in terms of probabilities, as asserted by
Appendix A.5. the following lemma.

3
Lemma 1. Let PX and PX 0 be two probability dis- where B µ (PX ) is the set of all distributions PX 0
tributions with distance " = (PX , PX 0 ). Then which have at most distance4 µ from PX .
there exists a joint distribution PXX 0 such that
The two entropy measures defined above are es-
Pr[X 6= X 0 ]  " . sentially equivalent. This means that any estimate
for the (smooth) min-entropy is a good estimate for
In other words, if two probability distributions the collision entropy, and vice versa.
X and X 0 are "-close, we may think of a common
random experiment where the values X and X 0 co- Lemma 3. For any µ 0 and µ0 > 0,
incide except with probability ". one of the practi- 0 1
µ
cally relevant implications of this is formalized by Hmin (X)  H2µ (X)  Hmin
µ+µ
(X) + log2 .
µ0
the following simple lemma. It shows that if an ap-
plication (e.g., a simulation algorithm or a crypto- Proof. The first inequality follows from the general
graphic scheme) is proved to work well with perfect inequality kPX k1 kPX k22 (which holds for nor-
random bits X, then it can also be used safely with malized PX ), and the second is a special case of
bits X 0 whose distribution is not exactly uniform. Lemma I.3 of [RW04].
Lemma 2. Let ⇧ be a stochastic process that takes
as input a random value X and may fail with a A.3 XOR of independent sources
probability pfail (P r(⇧(X)). If the input X is re-
The following lemma asserts that good randomness
placed by X 0 then the failure probability can in-
can be obtained by combining bits generated by
crease by at most " := (PX , PX 0 ), i.e.,
a number of mutually independent weak random
0
pfail (⇧(X ))  pfail (⇧(X)) + " . sources. While this method is costly and slow, it
may be used for generating the initial random seed
Proof. We may describe the stochastic process as a (i.e., the matrix m in the construction described in
function f which takes as input X as well as some Sections 1.1; see also Section 1.3), which only needs
additional randomness R, and outputs either “fail” to be determined once.
or “success”. Obviously, the outputs f (X, R) and
Lemma 4. Let X1 , . . . Xr be r independent random
f (X 0 , R) can only deviate if X 6= X 0 . Since, accord-
bits such that, for some b > 0,
ing to Lemma 1, the probability that this happens
is bounded by ", the assertion follows. (X , U )  b 8i .
i
P
A.2 Definitions of entropies and ba- Then the bit X = i Xi mod 2 satisfies
sic properties 1
(X, U )  (2b)r .
Definition 2. The min-entropy Hmin and the col- 2
lision entropy H2 of a random variable X with dis-
Proof. A simple calculation shows that, for two in-
tribution PX are defined by
dependent bits X1 and X2 with bi = (Xi , U ), and
Hmin (X) = log2 kPX k1 with X = X1 + X2 mod 2,

H2 (X) = log2 kPX k22 . (X, U ) = 2b1 b2 .

Definition 3. For any µ 0, the smooth min- The claim then follows by recursive application of
µ
entropy Hmin and the smooth collision entropy H2µ this rule.
of a random variable X are defined by 4 The recent literature on smooth entropies uses the puri-

µ fied distance instead of the statistical distance. The purified


Hmin (X) = max Hmin (X 0 ) distance is a more natural choice in the context of quantum
PX 0 2Bµ (PX )
information. However, since the results reported here are
H2µ (X) = max H2 (X 0 ) . purely classical, it is more convenient and technically easier
PX 0 2Bµ (PX ) to use the statistical distance.

4
A.4 Randomness extraction by two- Remark 1. The distance on the left hand side of
universal hashing Theorem 1 can be rewritten as
⌦ ↵
Definition 4. A family {fs }s2S of functions with PfS (X)S , PU ⇥ PS = (Pfs (X) , PU ) s
codomain U is called two-universal if for any dis-
tinct inputs x 6= x0 where h·is denotes the expectation value over s cho-
sen uniformly at random from the set S.
⌦ ↵ 1
fs (x),fs (x0 ) s  ,
|U| Since these results are expressed using the sta-
tistical distance, it is easy to interpret them opera-
where h·is denotes the expectation value over s cho- tionally, according to the discussion of Section A.1.
sen uniformly at random from the set S In particular, together with Lemma 1, the above
remark implies that (on average over the choices of
In other words, for any fixed pair of distinct in-
s) there exists a uniformly distributed random vari-
puts, the collision probability for a function chosen
able U such that the function output fs (X) is iden-
at random from a two-universal family is low. An
tical to U except with probability ". In other words,
explicit construction of a family of functions with
" is the maximum probability by which fs (X) de-
this property is given in Section 1.1, and further
viates from a uniformly chosen value.
constructions can be found in [CW79] and [WC81].

Theorem 1. For any random variable X with al- A.5 Technical statement of result
phabet X , for any two-universal family {fs }s2S of and assumptions
functions from X to {0, 1}k , and for S distributed
uniformly (over S) and independently of X, Combining the facts outlined above, we obtain the
following statement. Consider the extractor spec-
1
PfS (X)S , PU ⇥ PS  " := 2 2 (H2 (X) k) , ified in Section 1.1, which takes as input an n-bit
string and outputs a k-bit string, and assume that
where PU denotes the uniform distribution over U . the following conditions are satisfied for appropri-
ately chosen parameters "seed , "stat , "hash 0:
Proof. First versions of this theorem have been
proved in [BBR88], [ILL89], and [BBCM95]. The • The matrix m used by the constructor is cho-
version stated here (in terms of statistical distance sen using a sequence of random bits whose
and collision entropy) can be obtained as the clas- joint distribution has distance at most "seed
sical special case of Theorem 5.5.1 of [Ren05]. from a perfectly uniform distribution. We re-
fer to Section 1.3 for a discussion of how this
Corollary 1. Theorem 1 remains valid if " is re-
can be achieved using a sufficiently large num-
placed by
ber of mutually independent random number
1
" := min 2 2 2 (H µ
(X) k)
+µ . generators.
µ
• The smooth collision entropy of the input bits,
Proof. For any µ, let X 0 be a random variable with H2"stat (X1 · · · Xn ), is lower bounded by sn,
(PX , PX 0 )  µ such that H2 (X 0 ) = H2µ (X). Then, with
by Theorem 1,
1
1 0 s := k + 2 log2 (1/"hash ) .
PfS (X 0 )S , PU ⇥ PS  2 2 (H2 (X ) k) n
1 µ
=2 2 (H2 (X) k)
. This is the case whenever

The assertion then follows from min sm s (9)


m

(PfS (X)S , PfS (X 0 )S )  (PX , PX 0 )  µ holds for

and the triangle inequality. sm := H2"stat (X1 , . . . Xm+1 ) H2"stat (X1 , . . . , Xm ) .

5
Condition (9) can be established using statis- [RW04] R. Renner and S. Wolf. Smooth Rényi
tical methods (cf. Section 2.2), with a reliabil- entropy and applications. In Proc. In-
ity bound of "stat for the statistical estimate. ternational Symposium on Information
(Note that an error probability of µ in the esti- Theory, page 233. IEEE, 2004.
mate for the collision entropy H2 corresponds
to estimating the smooth collision entropy H2µ . [Tre01] L. Trevisan. Extractors and pseudoran-
This explains why we use this entropy measure dom generators. Journal of the ACM,
here.) 48:860–879, 2001.

Under these conditions, the probability that the [WC81] M. N. Wegman and J. L. Carter. New
output string deviates from a perfectly uniform k- hash functions and their use in au-
bit string is upper bounded by " = "seed + "stat + thentication and set equality. Jour-
"hash . nal of Computer and System Sciences,
22:265–279, 1981.

References
[BBCM95] C. H. Bennett, G. Brassard,
C. Crépeau, and U. Maurer. Gener-
alized privacy amplification. IEEE
Transaction on Information Theory,
41(6):1915–1923, 1995.
[BBR88] C. H. Bennett, G. Brassard, and J.-M.
Robert. Privacy amplification by public
discussion. SIAM Journal on Comput-
ing, 17(2):210–229, 1988.
[CW79] J. L. Carter and M. N. Wegman. Uni-
versal classes of hash functions. Jour-
nal of Computer and System Sciences,
18:143–154, 1979.
[ILL89] R. Impagliazzo, L. A. Levin, and
M. Luby. Pseudo-random generation
from one-way functions (extended ab-
stract). In Proceedings of the Twenty-
First Annual ACM Symposium on The-
ory of Computing, pages 12–24, 1989.
[Ren05] R. Renner. Security of Quan-
tum Key Distribution. PhD thesis,
Swiss Federal Institute of Technology
(ETH) Zurich, 2005. Available at
arXiv:quant-ph/0512258.
[RK05] R. Renner and R. König. Univer-
sally composable privacy amplification
against quantum adversaries. In Sec-
ond Theory of Cryptography Confer-
ence TCC, volume 3378 of Lecture
Notes in Computer Science, pages 407–
425. Springer, 2005.

You might also like