]> AND Private Git Repository - 14Secrypt.git/blob - crCOUCHOT14/main.tex
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
ajout de cr
[14Secrypt.git] / crCOUCHOT14 / main.tex
1 \documentclass[a4paper,twoside]{article}
2
3 \usepackage[utf8]{inputenc}
4 \usepackage[T1]{fontenc} 
5 \usepackage[english]{babel}
6 %\usepackage{ntheorem}
7 \usepackage{alltt}
8 \usepackage{amsmath,amssymb,amsthm,amstext,latexsym,eufrak,euscript}
9 \usepackage{subfigure,pstricks,pst-node,pst-coil}
10 \usepackage{dsfont}
11 \usepackage{stmaryrd}
12 \usepackage{cite}
13 \usepackage{graphicx}
14 \usepackage{algorithm2e}
15 \usepackage[font=footnotesize]{subfig}
16 \usepackage{listings}
17 \usepackage{booktabs}
18 \usepackage{epsfig}
19 \usepackage{url}
20 \usepackage{calc}
21 \usepackage{multicol}
22 \usepackage{pslatex}
23 \usepackage{apalike}
24 \usepackage{SCITEPRESS}
25 \usepackage{caption}
26
27
28
29 \subfigtopskip=0pt
30 \subfigcapskip=0pt
31 \subfigbottomskip=0pt
32
33
34
35
36
37
38
39 \newcommand{\JFC}[1]{\begin{color}{green}\textit{}\end{color}}
40 \newcommand{\CG}[1]{\begin{color}{blue}\textit{}\end{color}}
41 \newcommand{\tv}[1] {\lVert #1 \rVert_{\rm TV}}
42
43
44 \newtheorem*{xpl}{Running example}
45 \newtheorem{theorem}{Theorem}
46  
47
48
49
50 \newcommand{\vectornorm}[1]{\ensuremath{\left|\left|#1\right|\right|_2}}
51 \newcommand{\ie}{\textit{i.e.}}
52 \newcommand{\Nats}[0]{\ensuremath{\mathbb{N}}}
53 \newcommand{\Reels}[0]{\ensuremath{\mathbb{R}}}
54 \newcommand{\Bool}[0]{\ensuremath{\mathds{B}}}
55 \newcommand{\rel}[0]{\ensuremath{{\mathcal{R}}}}
56 \newcommand{\Gall}[0]{\ensuremath{\mathcal{G}}}
57
58 \begin{document}
59
60 \title{Pseudorandom Number Generators with Balanced Gray Codes}
61
62
63 \author{\authorname{J.-F. Couchot\sup{1}, P.-C. Heam\sup{1}, C. Guyeux\sup{1}, Q. Wang\sup{2},  and J. M. Bahi\sup{1}}
64 \affiliation{\sup{1}FEMTO-ST Institute, University of Franche-Comt\'{e}, France}
65 \affiliation{\sup{2}College of Automation, Guangdong University of Technology, China }
66 \email{\{jean-francois.couchot,pierre-cyrille.heam,christophe.guyeux,jacques.bahi\}@univ-fcomte.fr, wangqianxue@gdut.edu.cn}
67 }
68
69 \keywords{Pseudorandom Number Generator, Theory of Chaos, Markov Matrices, Hamiltonian Paths, Mixing Time, Gray Codes, Statistical Tests}
70
71 \abstract{In this article,
72 it is shown that a large class of truly chaotic Pseudorandom Number Generators
73 can be constructed. The generators are based on iterating Boolean maps, which are computed 
74 using balanced Gray codes. The number of such Gray codes gives the size of the class.
75 The construction of such generators is automatic for small number of bits, but remains an open problem when this 
76 number becomes large. A running example is used throughout the paper. Finally, first statistical experiments of these generators are presented, they show how efficient and promising the proposed
77 approach seems.}
78
79
80 \onecolumn \maketitle \normalsize \vfill
81
82
83
84
85
86
87 \vspace{-8em}
88 \section{\uppercase{Introduction}}
89 \vspace{-1em}
90 Many fields of research or applications like numerical simulations, 
91 stochastic optimization, or information security are highly dependent on
92 the use of fast and unbiased random number generators. Depending on the
93 targeted application, reproducibility must be either required, leading
94 to deterministic algorithms that produce numbers as close as possible
95 to random sequences, or refused, which implies to use an external
96 physical noise. The formers are called pseudorandom number generators
97 (PRNGs) while the laters are designed by truly random number generators (TRNGs).
98 TRNGs are used for instance in cypher keys generation, or in hardware based
99 simulations or security devices. Such TRNGs are often based on a chaotic
100 physical signal, may be quantized depending on the application.
101 This quantization however raises the problem of the degradation of chaotic 
102 properties.
103
104 The use of PRNGs, for its part, is a necessity in a large variety 
105 of numerical simulations, in which
106 responses of devices under study must be compared using the same ``random''
107 stream. This reproducibility is required too for symmetric encryption like
108 one-time pad, as sender and receiver must share the same pad. However, in
109 that situation, security of the pseudorandom stream must be mathematically
110 proven: an attacker must not be able to computationally distinguish a
111 pseudorandom sequence generated by the considered PRNG with a really random
112 one. Such cryptographically secure pseudorandom number generators are
113 however only useful in cryptographic contexts, due to their slowness
114 resulting from their security. 
115
116
117 Other kind of properties are desired for PRNGs used in numerical simulations
118 or in programs that embed a Monte-Carlo algorithm. In these situations,
119 required properties are speed and random-like profiles of the generated 
120 sequences. The fact that a given PRNG is unbiased and behaves as a white
121 noise is thus verified using batteries of statistical tests on a large amount
122 of pseudorandom numbers. Reputed and up-to-date batteries are
123 currently the NIST suite~\cite{Nist10}, and DieHARD~\cite{Marsaglia1996}.
124 %and TestU01~\cite{Simard07testu01:a}, this latter being the
125 %most stringent one. 
126 Finally, chaotic properties can be desired when
127 simulating a chaotic physical phenomenon or in hardware security, in 
128 which cryptographical proofs are not realizable.
129 In both truly and pseudorandom number generation, there is thus a need
130 to mathematically guarantee the presence of chaos, and to show that 
131 a post-treatment on a given secure and/or unbiased generator can be realized,
132 which adds chaos without deflating these desired properties.
133
134
135 This work takes place in this domain with the desire of automatically 
136 generating a large class of PRNGs with chaos and statistical properties.
137 In a sense, it is close to~\cite{BCGR11} where the authors shown that 
138 some Boolean maps may be embedded into an algorithm to provide a PRNG that has both
139 the theoretical Devaney's chaos property and the practical 
140 property of succeeding NIST statistical battery of tests.  
141 To achieve this, it has been proven in 
142 this article that it is sufficient   
143 for the iteration graph to be strongly connected,
144 and it is necessary and sufficient for its Markov probability matrix to be doubly stochastic.
145 However, they do not purpose conditions 
146 to provide such Boolean maps.
147 Admittedly, sufficient conditions
148 to retrieve Boolean maps whose graphs are 
149 strongly connected are given, but it remains to further filter those whose 
150 Markov matrix is doubly stochastic.
151 This approach suffers from delaying the second requirement to a final step
152 whereas this is a necessary condition. 
153 In this position article, we provide a completely new approach
154 to generate Boolean functions, whose Markov matrix is doubly stochastic and whose
155 graph of iterations is strongly connected. 
156 Furthermore the rate of convergence is always taken into consideration to provide 
157 PRNG with good statistical properties.
158
159
160 This research work is organized as follows.
161 It firstly recall some preliminaries that make the document self-contained (Section~\ref{sec:preliminaries}),
162 The next section (Section~\ref{sec:DSSC}) shows how this problem can be theoretically solved with a classical constraint logic programming.
163 Section~\ref{sec:hamiltonian} is the strongest contribution of this work.
164 It presents the main algorithm to generate Boolean maps with all the required properties and 
165 proves that such a construction is correct. 
166 Statistical evaluations are then presented in Section~\ref{sec:exp}. 
167 Conclusive remarks, open problems, and perspectives are 
168 finally provided.
169
170
171 \vspace{-2em}
172 \section{\uppercase{Preliminaries}}\label{sec:preliminaries}
173 \vspace{-1em}
174 In what follows, we consider the Boolean algebra on the set 
175 $\Bool=\{0,1\}$ with the classical operators of conjunction '.', 
176 of disjunction '+', of negation '$\overline{~}$', and of 
177 disjunctive union $\oplus$. 
178
179 Let $n$ be a positive integer. A  {\emph{Boolean map} $f$ is 
180 a function from the Boolean domain 
181  to itself 
182 such that 
183 $x=(x_1,\dots,x_n)$ maps to $f(x)=(f_1(x),\dots,f_n(x))$.
184 Functions are iterated as follows. 
185 At the $t^{th}$ iteration, only the $s_{t}-$th component is
186 ``iterated'', where $s = \left(s_t\right)_{t \in \mathds{N}}$ is a sequence of indices taken in $\llbracket 1;n \rrbracket$ called ``strategy''. Formally,
187 let $F_f: \llbracket1;n\rrbracket\times \Bool^{n}$ to $\Bool^n$ be defined by
188 \[
189 F_f(i,x)=(x_1,\dots,x_{i-1},f_i(x),x_{i+1},\dots,x_n).
190 \]
191 Then, let $x^0\in\Bool^n$ be an initial configuration
192 and $s\in
193 \llbracket1;n\rrbracket^\Nats$ be a strategy, 
194 the dynamics are described by the recurrence
195 \begin{equation}\label{eq:asyn}
196 x^{t+1}=F_f(s_t,x^t).
197 \end{equation}
198
199
200 Let be given a Boolean map $f$. Its associated   
201 {\emph{iteration graph}}  $\Gamma(f)$ is the
202 directed graph such that  the set of vertices is
203 $\Bool^n$, and for all $x\in\Bool^n$ and $i\in \llbracket1;n\rrbracket$,
204 the graph $\Gamma(f)$ contains an arc from $x$ to $F_f(i,x)$. 
205
206 \begin{xpl}
207 Let us consider for instance $n=3$. Let 
208 $f^*: \Bool^3 \rightarrow \Bool^3$ be defined by
209 $f^*(x_1,x_2,x_3)=(x_2 \oplus x_3, x_1 \oplus \overline{x_3},\overline{x_3})$.
210 The iteration graph $\Gamma(f^*)$ of this function is given in 
211 Figure~\ref{fig:iteration:f*}.
212
213 \vspace{-1em}
214 \begin{figure}[ht]
215 \begin{center}
216 \includegraphics[scale=0.5]{iter_f0b.eps}
217 \end{center}
218 \vspace{-0.5em}
219 \caption{Iteration Graph $\Gamma(f^*)$ of the function $f^*$}\label{fig:iteration:f*}
220 \end{figure}
221 \end{xpl}
222
223 \vspace{-0.5em}
224 It is easy to associate a Markov Matrix $M$ to such a graph $G(f)$
225 as follows:
226
227 $M_{ij} = \frac{1}{n}$ if there is an edge from $i$ to $j$ in $\Gamma(f)$ and $i \neq j$;  $M_{ii} = 1 - \sum\limits_{j=1, j\neq i}^n M_{ij}$; and $M_{ij} = 0$ otherwise.
228
229 \begin{xpl}
230 The Markov matrix associated to the function $f^*$ is 
231 $$
232 \dfrac{1}{3}
233 \left(
234 \begin{array}{llllllll}
235 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 \\ 
236 1 & 1 & 0 & 0 & 0 & 1 & 0 & 0 \\ 
237 0 & 0 & 1 & 1 & 0 & 0 & 1 & 0 \\ 
238 0 & 1 & 1 & 1 & 0 & 0 & 0 & 0 \\ 
239 1 & 0 & 0 & 0 & 1 & 1 & 0 & 0 \\ 
240 0 & 0 & 0 & 0 & 1 & 1 & 0 & 1 \\ 
241 0 & 0 & 0 & 0 & 1 & 0 & 1 & 1 \\ 
242 0 & 0 & 0 & 1 & 0 & 0 & 1 & 1 
243 \end{array}
244 \right)
245 $$
246  
247
248 \end{xpl}
249
250
251 It is usual to check whether rows of such kind of matrices
252 converge to a specific 
253 distribution. 
254 Let us first recall the  \emph{Total Variation} distance $\tv{\pi-\mu}$,
255 which is defined for two distributions $\pi$ and $\mu$ on the same set 
256 $\Omega$  by:
257 $$\tv{\pi-\mu}=\max_{A\subset \Omega} |\pi(A)-\mu(A)|.$$ 
258 % It is known that
259 % $$\tv{\pi-\mu}=\frac{1}{2}\sum_{x\in\Omega}|\pi(x)-\mu(x)|.$$
260
261 Let then $M(x,\cdot)$ be the
262 distribution induced by the $x$-th row of $M$. If the Markov chain
263 induced by
264 $M$ has a stationary distribution $\pi$, then we define
265 $$d(t)=\max_{x\in\Omega}\tv{M^t(x,\cdot)-\pi}.$$
266 Intuitively $d(t)$ is the largest deviation between
267 the distribution $\pi$ and $M^t(x,\cdot)$, which 
268 is the result of iterating $t$ times the function.
269 Finally, let $\varepsilon$ be a positive number, the \emph{mixing time} 
270 with respect to $\varepsilon$ is given by
271 $$t_{\rm mix}(\varepsilon)=\min\{t \mid d(t)\leq \varepsilon\}.$$
272 It defines the smallest iteration number 
273 that is sufficient to obtain a deviation lesser than $\varepsilon$.
274 % Notice that the upper and lower bounds of mixing times cannot    
275 % directly be computed with eigenvalues formulae as expressed 
276 % in~\cite[Chap. 12]{LevinPeresWilmer2006}. The authors of this latter work  
277 % only consider reversible Markov matrices whereas we do no restrict our 
278 % matrices to such a form.
279
280
281
282 Let us finally present the pseudorandom number generator $\chi_{\textit{14Secrypt}}$
283 which is based on random walks in $\Gamma(f)$. 
284 More precisely, let be given a Boolean map $f:\Bool^n \rightarrow \Bool^n$,
285 a PRNG \textit{Random},
286 an integer $b$ that corresponds to an awaited mixing time, and 
287 an initial configuration $x^0$. 
288 Starting from $x^0$, the algorithm repeats $b$ times 
289 a random choice of which edge to follow and traverses this edge.
290 The final configuration is thus outputted.
291 This PRNG is formalized in Algorithm~\ref{CI Algorithm}.
292
293
294
295 \vspace{-1em}
296 \begin{algorithm}[ht]
297 %\begin{scriptsize}
298 \KwIn{a function $f$, an iteration number $b$, an initial configuration $x^0$ ($n$ bits)}
299 \KwOut{a configuration $x$ ($n$ bits)}
300 $x\leftarrow x^0$\;
301 \For{$i=0,\dots,b-1$}
302 {
303 $s\leftarrow{\textit{Random}(n)}$\;
304 $x\leftarrow{F_f(s,x)}$\;
305 }
306 return $x$\;
307 %\end{scriptsize}
308 \caption{Pseudo Code of the $\chi_{\textit{14Secrypt}}$ PRNG}
309 \label{CI Algorithm}
310 \end{algorithm}
311 \vspace{-0.5em}
312 This PRNG is a particularized version of Algorithm given in~\cite{BCGR11}.
313 Compared to this latter, the length of the random 
314 walk of our algorithm is always constant (and is equal to $b$) whereas it 
315 was given by a second PRNG in this latter.
316 However, all the theoretical results that are given in~\cite{BCGR11} remain
317 true since the proofs do not rely on this fact. 
318
319 Let $f: \Bool^{n} \rightarrow \Bool^{n}$.
320 It has been shown~\cite[Th. 4, p. 135]{BCGR11}} that 
321 if its iteration graph is strongly connected, then 
322 the output of $\chi_{\textit{14Secrypt}}$ follows 
323 a law that tends to the uniform distribution 
324 if and only if its Markov matrix is a doubly stochastic matrix.
325   
326 Let us now present  a method to
327 generate  functions
328 with Doubly Stochastic matrix and Strongly Connected iteration graph,
329  denoted as DSSC matrix.   
330
331
332
333 \vspace{-2em}
334 \section{\uppercase{Generation of DSSC Matrices}}\label{sec:DSSC}
335 \vspace{-1em}
336 This aim of this section is to show 
337 that finding DSSC matrices from a hypercube
338 is a typical finite domain satisfaction 
339 problem, classically denoted as 
340 Constraint Logic Programming on Finite Domains (CLPFD). 
341 This part is addressed in the first section. Next, we analyse the first
342 results to provide a generation of DSSC matrices with small mixing times. 
343
344 \vspace{-1em}
345 \subsection{Constraint Logic Programming on Finite Domains}
346 \vspace{-1em}
347 First of all,  
348 let $n$ be the number of elements. In order to avoid fractions 
349 in this article, we consider here that the 
350 sum of each column and each row is $n$. It  can easily be normalized to 1.  
351 The goal is thus to find all the $2^n\times 2^n$ matrices $M$ 
352 such that: 
353   
354 \begin{enumerate}
355 \item $M_{ij}$ is 0 if $j$ is not a neighbor of $i$, \textit{i.e.},
356   there is no edge from $i$ to $j$ in the $n$-cube.
357 \item $0 \le M_{ii} \le n$: the number of loops around $i$ is lesser than $n$  
358 \item Otherwise $0 \le M_{ij} \le 1$: if the edge from $i$ to $j$ is kept, 
359 $M_{ij}$ is 1, and 0 otherwise.
360 \item For any index of line $i$, $1 \le i\le 2^n$, $n = \sum_{1 \le j\le 2^n} M_{ij}$: 
361   the matrix is right stochastic.
362 \item For any index of column $j$, 
363   $1 \le j\le 2^n$, $n = \sum_{1 \le i\le 2^n} M_{ij}$: 
364   the matrix is left stochastic. 
365 \item All the values of $\sum_{1\le k\le 2^n}M^k$ are strictly positive, \textit{i.e.}, the induced graph is strongly connected.
366 \end{enumerate}
367
368
369 Since these variables range into finite integer domains with sum and 
370 product operations, this problem can be theoretically handled by  
371 Constraint Logic Programming on Finite Domains (CLPFD), as implemented
372 in prolog.
373
374 Finally, we define the relation $\mathcal{R}$, which is established on the 
375 two functions
376 $f$ and $g$ if the iteration graphs $\Gamma(f)$ and $\Gamma(g)$ 
377 are isomorphic. 
378 Obviously, this is an equivalence relation. 
379
380
381 \vspace{-1em}
382 \subsection{Analysis of the  Approach}
383 \vspace{-1em}
384
385 When executed on a personal computer, the prolog algorithm finds 
386 in less than 1 second the 49 solutions when $n$ is 2, where only 2 are not equivalent, and in less than 1 minute the 27642 solutions where only 111 are
387 not equivalent when $n$ is 3. But it does not achieve the generation of 
388 all the solutions when $n$ is 4.
389 This approach suffers from not being efficient enough for large $n$ due to 
390 a \emph{generate and test} approach, despite the efficiency of the native 
391 backtrack of in CLP.
392
393 However, first results for small values of $n$ have been evaluated.  
394 More precisely, non equivalent generated
395 functions have been compared according to their 
396 ability to efficiently produce uniformly distributed outputs, \textit{i.e.},
397 to have the smallest mixing time.
398
399 \begin{xpl}
400 Table~\ref{table:mixing:3} gives the 5 best Boolean functions
401 ordered by their mixing times (MT) in the third column for $\varepsilon=10^{-5}$. 
402 \begin{table}[ht]
403 \begin{small}
404 $$
405 \begin{array}{|l|l|l|}
406 \hline
407 \textrm{Name} & \textrm{Image} & \textrm{MT}\\
408 \hline
409 f^* &  (x_2 \oplus x_3, x_1 \oplus \overline{x_3},\overline{x_3})  &  16   \\
410 \hline
411 f^a  &  (x_2 \oplus x_3, \overline{x_1}\overline{x_3} + x_1\overline{x_2},
412 \overline{x_1}\overline{x_3} + x_1x_2)  &  17   \\
413 \hline
414 f^b  &  (\overline{x_1}(x_2+x_3) + x_2x_3,\overline{x_1}(\overline{x_2}+\overline{x_3}) + \overline{x_2}\overline{x_3}, &  \\
415 & \qquad \overline{x_3}(\overline{x_1}+x_2) + \overline{x_1}x_2)  &  26   \\
416 \hline
417 f^c  &  (\overline{x_1}(x_2+x_3) + x_2x_3,\overline{x_1}(\overline{x_2}+\overline{x_3}) + \overline{x_2}\overline{x_3}, & \\
418 & \overline{x_3}(\overline{x_1}+x_2) + \overline{x_1}x_2)  &  29   \\
419 \hline
420 f^d  &  (x_1\oplus x_2,x_3(\overline{x_1}+\overline{x_2}),\overline{x_3})  &  30   \\
421 \hline
422 % [3, 4, 7, 0, 1, 6, 5, 2], #16
423 % [3, 4, 7, 0, 2, 6, 5, 1], #17
424 % [3, 6, 7, 5, 2, 0, 1, 4], #26 
425 % [3, 4, 7, 5, 2, 6, 1, 0], #29
426 % [3, 2, 5, 6, 7, 0, 1, 4]] #30
427 \end{array}
428 $$
429 \end{small}
430 \caption{The 5 Boolean functions with smallest MT when $n=3$.}\label{table:mixing:3}
431 \end{table}
432 \end{xpl}
433
434 A syntactical analysis of the functions for $n$=3 
435 does not help to understand
436 how to build a Boolean map with a small mixing time. 
437 However the iteration graph of $f^*$ 
438 (given in Figure~\ref{fig:iteration:f*}) 
439 is the $3$-cube in which the cycle 
440 $000,100,101,001,011,111,110,010,000$ 
441 has been removed.
442 This cycle that visits each vertex exactly once is usually denotes as 
443 \emph{Hamiltonian cycle}.
444 We are now focusing on the generation of DSSC matrices by  
445 removing Hamiltonian cycles of the $n$-cube. 
446
447
448 \vspace{-2em}
449 \section{\uppercase{Removing Hamiltonian Cycles}}\label{sec:hamiltonian}
450 \vspace{-1em}
451 The first theoretical section shows that this approach produces DSSC matrix, as wished.
452 The motivation to focus on balanced Gray code is then given in Sec.~\ref{sub:gray}.
453 We end this section by recalling an algorithm that aims at computing such codes (Section~\ref{sub:algo:gray}).
454
455 \vspace{-1em}
456 \subsection{Theoretical Aspects of Removing Hamiltonian Cycles}
457 \vspace{-1em}
458
459 We first have the following result on stochastic matrix and $n$-cube without
460 Hamiltonian cycle.
461
462 \begin{theorem}
463 The Markov Matrix $M$ resulting from the $n$-cube in
464 which an Hamiltonian 
465 cycle is removed, is doubly stochastic.
466 \end{theorem}
467 \begin{proof}
468 An Hamiltonian cycle visits each vertex exactly once. 
469 For each vertex $v$ in the $n$-cube,
470 one ongoing edge $(o,v)$ and one outgoing edge $(v,e)$ 
471 are thus removed.
472
473 Let us consider the Markov matrix $M$ of the $n$-cube. 
474 It is obviously doubly stochastic.
475 Since we exactly remove one outgoing edge, the value of $M_{ve}$ decreases
476 from $\frac{1}{n}$  to 0 and
477 $M_{vv}$ is $\frac{1}{n}$. The $M$ matrix is stochastic again.
478 Similarly for ongoing edge, since one ongoing edge is dropped for each 
479 vertex, the value of $M_{ov}$ decreases
480 from $\frac{1}{n}$  to $0$. Moreover, since $M_{vv}$ is $\frac{1}{n}$,
481 the sum of values in column $v$ is $1$, and $M$ is doubly stochastic. 
482 \end{proof}
483
484 The following result states that the $n$-cube without one
485 Hamiltonian cycle 
486 has the awaited property with regard to the connectivity.
487
488 \begin{theorem}
489 The iteration graph issued from the $n$-cube where an Hamiltonian 
490 cycle is removed is strongly connected.
491 \end{theorem}
492 \begin{proof}
493 We consider the reverse cycle $r$ of the Hamiltonian cycle $c$.
494 There is no edge that belongs to both $r$ and $c$: otherwise $c$
495 would contain one vertex twice. Thus, no edges of $r$ has been removed.
496 The cycle $r$ is obviously an Hamiltonian cycle and contains all the nodes.
497 Any node of the $n$-cube where $c$ has been removed  can thus reach any node.  
498 The  iteration graph is thus strongly connected.  
499 \end{proof}
500
501 Removing an Hamiltonian cycle in the $n$-cube solves thus the DSSC constraint.
502 We are then left to focus on the generation of Hamiltonian cycles in the 
503 $n$-cube. Such a problem is equivalent to find Gray codes, \textit{i.e.},
504 to find a sequence of $2^n$ codewords ($n$-bits strings) 
505 where two successive elements differ in only one bit position. 
506 The next section is dedicated to these codes.
507
508 \vspace{-1em}
509 \subsection{Linking to (Totally) Balanced Gray Codes}\label{sub:gray}
510 \vspace{-1em}
511 Many research works~\cite{journals/combinatorics/BhatS96,VanSup04,journals/combinatorics/FlahiveB07} 
512 have addressed the subject of finding Gray  codes.
513 Since our approach is based on removing a cycle, we are concerned 
514 with cyclic Gray codes, \textit{i.e.}, sequences where the last codeword   
515 differs in only one bit position from the first one.
516
517 Let $n$ be a given integer. As far as we know, 
518 the exact number of Gray codes in $\Bool^n$ is not known but 
519 a lower bound, $$\left(\frac{n*\log2}{e \log \log n}*(1 - o(1))\right)^{2^n}$$
520 has been given in~\cite{Feder:2009:NTB:1496397.1496515}.
521 For example, when $n$ is $6$, such a number is larger than $10^{13}$.
522
523 To avoid this combinatorial explosion, we want to
524 restrict the generation to any Gray code 
525 such that the induced graph of iteration $\Gamma(f)$ is 
526 ``uniform''. In other words, if we count in $\Gamma(f)$ 
527 the number of edges that modify the bit $i$, for $1 \le i \le n$,
528 all these values have to be close to each other.
529 Such an approach is equivalent to restrict the search of cyclic Gray codes
530 which are uniform too.
531
532 This notion can be formalized as follows. Let  $L = w_1, w_2, \dots, w_{2^n}$ be the sequence 
533 of a $n$-bits cyclic Gray code. Let $S = s_1, s_2, \dots, s_{2^n}$ be the 
534 transition sequence where $s_i$, $1 \le i \le 2^n$ indicates which bit position changes between 
535 codewords at index $i$ and $i+1$ modulo $2^n$. 
536 Let $\textit{TC}_n : \{1,\dots, n\} \rightarrow \{0, \ldots, 2^n\}$ the \emph{transition count} function
537 that counts the number of times $i$ occurs in $S$, \textit{i.e.}, the number of times 
538 the bit $i$ has been switched in $L$.   
539 The Gray code is \emph{totally balanced} if $\textit{TC}_n$ is constant (and equal to $\frac{2^n}{n}$).
540 It is \emph{balanced} if for any two bit indices $i$ and $j$, 
541 $|\textit{TC}_n(i) - \textit{TC}_n(j)| \le  2$.
542    
543 \begin{xpl}
544 Let $L^*$ be the Gray code $000,100,101,001,011,111,110,010$ 
545 that corresponds to the Hamiltonian cycle that has been removed in $\Gamma(f^*)$. 
546 It is balanced since its transition sequence is $S=3,1,3,2,3,1,3,2$ 
547 and its transition count function is 
548 $\textit{TC}_3(1)= \textit{TC}_3(2)=2$ and  $\textit{TC}_3(3)=4$.
549
550 Let $L^4$ be the cyclic Gray code  
551 $0000, 0010, 0110, 1110, 1111, 0111, 0011, 0001, 0101,$
552 $0100, 1100, 1101, 1001, 1011, 1010, 1000$.
553  Since $S=2,3,4,1,4,3,2,3,1,4,1,3,2,1,2,4$ $\textit{TC}_4$ is equal to 4 everywhere, this code
554 is thus totally balanced.
555 \end{xpl}
556
557 \vspace{-1em}
558 \subsection{Induction-Based Generation of  Balanced Gray Codes}\label{sub:algo:gray} 
559 \vspace{-1em}
560
561 The algorithm we adapt is based on the ``Construction B''~\cite{VanSup04} we recall now.
562 This method inductively constructs $n$-bits Gray code given a $n-2$-bit Gray code.
563
564 It starts with the transition sequence $S_{n-2}$ of such code.
565
566 \begin{enumerate}
567 \item \label{item:nondet}Let $l$ be an even positive integer. Find 
568 $u_1, u_2, \dots , u_{l-2}, v$ (maybe empty) subsequences of $S_{n-2}$ 
569 such that $S_{n-2}$ is the concatenation of 
570 $$
571 s_{i_1}, u_0, s_{i_2}, u_1, s_{i_3}, u_2, . . . , s_{i_l-1}, u_{l-2}, s_{i_l}, v
572 $$
573 where $i_1 = 1$, $i_2 = 2$, and $u_0 = \emptyset$ (the empty sequence).
574 \item Replace in $S_{n-2}$ the sequences $u_0, u_1, u_2, \ldots, u_{l-2}$ 
575   by 
576   $n - 1,  u'(u_1,n - 1, n) , u'(u_2,n, n - 1), u'(u_3,n - 1,n), \dots, u'(u_{l-2},n, n - 1)$
577   respectively, where $u'(u,x,y)$ is the sequence $u,x,u^R,y,u$ such that 
578   $u^R$ is $u$ in reversed order. The obtained sequence is further denoted as $U$.
579 \item Construct the sequences $V=v^R,n,v$, $W=n-1,S_{n-2},n$, and let $W'$ be $W$ where the first 
580 two elements have been exchanged.
581 \item The transition sequence $S_{n}$ is thus the concatenation $U^R, V, W'$.
582 \end{enumerate} 
583
584 It has been proven in~\cite{VanSup04} that 
585 $S_{n}$ is transition sequence of a cyclic $n$-bits Gray code 
586 if $S_{n-2}$ is. 
587 However, the step~\ref{item:nondet} is not a constructive 
588 step that precises how to select the subsequences which ensures that 
589 yielded Gray code is balanced.
590
591 Let us now  evaluate the number of subsequences $u$  
592 than can be produced. Since $s_{i_1}$ and $s_{i_2}$ are well
593 defined, we have to chose the $l-2$ elements of $s_3,s_4,\dots,s_{2^{n-2}}$
594 that become $s_{i_3},\dots, s_{i_l}$. Let $l = 2l'$.
595 There are thus 
596 $$
597 \#_n = \sum_{l'=1}^{2^{n-3}} {2^{n-2}-2 \choose 2l'-2}
598 $$
599 distinct subsequences $u$.
600 Numerical values of $\#_n$ are given in table~\ref{table:combinations}.
601 Even for small values of $n$, it is not reasonable to hope to evaluate the whole 
602 set of subsequences.
603 \begin{table}[ht]
604 \begin{scriptsize}
605 \begin{center}
606 \begin{tabular}{|l|l|l|l|l|l|l|l|l|}
607 \hline
608 $n$ &  5 & 6 & 7 & 8 & 9 \\  
609 \hline
610 $\#_n$ & 
611 31 & 8191 & 5.3e8 & 2.3e18 & 4.2e37\\
612 \hline
613 $\#'_n$ & 
614 15 & 3003 & 1.4e8 & 4.5e17 & 1.6e36 \\
615 \hline
616 \end{tabular}
617 \end{center}
618 \end{scriptsize}
619 \caption{Number of distinct $u$ subsequences.}\label{table:combinations}
620 \end{table}
621
622 However, it is  shown in the article that $\textit{TC}_n(n-1)$ and $\textit{TC}_n(n)$ are
623 equal to $l$. Since this step aims at generating (totally) balanced Gray codes,  
624 we have set $l$ to be the largest even integer less or equal than $\frac{2^n}{n}$.
625 This improvement allows to reduce the number of subsequences to study.
626 Examples of such cardinalities are given in table~\ref{table:combinations} and are refered as 
627 $\#'_n$.
628
629 Finally, the table~\ref{table:nbFunc} gives the number of non-equivalent functions issued from 
630 (totally) balanced Gray codes that can be generated
631 with the approach presented in this article with respect to the number of bits. In other words, it corresponds to the size of the class of generators that can be produced.
632
633 \begin{table}[ht]
634 \begin{center}
635 \begin{scriptsize}
636 \begin{tabular}{|l|c|c|c|c|}
637 \hline
638 $n$              & 3 & 4 & 5 & 6  \\
639 \hline
640 nb. of functions & 1 & 1 & 2 & 1332   \\
641 \hline
642 \end{tabular}
643 \end{scriptsize}
644 \end{center}
645 \caption{Generators Numbers w.r.t. bits Numbers.}
646 \label{table:nbFunc}
647 \end{table}
648
649
650 \vspace{-2em}
651 \section{\uppercase{Experiments}}\label{sec:exp}
652 \vspace{-1em}
653 We have directly implemented the algorithm given in Figure~\ref{CI Algorithm}.
654 For function $f$ and our experiments $b$ is set
655 with the value given in the fourth column of Table~\ref{table:nc}.
656
657 % We present in Algorithm~\ref{CI} the method
658 % that allows to take any chaotic function as the core of a pseudo
659 % random number generator. Among the parameters, it takes the
660 % number b of minimal iterations that have to be executed to
661 % get a uniform like distribution. For function $f$ and our experiments $b$ is set
662 % with the value given in the fourth column of Table~\ref{table:nc}.
663 % \begin{algorithm}[ht]
664 % %\begin{scriptsize}
665 % \KwIn{a function $f$, an iteration number $b$, an initial configuration $x^0$ ($n$ bits)}
666 % \KwOut{a configuration $x$ ($n$ bits)}
667 % $x\leftarrow x^0$\;
668 % \For{$i=0,\dots,b-1$}
669 % {
670 % $s\leftarrow{\textit{Random}~mod~n}$\;
671 % $x\leftarrow{(x-(x\&(1<<s))+f(x)\&(1<<s))}$\;
672 % }
673 % return $x$\;
674 % %\end{scriptsize}
675 % \caption{Pseudo Code of the $\chi_{\textit{14Secrypt}}$ PRNG}
676 % \label{CI}
677 % \end{algorithm}
678
679 %$$ 
680 %\begin{array}{l}
681 %(\overline{x_1}(\overline{x_2}.x_4)+\overline{x_2}.\overline{x_3}.\overline{x_4}+ x_2.x_3%.x_4,\\
682 %x_1.\overline{x_2} + x_1.\overline{x_3}.\overline{x_4}+\overline{x_1}x_3x_4 + \overline{x_%2}.\overline{x_3}.\overline{x_4},\\
683 % x_2.\overline{x_3}+\overline{x_2}(x_1 \oplus x_3),\\
684 %\overline{x_2}.\overline{x_3}+x_1.\overline{x_2}x_3+\overline{x_1}x_2(\overline{x_3}
685 %+\overline{x_4}))
686 %\end{array}
687 %$$
688
689
690 \begin{table*}[t]
691 \begin{center}
692 \begin{scriptsize}
693 \begin{tabular}{|c|c|c|c|}
694 \hline
695 Function $f$ & $f(x)$, for $x$ in $(0,1,2,\hdots,2^n-1)$ & $n$ & $b$ \\ 
696 \hline
697 $\textcircled{a}$&[13,10,9,14,3,11,1,12,15,4,7,5,2,6,0,8]&4&32\\
698 % (
699 %\overline{x_1}(\overline{x_2}x_4)+\overline{x_2}\overline{x_3}\overline{x_4}+ x_2x_3x_4,
700 %x_1\overline{x_2} + x_1\overline{x_3}\overline{x_4}+\overline{x_1}x_3x_4 + \overline{x_2}\overline{x_3}\overline{x_4},
701 % x_2\overline{x_3}+\overline{x_2}(x_1 \oplus x_3),
702 %\overline{x_2}\overline{x_3}+x_1\overline{x_2}x_3+\overline{x_1}x_2(\overline{x_3}+\overline{x_4}))
703 \hline
704 &[55,60,45,56,58,62,61,40,53,38,52,54,35,51,33,49,39,14,
705 47,46,59,43,57,44,37,6,36,4,3,50,1,48,
706 &&\\
707 $\textcircled{b}$&
708 63,26,25,30,19,27,17,28,31,20,23,21,18,22,16,24,13,12,29,8,10,42,41,
709 0,15,2,7,5,11,34,9,32]&6&49\\
710 \hline
711 &[223,250,249,254,187,234,241,252,183,230,229,180,227,178,240,248,237,236,253,172,251,238,201, 224,247,166,165,244,&&\\
712 &
713 163,242,161,225,215,220,205,216,218,222,221,208,213,210,135,196,199,132,
714 194,130,129,200,159,186,185,190,59,170,177,&&\\
715 &188,191,246,245,52,243,50,176,184,173,46,189,174,235,42,233,232,231,38,37,228,35,226,33,168,151,156,141,152,154,158,&&\\
716 &157,144,149,146,148,150,155,147,153,145,175,14,143,204,11,202,169,8,7,198,197,4,195,2,1,192,255,124,109,120,107,126,&&\\
717 $\textcircled{c}$&
718 125,112,103,114,116,100,123,98,121,113,79,106,111,110,75,122,97,108,71,118,117,68,115,66,96,104,127,90,89,94,83,91,81,&8&75\\
719 &92,95,84,87,85,82,86,80,88,77,76,93,72,74,78,105,64,69,102,101,70,99,67,73,65,55,60,45,56,51,62,61,48,119,182,181,53,&&\\
720 &179,54,57,49,15,44,47,40,171,58,9,32,167,6,5,164,3,162,41,160,63,26,25,30,19,27,17,28,31,20,23,21,18,22,16,24,13,10,&&\\
721 &29,140,43,138,137,12,39,134,133,36,131,34,0,128]&&\\
722 \hline
723 \end{tabular}
724 \end{scriptsize}
725 \end{center}
726 \caption{Functions with DSCC Matrix and smallest MT\label{table:nc}}
727 \end{table*}
728
729
730 For each number $n=4, 6, 8$ of bits, we have generated all the functions according the method 
731 given in Section~\ref{sec:hamiltonian}.
732 For each $n$, we have then restricted this evaluation to the function 
733 whose Markov Matrix has the smallest mixing time. Such functions are 
734 given in Table~\ref{table:nc}.
735 In this table, let us consider for instance 
736 the function $\textcircled{a}$ from $\Bool^4$ to $\Bool^4$
737 defined by the following images : 
738 $[13, 10, 9, 14, 3, 11, 1, 12, 15, 4, 7, 5, 2, 6, 0, 8]$.
739 In other words,  the image of $3~(0011)$ by $\textcircled{a}$ is $14~(1110)$: it is obtained as  the  binary  value  of  the  fourth element  in  the  second  list
740 (namely~14).  
741
742
743 Let us first discuss about results against the NIST test suite. 
744 In our experiments, 100 sequences (s = 100) of 1,000,000 bits are generated and tested.
745 If the value $\mathbb{P}_T$ of any test is smaller than 0.0001, the sequences are considered to be not good enough
746 and the generator is unsuitable. Table~\ref{The passing rate} shows $\mathbb{P}_T$ of sequences based on discrete
747 chaotic iterations using different schemes. If there are at least two statistical values in a test, this test is
748 marked with an asterisk and the average value is computed to characterize the statistics.
749 We can see in Table \ref{The passing rate} that all the rates are greater than 97/100, \textit{i. e.}, all the generators pass the NIST test.
750 \begin{table} 
751 \renewcommand{\arraystretch}{1.3}
752 \begin{center}
753 \begin{scriptsize}
754 \setlength{\tabcolsep}{2pt}
755   \begin{tabular}{|l||c||c||c|}
756     \hline
757 Method &$\textcircled{a}$& $\textcircled{b}$ & $\textcircled{c}$   \\ \hline\hline
758 Frequency (Monobit)& 0.678/99& 0.574/99& 0.699/96\\ \hline 
759 Frequency  within a Block& 0.102/99& 0.816/98& 0.419/99\\ \hline 
760 Runs& 0.171/98& 0.657/98& 0.554/99\\ \hline 
761 Longest Run of Ones in a Block& 0.115/98& 0.534/100& 0.534/98\\ \hline 
762 Binary Matrix Rank& 0.401/97& 0.554/99& 0.911/99\\ \hline 
763 Discrete Fourier Transform (Spect.)& 0.554/98& 0.350/98& 0.080/99\\ \hline 
764 Non-overlapping Template Match.*& 0.509/99& 0.443/99& 0.499/99\\ \hline 
765 Overlapping Template Matching& 0.437/99& 0.699/100& 0.236/99\\ \hline 
766 Maurer's "Universal Statistical"& 0.171/99& 0.000/97& 0.657/99\\ \hline 
767 Linear Complexity& 0.171/100& 0.637/99& 0.834/100\\ \hline 
768 Serial* (m=10)& 0.435/100& 0.565/98& 0.592/100\\ \hline 
769 Approximate Entropy (m=10)& 0.137/98& 0.867/99& 0.062/100\\ \hline 
770 Cumulative Sums (Cusum)*& 0.580/99& 0.368/99& 0.569/97\\ \hline 
771 Random Excursions*& 0.245/98& 0.421/99& 0.656/99\\ \hline 
772 Random Excursions Variant*& 0.292/99& 0.450/99& 0.520/100\\ \hline
773 Success & 15/15 & 15/15 & 15/15 \\ 
774 \hline
775 \end{tabular}
776 \end{scriptsize}
777 \end{center}
778 \caption{NIST SP 800-22 test results ($\mathbb{P}_T$)}
779 \label{The passing rate}
780 \end{table}
781
782
783 Concerning the DieHARD battery of test, 
784 all the generator presented in this document can
785 pass this one.
786
787 % \begin{table}[htc]
788 % \renewcommand{\arraystretch}{1.3}
789 % \caption{Results of DieHARD battery of tests}
790 % \label{Results of DieHARD battery of tests}
791 % \begin{center}
792 % \begin{tabular}{@{}l@{}l@{}ccc@{}} \toprule
793 % \textbf{No.} &\textbf{Test name} &\multicolumn{3}{c}{\textbf{Generators}} \\ \cmidrule(r){3-5}
794 % & & $\textcircled{a}$ &  $\textcircled{b}$ & $\textcircled{c}$ \\ \midrule
795 % 1 & Overlapping Sum &Pass &Pass &Pass \\
796 % 2 & Runs Up 1 &Pass & Pass &Pass \\
797 % &Runs Down 1 &Pass &Pass &Pass \\
798 % &Runs Up 2 &Pass &Pass &Pass \\
799 % &Runs Down 2 &Pass & Pass &Pass \\
800 % 3 & 3D Spheres &Pass &Pass &Pass \\
801 % 4 & Parking Lot &Pass &Pass &Pass \\
802 % 5 & Birthday Spacing &Pass &Pass &Pass \\
803 % 6 & Count the ones 1 &Pass &Pass &Pass \\
804 % 7 &Binary Rank $6 \times 8$ &Pass & Pass &Pass \\
805 % 8 &Binary Rank $31 \times 31$ &Pass &Pass &Pass \\
806 % 9 &Binary Rank $32 \times 32$ &Pass &Pass &Pass \\
807 % 10 &Count the ones 2 &Pass &Pass&Pass \\
808 % 11 &Bit Stream &Pass &Pass&Pass  \\
809 % 12 &Craps Wins &Pass &Pass&Pass  \\
810 % &Throws &Pass &Pass &Pass  \\
811 % 13 &Minimum Distance &Pass &Pass &Pass  \\
812 % 14 &Overlapping Perm. &Pass &Pass &Pass  \\
813 % 15 &Squeeze &Pass &Pass&Pass \\
814 % 16 &OPSO &Pass &Pass&Pass \\
815 % 17 &OQSO &Pass &Pass&Pass  \\
816 % 18 &DNA &Pass &Pass&Pass  \\
817 % &Number of tests passed &18 &18 &18 \\\bottomrule
818 % \end{tabular}
819 % \end{center}
820 % \end{table}
821
822
823 % \vspace{-1em}
824 % \subsection{TestU01}
825 % \label{Subsec:TestU01}
826 % \vspace{-1em}
827
828 % TestU01~\cite{Simard07testu01:a} is a software library that 
829 % provides general implementations of the classical statistical tests for 
830 % random number generators, as well as several others proposed in the 
831 % literature, and some original ones. This library is currently the
832 % most reputed and stringent one for testing the randomness
833 % profile of a given sequence. TestU01 encompasses the NIST and DieHARD
834 % tests suites with 2 batteries specific to hardware based generators 
835 % (namely, Rabbit and Alphabit). Its three core batteries of tests are
836 % however SmallCrush, Crush, and BigCrush, classified according to
837 % their difficulty.
838
839 % To date, we can claim after experiments that $\textcircled{a}$
840 % generator is able to pass the 15 tests embedded into the 
841 % SmallCrush battery and it succedded too to pass the 144 tests of 
842 % the Crush one. BigCrush results on $\textcircled{a}$ are
843 % expected soon, while TestU01 has been launched too on generators
844 % having the other iteration functions detailed in this article.
845
846
847 \vspace{-2em}
848 \section{\uppercase{Conclusion}}\label{sec:conclusion}
849 \vspace{-1em}
850 This article has presented a method to compute a large class of truly chaotic PRNGs.
851 First experiments through the batteries of NIST, and DieHard %, and TestU01
852 have shown that the statistical properties are almost established for $n=4,6,8$.
853 The iterated map inside the generator is built by removing 
854 from a $n$-cube an Hamiltonian path that corresponds to a (totally) balanced Gray code.  
855 The number of balanced gray code is large and each of them can be 
856 considered as a key of the PRNG.
857 However, many problems still remain open, most important ones being listed 
858 thereafter. 
859
860 The first one involves the function to iterate. Producing a DSSC matrix is indeed necessary and sufficient
861 but is not linked with the convergence rate to the uniform distribution. 
862 To solve this problem, we have proposed to remove from the $n$-cube an Hamiltonian path that 
863 is a (totally) balanced Gray code. We do not have proven that this 
864 proposal is the one that minimizes the  mixing time. This optimization task is an open problem we plan to study.
865
866 Secondly, the approach depends on finding (totally) balanced Gray 
867 codes. Even if such codes exist for all even numbers, there is no constructive method to built them
868 when $n$ is large, as far as we know. These two open problems will
869 be investigated in a future work.
870
871
872 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
873 \bibliographystyle{apalike}
874 {\small
875 \bibliography{markov}}
876 \end{document}