]> AND Private Git Repository - prng_gpu.git/blob - prng_gpu.tex
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
9de2d15de29484c0c8eb1457cef58847bc4c70f9
[prng_gpu.git] / prng_gpu.tex
1 \documentclass{article}
2 \usepackage[utf8]{inputenc}
3 \usepackage[T1]{fontenc}
4 \usepackage{fullpage}
5 \usepackage{fancybox}
6 \usepackage{amsmath}
7 \usepackage{amscd}
8 \usepackage{moreverb}
9 \usepackage{commath}
10 \usepackage{algorithm2e}
11 \usepackage{listings}
12 \usepackage[standard]{ntheorem}
13
14 % Pour mathds : les ensembles IR, IN, etc.
15 \usepackage{dsfont}
16
17 % Pour avoir des intervalles d'entiers
18 \usepackage{stmaryrd}
19
20 \usepackage{graphicx}
21 % Pour faire des sous-figures dans les figures
22 \usepackage{subfigure}
23
24 \usepackage{color}
25
26 \newtheorem{notation}{Notation}
27
28 \newcommand{\X}{\mathcal{X}}
29 \newcommand{\Go}{G_{f_0}}
30 \newcommand{\B}{\mathds{B}}
31 \newcommand{\N}{\mathds{N}}
32 \newcommand{\BN}{\mathds{B}^\mathsf{N}}
33 \let\sur=\overline
34
35 \newcommand{\alert}[1]{\begin{color}{blue}\textit{#1}\end{color}}
36
37 \title{Efficient and Cryptographically Secure Generation of Chaotic Pseudorandom Numbers on GPU}
38 \begin{document}
39
40 \author{Jacques M. Bahi, Rapha\"{e}l Couturier,  Christophe
41 Guyeux, and Pierre-Cyrille Heam\thanks{Authors in alphabetic order}}
42    
43 \maketitle
44
45 \begin{abstract}
46 In this paper we present a new pseudorandom number generator (PRNG) on
47 graphics processing units  (GPU). This PRNG is based  on the so-called chaotic iterations.  It
48 is firstly proven  to be chaotic according to the Devaney's  formulation. We thus propose  an efficient
49 implementation  for  GPU that successfully passes the   {\it BigCrush} tests, deemed to be the  hardest
50 battery of tests in TestU01.  Experiments show that this PRNG can generate
51 about 20 billions of random numbers  per second on Tesla C1060 and NVidia GTX280
52 cards.
53 It is finally established that, under reasonable assumptions, the proposed PRNG can be cryptographically 
54 secure.
55
56
57 \end{abstract}
58
59 \section{Introduction}
60
61 Randomness is of importance in many fields as scientific simulations or cryptography. 
62 ``Random numbers'' can mainly be generated either by a deterministic and reproducible algorithm
63 called a pseudorandom number generator (PRNG), or by a physical non-deterministic 
64 process having all the characteristics of a random noise, called a truly random number
65 generator (TRNG). 
66 In this paper, we focus on reproducible generators, useful for instance in
67 Monte-Carlo based simulators or in several cryptographic schemes.
68 These domains need PRNGs that are statistically irreproachable. 
69 On some fields as in numerical simulations, speed is a strong requirement
70 that is usually attained by using parallel architectures. In that case,
71 a recurrent problem is that a deflate of the statistical qualities is often
72 reported, when the parallelization of a good PRNG is realized.
73 This is why ad-hoc PRNGs for each possible architecture must be found to
74 achieve both speed and randomness.
75 On the other side, speed is not the main requirement in cryptography: the great
76 need is to define \emph{secure} generators being able to withstand malicious
77 attacks. Roughly speaking, an attacker should not be able in practice to make 
78 the distinction between numbers obtained with the secure generator and a true random
79 sequence. 
80 Finally, a small part of the community working in this domain focus on a
81 third requirement, that is to define chaotic generators.
82 The main idea is to take benefits from a chaotic dynamical system to obtain a
83 generator that is unpredictable, disordered, sensible to its seed, or in other words chaotic.
84 Their desire is to map a given chaotic dynamics into a sequence that seems random 
85 and unassailable due to chaos.
86 However, the chaotic maps used as a pattern are defined in the real line 
87 whereas computers deal with finite precision numbers.
88 This distortion leads to a deflation of both chaotic properties and speed.
89 Furthermore, authors of such chaotic generators often claim their PRNG
90 as secure due to their chaos properties, but there is no obvious relation
91 between chaos and security as it is understood in cryptography.
92 This is why the use of chaos for PRNG still remains marginal and disputable.
93
94 The authors' opinion is that topological properties of disorder, as they are
95 properly defined in the mathematical theory of chaos, can reinforce the quality
96 of a PRNG. But they are not substitutable for security or statistical perfection.
97 Indeed, to the authors' point of view, such properties can be useful in the two following situations. On the
98 one hand, a post-treatment based on a chaotic dynamical system can be applied
99 to a PRNG statistically deflective, in order to improve its statistical 
100 properties. Such an improvement can be found, for instance, in~\cite{bgw09:ip,bcgr11:ip}.
101 On the other hand, chaos can be added to a fast, statistically perfect PRNG and/or a
102 cryptographically secure one, in case where chaos can be of interest,
103 \emph{only if these last properties are not lost during
104 the proposed post-treatment}. Such an assumption is behind this research work.
105 It leads to the attempts to define a 
106 family of PRNGs that are chaotic while being fast and statistically perfect,
107 or cryptographically secure.
108 Let us finish this paragraph by noticing that, in this paper, 
109 statistical perfection refers to the ability to pass the whole 
110 {\it BigCrush} battery of tests, which is widely considered as the most
111 stringent statistical evaluation of a sequence claimed as random.
112 This battery can be found into the well-known TestU01 package.
113 Chaos, for its part, refers to the well-established definition of a
114 chaotic dynamical system proposed by Devaney~\cite{Devaney}.
115
116
117 In a previous work~\cite{bgw09:ip,guyeux10} we have proposed a post-treatment on PRNGs making them behave
118 as a chaotic dynamical system. Such a post-treatment leads to a new category of
119 PRNGs. We have shown that proofs of Devaney's chaos can be established for this
120 family, and that the sequence obtained after this post-treatment can pass the
121 NIST, DieHARD, and TestU01 batteries of tests, even if the inputted generators
122 cannot.
123 The proposition of this paper is to improve widely the speed of the formerly
124 proposed generator, without any lack of chaos or statistical properties.
125 In particular, a version of this PRNG on graphics processing units (GPU)
126 is proposed.
127 Although GPU was initially designed  to accelerate
128 the manipulation of  images, they are nowadays commonly  used in many scientific
129 applications. Therefore,  it is important  to be able to  generate pseudorandom
130 numbers inside a GPU when a scientific application runs in it. This remark
131 motivates our proposal of a chaotic and statistically perfect PRNG for GPU.  
132 Such device
133 allows us to generated almost 20 billions of pseudorandom numbers per second.
134 Last, but not least, we show that the proposed post-treatment preserves the
135 cryptographical security of the inputted PRNG, when this last has such a 
136 property.
137
138 The remainder of this paper  is organized as follows. In Section~\ref{section:related
139   works} we  review some GPU implementations  of PRNGs.  Section~\ref{section:BASIC
140   RECALLS} gives some basic recalls  on the well-known Devaney's formulation of chaos, 
141   and on an iteration process called ``chaotic
142 iterations'' on which the post-treatment is based. 
143 Proofs of chaos are given in  Section~\ref{sec:pseudorandom}.
144 Section~\ref{sec:efficient    prng}   presents   an   efficient
145 implementation of  this chaotic PRNG  on a CPU, whereas   Section~\ref{sec:efficient prng
146   gpu}   describes   the  GPU   implementation. 
147 Such generators are experimented in 
148 Section~\ref{sec:experiments}.
149 We show in Section~\ref{sec:security analysis} that, if the inputted
150 generator is cryptographically secure, then it is the case too for the
151 generator provided by the post-treatment.
152 Such a proof leads to the proposition of a cryptographically secure and
153 chaotic generator on GPU based on the famous Blum Blum Shum
154 in Section~\ref{sec:CSGPU}.
155 This research work ends by a conclusion section, in which the contribution is
156 summarized and intended future work is presented.
157
158
159
160
161 \section{Related works on GPU based PRNGs}
162 \label{section:related works}
163 In the litterature many authors have work on defining GPU based PRNGs. We do not
164 want to be exhaustive and we just give the most significant works from our point
165 of view. When authors mention the  number of random numbers generated per second
166 we mention  it. We  consider that  a million numbers  per second  corresponds to
167 1MSample/s and than a billion numbers per second corresponds to 1GSample/s.
168
169 In \cite{Pang:2008:cec},  the authors define  a PRNG based on  cellular automata
170 which  does   not  require  high  precision  integer   arithmetics  nor  bitwise
171 operations. There is no mention of statistical tests nor proof that this PRNG is
172 chaotic.  Concerning   the  speed  of   generation,  they  can   generate  about
173 3.2MSample/s on a GeForce 7800 GTX GPU (which is quite old now).
174
175 In \cite{ZRKB10}, the authors propose  different versions of efficient GPU PRNGs
176 based on  Lagged Fibonacci, Hybrid  Taus or Hybrid  Taus.  They have  used these
177 PRNGs   for  Langevin   simulations   of  biomolecules   fully  implemented   on
178 GPU. Performance of  the GPU versions are far better than  those obtained with a
179 CPU and these PRNGs succeed to pass the {\it BigCrush} test of TestU01. There is
180 no mention that their PRNGs have chaos mathematical properties.
181
182
183 Authors of~\cite{conf/fpga/ThomasHL09}  have studied the  implementation of some
184 PRNGs on  diferrent computing architectures: CPU,  field-programmable gate array
185 (FPGA), GPU and massively parallel  processor. This study is interesting because
186 it  shows the  performance  of the  same  PRNGs on  different architeture.   For
187 example,  the FPGA  is globally  the  fastest architecture  and it  is also  the
188 efficient one because it provides the fastest number of generated random numbers
189 per joule. Concerning the GPU,  authors can generate betweend 11 and 16GSample/s
190 with a GTX 280  GPU. The drawback of this work is  that those PRNGs only succeed
191 the {\it Crush} test which is easier than the {\it Big Crush} test.
192
193 Cuda  has developped  a  library for  the  generation of  random numbers  called
194 Curand~\cite{curand11}.        Several       PRNGs        are       implemented:
195 Xorwow~\cite{Marsaglia2003} and  some variants of Sobol. Some  tests report that
196 the  fastest version provides  15GSample/s on  the new  Fermi C2050  card. Their
197 PRNGs fail to succeed the whole tests of TestU01 on only one test.
198 \newline
199 \newline
200 To the best of our knowledge no GPU implementation have been proven to have chaotic properties.
201
202 \section{Basic Recalls}
203 \label{section:BASIC RECALLS}
204 This section is devoted to basic definitions and terminologies in the fields of
205 topological chaos and chaotic iterations.
206 \subsection{Devaney's Chaotic Dynamical Systems}
207
208 In the sequel $S^{n}$ denotes the $n^{th}$ term of a sequence $S$ and $V_{i}$
209 denotes the $i^{th}$ component of a vector $V$. $f^{k}=f\circ ...\circ f$
210 is for the $k^{th}$ composition of a function $f$. Finally, the following
211 notation is used: $\llbracket1;N\rrbracket=\{1,2,\hdots,N\}$.
212
213
214 Consider a topological space $(\mathcal{X},\tau)$ and a continuous function $f :
215 \mathcal{X} \rightarrow \mathcal{X}$.
216
217 \begin{definition}
218 $f$ is said to be \emph{topologically transitive} if, for any pair of open sets
219 $U,V \subset \mathcal{X}$, there exists $k>0$ such that $f^k(U) \cap V \neq
220 \varnothing$.
221 \end{definition}
222
223 \begin{definition}
224 An element $x$ is a \emph{periodic point} for $f$ of period $n\in \mathds{N}^*$
225 if $f^{n}(x)=x$.% The set of periodic points of $f$ is denoted $Per(f).$
226 \end{definition}
227
228 \begin{definition}
229 $f$ is said to be \emph{regular} on $(\mathcal{X}, \tau)$ if the set of periodic
230 points for $f$ is dense in $\mathcal{X}$: for any point $x$ in $\mathcal{X}$,
231 any neighborhood of $x$ contains at least one periodic point (without
232 necessarily the same period).
233 \end{definition}
234
235
236 \begin{definition}[Devaney's formulation of chaos~\cite{Devaney}]
237 $f$ is said to be \emph{chaotic} on $(\mathcal{X},\tau)$ if $f$ is regular and
238 topologically transitive.
239 \end{definition}
240
241 The chaos property is strongly linked to the notion of ``sensitivity'', defined
242 on a metric space $(\mathcal{X},d)$ by:
243
244 \begin{definition}
245 \label{sensitivity} $f$ has \emph{sensitive dependence on initial conditions}
246 if there exists $\delta >0$ such that, for any $x\in \mathcal{X}$ and any
247 neighborhood $V$ of $x$, there exist $y\in V$ and $n > 0$ such that
248 $d\left(f^{n}(x), f^{n}(y)\right) >\delta $.
249
250 $\delta$ is called the \emph{constant of sensitivity} of $f$.
251 \end{definition}
252
253 Indeed, Banks \emph{et al.} have proven in~\cite{Banks92} that when $f$ is
254 chaotic and $(\mathcal{X}, d)$ is a metric space, then $f$ has the property of
255 sensitive dependence on initial conditions (this property was formerly an
256 element of the definition of chaos). To sum up, quoting Devaney
257 in~\cite{Devaney}, a chaotic dynamical system ``is unpredictable because of the
258 sensitive dependence on initial conditions. It cannot be broken down or
259 simplified into two subsystems which do not interact because of topological
260 transitivity. And in the midst of this random behavior, we nevertheless have an
261 element of regularity''. Fundamentally different behaviors are consequently
262 possible and occur in an unpredictable way.
263
264
265
266 \subsection{Chaotic Iterations}
267 \label{sec:chaotic iterations}
268
269
270 Let us consider  a \emph{system} with a finite  number $\mathsf{N} \in
271 \mathds{N}^*$ of elements  (or \emph{cells}), so that each  cell has a
272 Boolean  \emph{state}. Having $\mathsf{N}$ Boolean values for these
273  cells  leads to the definition of a particular \emph{state  of the
274 system}. A sequence which  elements belong to $\llbracket 1;\mathsf{N}
275 \rrbracket $ is called a \emph{strategy}. The set of all strategies is
276 denoted by $\llbracket 1, \mathsf{N} \rrbracket^\mathds{N}.$
277
278 \begin{definition}
279 \label{Def:chaotic iterations}
280 The      set       $\mathds{B}$      denoting      $\{0,1\}$,      let
281 $f:\mathds{B}^{\mathsf{N}}\longrightarrow  \mathds{B}^{\mathsf{N}}$ be
282 a  function  and  $S\in  \llbracket 1, \mathsf{N} \rrbracket^\mathds{N}$  be  a  ``strategy''.  The  so-called
283 \emph{chaotic      iterations}     are     defined      by     $x^0\in
284 \mathds{B}^{\mathsf{N}}$ and
285 \begin{equation}
286 \forall    n\in     \mathds{N}^{\ast     },    \forall     i\in
287 \llbracket1;\mathsf{N}\rrbracket ,x_i^n=\left\{
288 \begin{array}{ll}
289   x_i^{n-1} &  \text{ if  }S^n\neq i \\
290   \left(f(x^{n-1})\right)_{S^n} & \text{ if }S^n=i.
291 \end{array}\right.
292 \end{equation}
293 \end{definition}
294
295 In other words, at the $n^{th}$ iteration, only the $S^{n}-$th cell is
296 \textquotedblleft  iterated\textquotedblright .  Note  that in  a more
297 general  formulation,  $S^n$  can   be  a  subset  of  components  and
298 $\left(f(x^{n-1})\right)_{S^{n}}$      can     be      replaced     by
299 $\left(f(x^{k})\right)_{S^{n}}$, where  $k<n$, describing for example,
300 delays  transmission~\cite{Robert1986,guyeux10}.  Finally,  let us  remark that
301 the term  ``chaotic'', in  the name of  these iterations,  has \emph{a
302 priori} no link with the mathematical theory of chaos, presented above.
303
304
305 Let us now recall how to define a suitable metric space where chaotic iterations
306 are continuous. For further explanations, see, e.g., \cite{guyeux10}.
307
308 Let $\delta $ be the \emph{discrete Boolean metric}, $\delta
309 (x,y)=0\Leftrightarrow x=y.$ Given a function $f$, define the function:
310 \begin{equation}
311 \begin{array}{lrll}
312 F_{f}: & \llbracket1;\mathsf{N}\rrbracket\times \mathds{B}^{\mathsf{N}} &
313 \longrightarrow & \mathds{B}^{\mathsf{N}} \\
314 & (k,E) & \longmapsto & \left( E_{j}.\delta (k,j)+f(E)_{k}.\overline{\delta
315 (k,j)}\right) _{j\in \llbracket1;\mathsf{N}\rrbracket},%
316 \end{array}%
317 \end{equation}%
318 \noindent where + and . are the Boolean addition and product operations.
319 Consider the phase space:
320 \begin{equation}
321 \mathcal{X} = \llbracket 1 ; \mathsf{N} \rrbracket^\mathds{N} \times
322 \mathds{B}^\mathsf{N},
323 \end{equation}
324 \noindent and the map defined on $\mathcal{X}$:
325 \begin{equation}
326 G_f\left(S,E\right) = \left(\sigma(S), F_f(i(S),E)\right), \label{Gf}
327 \end{equation}
328 \noindent where $\sigma$ is the \emph{shift} function defined by $\sigma
329 (S^{n})_{n\in \mathds{N}}\in \llbracket 1, \mathsf{N} \rrbracket^\mathds{N}\longrightarrow (S^{n+1})_{n\in
330 \mathds{N}}\in \llbracket 1, \mathsf{N} \rrbracket^\mathds{N}$ and $i$ is the \emph{initial function} 
331 $i:(S^{n})_{n\in \mathds{N}} \in \llbracket 1, \mathsf{N} \rrbracket^\mathds{N}\longrightarrow S^{0}\in \llbracket
332 1;\mathsf{N}\rrbracket$. Then the chaotic iterations proposed in
333 Definition \ref{Def:chaotic iterations} can be described by the following iterations:
334 \begin{equation}
335 \left\{
336 \begin{array}{l}
337 X^0 \in \mathcal{X} \\
338 X^{k+1}=G_{f}(X^k).%
339 \end{array}%
340 \right.
341 \end{equation}%
342
343 With this formulation, a shift function appears as a component of chaotic
344 iterations. The shift function is a famous example of a chaotic
345 map~\cite{Devaney} but its presence is not sufficient enough to claim $G_f$ as
346 chaotic. 
347 To study this claim, a new distance between two points $X = (S,E), Y =
348 (\check{S},\check{E})\in
349 \mathcal{X}$ has been introduced in \cite{guyeux10} as follows:
350 \begin{equation}
351 d(X,Y)=d_{e}(E,\check{E})+d_{s}(S,\check{S}),
352 \end{equation}
353 \noindent where
354 \begin{equation}
355 \left\{
356 \begin{array}{lll}
357 \displaystyle{d_{e}(E,\check{E})} & = & \displaystyle{\sum_{k=1}^{\mathsf{N}%
358 }\delta (E_{k},\check{E}_{k})}, \\
359 \displaystyle{d_{s}(S,\check{S})} & = & \displaystyle{\dfrac{9}{\mathsf{N}}%
360 \sum_{k=1}^{\infty }\dfrac{|S^k-\check{S}^k|}{10^{k}}}.%
361 \end{array}%
362 \right.
363 \end{equation}
364
365
366 This new distance has been introduced to satisfy the following requirements.
367 \begin{itemize}
368 \item When the number of different cells between two systems is increasing, then
369 their distance should increase too.
370 \item In addition, if two systems present the same cells and their respective
371 strategies start with the same terms, then the distance between these two points
372 must be small because the evolution of the two systems will be the same for a
373 while. Indeed, the two dynamical systems start with the same initial condition,
374 use the same update function, and as strategies are the same for a while, then
375 components that are updated are the same too.
376 \end{itemize}
377 The distance presented above follows these recommendations. Indeed, if the floor
378 value $\lfloor d(X,Y)\rfloor $ is equal to $n$, then the systems $E, \check{E}$
379 differ in $n$ cells ($d_e$ is indeed the Hamming distance). In addition, $d(X,Y) - \lfloor d(X,Y) \rfloor $ is a
380 measure of the differences between strategies $S$ and $\check{S}$. More
381 precisely, this floating part is less than $10^{-k}$ if and only if the first
382 $k$ terms of the two strategies are equal. Moreover, if the $k^{th}$ digit is
383 nonzero, then the $k^{th}$ terms of the two strategies are different.
384 The impact of this choice for a distance will be investigate at the end of the document.
385
386 Finally, it has been established in \cite{guyeux10} that,
387
388 \begin{proposition}
389 Let $f$ be a map from $\mathds{B}^\mathsf{N}$ to itself. Then $G_{f}$ is continuous in
390 the metric space $(\mathcal{X},d)$.
391 \end{proposition}
392
393 The chaotic property of $G_f$ has been firstly established for the vectorial
394 Boolean negation $f(x_1,\hdots, x_\mathsf{N}) =  (\overline{x_1},\hdots, \overline{x_\mathsf{N}})$ \cite{guyeux10}. To obtain a characterization, we have secondly
395 introduced the notion of asynchronous iteration graph recalled bellow.
396
397 Let $f$ be a map from $\mathds{B}^\mathsf{N}$ to itself. The
398 {\emph{asynchronous iteration graph}} associated with $f$ is the
399 directed graph $\Gamma(f)$ defined by: the set of vertices is
400 $\mathds{B}^\mathsf{N}$; for all $x\in\mathds{B}^\mathsf{N}$ and 
401 $i\in \llbracket1;\mathsf{N}\rrbracket$,
402 the graph $\Gamma(f)$ contains an arc from $x$ to $F_f(i,x)$. 
403 The relation between $\Gamma(f)$ and $G_f$ is clear: there exists a
404 path from $x$ to $x'$ in $\Gamma(f)$ if and only if there exists a
405 strategy $s$ such that the parallel iteration of $G_f$ from the
406 initial point $(s,x)$ reaches the point $x'$.
407
408 We have finally proven in \cite{bcgr11:ip} that,
409
410
411 \begin{theorem}
412 \label{Th:Caractérisation   des   IC   chaotiques}  
413 Let $f:\mathds{B}^\mathsf{N}\to\mathds{B}^\mathsf{N}$. $G_f$ is chaotic  (according to  Devaney) 
414 if and only if $\Gamma(f)$ is strongly connected.
415 \end{theorem}
416
417 This result of chaos has lead us to study the possibility to build a
418 pseudorandom number generator (PRNG) based on the chaotic iterations. 
419 As $G_f$, defined on the domain   $\llbracket 1 ;  \mathsf{N} \rrbracket^{\mathds{N}} 
420 \times \mathds{B}^\mathsf{N}$, is build from Boolean networks $f : \mathds{B}^\mathsf{N}
421 \rightarrow \mathds{B}^\mathsf{N}$, we can preserve the theoretical properties on $G_f$
422 during implementations (due to the discrete nature of $f$). It is as if
423 $\mathds{B}^\mathsf{N}$ represents the memory of the computer whereas $\llbracket 1 ;  \mathsf{N}
424 \rrbracket^{\mathds{N}}$ is its input stream (the seeds, for instance).
425
426 \section{Application to pseudorandomness}
427 \label{sec:pseudorandom}
428 \subsection{A First pseudorandom Number Generator}
429
430 We have proposed in~\cite{bgw09:ip} a new family of generators that receives 
431 two PRNGs as inputs. These two generators are mixed with chaotic iterations, 
432 leading thus to a new PRNG that improves the statistical properties of each
433 generator taken alone. Furthermore, our generator 
434 possesses various chaos properties that none of the generators used as input
435 present.
436
437 \begin{algorithm}[h!]
438 %\begin{scriptsize}
439 \KwIn{a function $f$, an iteration number $b$, an initial configuration $x^0$
440 ($n$ bits)}
441 \KwOut{a configuration $x$ ($n$ bits)}
442 $x\leftarrow x^0$\;
443 $k\leftarrow b + \textit{XORshift}(b)$\;
444 \For{$i=0,\dots,k$}
445 {
446 $s\leftarrow{\textit{XORshift}(n)}$\;
447 $x\leftarrow{F_f(s,x)}$\;
448 }
449 return $x$\;
450 %\end{scriptsize}
451 \caption{PRNG with chaotic functions}
452 \label{CI Algorithm}
453 \end{algorithm}
454
455 \begin{algorithm}[h!]
456 \KwIn{the internal configuration $z$ (a 32-bit word)}
457 \KwOut{$y$ (a 32-bit word)}
458 $z\leftarrow{z\oplus{(z\ll13)}}$\;
459 $z\leftarrow{z\oplus{(z\gg17)}}$\;
460 $z\leftarrow{z\oplus{(z\ll5)}}$\;
461 $y\leftarrow{z}$\;
462 return $y$\;
463 \medskip
464 \caption{An arbitrary round of \textit{XORshift} algorithm}
465 \label{XORshift}
466 \end{algorithm}
467
468
469
470
471
472 This generator is synthesized in Algorithm~\ref{CI Algorithm}.
473 It takes as input: a function $f$;
474 an integer $b$, ensuring that the number of executed iterations is at least $b$
475 and at most $2b+1$; and an initial configuration $x^0$.
476 It returns the new generated configuration $x$.  Internally, it embeds two
477 \textit{XORshift}$(k)$ PRNGs~\cite{Marsaglia2003} that returns integers
478 uniformly distributed
479 into $\llbracket 1 ; k \rrbracket$.
480 \textit{XORshift} is a category of very fast PRNGs designed by George Marsaglia,
481 which repeatedly uses the transform of exclusive or (XOR, $\oplus$) on a number
482 with a bit shifted version of it. This PRNG, which has a period of
483 $2^{32}-1=4.29\times10^9$, is summed up in Algorithm~\ref{XORshift}. It is used
484 in our PRNG to compute the strategy length and the strategy elements.
485
486
487 We have proven in \cite{bcgr11:ip} that,
488 \begin{theorem}
489   Let $f: \mathds{B}^{n} \rightarrow \mathds{B}^{n}$, $\Gamma(f)$ its
490   iteration graph, $\check{M}$ its adjacency
491   matrix and $M$ a $n\times n$ matrix defined as in the previous lemma.
492   If $\Gamma(f)$ is strongly connected, then 
493   the output of the PRNG detailed in Algorithm~\ref{CI Algorithm} follows 
494   a law that tends to the uniform distribution 
495   if and only if $M$ is a double stochastic matrix.
496 \end{theorem} 
497
498 This former generator as successively passed various batteries of statistical tests, as the NIST tests~\cite{bcgr11:ip}.
499
500 \subsection{Improving the Speed of the Former Generator}
501
502 Instead of updating only one cell at each iteration, we can try to choose a
503 subset of components and to update them together. Such an attempt leads
504 to a kind of merger of the two sequences used in Algorithm 
505 \ref{CI Algorithm}. When the updating function is the vectorial negation,
506 this algorithm can be rewritten as follows:
507
508 \begin{equation}
509 \left\{
510 \begin{array}{l}
511 x^0 \in \llbracket 0, 2^\mathsf{N}-1 \rrbracket, S \in \llbracket 0, 2^\mathsf{N}-1 \rrbracket^\mathds{N} \\
512 \forall n \in \mathds{N}^*, x^n = x^{n-1} \oplus S^n,
513 \end{array}
514 \right.
515 \label{equation Oplus}
516 \end{equation}
517 where $\oplus$ is for the bitwise exclusive or between two integers. 
518 This rewritten can be understood as follows. The $n-$th term $S^n$ of the
519 sequence $S$, which is an integer of $\mathsf{N}$ binary digits, presents
520 the list of cells to update in the state $x^n$ of the system (represented
521 as an integer having $\mathsf{N}$ bits too). More precisely, the $k-$th 
522 component of this state (a binary digit) changes if and only if the $k-$th 
523 digit in the binary decomposition of $S^n$ is 1.
524
525 The single basic component presented in Eq.~\ref{equation Oplus} is of 
526 ordinary use as a good elementary brick in various PRNGs. It corresponds
527 to the following discrete dynamical system in chaotic iterations:
528
529 \begin{equation}
530 \forall    n\in     \mathds{N}^{\ast     },    \forall     i\in
531 \llbracket1;\mathsf{N}\rrbracket ,x_i^n=\left\{
532 \begin{array}{ll}
533   x_i^{n-1} &  \text{ if  } i \notin \mathcal{S}^n \\
534   \left(f(x^{n-1})\right)_{S^n} & \text{ if }i \in \mathcal{S}^n.
535 \end{array}\right.
536 \label{eq:generalIC}
537 \end{equation}
538 where $f$ is the vectorial negation and $\forall n \in \mathds{N}$, 
539 $\mathcal{S}^n \subset \llbracket 1, \mathsf{N} \rrbracket$ is such that
540 $k \in \mathcal{S}^n$ if and only if the $k-$th digit in the binary
541 decomposition of $S^n$ is 1. Such chaotic iterations are more general
542 than the ones presented in Definition \ref{Def:chaotic iterations} for 
543 the fact that, instead of updating only one term at each iteration,
544 we select a subset of components to change.
545
546
547 Obviously, replacing Algorithm~\ref{CI Algorithm} by 
548 Equation~\ref{equation Oplus}, possible when the iteration function is
549 the vectorial negation, leads to a speed improvement. However, proofs
550 of chaos obtained in~\cite{bg10:ij} have been established
551 only for chaotic iterations of the form presented in Definition 
552 \ref{Def:chaotic iterations}. The question is now to determine whether the
553 use of more general chaotic iterations to generate pseudorandom numbers 
554 faster, does not deflate their topological chaos properties.
555
556 \subsection{Proofs of Chaos of the General Formulation of the Chaotic Iterations}
557 \label{deuxième def}
558 Let us consider the discrete dynamical systems in chaotic iterations having 
559 the general form:
560
561 \begin{equation}
562 \forall    n\in     \mathds{N}^{\ast     },    \forall     i\in
563 \llbracket1;\mathsf{N}\rrbracket ,x_i^n=\left\{
564 \begin{array}{ll}
565   x_i^{n-1} &  \text{ if  } i \notin \mathcal{S}^n \\
566   \left(f(x^{n-1})\right)_{S^n} & \text{ if }i \in \mathcal{S}^n.
567 \end{array}\right.
568 \label{general CIs}
569 \end{equation}
570
571 In other words, at the $n^{th}$ iteration, only the cells whose id is
572 contained into the set $S^{n}$ are iterated.
573
574 Let us now rewrite these general chaotic iterations as usual discrete dynamical
575 system of the form $X^{n+1}=f(X^n)$ on an ad hoc metric space. Such a formulation
576 is required in order to study the topological behavior of the system.
577
578 Let us introduce the following function:
579 \begin{equation}
580 \begin{array}{cccc}
581  \chi: & \llbracket 1; \mathsf{N} \rrbracket \times \mathcal{P}\left(\llbracket 1; \mathsf{N} \rrbracket\right) & \longrightarrow & \mathds{B}\\
582          & (i,X) & \longmapsto  & \left\{ \begin{array}{ll} 0 & \textrm{if }i \notin X, \\ 1 & \textrm{if }i \in X,  \end{array}\right.
583 \end{array} 
584 \end{equation}
585 where $\mathcal{P}\left(X\right)$ is for the powerset of the set $X$, that is, $Y \in \mathcal{P}\left(X\right) \Longleftrightarrow Y \subset X$.
586
587 Given a function $f:\mathds{B}^\mathsf{N} \longrightarrow \mathds{B}^\mathsf{N} $, define the function:
588 \begin{equation}
589 \begin{array}{lrll}
590 F_{f}: & \mathcal{P}\left(\llbracket1;\mathsf{N}\rrbracket \right) \times \mathds{B}^{\mathsf{N}} &
591 \longrightarrow & \mathds{B}^{\mathsf{N}} \\
592 & (P,E) & \longmapsto & \left( E_{j}.\chi (j,P)+f(E)_{j}.\overline{\chi
593 (j,P)}\right) _{j\in \llbracket1;\mathsf{N}\rrbracket},%
594 \end{array}%
595 \end{equation}%
596 where + and . are the Boolean addition and product operations, and $\overline{x}$ 
597 is the negation of the Boolean $x$.
598 Consider the phase space:
599 \begin{equation}
600 \mathcal{X} = \mathcal{P}\left(\llbracket 1 ; \mathsf{N} \rrbracket\right)^\mathds{N} \times
601 \mathds{B}^\mathsf{N},
602 \end{equation}
603 \noindent and the map defined on $\mathcal{X}$:
604 \begin{equation}
605 G_f\left(S,E\right) = \left(\sigma(S), F_f(i(S),E)\right), \label{Gf}
606 \end{equation}
607 \noindent where $\sigma$ is the \emph{shift} function defined by $\sigma
608 (S^{n})_{n\in \mathds{N}}\in \mathcal{P}\left(\llbracket 1 ; \mathsf{N} \rrbracket\right)^\mathds{N}\longrightarrow (S^{n+1})_{n\in
609 \mathds{N}}\in \mathcal{P}\left(\llbracket 1 ; \mathsf{N} \rrbracket\right)^\mathds{N}$ and $i$ is the \emph{initial function} 
610 $i:(S^{n})_{n\in \mathds{N}} \in \mathcal{P}\left(\llbracket 1 ; \mathsf{N} \rrbracket\right)^\mathds{N}\longrightarrow S^{0}\in \mathcal{P}\left(\llbracket 1 ; \mathsf{N} \rrbracket\right)$. 
611 Then the general chaotic iterations defined in Equation \ref{general CIs} can 
612 be described by the following discrete dynamical system:
613 \begin{equation}
614 \left\{
615 \begin{array}{l}
616 X^0 \in \mathcal{X} \\
617 X^{k+1}=G_{f}(X^k).%
618 \end{array}%
619 \right.
620 \end{equation}%
621
622 Another time, a shift function appears as a component of these general chaotic 
623 iterations. 
624
625 To study the Devaney's chaos property, a distance between two points 
626 $X = (S,E), Y = (\check{S},\check{E})$ of $\mathcal{X}$ must be defined.
627 Let us introduce:
628 \begin{equation}
629 d(X,Y)=d_{e}(E,\check{E})+d_{s}(S,\check{S}),
630 \label{nouveau d}
631 \end{equation}
632 \noindent where
633 \begin{equation}
634 \left\{
635 \begin{array}{lll}
636 \displaystyle{d_{e}(E,\check{E})} & = & \displaystyle{\sum_{k=1}^{\mathsf{N}%
637 }\delta (E_{k},\check{E}_{k})}\textrm{ is another time the Hamming distance}, \\
638 \displaystyle{d_{s}(S,\check{S})} & = & \displaystyle{\dfrac{9}{\mathsf{N}}%
639 \sum_{k=1}^{\infty }\dfrac{|S^k\Delta {S}^k|}{10^{k}}}.%
640 \end{array}%
641 \right.
642 \end{equation}
643 where $|X|$ is the cardinality of a set $X$ and $A\Delta B$ is for the symmetric difference, defined for sets A, B as
644 $A\,\Delta\,B = (A \setminus B) \cup (B \setminus A)$.
645
646
647 \begin{proposition}
648 The function $d$ defined in Eq.~\ref{nouveau d} is a metric on $\mathcal{X}$.
649 \end{proposition}
650
651 \begin{proof}
652  $d_e$ is the Hamming distance. We will prove that $d_s$ is a distance
653 too, thus $d$ will be a distance as sum of two distances.
654  \begin{itemize}
655 \item Obviously, $d_s(S,\check{S})\geqslant 0$, and if $S=\check{S}$, then 
656 $d_s(S,\check{S})=0$. Conversely, if $d_s(S,\check{S})=0$, then 
657 $\forall k \in \mathds{N}, |S^k\Delta {S}^k|=0$, and so $\forall k, S^k=\check{S}^k$.
658  \item $d_s$ is symmetric 
659 ($d_s(S,\check{S})=d_s(\check{S},S)$) due to the commutative property
660 of the symmetric difference. 
661 \item Finally, $|S \Delta S''| = |(S \Delta \varnothing) \Delta S''|= |S \Delta (S'\Delta S') \Delta S''|= |(S \Delta S') \Delta (S' \Delta S'')|\leqslant |S \Delta S'| + |S' \Delta S''|$, 
662 and so for all subsets $S,S',$ and $S''$ of $\llbracket 1, \mathsf{N} \rrbracket$, 
663 we have $d_s(S,S'') \leqslant d_e(S,S')+d_s(S',S'')$, and the triangle
664 inequality is obtained.
665  \end{itemize}
666 \end{proof}
667
668
669 Before being able to study the topological behavior of the general 
670 chaotic iterations, we must firstly establish that:
671
672 \begin{proposition}
673  For all $f:\mathds{B}^\mathsf{N} \longrightarrow \mathds{B}^\mathsf{N} $, the function $G_f$ is continuous on 
674 $\left( \mathcal{X},d\right)$.
675 \end{proposition}
676
677
678 \begin{proof}
679 We use the sequential continuity.
680 Let $(S^n,E^n)_{n\in \mathds{N}}$ be a sequence of the phase space $%
681 \mathcal{X}$, which converges to $(S,E)$. We will prove that $\left(
682 G_{f}(S^n,E^n)\right) _{n\in \mathds{N}}$ converges to $\left(
683 G_{f}(S,E)\right) $. Let us remark that for all $n$, $S^n$ is a strategy,
684 thus, we consider a sequence of strategies (\emph{i.e.}, a sequence of
685 sequences).\newline
686 As $d((S^n,E^n);(S,E))$ converges to 0, each distance $d_{e}(E^n,E)$ and $d_{s}(S^n,S)$ converges
687 to 0. But $d_{e}(E^n,E)$ is an integer, so $\exists n_{0}\in \mathds{N},$ $%
688 d_{e}(E^n,E)=0$ for any $n\geqslant n_{0}$.\newline
689 In other words, there exists a threshold $n_{0}\in \mathds{N}$ after which no
690 cell will change its state:
691 $\exists n_{0}\in \mathds{N},n\geqslant n_{0}\Rightarrow E^n = E.$
692
693 In addition, $d_{s}(S^n,S)\longrightarrow 0,$ so $\exists n_{1}\in %
694 \mathds{N},d_{s}(S^n,S)<10^{-1}$ for all indexes greater than or equal to $%
695 n_{1}$. This means that for $n\geqslant n_{1}$, all the $S^n$ have the same
696 first term, which is $S^0$: $\forall n\geqslant n_{1},S_0^n=S_0.$
697
698 Thus, after the $max(n_{0},n_{1})^{th}$ term, states of $E^n$ and $E$ are
699 identical and strategies $S^n$ and $S$ start with the same first term.\newline
700 Consequently, states of $G_{f}(S^n,E^n)$ and $G_{f}(S,E)$ are equal,
701 so, after the $max(n_0, n_1)^{th}$ term, the distance $d$ between these two points is strictly less than 1.\newline
702 \noindent We now prove that the distance between $\left(
703 G_{f}(S^n,E^n)\right) $ and $\left( G_{f}(S,E)\right) $ is convergent to
704 0. Let $\varepsilon >0$. \medskip
705 \begin{itemize}
706 \item If $\varepsilon \geqslant 1$, we see that distance
707 between $\left( G_{f}(S^n,E^n)\right) $ and $\left( G_{f}(S,E)\right) $ is
708 strictly less than 1 after the $max(n_{0},n_{1})^{th}$ term (same state).
709 \medskip
710 \item If $\varepsilon <1$, then $\exists k\in \mathds{N},10^{-k}\geqslant
711 \varepsilon > 10^{-(k+1)}$. But $d_{s}(S^n,S)$ converges to 0, so
712 \begin{equation*}
713 \exists n_{2}\in \mathds{N},\forall n\geqslant
714 n_{2},d_{s}(S^n,S)<10^{-(k+2)},
715 \end{equation*}%
716 thus after $n_{2}$, the $k+2$ first terms of $S^n$ and $S$ are equal.
717 \end{itemize}
718 \noindent As a consequence, the $k+1$ first entries of the strategies of $%
719 G_{f}(S^n,E^n)$ and $G_{f}(S,E)$ are the same ($G_{f}$ is a shift of strategies) and due to the definition of $d_{s}$, the floating part of
720 the distance between $(S^n,E^n)$ and $(S,E)$ is strictly less than $%
721 10^{-(k+1)}\leqslant \varepsilon $.\bigskip \newline
722 In conclusion,
723 $$
724 \forall \varepsilon >0,\exists N_{0}=max(n_{0},n_{1},n_{2})\in \mathds{N}%
725 ,\forall n\geqslant N_{0},
726  d\left( G_{f}(S^n,E^n);G_{f}(S,E)\right)
727 \leqslant \varepsilon .
728 $$
729 $G_{f}$ is consequently continuous.
730 \end{proof}
731
732
733 It is now possible to study the topological behavior of the general chaotic
734 iterations. We will prove that,
735
736 \begin{theorem}
737 \label{t:chaos des general}
738  The general chaotic iterations defined on Equation~\ref{general CIs} satisfy
739 the Devaney's property of chaos.
740 \end{theorem}
741
742 Let us firstly prove the following lemma.
743
744 \begin{lemma}[Strong transitivity]
745 \label{strongTrans}
746  For all couples $X,Y \in \mathcal{X}$ and any neighborhood $V$ of $X$, we can 
747 find $n \in \mathds{N}^*$ and $X' \in V$ such that $G^n(X')=Y$.
748 \end{lemma}
749
750 \begin{proof}
751  Let $X=(S,E)$, $\varepsilon>0$, and $k_0 = \lfloor log_{10}(\varepsilon)+1 \rfloor$. 
752 Any point $X'=(S',E')$ such that $E'=E$ and $\forall k \leqslant k_0, S'^k=S^k$, 
753 are in the open ball $\mathcal{B}\left(X,\varepsilon\right)$. Let us define 
754 $\check{X} = \left(\check{S},\check{E}\right)$, where $\check{X}= G^{k_0}(X)$.
755 We denote by $s\subset \llbracket 1; \mathsf{N} \rrbracket$ the set of coordinates
756 that are different between $\check{E}$ and the state of $Y$. Thus each point $X'$ of
757 the form $(S',E')$ where $E'=E$ and $S'$ starts with 
758 $(S^0, S^1, \hdots, S^{k_0},s,\hdots)$, verifies the following properties:
759 \begin{itemize}
760  \item $X'$ is in $\mathcal{B}\left(X,\varepsilon\right)$,
761  \item the state of $G_f^{k_0+1}(X')$ is the state of $Y$.
762 \end{itemize}
763 Finally the point $\left(\left(S^0, S^1, \hdots, S^{k_0},s,s^0, s^1, \hdots\right); E\right)$, 
764 where $(s^0,s^1, \hdots)$ is the strategy of $Y$, satisfies the properties
765 claimed in the lemma.
766 \end{proof}
767
768 We can now prove the Theorem~\ref{t:chaos des general}...
769
770 \begin{proof}[Theorem~\ref{t:chaos des general}]
771 Firstly, strong transitivity implies transitivity.
772
773 Let $(S,E) \in\mathcal{X}$ and $\varepsilon >0$. To
774 prove that $G_f$ is regular, it is sufficient to prove that
775 there exists a strategy $\tilde S$ such that the distance between
776 $(\tilde S,E)$ and $(S,E)$ is less than $\varepsilon$, and such that
777 $(\tilde S,E)$ is a periodic point.
778
779 Let $t_1=\lfloor-\log_{10}(\varepsilon)\rfloor$, and let $E'$ be the
780 configuration that we obtain from $(S,E)$ after $t_1$ iterations of
781 $G_f$. As $G_f$ is strongly transitive, there exists a strategy $S'$ 
782 and $t_2\in\mathds{N}$ such
783 that $E$ is reached from $(S',E')$ after $t_2$ iterations of $G_f$.
784
785 Consider the strategy $\tilde S$ that alternates the first $t_1$ terms
786 of $S$ and the first $t_2$ terms of $S'$: $$\tilde
787 S=(S_0,\dots,S_{t_1-1},S'_0,\dots,S'_{t_2-1},S_0,\dots,S_{t_1-1},S'_0,\dots,S'_{t_2-1},S_0,\dots).$$ It
788 is clear that $(\tilde S,E)$ is obtained from $(\tilde S,E)$ after
789 $t_1+t_2$ iterations of $G_f$. So $(\tilde S,E)$ is a periodic
790 point. Since $\tilde S_t=S_t$ for $t<t_1$, by the choice of $t_1$, we
791 have $d((S,E),(\tilde S,E))<\epsilon$.
792 \end{proof}
793
794
795
796 \section{Efficient PRNG based on Chaotic Iterations}
797 \label{sec:efficient prng}
798
799 In  order to  implement efficiently  a PRNG  based on  chaotic iterations  it is
800 possible to improve  previous works [ref]. One solution  consists in considering
801 that the  strategy used contains all the  bits for which the  negation is
802 achieved out. Then in order to apply  the negation on these bits we can simply
803 apply the  xor operator between  the current number  and the strategy. In
804 order to obtain the strategy we also use a classical PRNG.
805
806 Here  is an  example with  16-bits numbers  showing how  the bitwise  operations
807 are
808 applied.  Suppose  that $x$ and the  strategy $S^i$ are defined  in binary mode.
809 Then the following table shows the result of $x$ xor $S^i$.
810 $$
811 \begin{array}{|cc|cccccccccccccccc|}
812 \hline
813 x      &=&1&0&1&1&1&0&1&0&1&0&0&1&0&0&1&0\\
814 \hline
815 S^i      &=&0&1&1&0&0&1&1&0&1&1&1&0&0&1&1&1\\
816 \hline
817 x \oplus S^i&=&1&1&0&1&1&1&0&0&0&1&1&1&0&1&0&1\\
818 \hline
819
820 \hline
821  \end{array}
822 $$
823
824
825
826
827
828 \lstset{language=C,caption={C code of the sequential chaotic iterations based
829 PRNG},label=algo:seqCIprng}
830 \begin{lstlisting}
831 unsigned int CIprng() {
832   static unsigned int x = 123123123;
833   unsigned long t1 = xorshift();
834   unsigned long t2 = xor128();
835   unsigned long t3 = xorwow();
836   x = x^(unsigned int)t1;
837   x = x^(unsigned int)(t2>>32);
838   x = x^(unsigned int)(t3>>32);
839   x = x^(unsigned int)t2;
840   x = x^(unsigned int)(t1>>32);
841   x = x^(unsigned int)t3;
842   return x;
843 }
844 \end{lstlisting}
845
846
847
848
849
850 In listing~\ref{algo:seqCIprng}  a sequential version of  our chaotic iterations
851 based PRNG is  presented.  The xor operator is  represented by \textasciicircum.
852 This  function uses  three classical  64-bits PRNG:  the  \texttt{xorshift}, the
853 \texttt{xor128}  and  the  \texttt{xorwow}.   In  the following,  we  call  them
854 xor-like PRNGSs.   These three PRNGs are  presented in~\cite{Marsaglia2003}.  As
855 each xor-like PRNG  used works with 64-bits and as our  PRNG works with 32-bits,
856 the use of \texttt{(unsigned int)} selects the 32 least significant bits whereas
857 \texttt{(unsigned int)(t3$>>$32)}  selects the 32 most significants  bits of the
858 variable \texttt{t}.   So to produce a  random number realizes  6 xor operations
859 with 6 32-bits  numbers produced by 3 64-bits PRNG.   This version successes the
860 BigCrush of the TestU01 battery~\cite{LEcuyerS07}.
861
862 \section{Efficient PRNGs based on chaotic iterations on GPU}
863 \label{sec:efficient prng gpu}
864
865 In  order to benefit  from computing  power of  GPU, a  program needs  to define
866 independent blocks of threads which  can be computed simultaneously. In general,
867 the larger the number of threads is,  the more local memory is used and the less
868 branching  instructions are  used (if,  while, ...),  the better  performance is
869 obtained  on  GPU.  So  with  algorithm  \ref{algo:seqCIprng}  presented in  the
870 previous section, it is possible to  build a similar program which computes PRNG
871 on   GPU.  In  the   CUDA~\cite{Nvid10}  environment,   threads  have   a  local
872 identificator, called \texttt{ThreadIdx} relative to the block containing them.
873
874
875 \subsection{Naive version for GPU}
876
877 From the CPU version, it is possible  to obtain a quite similar version for GPU.
878 The principe consists in assigning the computation of a PRNG as in sequential to
879 each thread  of the  GPU.  Of course,  it is  essential that the  three xor-like
880 PRNGs  used for  our computation  have different  parameters. So  we  chose them
881 randomly with  another PRNG. As the  initialisation is performed by  the CPU, we
882 have  chosen  to  use  the  ISAAC  PRNG~\cite{Jenkins96}  to  initalize  all  the
883 parameters for  the GPU version  of our PRNG.   The implementation of  the three
884 xor-like  PRNGs  is  straightforward  as  soon as  their  parameters  have  been
885 allocated in  the GPU memory.  Each xor-like PRNGs  used works with  an internal
886 number  $x$  which keeps  the  last  generated  random numbers.  Other  internal
887 variables  are   also  used   by  the  xor-like   PRNGs.  More   precisely,  the
888 implementation of the  xor128, the xorshift and the  xorwow respectively require
889 4, 5 and 6 unsigned long as internal variables.
890
891 \begin{algorithm}
892
893 \KwIn{InternalVarXorLikeArray: array with internal variables of the 3 xor-like
894 PRNGs in global memory\;
895 NumThreads: Number of threads\;}
896 \KwOut{NewNb: array containing random numbers in global memory}
897 \If{threadIdx is concerned by the computation} {
898   retrieve data from InternalVarXorLikeArray[threadIdx] in local variables\;
899   \For{i=1 to n} {
900     compute a new PRNG as in Listing\ref{algo:seqCIprng}\;
901     store the new PRNG in NewNb[NumThreads*threadIdx+i]\;
902   }
903   store internal variables in InternalVarXorLikeArray[threadIdx]\;
904 }
905
906 \caption{main kernel for the chaotic iterations based PRNG GPU naive version}
907 \label{algo:gpu_kernel}
908 \end{algorithm}
909
910 Algorithm~\ref{algo:gpu_kernel}  presents a naive  implementation of  PRNG using
911 GPU.  According  to the available  memory in the  GPU and the number  of threads
912 used simultenaously,  the number  of random numbers  that a thread  can generate
913 inside   a    kernel   is   limited,   i.e.    the    variable   \texttt{n}   in
914 algorithm~\ref{algo:gpu_kernel}. For example, if  $100,000$ threads are used and
915 if $n=100$\footnote{in fact, we need to add the initial seed (a 32-bits number)}
916 then   the  memory   required   to  store   internals   variables  of   xor-like
917 PRNGs\footnote{we multiply this number by $2$ in order to count 32-bits numbers}
918 and  random  number of  our  PRNG  is  equals to  $100,000\times  ((4+5+6)\times
919 2+(1+100))=1,310,000$ 32-bits numbers, i.e. about $52$Mb.
920
921 All the  tests performed  to pass the  BigCrush of TestU01  succeeded. Different
922 number of threads, called \texttt{NumThreads} in our algorithm, have been tested
923 upto $10$ millions.
924 \newline
925 \newline
926 {\bf QUESTION : on laisse cette remarque, je suis mitigé !!!}
927
928 \begin{remark}
929 Algorithm~\ref{algo:gpu_kernel}  has  the  advantage to  manipulate  independent
930 PRNGs, so this version is easily usable on a cluster of computer. The only thing
931 to ensure is to use a single ISAAC PRNG. For this, a simple solution consists in
932 using a master node for the initialization which computes the initial parameters
933 for all the differents nodes involves in the computation.
934 \end{remark}
935
936 \subsection{Improved version for GPU}
937
938 As GPU cards using CUDA have shared memory between threads of the same block, it
939 is possible  to use this  feature in order  to simplify the  previous algorithm,
940 i.e., using less  than 3 xor-like PRNGs. The solution  consists in computing only
941 one xor-like PRNG by thread, saving  it into shared memory and using the results
942 of some  other threads in the  same block of  threads. In order to  define which
943 thread uses the result of which other  one, we can use a permutation array which
944 contains  the indexes  of  all threads  and  for which  a  permutation has  been
945 performed.  In Algorithm~\ref{algo:gpu_kernel2}, 2 permutations arrays are used.
946 The    variable   \texttt{offset}    is    computed   using    the   value    of
947 \texttt{permutation\_size}.   Then we  can compute  \texttt{o1}  and \texttt{o2}
948 which represent the indexes of the  other threads for which the results are used
949 by the  current thread. In  the algorithm, we  consider that a  64-bits xor-like
950 PRNG is used, that is why both 32-bits parts are used.
951
952 This version also succeeds to the {\it BigCrush} batteries of tests.
953
954 \begin{algorithm}
955
956 \KwIn{InternalVarXorLikeArray: array with internal variables of 1 xor-like PRNGs
957 in global memory\;
958 NumThreads: Number of threads\;
959 tab1, tab2: Arrays containing permutations of size permutation\_size\;}
960
961 \KwOut{NewNb: array containing random numbers in global memory}
962 \If{threadId is concerned} {
963   retrieve data from InternalVarXorLikeArray[threadId] in local variables including shared memory and x\;
964   offset = threadIdx\%permutation\_size\;
965   o1 = threadIdx-offset+tab1[offset]\;
966   o2 = threadIdx-offset+tab2[offset]\;
967   \For{i=1 to n} {
968     t=xor-like()\;
969     t=t$\oplus$shmem[o1]$\oplus$shmem[o2]\;
970     shared\_mem[threadId]=t\;
971     x = x $\oplus$ t\;
972
973     store the new PRNG in NewNb[NumThreads*threadId+i]\;
974   }
975   store internal variables in InternalVarXorLikeArray[threadId]\;
976 }
977
978 \caption{main kernel for the chaotic iterations based PRNG GPU efficient
979 version}
980 \label{algo:gpu_kernel2}
981 \end{algorithm}
982
983 \subsection{Theoretical Evaluation of the Improved Version}
984
985 A run of Algorithm~\ref{algo:gpu_kernel2} consists in three operations having 
986 the form of Equation~\ref{equation Oplus}, which is equivalent to the iterative
987 system of Eq.~\ref{eq:generalIC}. That is, three iterations of the general chaotic
988 iterations are realized between two stored values of the PRNG.
989 To be certain that we are in the framework of Theorem~\ref{t:chaos des general},
990 we must guarantee that this dynamical system iterates on the space 
991 $\mathcal{X} = \mathcal{P}\left(\llbracket 1, \mathsf{N} \rrbracket\right)^\mathds{N}\times\mathds{B}^\mathsf{N}$.
992 The left term $x$ obviously belongs into $\mathds{B}^ \mathsf{N}$.
993 To prevent from any flaws of chaotic properties, we must check that each right 
994 term, corresponding to terms of the strategies,  can possibly be equal to any
995 integer of $\llbracket 1, \mathsf{N} \rrbracket$. 
996
997 Such a result is obvious for the two first lines, as for the xor-like(), all the
998 integers belonging into its interval of definition can occur at each iteration.
999 It can be easily stated for the two last lines by an immediate mathematical
1000 induction.
1001
1002 Thus Algorithm~\ref{algo:gpu_kernel2} is a concrete realization of the general
1003 chaotic iterations presented previously, and for this reason, it satisfies the 
1004 Devaney's formulation of a chaotic behavior.
1005
1006 \section{Experiments}
1007 \label{sec:experiments}
1008
1009 Different experiments  have been  performed in order  to measure  the generation
1010 speed. We have used  a computer equiped with Tesla C1060 NVidia  GPU card and an
1011 Intel  Xeon E5530 cadenced  at 2.40  GHz for  our experiments  and we  have used
1012 another one  equipped with  a less performant  CPU and  a GeForce GTX  280. Both
1013 cards have 240 cores.
1014
1015 In  Figure~\ref{fig:time_xorlike_gpu} we  compare the  number of  random numbers
1016 generated per second with the xor-like based PRNG. In this figure, the optimized
1017 version use the {\it xor64} described in~\cite{Marsaglia2003}. The naive version
1018 use  the three  xor-like  PRNGs described  in Listing~\ref{algo:seqCIprng}.   In
1019 order to obtain the optimal performance we removed the storage of random numbers
1020 in the GPU memory. This step is time consuming and slows down the random numbers
1021 generation.  Moreover, if one is  interested by applications that consume random
1022 numbers  directly   when  they  are  generated,  their   storage  are  completely
1023 useless. In this  figure we can see  that when the number of  threads is greater
1024 than approximately 30,000 upto 5 millions the number of random numbers generated
1025 per second  is almost constant.  With the  naive version, it is  between 2.5 and
1026 3GSample/s.   With  the  optimized   version,  it  is  approximately  equals  to
1027 20GSample/s. Finally  we can remark  that both GPU  cards are quite  similar. In
1028 practice,  the Tesla C1060  has more  memory than  the GTX  280 and  this memory
1029 should be of better quality.
1030
1031 \begin{figure}[htbp]
1032 \begin{center}
1033   \includegraphics[scale=.7]{curve_time_xorlike_gpu.pdf}
1034 \end{center}
1035 \caption{Number of random numbers generated per second with the xorlike based PRNG}
1036 \label{fig:time_xorlike_gpu}
1037 \end{figure}
1038
1039
1040 In  comparison,   Listing~\ref{algo:seqCIprng}  allows  us   to  generate  about
1041 138MSample/s with only one core of the Xeon E5530.
1042
1043
1044 In Figure~\ref{fig:time_bbs_gpu}  we highlight the performance  of the optimized
1045 BBS based  PRNG on GPU. Performances are  less important. On the  Tesla C1060 we
1046 obtain approximately 1.8GSample/s and on the GTX 280 about 1.6GSample/s.
1047
1048 \begin{figure}[htbp]
1049 \begin{center}
1050   \includegraphics[scale=.7]{curve_time_bbs_gpu.pdf}
1051 \end{center}
1052 \caption{Number of random numbers generated per second with the BBS based PRNG}
1053 \label{fig:time_bbs_gpu}
1054 \end{figure}
1055
1056 Both  these  experimentations allows  us  to conclude  that  it  is possible  to
1057 generate a  huge number of pseudorandom  numbers with the  xor-like version and
1058 about tens  times less with the BBS  based version. The former  version has only
1059 chaotic properties whereas the latter also has cryptographically properties.
1060
1061
1062 %% \section{Cryptanalysis of the Proposed PRNG}
1063
1064
1065 %% Mettre ici la preuve de PCH
1066
1067 %\section{The relativity of disorder}
1068 %\label{sec:de la relativité du désordre}
1069
1070 %In the next two sections, we investigate the impact of the choices that have
1071 %lead to the definitions of measures in Sections \ref{sec:chaotic iterations} and \ref{deuxième def}.
1072
1073 %\subsection{Impact of the topology's finenesse}
1074
1075 %Let us firstly introduce the following notations.
1076
1077 %\begin{notation}
1078 %$\mathcal{X}_\tau$ will denote the topological space
1079 %$\left(\mathcal{X},\tau\right)$, whereas $\mathcal{V}_\tau (x)$ will be the set
1080 %of all the neighborhoods of $x$ when considering the topology $\tau$ (or simply
1081 %$\mathcal{V} (x)$, if there is no ambiguity).
1082 %\end{notation}
1083
1084
1085
1086 %\begin{theorem}
1087 %\label{Th:chaos et finesse}
1088 %Let $\mathcal{X}$ a set and $\tau, \tau'$ two topologies on $\mathcal{X}$ s.t.
1089 %$\tau'$ is finer than $\tau$. Let $f:\mathcal{X} \to \mathcal{X}$, continuous
1090 %both for $\tau$ and $\tau'$.
1091
1092 %If $(\mathcal{X}_{\tau'},f)$ is chaotic according to Devaney, then
1093 %$(\mathcal{X}_\tau,f)$ is chaotic too.
1094 %\end{theorem}
1095
1096 %\begin{proof}
1097 %Let us firstly establish the transitivity of $(\mathcal{X}_\tau,f)$.
1098
1099 %Let $\omega_1, \omega_2$ two open sets of $\tau$. Then $\omega_1, \omega_2 \in
1100 %\tau'$, becaus $\tau'$ is finer than $\tau$. As $f$ is $\tau'-$transitive, we
1101 %can deduce that $\exists n \in \mathds{N}, \omega_1 \cap f^{(n)}(\omega_2) =
1102 %\varnothing$. Consequently, $f$ is $\tau-$transitive.
1103
1104 %Let us now consider the regularity of $(\mathcal{X}_\tau,f)$, \emph{i.e.}, for
1105 %all $x \in \mathcal{X}$, and for all $\tau-$neighborhood $V$ of $x$, there is a
1106 %periodic point for $f$ into $V$.
1107
1108 %Let $x \in \mathcal{X}$ and $V \in \mathcal{V}_\tau (x)$ a $\tau-$neighborhood
1109 %of $x$. By definition, $\exists \omega \in \tau, x \in \omega \subset V$.
1110
1111 %But $\tau \subset \tau'$, so $\omega \in \tau'$, and then $V \in
1112 %\mathcal{V}_{\tau'} (x)$. As $(\mathcal{X}_{\tau'},f)$ is regular, there is a
1113 %periodic point for $f$ into $V$, and the regularity of $(\mathcal{X}_\tau,f)$ is
1114 %proven. 
1115 %\end{proof}
1116
1117 %\subsection{A given system can always be claimed as chaotic}
1118
1119 %Let $f$ an iteration function on $\mathcal{X}$ having at least a fixed point.
1120 %Then this function is chaotic (in a certain way):
1121
1122 %\begin{theorem}
1123 %Let $\mathcal{X}$ a nonempty set and $f: \mathcal{X} \to \X$ a function having
1124 %at least a fixed point.
1125 %Then $f$ is $\tau_0-$chaotic, where $\tau_0$ is the trivial (indiscrete)
1126 %topology on $\X$.
1127 %\end{theorem}
1128
1129
1130 %\begin{proof}
1131 %$f$ is transitive when $\forall \omega, \omega' \in \tau_0 \setminus
1132 %\{\varnothing\}, \exists n \in \mathds{N}, f^{(n)}(\omega) \cap \omega' \neq
1133 %\varnothing$.
1134 %As $\tau_0 = \left\{ \varnothing, \X \right\}$, this is equivalent to look for
1135 %an integer $n$ s.t. $f^{(n)}\left( \X \right) \cap \X \neq \varnothing$. For
1136 %instance, $n=0$ is appropriate.
1137
1138 %Let us now consider $x \in \X$ and $V \in \mathcal{V}_{\tau_0} (x)$. Then $V =
1139 %\mathcal{X}$, so $V$ has at least a fixed point for $f$. Consequently $f$ is
1140 %regular, and the result is established.
1141 %\end{proof}
1142
1143
1144
1145
1146 %\subsection{A given system can always be claimed as non-chaotic}
1147
1148 %\begin{theorem}
1149 %Let $\mathcal{X}$ be a set and $f: \mathcal{X} \to \X$.
1150 %If $\X$ is infinite, then $\left( \X_{\tau_\infty}, f\right)$ is not chaotic
1151 %(for the Devaney's formulation), where $\tau_\infty$ is the discrete topology.
1152 %\end{theorem}
1153
1154 %\begin{proof}
1155 %Let us prove it by contradiction, assuming that $\left(\X_{\tau_\infty},
1156 %f\right)$ is both transitive and regular.
1157
1158 %Let $x \in \X$ and $\{x\}$ one of its neighborhood. This neighborhood must
1159 %contain a periodic point for $f$, if we want that $\left(\X_{\tau_\infty},
1160 %f\right)$ is regular. Then $x$ must be a periodic point of $f$.
1161
1162 %Let $I_x = \left\{ f^{(n)}(x), n \in \mathds{N}\right\}$. This set is finite
1163 %because  $x$ is periodic, and $\mathcal{X}$ is infinite, then $\exists y \in
1164 %\mathcal{X}, y \notin I_x$.
1165
1166 %As $\left(\X_{\tau_\infty}, f\right)$ must be transitive, for all open nonempty
1167 %sets $A$ and $B$, an integer $n$ must satisfy $f^{(n)}(A) \cap B \neq
1168 %\varnothing$. However $\{x\}$ and $\{y\}$ are open sets and $y \notin I_x
1169 %\Rightarrow \forall n, f^{(n)}\left( \{x\} \right) \cap \{y\} = \varnothing$.
1170 %\end{proof}
1171
1172
1173
1174
1175
1176
1177 %\section{Chaos on the order topology}
1178 %\label{sec: chaos order topology}
1179 %\subsection{The phase space is an interval of the real line}
1180
1181 %\subsubsection{Toward a topological semiconjugacy}
1182
1183 %In what follows, our intention is to establish, by using a topological
1184 %semiconjugacy, that chaotic iterations over $\mathcal{X}$ can be described as
1185 %iterations on a real interval. To do so, we must firstly introduce some
1186 %notations and terminologies. 
1187
1188 %Let $\mathcal{S}_\mathsf{N}$ be the set of sequences belonging into $\llbracket
1189 %1; \mathsf{N}\rrbracket$ and $\mathcal{X}_{\mathsf{N}} = \mathcal{S}_\mathsf{N}
1190 %\times \B^\mathsf{N}$.
1191
1192
1193 %\begin{definition}
1194 %The function $\varphi: \mathcal{S}_{10} \times\mathds{B}^{10} \rightarrow \big[
1195 %0, 2^{10} \big[$ is defined by:
1196 %\begin{equation}
1197 % \begin{array}{cccl}
1198 %\varphi: & \mathcal{X}_{10} = \mathcal{S}_{10} \times\mathds{B}^{10}&
1199 %\longrightarrow & \big[ 0, 2^{10} \big[ \\
1200 % & (S,E) = \left((S^0, S^1, \hdots ); (E_0, \hdots, E_9)\right) & \longmapsto &
1201 %\varphi \left((S,E)\right)
1202 %\end{array}
1203 %\end{equation}
1204 %where $\varphi\left((S,E)\right)$ is the real number:
1205 %\begin{itemize}
1206 %\item whose integral part $e$ is $\displaystyle{\sum_{k=0}^9 2^{9-k} E_k}$, that
1207 %is, the binary digits of $e$ are $E_0 ~ E_1 ~ \hdots ~ E_9$.
1208 %\item whose decimal part $s$ is equal to $s = 0,S^0~ S^1~ S^2~ \hdots =
1209 %\sum_{k=1}^{+\infty} 10^{-k} S^{k-1}.$ 
1210 %\end{itemize}
1211 %\end{definition}
1212
1213
1214
1215 %$\varphi$ realizes the association between a point of $\mathcal{X}_{10}$ and a
1216 %real number into $\big[ 0, 2^{10} \big[$. We must now translate the chaotic
1217 %iterations $\Go$ on this real interval. To do so, two intermediate functions
1218 %over $\big[ 0, 2^{10} \big[$ must be introduced:
1219
1220
1221 %\begin{definition}
1222 %\label{def:e et s}
1223 %Let $x \in \big[ 0, 2^{10} \big[$ and:
1224 %\begin{itemize}
1225 %\item $e_0, \hdots, e_9$ the binary digits of the integral part of $x$:
1226 %$\displaystyle{\lfloor x \rfloor = \sum_{k=0}^{9} 2^{9-k} e_k}$.
1227 %\item $(s^k)_{k\in \mathds{N}}$ the digits of $x$, where the chosen decimal
1228 %decomposition of $x$ is the one that does not have an infinite number of 9: 
1229 %$\displaystyle{x = \lfloor x \rfloor + \sum_{k=0}^{+\infty} s^k 10^{-k-1}}$.
1230 %\end{itemize}
1231 %$e$ and $s$ are thus defined as follows:
1232 %\begin{equation}
1233 %\begin{array}{cccl}
1234 %e: & \big[ 0, 2^{10} \big[ & \longrightarrow & \mathds{B}^{10} \\
1235 % & x & \longmapsto & (e_0, \hdots, e_9)
1236 %\end{array}
1237 %\end{equation}
1238 %and
1239 %\begin{equation}
1240 % \begin{array}{cccc}
1241 %s: & \big[ 0, 2^{10} \big[ & \longrightarrow & \llbracket 0, 9
1242 %\rrbracket^{\mathds{N}} \\
1243 % & x & \longmapsto & (s^k)_{k \in \mathds{N}}
1244 %\end{array}
1245 %\end{equation}
1246 %\end{definition}
1247
1248 %We are now able to define the function $g$, whose goal is to translate the
1249 %chaotic iterations $\Go$ on an interval of $\mathds{R}$.
1250
1251 %\begin{definition}
1252 %$g:\big[ 0, 2^{10} \big[ \longrightarrow \big[ 0, 2^{10} \big[$ is defined by:
1253 %\begin{equation}
1254 %\begin{array}{cccc}
1255 %g: & \big[ 0, 2^{10} \big[ & \longrightarrow & \big[ 0, 2^{10} \big[ \\
1256 % & x & \longmapsto & g(x)
1257 %\end{array}
1258 %\end{equation}
1259 %where g(x) is the real number of $\big[ 0, 2^{10} \big[$ defined bellow:
1260 %\begin{itemize}
1261 %\item its integral part has a binary decomposition equal to $e_0', \hdots,
1262 %e_9'$, with:
1263 % \begin{equation}
1264 %e_i' = \left\{
1265 %\begin{array}{ll}
1266 %e(x)_i & \textrm{ if } i \neq s^0\\
1267 %e(x)_i + 1 \textrm{ (mod 2)} & \textrm{ if } i = s^0\\
1268 %\end{array}
1269 %\right.
1270 %\end{equation}
1271 %\item whose decimal part is $s(x)^1, s(x)^2, \hdots$
1272 %\end{itemize}
1273 %\end{definition}
1274
1275 %\bigskip
1276
1277
1278 %In other words, if $x = \displaystyle{\sum_{k=0}^{9} 2^{9-k} e_k + 
1279 %\sum_{k=0}^{+\infty} s^{k} ~10^{-k-1}}$, then:
1280 %\begin{equation}
1281 %g(x) =
1282 %\displaystyle{\sum_{k=0}^{9} 2^{9-k} (e_k + \delta(k,s^0) \textrm{ (mod 2)}) + 
1283 %\sum_{k=0}^{+\infty} s^{k+1} 10^{-k-1}}. 
1284 %\end{equation}
1285
1286
1287 %\subsubsection{Defining a metric on $\big[ 0, 2^{10} \big[$}
1288
1289 %Numerous metrics can be defined on the set $\big[ 0, 2^{10} \big[$, the most
1290 %usual one being the Euclidian distance recalled bellow:
1291
1292 %\begin{notation}
1293 %\index{distance!euclidienne}
1294 %$\Delta$ is the Euclidian distance on $\big[ 0, 2^{10} \big[$, that is,
1295 %$\Delta(x,y) = |y-x|^2$.
1296 %\end{notation}
1297
1298 %\medskip
1299
1300 %This Euclidian distance does not reproduce exactly the notion of proximity
1301 %induced by our first distance $d$ on $\X$. Indeed $d$ is finer than $\Delta$.
1302 %This is the reason why we have to introduce the following metric:
1303
1304
1305
1306 %\begin{definition}
1307 %Let $x,y \in \big[ 0, 2^{10} \big[$.
1308 %$D$ denotes the function from $\big[ 0, 2^{10} \big[^2$ to $\mathds{R}^+$
1309 %defined by: $D(x,y) = D_e\left(e(x),e(y)\right) + D_s\left(s(x),s(y)\right)$,
1310 %where:
1311 %\begin{center}
1312 %$\displaystyle{D_e(E,\check{E}) = \sum_{k=0}^\mathsf{9} \delta (E_k,
1313 %\check{E}_k)}$, ~~and~ $\displaystyle{D_s(S,\check{S}) = \sum_{k = 1}^\infty
1314 %\dfrac{|S^k-\check{S}^k|}{10^k}}$.
1315 %\end{center}
1316 %\end{definition}
1317
1318 %\begin{proposition}
1319 %$D$ is a distance on $\big[ 0, 2^{10} \big[$.
1320 %\end{proposition}
1321
1322 %\begin{proof}
1323 %The three axioms defining a distance must be checked.
1324 %\begin{itemize}
1325 %\item $D \geqslant 0$, because everything is positive in its definition. If
1326 %$D(x,y)=0$, then $D_e(x,y)=0$, so the integral parts of $x$ and $y$ are equal
1327 %(they have the same binary decomposition). Additionally, $D_s(x,y) = 0$, then
1328 %$\forall k \in \mathds{N}^*, s(x)^k = s(y)^k$. In other words, $x$ and $y$ have
1329 %the same $k-$th decimal digit, $\forall k \in \mathds{N}^*$. And so $x=y$.
1330 %\item $D(x,y)=D(y,x)$.
1331 %\item Finally, the triangular inequality is obtained due to the fact that both
1332 %$\delta$ and $\Delta(x,y)=|x-y|$ satisfy it.
1333 %\end{itemize}
1334 %\end{proof}
1335
1336
1337 %The convergence of sequences according to $D$ is not the same than the usual
1338 %convergence related to the Euclidian metric. For instance, if $x^n \to x$
1339 %according to $D$, then necessarily the integral part of each $x^n$ is equal to
1340 %the integral part of $x$ (at least after a given threshold), and the decimal
1341 %part of $x^n$ corresponds to the one of $x$ ``as far as required''.
1342 %To illustrate this fact, a comparison between $D$ and the Euclidian distance is
1343 %given Figure \ref{fig:comparaison de distances}. These illustrations show that
1344 %$D$ is richer and more refined than the Euclidian distance, and thus is more
1345 %precise.
1346
1347
1348 %\begin{figure}[t]
1349 %\begin{center}
1350 %  \subfigure[Function $x \to dist(x;1,234) $ on the interval
1351 %$(0;5)$.]{\includegraphics[scale=.35]{DvsEuclidien.pdf}}\quad
1352 %  \subfigure[Function $x \to dist(x;3) $ on the interval
1353 %$(0;5)$.]{\includegraphics[scale=.35]{DvsEuclidien2.pdf}}
1354 %\end{center}
1355 %\caption{Comparison between $D$ (in blue) and the Euclidian distane (in green).}
1356 %\label{fig:comparaison de distances}
1357 %\end{figure}
1358
1359
1360
1361
1362 %\subsubsection{The semiconjugacy}
1363
1364 %It is now possible to define a topological semiconjugacy between $\mathcal{X}$
1365 %and an interval of $\mathds{R}$:
1366
1367 %\begin{theorem}
1368 %Chaotic iterations on the phase space $\mathcal{X}$ are simple iterations on
1369 %$\mathds{R}$, which is illustrated by the semiconjugacy of the diagram bellow:
1370 %\begin{equation*}
1371 %\begin{CD}
1372 %\left(~\mathcal{S}_{10} \times\mathds{B}^{10}, d~\right) @>G_{f_0}>>
1373 %\left(~\mathcal{S}_{10} \times\mathds{B}^{10}, d~\right)\\
1374 %    @V{\varphi}VV                    @VV{\varphi}V\\
1375 %\left( ~\big[ 0, 2^{10} \big[, D~\right)  @>>g> \left(~\big[ 0, 2^{10} \big[,
1376 %D~\right)
1377 %\end{CD}
1378 %\end{equation*}
1379 %\end{theorem}
1380
1381 %\begin{proof}
1382 %$\varphi$ has been constructed in order to be continuous and onto.
1383 %\end{proof}
1384
1385 %In other words, $\mathcal{X}$ is approximately equal to $\big[ 0, 2^\mathsf{N}
1386 %\big[$.
1387
1388
1389
1390
1391
1392
1393 %\subsection{Study of the chaotic iterations described as a real function}
1394
1395
1396 %\begin{figure}[t]
1397 %\begin{center}
1398 %  \subfigure[ICs on the interval
1399 %$(0,9;1)$.]{\includegraphics[scale=.35]{ICs09a1.pdf}}\quad
1400 %  \subfigure[ICs on the interval
1401 %$(0,7;1)$.]{\includegraphics[scale=.35]{ICs07a95.pdf}}\\
1402 %  \subfigure[ICs on the interval
1403 %$(0,5;1)$.]{\includegraphics[scale=.35]{ICs05a1.pdf}}\quad
1404 %  \subfigure[ICs on the interval
1405 %$(0;1)$]{\includegraphics[scale=.35]{ICs0a1.pdf}}
1406 %\end{center}
1407 %\caption{Representation of the chaotic iterations.}
1408 %\label{fig:ICs}
1409 %\end{figure}
1410
1411
1412
1413
1414 %\begin{figure}[t]
1415 %\begin{center}
1416 %  \subfigure[ICs on the interval
1417 %$(510;514)$.]{\includegraphics[scale=.35]{ICs510a514.pdf}}\quad
1418 %  \subfigure[ICs on the interval
1419 %$(1000;1008)$]{\includegraphics[scale=.35]{ICs1000a1008.pdf}}
1420 %\end{center}
1421 %\caption{ICs on small intervals.}
1422 %\label{fig:ICs2}
1423 %\end{figure}
1424
1425 %\begin{figure}[t]
1426 %\begin{center}
1427 %  \subfigure[ICs on the interval
1428 %$(0;16)$.]{\includegraphics[scale=.3]{ICs0a16.pdf}}\quad
1429 %  \subfigure[ICs on the interval 
1430 %$(40;70)$.]{\includegraphics[scale=.45]{ICs40a70.pdf}}\quad
1431 %\end{center}
1432 %\caption{General aspect of the chaotic iterations.}
1433 %\label{fig:ICs3}
1434 %\end{figure}
1435
1436
1437 %We have written a Python program to represent the chaotic iterations with the
1438 %vectorial negation on the real line $\mathds{R}$. Various representations of
1439 %these CIs are given in Figures \ref{fig:ICs}, \ref{fig:ICs2} and \ref{fig:ICs3}.
1440 %It can be remarked that the function $g$ is a piecewise linear function: it is
1441 %linear on each interval having the form $\left[ \dfrac{n}{10},
1442 %\dfrac{n+1}{10}\right[$, $n \in \llbracket 0;2^{10}\times 10 \rrbracket$ and its
1443 %slope is equal to 10. Let us justify these claims:
1444
1445 %\begin{proposition}
1446 %\label{Prop:derivabilite des ICs}
1447 %Chaotic iterations $g$ defined on $\mathds{R}$ have derivatives of all orders on
1448 %$\big[ 0, 2^{10} \big[$, except on the 10241 points in $I$ defined by $\left\{
1449 %\dfrac{n}{10} ~\big/~ n \in \llbracket 0;2^{10}\times 10\rrbracket \right\}$.
1450
1451 %Furthermore, on each interval of the form $\left[ \dfrac{n}{10},
1452 %\dfrac{n+1}{10}\right[$, with $n \in \llbracket 0;2^{10}\times 10 \rrbracket$,
1453 %$g$ is a linear function, having a slope equal to 10: $\forall x \notin I,
1454 %g'(x)=10$.
1455 %\end{proposition}
1456
1457
1458 %\begin{proof}
1459 %Let $I_n = \left[ \dfrac{n}{10}, \dfrac{n+1}{10}\right[$, with $n \in \llbracket
1460 %0;2^{10}\times 10 \rrbracket$. All the points of $I_n$ have the same integral
1461 %prat $e$ and the same decimal part $s^0$: on the set $I_n$,  functions $e(x)$
1462 %and $x \mapsto s(x)^0$ of Definition \ref{def:e et s} only depend on $n$. So all
1463 %the images $g(x)$ of these points $x$:
1464 %\begin{itemize}
1465 %\item Have the same integral part, which is $e$, except probably the bit number
1466 %$s^0$. In other words, this integer has approximately the same binary
1467 %decomposition than $e$, the sole exception being the digit $s^0$ (this number is
1468 %then either $e+2^{10-s^0}$ or $e-2^{10-s^0}$, depending on the parity of $s^0$,
1469 %\emph{i.e.}, it is equal to $e+(-1)^{s^0}\times 2^{10-s^0}$).
1470 %\item A shift to the left has been applied to the decimal part $y$, losing by
1471 %doing so the common first digit $s^0$. In other words, $y$ has been mapped into
1472 %$10\times y - s^0$.
1473 %\end{itemize}
1474 %To sum up, the action of $g$ on the points of $I$ is as follows: first, make a
1475 %multiplication by 10, and second, add the same constant to each term, which is
1476 %$\dfrac{1}{10}\left(e+(-1)^{s^0}\times 2^{10-s^0}\right)-s^0$.
1477 %\end{proof}
1478
1479 %\begin{remark}
1480 %Finally, chaotic iterations are elements of the large family of functions that
1481 %are both chaotic and piecewise linear (like the tent map).
1482 %\end{remark}
1483
1484
1485
1486 %\subsection{Comparison of the two metrics on $\big[ 0, 2^\mathsf{N} \big[$}
1487
1488 %The two propositions bellow allow to compare our two distances on $\big[ 0,
1489 %2^\mathsf{N} \big[$:
1490
1491 %\begin{proposition}
1492 %Id: $\left(~\big[ 0, 2^\mathsf{N} \big[,\Delta~\right) \to \left(~\big[ 0,
1493 %2^\mathsf{N} \big[, D~\right)$ is not continuous. 
1494 %\end{proposition}
1495
1496 %\begin{proof}
1497 %The sequence $x^n = 1,999\hdots 999$ constituted by $n$ 9 as decimal part, is
1498 %such that:
1499 %\begin{itemize}
1500 %\item $\Delta (x^n,2) \to 0.$
1501 %\item But $D(x^n,2) \geqslant 1$, then $D(x^n,2)$ does not converge to 0.
1502 %\end{itemize}
1503
1504 %The sequential characterization of the continuity concludes the demonstration.
1505 %\end{proof}
1506
1507
1508
1509 %A contrario:
1510
1511 %\begin{proposition}
1512 %Id: $\left(~\big[ 0, 2^\mathsf{N} \big[,D~\right) \to \left(~\big[ 0,
1513 %2^\mathsf{N} \big[, \Delta ~\right)$ is a continuous fonction. 
1514 %\end{proposition}
1515
1516 %\begin{proof}
1517 %If $D(x^n,x) \to 0$, then $D_e(x^n,x) = 0$ at least for $n$ larger than a given
1518 %threshold, because $D_e$ only returns integers. So, after this threshold, the
1519 %integral parts of all the $x^n$ are equal to the integral part of $x$. 
1520
1521 %Additionally, $D_s(x^n, x) \to 0$, then $\forall k \in \mathds{N}^*, \exists N_k
1522 %\in \mathds{N}, n \geqslant N_k \Rightarrow D_s(x^n,x) \leqslant 10^{-k}$. This
1523 %means that for all $k$, an index $N_k$ can be found such that, $\forall n
1524 %\geqslant N_k$, all the $x^n$ have the same $k$ firsts digits, which are the
1525 %digits of $x$. We can deduce the convergence $\Delta(x^n,x) \to 0$, and thus the
1526 %result.
1527 %\end{proof}
1528
1529 %The conclusion of these propositions is that the proposed metric is more precise
1530 %than the Euclidian distance, that is:
1531
1532 %\begin{corollary}
1533 %$D$ is finer than the Euclidian distance $\Delta$.
1534 %\end{corollary}
1535
1536 %This corollary can be reformulated as follows:
1537
1538 %\begin{itemize}
1539 %\item The topology produced by $\Delta$ is a subset of the topology produced by
1540 %$D$.
1541 %\item $D$ has more open sets than $\Delta$.
1542 %\item It is harder to converge for the topology $\tau_D$ inherited by $D$, than
1543 %to converge with the one inherited by $\Delta$, which is denoted here by
1544 %$\tau_\Delta$.
1545 %\end{itemize}
1546
1547
1548 %\subsection{Chaos of the chaotic iterations on $\mathds{R}$}
1549 %\label{chpt:Chaos des itérations chaotiques sur R}
1550
1551
1552
1553 %\subsubsection{Chaos according to Devaney}
1554
1555 %We have recalled previously that the chaotic iterations $\left(\Go,
1556 %\mathcal{X}_d\right)$ are chaotic according to the formulation of Devaney. We
1557 %can deduce that they are chaotic on $\mathds{R}$ too, when considering the order
1558 %topology, because:
1559 %\begin{itemize}
1560 %\item $\left(\Go, \mathcal{X}_d\right)$ and $\left(g, \big[ 0, 2^{10}
1561 %\big[_D\right)$ are semiconjugate by $\varphi$,
1562 %\item Then $\left(g, \big[ 0, 2^{10} \big[_D\right)$ is a system chaotic
1563 %according to Devaney, because the semiconjugacy preserve this character.
1564 %\item But the topology generated by $D$ is finer than the topology generated by
1565 %the Euclidian distance $\Delta$ -- which is the order topology.
1566 %\item According to Theorem \ref{Th:chaos et finesse}, we can deduce that the
1567 %chaotic iterations $g$ are indeed chaotic, as defined by Devaney, for the order
1568 %topology on $\mathds{R}$.
1569 %\end{itemize}
1570
1571 %This result can be formulated as follows.
1572
1573 %\begin{theorem}
1574 %\label{th:IC et topologie de l'ordre}
1575 %The chaotic iterations $g$ on $\mathds{R}$ are chaotic according to the
1576 %Devaney's formulation, when $\mathds{R}$ has his usual topology, which is the
1577 %order topology.
1578 %\end{theorem}
1579
1580 %Indeed this result is weaker than the theorem establishing the chaos for the
1581 %finer topology $d$. However the Theorem \ref{th:IC et topologie de l'ordre}
1582 %still remains important. Indeed, we have studied in our previous works a set
1583 %different from the usual set of study ($\mathcal{X}$ instead of $\mathds{R}$),
1584 %in order to be as close as possible from the computer: the properties of
1585 %disorder proved theoretically will then be preserved when computing. However, we
1586 %could wonder whether this change does not lead to a disorder of a lower quality.
1587 %In other words, have we replaced a situation of a good disorder lost when
1588 %computing, to another situation of a disorder preserved but of bad quality.
1589 %Theorem \ref{th:IC et topologie de l'ordre} prove exactly the contrary.
1590
1591
1592
1593
1594
1595
1596
1597 \section{Security Analysis}
1598 \label{sec:security analysis}
1599
1600
1601
1602 In this section the concatenation of two strings $u$ and $v$ is classically
1603 denoted by $uv$.
1604 In a cryptographic context, a pseudorandom generator is a deterministic
1605 algorithm $G$ transforming strings  into strings and such that, for any
1606 seed $w$ of length $N$, $G(w)$ (the output of $G$ on the input $w$) has size
1607 $\ell_G(N)$ with $\ell_G(N)>N$.
1608 The notion of {\it secure} PRNGs can now be defined as follows. 
1609
1610 \begin{definition}
1611 A cryptographic PRNG $G$ is secure if for any probabilistic polynomial time
1612 algorithm $D$, for any positive polynomial $p$, and for all sufficiently
1613 large $k$'s,
1614 $$| \mathrm{Pr}[D(G(U_k))=1]-Pr[D(U_{\ell_G(k)}=1]|< \frac{1}{p(N)},$$
1615 where $U_r$ is the uniform distribution over $\{0,1\}^r$ and the
1616 probabilities are taken over $U_N$, $U_{\ell_G(N)}$ as well as over the
1617 internal coin tosses of $D$. 
1618 \end{definition}
1619
1620 Intuitively, it means that there is no polynomial time algorithm that can
1621 distinguish a perfect uniform random generator from $G$ with a non
1622 negligible probability. The interested reader is referred
1623 to~\cite[chapter~3]{Goldreich} for more information. Note that it is
1624 quite easily possible to change the function $\ell$ into any polynomial
1625 function $\ell^\prime$ satisfying $\ell^\prime(N)>N)$~\cite[Chapter 3.3]{Goldreich}.
1626
1627 The generation schema developed in (\ref{equation Oplus}) is based on a
1628 pseudorandom generator. Let $H$ be a cryptographic PRNG. We may assume,
1629 without loss of generality, that for any string $S_0$ of size $N$, the size
1630 of $H(S_0)$ is $kN$, with $k>2$. It means that $\ell_H(N)=kN$. 
1631 Let $S_1,\ldots,S_k$ be the 
1632 strings of length $N$ such that $H(S_0)=S_1 \ldots S_k$ ($H(S_0)$ is the concatenation of
1633 the $S_i$'s). The cryptographic PRNG $X$ defined in (\ref{equation Oplus})
1634 is the algorithm mapping any string of length $2N$ $x_0S_0$ into the string
1635 $(x_0\oplus S_0 \oplus S_1)(x_0\oplus S_0 \oplus S_1\oplus S_2)\ldots
1636 (x_o\bigoplus_{i=0}^{i=k}S_i)$. Particularly one has $\ell_{X}(2N)=kN=\ell_H(N)$. 
1637 We claim now that if this PRNG is secure,
1638 then the new one is secure too.
1639
1640 \begin{proposition}
1641 If $H$ is a secure cryptographic PRNG, then $X$ is a secure cryptographic
1642 PRNG too.
1643 \end{proposition}
1644
1645 \begin{proof}
1646 The proposition is proved by contraposition. Assume that $X$ is not
1647 secure. By Definition, there exists a polynomial time probabilistic
1648 algorithm $D$, a positive polynomial $p$, such that for all $k_0$ there exists
1649 $N\geq \frac{k_0}{2}$ satisfying 
1650 $$| \mathrm{Pr}[D(X(U_{2N}))=1]-\mathrm{Pr}[D(U_{kN}=1]|\geq \frac{1}{p(2N)}.$$
1651 We describe a new probabilistic algorithm $D^\prime$ on an input $w$ of size
1652 $kN$:
1653 \begin{enumerate}
1654 \item Decompose $w$ into $w=w_1\ldots w_{k}$, where each $w_i$ has size $N$.
1655 \item Pick a string $y$ of size $N$ uniformly at random.
1656 \item Compute $z=(y\oplus w_1)(y\oplus w_1\oplus w_2)\ldots (y
1657   \bigoplus_{i=1}^{i=k} w_i).$
1658 \item Return $D(z)$.
1659 \end{enumerate}
1660
1661
1662 Consider  for each $y\in \mathbb{B}^{kN}$ the function $\varphi_{y}$
1663 from $\mathbb{B}^{kN}$ into $\mathbb{B}^{kN}$ mapping $w=w_1\ldots w_k$
1664 (each $w_i$ has length $N$) to 
1665 $(y\oplus w_1)(y\oplus w_1\oplus w_2)\ldots (y
1666   \bigoplus_{i=1}^{i=k_1} w_i).$ By construction, one has for every $w$,
1667 \begin{equation}\label{PCH-1}
1668 D^\prime(w)=D(\varphi_y(w)),
1669 \end{equation}
1670 where $y$ is randomly generated. 
1671 Moreover, for each $y$, $\varphi_{y}$ is injective: if 
1672 $(y\oplus w_1)(y\oplus w_1\oplus w_2)\ldots (y\bigoplus_{i=1}^{i=k_1}
1673 w_i)=(y\oplus w_1^\prime)(y\oplus w_1^\prime\oplus w_2^\prime)\ldots
1674 (y\bigoplus_{i=1}^{i=k} w_i^\prime)$, then for every $1\leq j\leq k$,
1675 $y\bigoplus_{i=1}^{i=j} w_i^\prime=y\bigoplus_{i=1}^{i=j} w_i$. It follows,
1676 by a direct induction, that $w_i=w_i^\prime$. Furthermore, since $\mathbb{B}^{kN}$
1677 is finite, each $\varphi_y$ is bijective. Therefore, and using (\ref{PCH-1}),
1678 one has
1679 \begin{equation}\label{PCH-2}
1680 \mathrm{Pr}[D^\prime(U_{kN})=1]=\mathrm{Pr}[D(\varphi_y(U_{kN}))=1]=\mathrm{Pr}[D(U_{kN})=1].
1681 \end{equation}
1682
1683 Now, using (\ref{PCH-1}) again, one has  for every $x$,
1684 \begin{equation}\label{PCH-3}
1685 D^\prime(H(x))=D(\varphi_y(H(x))),
1686 \end{equation}
1687 where $y$ is randomly generated. By construction, $\varphi_y(H(x))=X(yx)$,
1688 thus
1689 \begin{equation}\label{PCH-3}
1690 D^\prime(H(x))=D(yx),
1691 \end{equation}
1692 where $y$ is randomly generated. 
1693 It follows that 
1694
1695 \begin{equation}\label{PCH-4}
1696 \mathrm{Pr}[D^\prime(H(U_{N}))=1]=\mathrm{Pr}[D(U_{2N})=1].
1697 \end{equation}
1698  From (\ref{PCH-2}) and (\ref{PCH-4}), one can deduce that
1699 there exist a polynomial time probabilistic
1700 algorithm $D^\prime$, a positive polynomial $p$, such that for all $k_0$ there exists
1701 $N\geq \frac{k_0}{2}$ satisfying 
1702 $$| \mathrm{Pr}[D(H(U_{N}))=1]-\mathrm{Pr}[D(U_{kN}=1]|\geq \frac{1}{p(2N)},$$
1703 proving that $H$ is not secure, a contradiction. 
1704 \end{proof}
1705
1706
1707
1708
1709 \section{A cryptographically secure prng for GPU}
1710 \label{sec:CSGPU}
1711 It is  possible to build a  cryptographically secure prng based  on the previous
1712 algorithm (algorithm~\ref{algo:gpu_kernel2}).   It simply consists  in replacing
1713 the  {\it  xor-like} algorithm  by  another  cryptographically  secure prng.  In
1714 practice, we suggest  to use the BBS algorithm~\cite{BBS}  which takes the form:
1715 $$x_{n+1}=x_n^2~ mod~ M$$  where $M$ is the product of  two prime numbers. Those
1716 prime numbers  need to be congruent  to 3 modulus  4. In practice, this  PRNG is
1717 known to  be slow and  not efficient for  the generation of random  numbers. For
1718 current  GPU   cards,  the  modulus   operation  is  the  most   time  consuming
1719 operation. So in  order to obtain quite reasonable  performances, it is required
1720 to use only modulus on 32  bits integer numbers. Consequently $x_n^2$ need to be
1721 less than  $2^{32}$ and the  number $M$  need to be  less than $2^{16}$.   So in
1722 pratice we can  choose prime numbers around 256 that are  congruent to 3 modulus
1723 4.  With  32 bits numbers,  only the  4 least significant  bits of $x_n$  can be
1724 chosen  (the   maximum  number  of   undistinguishing  is  less  or   equals  to
1725 $log_2(log_2(x_n))$). So  to generate a 32 bits  number, we need to  use 8 times
1726 the BBS algorithm, with different combinations of $M$ is required.
1727
1728 Currently this PRNG does not succeed to pass all the tests of TestU01.
1729
1730
1731 \section{Conclusion}
1732
1733
1734 In  this  paper  we have  presented  a  new  class  of  PRNGs based  on  chaotic
1735 iterations. We have proven that these PRNGs are chaotic in the sense of Devenay.
1736 We also propose a PRNG cryptographically secure and its implementation on GPU.
1737
1738 An  efficient implementation  on  GPU based  on  a xor-like  PRNG  allows us  to
1739 generate   a  huge   number   of  pseudorandom   numbers   per  second   (about
1740 20Gsample/s). This PRNG succeeds to pass the hardest batteries of TestU01.
1741
1742 In future  work we plan to  extend this work  for parallel PRNG for  clusters or
1743 grid computing. We also plan to improve  the BBS version in order to succeed all
1744 the tests of TestU01.
1745
1746
1747
1748 \bibliographystyle{plain} 
1749 \bibliography{mabase}
1750 \end{document}