1 \documentclass[a4paper,twoside]{article}
3 \usepackage[utf8]{inputenc}
4 \usepackage[T1]{fontenc}
5 \usepackage[english]{babel}
8 \usepackage{amsmath,amssymb,amsthm,amstext,latexsym,eufrak,euscript}
9 \usepackage{subfigure,pstricks,pst-node,pst-coil}
14 \usepackage{algorithm2e}
15 \usepackage[font=footnotesize]{subfig}
24 \usepackage{SCITEPRESS}
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}}
44 \newtheorem*{xpl}{Running example}
45 \newtheorem{theorem}{Theorem}
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}}}
60 \title{Pseudorandom Number Generators with Balanced Gray Codes}
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}
69 \keywords{Pseudorandom Number Generator, Theory of Chaos, Markov Matrices, Hamiltonian Paths, Mixing Time, Gray Codes, Statistical Tests}
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
80 \onecolumn \maketitle \normalsize \vfill
87 \section{\uppercase{Introduction}}
89 Many fields of research or applications like numerical simulations,
90 stochastic optimization, or information security are highly dependent on
91 the use of fast and unbiased random number generators. Depending on the
92 targeted application, reproducibility must be either required, leading
93 to deterministic algorithms that produce numbers as close as possible
94 to random sequences, or refused, which implies to use an external
95 physical noise. The formers are called pseudorandom number generators
96 (PRNGs) while the laters are designed by truly random number generators (TRNGs).
97 TRNGs are used for instance in cypher keys generation, or in hardware based
98 simulations or security devices. Such TRNGs are often based on a chaotic
99 physical signal, may be quantized depending on the application.
100 This quantization however raises the problem of the degradation of chaotic
103 The use of PRNGs, for its part, is a necessity in a large variety
104 of numerical simulations, in which
105 responses of devices under study must be compared using the same ``random''
106 stream. This reproducibility is required too for symmetric encryption like
107 one-time pad, as sender and receiver must share the same pad. However, in
108 that situation, security of the pseudorandom stream must be mathematically
109 proven: an attacker must not be able to computationally distinguish a
110 pseudorandom sequence generated by the considered PRNG with a really random
111 one. Such cryptographically secure pseudorandom number generators are
112 however only useful in cryptographic contexts, due to their slowness
113 resulting from their security.
116 Other kind of properties are desired for PRNGs used in numerical simulations
117 or in programs that embed a Monte-Carlo algorithm. In these situations,
118 required properties are speed and random-like profiles of the generated
119 sequences. The fact that a given PRNG is unbiased and behaves as a white
120 noise is thus verified using batteries of statistical tests on a large amount
121 of pseudorandom numbers. Reputed and up-to-date batteries are
122 currently the NIST suite~\cite{Nist10}, DieHARD~\cite{Marsaglia1996},
123 and TestU01~\cite{Simard07testu01:a}, this latter being the
124 most stringent one. Finally, chaotic properties can be desired when
125 simulating a chaotic physical phenomenon or in hardware security, in
126 which cryptographical proofs are not realizable.
127 In both truly and pseudorandom number generation, there is thus a need
128 to mathematically guarantee the presence of chaos, and to show that
129 a post-treatment on a given secure and/or unbiased generator can be realized,
130 which adds chaos without deflating these desired properties.
133 This work takes place in this domain with the desire of automatically
134 generating a large class of PRNGs with chaos and statistical properties.
135 In a sense, it is close to~\cite{BCGR11} where the authors shown that
136 some Boolean maps may be embedded into an algorithm to provide a PRNG that has both
137 the theoretical Devaney's chaos property and the practical
138 property of succeeding NIST statistical battery of tests.
139 To achieve this, it has been proven in
140 this article that it is sufficient
141 for the iteration graph to be strongly connected,
142 and it is necessary and sufficient for its Markov probability matrix to be doubly stochastic.
143 However, they do not purpose conditions
144 to provide such Boolean maps.
145 Admittedly, sufficient conditions
146 to retrieve Boolean maps whose graphs are
147 strongly connected are given, but it remains to further filter those whose
148 Markov matrix is doubly stochastic.
149 This approach suffers from delaying the second requirement to a final step
150 whereas this is a necessary condition.
151 In this position article, we provide a completely new approach
152 to generate Boolean functions, whose Markov matrix is doubly stochastic and whose
153 graph of iterations is strongly connected.
154 Furthermore the rate of convergence is always taken into consideration to provide
155 PRNG with good statistical properties.
158 This research work is organized as follows.
159 It firstly recall some preliminaries that make the document self-contained (Section~\ref{sec:preliminaries}),
160 The next section (Section~\ref{sec:DSSC}) shows how this problem can be theoretically solved with a classical constraint logic programming.
161 Section~\ref{sec:hamiltonian} is the strongest contribution of this work.
162 It presents the main algorithm to generate Boolean maps with all the required properties and
163 proves that such a construction is correct.
164 Statistical evaluations are then presented in Section~\ref{sec:exp}.
165 Conclusive remarks, open problems, and perspectives are
170 \section{\uppercase{Preliminaries}}\label{sec:preliminaries}
172 In what follows, we consider the Boolean algebra on the set
173 $\Bool=\{0,1\}$ with the classical operators of conjunction '.',
174 of disjunction '+', of negation '$\overline{~}$', and of
175 disjunctive union $\oplus$.
177 Let $n$ be a positive integer. A {\emph{Boolean map} $f$ is
178 a function from the Boolean domain
181 $x=(x_1,\dots,x_n)$ maps to $f(x)=(f_1(x),\dots,f_n(x))$.
182 Functions are iterated as follows.
183 At the $t^{th}$ iteration, only the $s_{t}-$th component is
184 ``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,
185 let $F_f: \llbracket1;n\rrbracket\times \Bool^{n}$ to $\Bool^n$ be defined by
187 F_f(i,x)=(x_1,\dots,x_{i-1},f_i(x),x_{i+1},\dots,x_n).
189 Then, let $x^0\in\Bool^n$ be an initial configuration
191 \llbracket1;n\rrbracket^\Nats$ be a strategy,
192 the dynamics are described by the recurrence
193 \begin{equation}\label{eq:asyn}
194 x^{t+1}=F_f(s_t,x^t).
198 Let be given a Boolean map $f$. Its associated
199 {\emph{iteration graph}} $\Gamma(f)$ is the
200 directed graph such that the set of vertices is
201 $\Bool^n$, and for all $x\in\Bool^n$ and $i\in \llbracket1;n\rrbracket$,
202 the graph $\Gamma(f)$ contains an arc from $x$ to $F_f(i,x)$.
205 Let us consider for instance $n=3$. Let
206 $f^*: \Bool^3 \rightarrow \Bool^3$ be defined by
207 $f^*(x_1,x_2,x_3)=(x_2 \oplus x_3, x_1 \oplus \overline{x_3},\overline{x_3})$.
208 The iteration graph $\Gamma(f^*)$ of this function is given in
209 Figure~\ref{fig:iteration:f*}.
215 \includegraphics[scale=0.5]{iter_f0b.eps}
217 \caption{Iteration Graph $\Gamma(f^*)$ of the function $f^*$}\label{fig:iteration:f*}
222 It is easy to associate a Markov Matrix $M$ to such a graph $G(f)$
225 \item $M_{ij} = \frac{1}{n}$ if there is an edge from $i$ to $j$ in $\Gamma(f)$ and $i \neq j$;
226 \item $M_{ii} = 1 - \sum\limits_{j=1, j\neq i}^n M_{ij}$;
227 \item $M_{ij} = 0$ otherwise.
231 The Markov matrix associated to the function $f^*$ is
235 \begin{array}{llllllll}
236 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 \\
237 1 & 1 & 0 & 0 & 0 & 1 & 0 & 0 \\
238 0 & 0 & 1 & 1 & 0 & 0 & 1 & 0 \\
239 0 & 1 & 1 & 1 & 0 & 0 & 0 & 0 \\
240 1 & 0 & 0 & 0 & 1 & 1 & 0 & 0 \\
241 0 & 0 & 0 & 0 & 1 & 1 & 0 & 1 \\
242 0 & 0 & 0 & 0 & 1 & 0 & 1 & 1 \\
243 0 & 0 & 0 & 1 & 0 & 0 & 1 & 1
252 It is usual to check whether rows of such kind of matrices
253 converge to a specific
255 Let us first recall the \emph{Total Variation} distance $\tv{\pi-\mu}$,
256 which is defined for two distributions $\pi$ and $\mu$ on the same set
258 $$\tv{\pi-\mu}=\max_{A\subset \Omega} |\pi(A)-\mu(A)|.$$
260 % $$\tv{\pi-\mu}=\frac{1}{2}\sum_{x\in\Omega}|\pi(x)-\mu(x)|.$$
262 Let then $M(x,\cdot)$ be the
263 distribution induced by the $x$-th row of $M$. If the Markov chain
265 $M$ has a stationary distribution $\pi$, then we define
266 $$d(t)=\max_{x\in\Omega}\tv{M^t(x,\cdot)-\pi}.$$
267 Intuitively $d(t)$ is the largest deviation between
268 the distribution $\pi$ and $M^t(x,\cdot)$, which
269 is the result of iterating $t$ times the function.
271 Finally, let $\varepsilon$ be a positive number, the \emph{mixing time}
272 with respect to $\varepsilon$ is given by
273 $$t_{\rm mix}(\varepsilon)=\min\{t \mid d(t)\leq \varepsilon\}.$$
274 It defines the smallest iteration number
275 that is sufficient to obtain a deviation lesser than $\varepsilon$.
276 Notice that the upper and lower bounds of mixing times cannot
277 directly be computed with eigenvalues formulae as expressed
278 in~\cite[Chap. 12]{LevinPeresWilmer2006}. The authors of this latter work
279 only consider reversible Markov matrices whereas we do no restrict our
280 matrices to such a form.
284 Let us finally present the pseudorandom number generator $\chi_{\textit{14Secrypt}}$
285 which is based on random walks in $\Gamma(f)$.
286 More precisely, let be given a Boolean map $f:\Bool^n \rightarrow \Bool^n$,
287 a PRNG \textit{Random},
288 an integer $b$ that corresponds to an awaited mixing time, and
289 an initial configuration $x^0$.
290 Starting from $x^0$, the algorithm repeats $b$ times
291 a random choice of which edge to follow and traverses this edge.
292 The final configuration is thus outputted.
293 This PRNG is formalized in Algorithm~\ref{CI Algorithm}.
298 \begin{algorithm}[ht]
300 \KwIn{a function $f$, an iteration number $b$, an initial configuration $x^0$ ($n$ bits)}
301 \KwOut{a configuration $x$ ($n$ bits)}
303 \For{$i=0,\dots,b-1$}
305 $s\leftarrow{\textit{Random}(n)}$\;
306 $x\leftarrow{F_f(s,x)}$\;
310 \caption{Pseudo Code of the $\chi_{\textit{14Secrypt}}$ PRNG}
315 This PRNG is a particularized version of Algorithm given in~\cite{BCGR11}.
316 Compared to this latter, the length of the random
317 walk of our algorithm is always constant (and is equal to $b$) whereas it
318 was given by a second PRNG in this latter.
319 However, all the theoretical results that are given in~\cite{BCGR11} remain
320 true since the proofs do not rely on this fact.
321 Let us recall the following theorem.
325 \begin{theorem}[{\cite[Th. 4, p. 135]{BCGR11}}]
326 Let $f: \Bool^{n} \rightarrow \Bool^{n}$, $\Gamma(f)$ its
327 iteration graph, and $M$ its Markov matrix .
328 If $\Gamma(f)$ is strongly connected, then
329 the output of the PRNG follows
330 a law that tends to the uniform distribution
331 if and only if $M$ is a doubly stochastic matrix.
335 With all this material,
336 we can present an efficient method to
337 generate Boolean functions
338 with Doubly Stochastic matrix and Strongly Connected iteration graph,
339 further (abusively) denoted as DSSC matrix.
343 \section{\uppercase{Generation of DSSC Matrices}}\label{sec:DSSC}
345 This aim of this section is to show
346 that finding DSSC matrices from a hypercube
347 is a typical finite domain satisfaction
348 problem, classically denoted as
349 Constraint Logic Programming on Finite Domains (CLPFD).
350 This part is addressed in the first section. Next, we analyse the first
351 results to provide a generation of DSSC matrices with small mixing times.
353 \subsection{Constraint Logic Programming on Finite Domains}
356 let $n$ be the number of elements. In order to avoid fractions
357 in this article, we consider here that the
358 sum of each column and each row is $n$. It can easily be normalized to 1.
359 The goal is thus to find all the $2^n\times 2^n$ matrices $M$
363 \item $M_{ij}$ is 0 if $j$ is not a neighbor of $i$, \textit{i.e.},
364 there is no edge from $i$ to $j$ in the $n$-cube.
365 \item $0 \le M_{ii} \le n$: the number of loops around $i$ is lesser than $n$
366 \item Otherwise $0 \le M_{ij} \le 1$: if the edge from $i$ to $j$ is kept,
367 $M_{ij}$ is 1, and 0 otherwise.
368 \item For any index of line $i$, $1 \le i\le 2^n$, $n = \sum_{1 \le j\le 2^n} M_{ij}$:
369 the matrix is right stochastic.
370 \item For any index of column $j$,
371 $1 \le j\le 2^n$, $n = \sum_{1 \le i\le 2^n} M_{ij}$:
372 the matrix is left stochastic.
373 \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.
377 Since these variables range into finite integer domains with sum and
378 product operations, this problem can be theoretically handled by
379 Constraint Logic Programming on Finite Domains (CLPFD), as implemented
381 The algorithm given in Figure~\ref{fig:prolog}
382 is indeed the core of the prolog file that is used to instantiate all the solutions
383 when $n$ is 2. In this code,
384 \verb+mmult(+$X,Y,R$\verb+)+ and
385 \verb+summ(+$X,Y,R$\verb+)+
386 are true if and only if $R$ is the matrix product
387 or the matrix sum between
388 $X$ and $Y$ respectively. It is not hard to adapt such a code to any
389 value of positive integer $n$.
393 \lstset{language=prolog}
396 M=[[M0_0, M0_1, 0, M0_3], [M1_0, M1_1, 0, M1_3],
397 [M2_0, 0, M2_2, M2_3], [0, M3_1, M3_2, M3_3]],
398 [M0_0, M1_1, M2_2, M3_3] ins 0..2,
399 [M0_1, M0_3, M1_0, M1_3, M2_0, M2_3, M3_1, M3_2]
401 M0_0+ M0_1+ M0_2 #=2, M1_0+ M1_1+ M1_3 #=2,
402 M2_0+ M2_2+ M2_3 #=2, M3_1+ M3_2+ M3_3 #=2,
403 M0_0+ M1_0+ M2_0 #=2, M0_1+ M1_1+ M3_1 #=2,
404 M0_2+ M2_2+ M3_2 #=2, M1_3+ M2_3+ M3_3 #=2,
414 \caption{Prolog Problem to Find DSSC Matrix when $n=2$}\label{fig:prolog}
417 Finally, we define the relation $\mathcal{R}$, which is established on the
419 $f$ and $g$ if the iteration graphs $\Gamma(f)$ and $\Gamma(g)$
421 Obviously, this is an equivalence relation.
425 \subsection{Analysis of the Approach}
427 When executed on a personal computer, prolog finds
428 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
429 not equivalent when $n$ is 3. But it does not achieve the generation of
430 all the solutions when $n$ is 4.
431 This approach suffers from not being efficient enough for large $n$ due to
432 a \emph{generate and test} approach, despite the efficiency of the native
435 However, first results for small values of $n$ have been evaluated.
436 More precisely, non equivalent generated
437 functions have been compared according to their
438 ability to efficiently produce uniformly distributed outputs, \textit{i.e.},
439 to have the smallest mixing time.
442 Table~\ref{table:mixing:3} gives the 5 best Boolean functions
443 ordered by their mixing times (MT) in the third column for $\varepsilon=10^{-5}$.
447 \begin{array}{|l|l|l|}
449 \textrm{Name} & \textrm{Image} & \textrm{MT}\\
451 f^* & (x_2 \oplus x_3, x_1 \oplus \overline{x_3},\overline{x_3}) & 16 \\
453 f^a & (x_2 \oplus x_3, \overline{x_1}\overline{x_3} + x_1\overline{x_2},
454 \overline{x_1}\overline{x_3} + x_1x_2) & 17 \\
456 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}, & \\
457 & \qquad \overline{x_3}(\overline{x_1}+x_2) + \overline{x_1}x_2) & 26 \\
459 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}, & \\
460 & \overline{x_3}(\overline{x_1}+x_2) + \overline{x_1}x_2) & 29 \\
462 f^d & (x_1\oplus x_2,x_3(\overline{x_1}+\overline{x_2}),\overline{x_3}) & 30 \\
464 % [3, 4, 7, 0, 1, 6, 5, 2], #16
465 % [3, 4, 7, 0, 2, 6, 5, 1], #17
466 % [3, 6, 7, 5, 2, 0, 1, 4], #26
467 % [3, 4, 7, 5, 2, 6, 1, 0], #29
468 % [3, 2, 5, 6, 7, 0, 1, 4]] #30
472 \caption{The 5 Boolean functions with smallest MT when $n=3$.}\label{table:mixing:3}
476 A syntactical analysis of the functions for $n$=3
477 does not help to understand
478 how to build a Boolean map with a small mixing time.
479 However the iteration graph of $f^*$
480 (given in Figure~\ref{fig:iteration:f*})
481 is the $3$-cube in which the cycle
482 $000,100,101,001,011,111,110,010,000$
484 This cycle that visits each vertex exactly once is usually denotes as
485 \emph{Hamiltonian cycle}.
486 We are now focusing on the generation of DSSC matrices by
487 removing Hamiltonian cycles of the $n$-cube. This is the aims of the next
491 \section{\uppercase{Removing Hamiltonian Cycles}}\label{sec:hamiltonian}
492 This section addresses the problem of removing an Hamiltonian path in the $n$-cube.
493 The first theoretical section shows that this approach produces DSSC matrix, as wished.
494 The motivation to focus on balanced Gray code is then given in Sec.~\ref{sub:gray}.
495 We end this section by recalling an algorithm that aims at computing such codes (Section~\ref{sub:algo:gray}).
497 \subsection{Theoretical Aspects of Removing Hamiltonian Cycles}
499 We first have the following result on stochastic matrix and $n$-cube without
503 The Markov Matrix $M$ resulting from the $n$-cube in
505 cycle is removed, is doubly stochastic.
508 An Hamiltonian cycle visits each vertex exactly once.
509 For each vertex $v$ in the $n$-cube,
510 one ongoing edge $(o,v)$ and one outgoing edge $(v,e)$
513 Let us consider the Markov matrix $M$ of the $n$-cube.
514 It is obviously doubly stochastic.
515 Since we exactly remove one outgoing edge, the value of $M_{ve}$ decreases
516 from $\frac{1}{n}$ to 0 and
517 $M_{vv}$ is $\frac{1}{n}$. The $M$ matrix is stochastic again.
518 Similarly for ongoing edge, since one ongoing edge is dropped for each
519 vertex, the value of $M_{ov}$ decreases
520 from $\frac{1}{n}$ to $0$. Moreover, since $M_{vv}$ is $\frac{1}{n}$,
521 the sum of values in column $v$ is $1$, and $M$ is doubly stochastic.
524 The following result states that the $n$-cube without one
526 has the awaited property with regard to the connectivity.
529 The iteration graph issued from the $n$-cube where an Hamiltonian
530 cycle is removed is strongly connected.
533 We consider the reverse cycle $r$ of the Hamiltonian cycle $c$.
534 There is no edge that belongs to both $r$ and $c$: otherwise $c$
535 would contain one vertex twice. Thus, no edges of $r$ has been removed.
536 The cycle $r$ is obviously an Hamiltonian cycle and contains all the nodes.
537 Any node of the $n$-cube where $c$ has been removed can thus reach any node.
538 The iteration graph is thus strongly connected.
541 Removing an Hamiltonian cycle in the $n$-cube solves thus the DSSC constraint.
542 We are then left to focus on the generation of Hamiltonian cycles in the
543 $n$-cube. Such a problem is equivalent to find Gray codes, \textit{i.e.},
544 to find a sequence of $2^n$ codewords ($n$-bits strings)
545 where two successive elements differ in only one bit position.
546 The next section is dedicated to these codes.
548 \subsection{Linking to (Totally) Balanced Gray Codes}\label{sub:gray}
549 Many research works~\cite{journals/combinatorics/BhatS96,VanSup04,journals/combinatorics/FlahiveB07}
550 have addressed the subject of finding Gray codes.
551 Since our approach is based on removing a cycle, we are concerned
552 with cyclic Gray codes, \textit{i.e.}, sequences where the last codeword
553 differs in only one bit position from the first one.
555 Let $n$ be a given integer. As far as we know,
556 the exact number of Gray codes in $\Bool^n$ is not known but
557 a lower bound, $$\left(\frac{n*\log2}{e \log \log n}*(1 - o(1))\right)^{2^n}$$
558 has been given in~\cite{Feder:2009:NTB:1496397.1496515}.
559 For example, when $n$ is $6$, such a number is larger than $10^{13}$.
561 To avoid this combinatorial explosion, we want to
562 restrict the generation to any Gray code
563 such that the induced graph of iteration $\Gamma(f)$ is
564 ``uniform''. In other words, if we count in $\Gamma(f)$
565 the number of edges that modify the bit $i$, for $1 \le i \le n$,
566 all these values have to be close to each other.
567 Such an approach is equivalent to restrict the search of cyclic Gray codes
568 which are uniform too.
570 This notion can be formalized as follows. Let $L = w_1, w_2, \dots, w_{2^n}$ be the sequence
571 of a $n$-bits cyclic Gray code. Let $S = s_1, s_2, \dots, s_{2^n}$ be the
572 transition sequence where $s_i$, $1 \le i \le 2^n$ indicates which bit position changes between
573 codewords at index $i$ and $i+1$ modulo $2^n$.
574 Let $\textit{TC}_n : \{1,\dots, n\} \rightarrow \{0, \ldots, 2^n\}$ the \emph{transition count} function
575 that counts the number of times $i$ occurs in $S$, \textit{i.e.}, the number of times
576 the bit $i$ has been switched in $L$.
577 The Gray code is \emph{totally balanced} if $\textit{TC}_n$ is constant (and equal to $\frac{2^n}{n}$).
578 It is \emph{balanced} if for any two bit indices $i$ and $j$,
579 $|\textit{TC}_n(i) - \textit{TC}_n(j)| \le 2$.
582 Let $L^*=000,100,101,001,011,111,110,010$ be the Gray code that corresponds to
583 the Hamiltonian cycle that has been removed in $f^*$.
584 Its transition sequence is $S=3,1,3,2,3,1,3,2$ and its transition count function is
585 $\textit{TC}_3(1)= \textit{TC}_3(2)=2$ and $\textit{TC}_3(3)=4$. Such a Gray code is balanced.
588 $L^4=0000, 0010, 0110, 1110, 1111, 0111, 0011, 0001, 0101,$
589 $0100, 1100, 1101, 1001, 1011, 1010, 1000$
590 be a cyclic Gray code. 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
591 is thus totally balanced.
593 On the contrary, for the standard $4$-bits Gray code
594 $L^{\textit{st}}=0000,0001,0011,0010,0110,0111,0101,0100,1100,$
595 $1101,1111,1110,1010,1011,1001,1000$,
596 we have $\textit{TC}_4(1)=8$ $\textit{TC}_4(2)=4$ $\textit{TC}_4(3)=\textit{TC}_4(4)=2$ and
597 the code is neither balanced nor totally balanced.
600 \subsection{Induction-Based Generation of Balanced Gray Codes}\label{sub:algo:gray}
601 The algorithm we adapt is based on the ``Construction B''~\cite{VanSup04} we recall now.
602 This method inductively constructs $n$-bits Gray code given a $n-2$-bit Gray code.
604 It starts with the transition sequence $S_{n-2}$ of such code.
607 \item \label{item:nondet}Let $l$ be an even positive integer. Find
608 $u_1, u_2, \dots , u_{l-2}, v$ (maybe empty) subsequences of $S_{n-2}$
609 such that $S_{n-2}$ is the concatenation of
611 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
613 where $i_1 = 1$, $i_2 = 2$, and $u_0 = \emptyset$ (the empty sequence).
614 \item Replace in $S_{n-2}$ the sequences $u_0, u_1, u_2, \ldots, u_{l-2}$
616 $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)$
617 respectively, where $u'(u,x,y)$ is the sequence $u,x,u^R,y,u$ such that
618 $u^R$ is $u$ in reversed order. The obtained sequence is further denoted as $U$.
619 \item Construct the sequences $V=v^R,n,v$, $W=n-1,S_{n-2},n$, and let $W'$ be $W$ where the first
620 two elements have been exchanged.
621 \item The transition sequence $S_{n}$ is thus the concatenation $U^R, V, W'$.
624 It has been proven in~\cite{VanSup04} that
625 $S_{n}$ is transition sequence of a cyclic $n$-bits Gray code
627 However, the step~\ref{item:nondet} is not a constructive
628 step that precises how to select the subsequences which ensures that
629 yielded Gray code is balanced.
631 Let us now evaluate the number of subsequences $u$
632 than can be produced. Since $s_{i_1}$ and $s_{i_2}$ are well
633 defined, we have to chose the $l-2$ elements of $s_3,s_4,\dots,s_{2^{n-2}}$
634 that become $s_{i_3},\dots, s_{i_l}$. Let $l = 2l'$.
637 \#_n = \sum_{l'=1}^{2^{n-3}} {2^{n-2}-2 \choose 2l'-2}
639 distinct subsequences $u$.
640 Numerical values of $\#_n$ are given in table~\ref{table:combinations}.
641 Even for small values of $n$, it is not reasonable to hope to evaluate the whole
645 \begin{tabular}{|l|l|l|l|l|l|l|l|l|}
647 $n$ & 5 & 6 & 7 & 8 & 9 \\
650 31 & 8191 & 5.3e8 & 2.3e18 & 4.2e37\\
653 15 & 3003 & 1.4e8 & 4.5e17 & 1.6e36 \\
657 \caption{Number of distinct $u$ subsequences.}\label{table:combinations}
660 However, it is shown in the article that $\textit{TC}_n(n-1)$ and $\textit{TC}_n(n)$ are
661 equal to $l$. Since this step aims at generating (totally) balanced Gray codes,
662 we have set $l$ to be the largest even integer less or equal than $\frac{2^n}{n}$.
663 This improvement allows to reduce the number of subsequences to study.
664 Examples of such cardinalities are given in table~\ref{table:combinations} and are refered as
667 Finally, the table~\ref{table:nbFunc} gives the number of non-equivalent functions issued from
668 (totally) balanced Gray codes that can be generated
669 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.
673 \begin{tabular}{|l|c|c|c|c|}
675 $n$ & 3 & 4 & 5 & 6 \\
677 nb. of functions & 1 & 1 & 2 & 1332 \\
681 \caption{Number of Generators w.r.t. the number of bits.}
686 \section{\uppercase{Experiments}}\label{sec:exp}
687 We present in Algorithm~\ref{CI} the method
688 that allows to take any chaotic function as the core of a pseudo
689 random number generator. Among the parameters, it takes the
690 number b of minimal iterations that have to be executed to
691 get a uniform like distribution. For function $f$ and our experiments $b$ is set
692 with the value given in the fourth column of Table~\ref{table:nc}.
693 \begin{algorithm}[ht]
695 \KwIn{a function $f$, an iteration number $b$, an initial configuration $x^0$ ($n$ bits)}
696 \KwOut{a configuration $x$ ($n$ bits)}
698 \For{$i=0,\dots,b-1$}
700 $s\leftarrow{\textit{Random}~mod~n}$\;
701 $x\leftarrow{(x-(x\&(1<<s))+f(x)\&(1<<s))}$\;
705 \caption{Pseudo Code of the $\chi_{\textit{14Secrypt}}$ PRNG}
711 %(\overline{x_1}(\overline{x_2}.x_4)+\overline{x_2}.\overline{x_3}.\overline{x_4}+ x_2.x_3%.x_4,\\
712 %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},\\
713 % x_2.\overline{x_3}+\overline{x_2}(x_1 \oplus x_3),\\
714 %\overline{x_2}.\overline{x_3}+x_1.\overline{x_2}x_3+\overline{x_1}x_2(\overline{x_3}
722 \begin{tabular}{|c|c|c|c|}
724 Function $f$ & $f(x)$, for $x$ in $(0,1,2,\hdots,2^n-1)$ & $n$ & $b$ \\
726 $\textcircled{a}$&[13, 10, 9, 14, 3, 11, 1, 12, 15, 4, 7, 5, 2, 6, 0, 8]&4&32\\
728 %\overline{x_1}(\overline{x_2}x_4)+\overline{x_2}\overline{x_3}\overline{x_4}+ x_2x_3x_4,
729 %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},
730 % x_2\overline{x_3}+\overline{x_2}(x_1 \oplus x_3),
731 %\overline{x_2}\overline{x_3}+x_1\overline{x_2}x_3+\overline{x_1}x_2(\overline{x_3}+\overline{x_4}))
733 &[55, 60, 45, 56, 58, 62, 61, 40, 53, 38, 52, 54, 35, 51, 33, 49, 39, 14,
736 47, 46, 59, 43, 57, 44, 37, 6, 36, 4, 3, 50, 1, 48, 63, 26, 25, 30, 19,
739 27, 17, 28, 31, 20, 23, 21, 18, 22, 16, 24, 13, 12, 29, 8, 10, 42, 41,
742 0, 15, 2, 7, 5, 11, 34, 9, 32]&&\\
745 &[223, 250, 249, 254, 187, 234, 241, 252, 183, 230, 229, 180, 227, 178, &&\\
747 240, 248, 237, 236, 253, 172, 251, 238, 201, 224, 247, 166, 165, 244,
750 163, 242, 161, 225, 215, 220, 205, 216, 218, 222, 221, 208, 213, 210,
753 135, 196, 199, 132, 194, 130, 129, 200, 159, 186, 185, 190, 59, 170,
756 177, 188, 191, 246, 245, 52, 243, 50, 176, 184, 173, 46, 189, 174, 235,
759 42, 233, 232, 231, 38, 37, 228, 35, 226, 33, 168, 151, 156, 141, 152,
762 154, 158, 157, 144, 149, 146, 148, 150, 155, 147, 153, 145, 175, 14,
765 143, 204, 11, 202, 169, 8, 7, 198, 197, 4, 195, 2, 1, 192, 255, 124,
768 109, 120, 107, 126, 125, 112, 103, 114, 116, 100, 123, 98, 121, 113, 79,
771 106, 111, 110, 75, 122, 97, 108, 71, 118, 117, 68, 115, 66, 96, 104,
774 127, 90, 89, 94, 83, 91, 81, 92, 95, 84, 87, 85, 82, 86, 80, 88, 77, 76,
777 93, 72, 74, 78, 105, 64, 69, 102, 101, 70, 99, 67, 73, 65, 55, 60, 45,
780 56, 51, 62, 61, 48, 119, 182, 181, 53, 179, 54, 57, 49, 15, 44, 47, 40,
783 171, 58, 9, 32, 167, 6, 5, 164, 3, 162, 41, 160, 63, 26, 25, 30, 19, 27,
786 17, 28, 31, 20, 23, 21, 18, 22, 16, 24, 13, 10, 29, 140, 43, 138, 137,
789 12, 39, 134, 133, 36, 131, 34, 0, 128]&&\\
795 \caption{Functions with DSCC Matrix and smallest MT\label{table:nc}}
799 For each number $n=4, 6, 8$ of bits, we have generated all the functions according the method
800 given in Section~\ref{sec:hamiltonian}.
801 For each $n$, we have then restricted this evaluation to the function
802 whose Markov Matrix has the smallest mixing time. Such functions are
803 given in Table~\ref{table:nc}.
804 In this table, let us consider for instance
805 the function $\textcircled{a}$ from $\Bool^4$ to $\Bool^4$
806 defined by the following images :
807 $[13, 10, 9, 14, 3, 11, 1, 12, 15, 4, 7, 5, 2, 6, 0, 8]$.
808 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
814 In our experiments, 100 sequences (s = 100) of 1,000,000 bits are generated and tested.
815 If the value $\mathbb{P}_T$ of any test is smaller than 0.0001, the sequences are considered to be not good enough
816 and the generator is unsuitable. Table~\ref{The passing rate} shows $\mathbb{P}_T$ of sequences based on discrete
817 chaotic iterations using different schemes. If there are at least two statistical values in a test, this test is
818 marked with an asterisk and the average value is computed to characterize the statistics.
819 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.
821 \renewcommand{\arraystretch}{1.3}
822 \caption{NIST SP 800-22 test results ($\mathbb{P}_T$)}
823 \label{The passing rate}
825 \begin{tabular}{|l||c||c||c|}
827 Method &$\textcircled{a}$& $\textcircled{b}$ & $\textcircled{c}$ \\ \hline\hline
828 Frequency (Monobit)& 0.678 (0.99)& 0.574 (0.99)& 0.699 (0.96)\\ \hline
829 Frequency within a Block& 0.102 (0.99)& 0.816 (0.98)& 0.419 (0.99)\\ \hline
830 Runs& 0.171 (0.98)& 0.657 (0.98)& 0.554 (0.99)\\ \hline
831 Longest Run of Ones in a Block& 0.115 (0.98)& 0.534 (1.0)& 0.534 (0.98)\\ \hline
832 Binary Matrix Rank& 0.401 (0.97)& 0.554 (0.99)& 0.911 (0.99)\\ \hline
833 Discrete Fourier Transform (Spectral)& 0.554 (0.98)& 0.350 (0.98)& 0.080 (0.99)\\ \hline
834 Non-overlapping Template Matching*& 0.509 (0.990)& 0.443 (0.990)& 0.499 (0.989)\\ \hline
835 Overlapping Template Matching& 0.437 (0.99)& 0.699 (1.0)& 0.236 (0.99)\\ \hline
836 Maurer's "Universal Statistical"& 0.171 (0.99)& 0.000 (0.97)& 0.657 (0.99)\\ \hline
837 Linear Complexity& 0.171 (1.0)& 0.637 (0.99)& 0.834 (1.0)\\ \hline
838 Serial* (m=10)& 0.435 (1.0)& 0.565 (0.98)& 0.592 (1.0)\\ \hline
839 Approximate Entropy (m=10)& 0.137 (0.98)& 0.867 (0.99)& 0.062 (1.0)\\ \hline
840 Cumulative Sums (Cusum) *& 0.580 (0.99)& 0.368 (0.99)& 0.569 (0.97)\\ \hline
841 Random Excursions *& 0.245 (0.980)& 0.421 (0.991)& 0.656 (0.985)\\ \hline
842 Random Excursions Variant *& 0.292 (0.991)& 0.450 (0.990)& 0.520 (0.996)\\ \hline
843 Success & 15/15 & 15/15 & 15/15 \\
850 \label{Subsec:DieHARD}
852 Table~\ref{Results of DieHARD battery of tests} gives the results derived from applying the DieHARD battery~\cite{Marsaglia1996} of tests
853 to the PRNGs considered in this work.
854 As it can be observed, all the generator presented in this document can pass the DieHARD battery of tests.
857 \renewcommand{\arraystretch}{1.3}
858 \caption{Results of DieHARD battery of tests}
859 \label{Results of DieHARD battery of tests}
861 \begin{tabular}{@{}l@{}l@{}ccc@{}} \toprule
862 \textbf{No.} &\textbf{Test name} &\multicolumn{3}{c}{\textbf{Generators}} \\ \cmidrule(r){3-5}
863 & & $\textcircled{a}$ & $\textcircled{b}$ & $\textcircled{c}$ \\ \midrule
864 1 & Overlapping Sum &Pass &Pass &Pass \\
865 2 & Runs Up 1 &Pass & Pass &Pass \\
866 &Runs Down 1 &Pass &Pass &Pass \\
867 &Runs Up 2 &Pass &Pass &Pass \\
868 &Runs Down 2 &Pass & Pass &Pass \\
869 3 & 3D Spheres &Pass &Pass &Pass \\
870 4 & Parking Lot &Pass &Pass &Pass \\
871 5 & Birthday Spacing &Pass &Pass &Pass \\
872 6 & Count the ones 1 &Pass &Pass &Pass \\
873 7 &Binary Rank $6 \times 8$ &Pass & Pass &Pass \\
874 8 &Binary Rank $31 \times 31$ &Pass &Pass &Pass \\
875 9 &Binary Rank $32 \times 32$ &Pass &Pass &Pass \\
876 10 &Count the ones 2 &Pass &Pass&Pass \\
877 11 &Bit Stream &Pass &Pass&Pass \\
878 12 &Craps Wins &Pass &Pass&Pass \\
879 &Throws &Pass &Pass &Pass \\
880 13 &Minimum Distance &Pass &Pass &Pass \\
881 14 &Overlapping Perm. &Pass &Pass &Pass \\
882 15 &Squeeze &Pass &Pass&Pass \\
883 16 &OPSO &Pass &Pass&Pass \\
884 17 &OQSO &Pass &Pass&Pass \\
885 18 &DNA &Pass &Pass&Pass \\
886 &Number of tests passed &18 &18 &18 \\\bottomrule
893 \label{Subsec:TestU01}
895 TestU01~\cite{Simard07testu01:a} is a software library that
896 provides general implementations of the classical statistical tests for
897 random number generators, as well as several others proposed in the
898 literature, and some original ones. This library is currently the
899 most reputed and stringent one for testing the randomness
900 profile of a given sequence. TestU01 encompasses the NIST and DieHARD
901 tests suites with 2 batteries specific to hardware based generators
902 (namely, Rabbit and Alphabit). Its three core batteries of tests are
903 however SmallCrush, Crush, and BigCrush, classified according to
906 To date, we can claim after experiments that $\textcircled{a}$
907 generator is able to pass the 15 tests embedded into the
908 SmallCrush battery and it succedded too to pass the 144 tests of
909 the Crush one. BigCrush results on $\textcircled{a}$ are
910 expected soon, while TestU01 has been launched too on generators
911 having the other iteration functions detailed in this article.
914 \section{\uppercase{Conclusion}}\label{sec:conclusion}
915 This article has presented a method to compute a large class of truly chaotic PRNGs.
916 First experiments through the batteries of NIST, DieHard, and TestU01
917 have shown that the statistical properties are almost established for $n=4,6,8$.
918 The iterated map inside the generator is built by removing
919 from a $n$-cube an Hamiltonian path that corresponds to a (totally) balanced Gray code.
920 The number of balanced gray code is large and each of them can be
921 considered as a key of the PRNG.
922 However, many problems still remain open, most important ones being listed
925 The first one involves the function to iterate. Producing a DSSC matrix is indeed necessary and sufficient
926 but is not linked with the convergence rate to the uniform distribution.
927 To solve this problem, we have proposed to remove from the $n$-cube an Hamiltonian path that
928 is a (totally) balanced Gray code. We do not have proven that this
929 proposal is the one that minimizes the mixing time. This optimization task is an open problem we plan to study.
931 Secondly, the approach depends on finding (totally) balanced Gray
932 codes. Even if such codes exist for all even numbers, there is no constructive method to built them
933 when $n$ is large, as far as we know. These two open problems will
934 be investigated in a future work.
937 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
938 \bibliographystyle{apalike}
940 \bibliography{markov}}