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

Private GIT Repository
petite modif
[prng_gpu.git] / prng_gpu.tex
1 %\documentclass{article}
2 \documentclass[10pt,journal,letterpaper,compsoc]{IEEEtran}
3 \usepackage[utf8]{inputenc}
4 \usepackage[T1]{fontenc}
5 \usepackage{fullpage}
6 \usepackage{fancybox}
7 \usepackage{amsmath}
8 \usepackage{amscd}
9 \usepackage{moreverb}
10 \usepackage{commath}
11 \usepackage[ruled,vlined]{algorithm2e}
12 \usepackage{listings}
13 \usepackage[standard]{ntheorem}
14
15 % Pour mathds : les ensembles IR, IN, etc.
16 \usepackage{dsfont}
17
18 % Pour avoir des intervalles d'entiers
19 \usepackage{stmaryrd}
20
21 \usepackage{graphicx}
22 % Pour faire des sous-figures dans les figures
23 \usepackage{subfigure}
24
25 \usepackage{color}
26
27 \newtheorem{notation}{Notation}
28
29 \newcommand{\X}{\mathcal{X}}
30 \newcommand{\Go}{G_{f_0}}
31 \newcommand{\B}{\mathds{B}}
32 \newcommand{\N}{\mathds{N}}
33 \newcommand{\BN}{\mathds{B}^\mathsf{N}}
34 \let\sur=\overline
35
36 \newcommand{\alert}[1]{\begin{color}{blue}\textit{#1}\end{color}}
37
38 \title{Efficient and Cryptographically Secure Generation of Chaotic Pseudorandom Numbers on GPU}
39 \begin{document}
40
41 \author{Jacques M. Bahi, Rapha\"{e}l Couturier,  Christophe
42 Guyeux, and Pierre-Cyrille Héam\thanks{Authors in alphabetic order}}
43    
44
45 \IEEEcompsoctitleabstractindextext{
46 \begin{abstract}
47 In this paper we present a new pseudorandom number generator (PRNG) on
48 graphics processing units  (GPU). This PRNG is based  on the so-called chaotic iterations.  It
49 is firstly proven  to be chaotic according to the Devaney's  formulation. We thus propose  an efficient
50 implementation  for  GPU that successfully passes the   {\it BigCrush} tests, deemed to be the  hardest
51 battery of tests in TestU01.  Experiments show that this PRNG can generate
52 about 20 billion of random numbers  per second on Tesla C1060 and NVidia GTX280
53 cards.
54 It is then established that, under reasonable assumptions, the proposed PRNG can be cryptographically 
55 secure.
56 A chaotic version of the Blum-Goldwasser asymmetric key encryption scheme is finally proposed.
57
58
59 \end{abstract}
60 }
61
62 \maketitle
63
64 \IEEEdisplaynotcompsoctitleabstractindextext
65 \IEEEpeerreviewmaketitle
66
67
68 \section{Introduction}
69
70 Randomness is of importance in many fields such as scientific simulations or cryptography. 
71 ``Random numbers'' can mainly be generated either by a deterministic and reproducible algorithm
72 called a pseudorandom number generator (PRNG), or by a physical non-deterministic 
73 process having all the characteristics of a random noise, called a truly random number
74 generator (TRNG). 
75 In this paper, we focus on reproducible generators, useful for instance in
76 Monte-Carlo based simulators or in several cryptographic schemes.
77 These domains need PRNGs that are statistically irreproachable. 
78 In some fields such as in numerical simulations, speed is a strong requirement
79 that is usually attained by using parallel architectures. In that case,
80 a recurrent problem is that a deflation of the statistical qualities is often
81 reported, when the parallelization of a good PRNG is realized.
82 This is why ad-hoc PRNGs for each possible architecture must be found to
83 achieve both speed and randomness.
84 On the other side, speed is not the main requirement in cryptography: the great
85 need is to define \emph{secure} generators able to withstand malicious
86 attacks. Roughly speaking, an attacker should not be able in practice to make 
87 the distinction between numbers obtained with the secure generator and a true random
88 sequence. 
89 Finally, a small part of the community working in this domain focuses on a
90 third requirement, that is to define chaotic generators.
91 The main idea is to take benefits from a chaotic dynamical system to obtain a
92 generator that is unpredictable, disordered, sensible to its seed, or in other word chaotic.
93 Their desire is to map a given chaotic dynamics into a sequence that seems random 
94 and unassailable due to chaos.
95 However, the chaotic maps used as a pattern are defined in the real line 
96 whereas computers deal with finite precision numbers.
97 This distortion leads to a deflation of both chaotic properties and speed.
98 Furthermore, authors of such chaotic generators often claim their PRNG
99 as secure due to their chaos properties, but there is no obvious relation
100 between chaos and security as it is understood in cryptography.
101 This is why the use of chaos for PRNG still remains marginal and disputable.
102
103 The authors' opinion is that topological properties of disorder, as they are
104 properly defined in the mathematical theory of chaos, can reinforce the quality
105 of a PRNG. But they are not substitutable for security or statistical perfection.
106 Indeed, to the authors' mind, such properties can be useful in the two following situations. On the
107 one hand, a post-treatment based on a chaotic dynamical system can be applied
108 to a PRNG statistically deflective, in order to improve its statistical 
109 properties. Such an improvement can be found, for instance, in~\cite{bgw09:ip,bcgr11:ip}.
110 On the other hand, chaos can be added to a fast, statistically perfect PRNG and/or a
111 cryptographically secure one, in case where chaos can be of interest,
112 \emph{only if these last properties are not lost during
113 the proposed post-treatment}. Such an assumption is behind this research work.
114 It leads to the attempts to define a 
115 family of PRNGs that are chaotic while being fast and statistically perfect,
116 or cryptographically secure.
117 Let us finish this paragraph by noticing that, in this paper, 
118 statistical perfection refers to the ability to pass the whole 
119 {\it BigCrush} battery of tests, which is widely considered as the most
120 stringent statistical evaluation of a sequence claimed as random.
121 This battery can be found in the well-known TestU01 package~\cite{LEcuyerS07}.
122 Chaos, for its part, refers to the well-established definition of a
123 chaotic dynamical system proposed by Devaney~\cite{Devaney}.
124
125
126 In a previous work~\cite{bgw09:ip,guyeux10} we have proposed a post-treatment on PRNGs making them behave
127 as a chaotic dynamical system. Such a post-treatment leads to a new category of
128 PRNGs. We have shown that proofs of Devaney's chaos can be established for this
129 family, and that the sequence obtained after this post-treatment can pass the
130 NIST~\cite{Nist10}, DieHARD~\cite{Marsaglia1996}, and TestU01~\cite{LEcuyerS07} batteries of tests, even if the inputted generators
131 cannot.
132 The proposition of this paper is to improve widely the speed of the formerly
133 proposed generator, without any lack of chaos or statistical properties.
134 In particular, a version of this PRNG on graphics processing units (GPU)
135 is proposed.
136 Although GPU was initially designed  to accelerate
137 the manipulation of  images, they are nowadays commonly  used in many scientific
138 applications. Therefore,  it is important  to be able to  generate pseudorandom
139 numbers inside a GPU when a scientific application runs in it. This remark
140 motivates our proposal of a chaotic and statistically perfect PRNG for GPU.  
141 Such device
142 allows us to generate almost 20 billion of pseudorandom numbers per second.
143 Furthermore, we show that the proposed post-treatment preserves the
144 cryptographical security of the inputted PRNG, when this last has such a 
145 property.
146 Last, but not least, we propose a rewriting of the Blum-Goldwasser asymmetric
147 key encryption protocol by using the proposed method.
148
149 The remainder of this paper  is organized as follows. In Section~\ref{section:related
150   works} we  review some GPU implementations  of PRNGs.  Section~\ref{section:BASIC
151   RECALLS} gives some basic recalls  on the well-known Devaney's formulation of chaos, 
152   and on an iteration process called ``chaotic
153 iterations'' on which the post-treatment is based. 
154 The proposed PRNG and its proof of chaos are given in  Section~\ref{sec:pseudorandom}.
155 Section~\ref{sec:efficient    PRNG}   presents   an   efficient
156 implementation of  this chaotic PRNG  on a CPU, whereas   Section~\ref{sec:efficient PRNG
157   gpu}   describes and evaluates theoretically  the  GPU   implementation. 
158 Such generators are experimented in 
159 Section~\ref{sec:experiments}.
160 We show in Section~\ref{sec:security analysis} that, if the inputted
161 generator is cryptographically secure, then it is the case too for the
162 generator provided by the post-treatment.
163 Such a proof leads to the proposition of a cryptographically secure and
164 chaotic generator on GPU based on the famous Blum Blum Shum
165 in Section~\ref{sec:CSGPU}, and to an improvement of the
166 Blum-Goldwasser protocol in Sect.~\ref{Blum-Goldwasser}.
167 This research work ends by a conclusion section, in which the contribution is
168 summarized and intended future work is presented.
169
170
171
172
173 \section{Related works on GPU based PRNGs}
174 \label{section:related works}
175
176 Numerous research works on defining GPU based PRNGs have already been proposed  in the
177 literature, so that exhaustivity is impossible.
178 This is why authors of this document only give reference to the most significant attempts 
179 in this domain, from their subjective point of view. 
180 The  quantity of pseudorandom numbers generated per second is mentioned here 
181 only when the information is given in the related work. 
182 A million numbers  per second will be simply written as
183 1MSample/s whereas a billion numbers per second is 1GSample/s.
184
185 In \cite{Pang:2008:cec}  a PRNG based on  cellular automata is defined
186 with no  requirement to an high  precision  integer   arithmetic  or to any bitwise
187 operations. Authors can   generate  about
188 3.2MSamples/s on a GeForce 7800 GTX GPU, which is quite an old card now.
189 However, there is neither a mention of statistical tests nor any proof of
190 chaos or cryptography in this document.
191
192 In \cite{ZRKB10}, the authors propose  different versions of efficient GPU PRNGs
193 based on  Lagged Fibonacci or Hybrid  Taus.  They have  used these
194 PRNGs   for  Langevin   simulations   of  biomolecules   fully  implemented   on
195 GPU. Performances of  the GPU versions are far better than  those obtained with a
196 CPU, and these PRNGs succeed to pass the {\it BigCrush} battery of TestU01. 
197 However the evaluations of the proposed PRNGs are only statistical ones.
198
199
200 Authors of~\cite{conf/fpga/ThomasHL09}  have studied the  implementation of some
201 PRNGs on  different computing architectures: CPU,  field-programmable gate array
202 (FPGA), massively parallel  processors, and GPU. This study is of interest, because
203 the  performance  of the  same  PRNGs on  different architectures are compared. 
204 FPGA appears as  the  fastest  and the most
205 efficient architecture, providing the fastest number of generated pseudorandom numbers
206 per joule. 
207 However, we notice that authors can ``only'' generate between 11 and 16GSamples/s
208 with a GTX 280  GPU, which should be compared with
209 the results presented in this document.
210 We can remark too that the PRNGs proposed in~\cite{conf/fpga/ThomasHL09} are only
211 able to pass the {\it Crush} battery, which is far easier than the {\it Big Crush} one.
212
213 Lastly, Cuda  has developed  a  library for  the  generation of  pseudorandom numbers  called
214 Curand~\cite{curand11}.        Several       PRNGs        are       implemented, among
215 other things 
216 Xorwow~\cite{Marsaglia2003} and  some variants of Sobol. The  tests reported show that
217 their  fastest version provides  15GSamples/s on  the new  Fermi C2050  card. 
218 But their PRNGs cannot pass the whole TestU01 battery (only one test is failed).
219 \newline
220 \newline
221 We can finally remark that, to the best of our knowledge, no GPU implementation has been proven to be chaotic, and the cryptographically secure property has surprisingly never been considered.
222
223 \section{Basic Recalls}
224 \label{section:BASIC RECALLS}
225
226 This section is devoted to basic definitions and terminologies in the fields of
227 topological chaos and chaotic iterations.
228 \subsection{Devaney's Chaotic Dynamical Systems}
229
230 In the sequel $S^{n}$ denotes the $n^{th}$ term of a sequence $S$ and $V_{i}$
231 denotes the $i^{th}$ component of a vector $V$. $f^{k}=f\circ ...\circ f$
232 is for the $k^{th}$ composition of a function $f$. Finally, the following
233 notation is used: $\llbracket1;N\rrbracket=\{1,2,\hdots,N\}$.
234
235
236 Consider a topological space $(\mathcal{X},\tau)$ and a continuous function $f :
237 \mathcal{X} \rightarrow \mathcal{X}$.
238
239 \begin{definition}
240 $f$ is said to be \emph{topologically transitive} if, for any pair of open sets
241 $U,V \subset \mathcal{X}$, there exists $k>0$ such that $f^k(U) \cap V \neq
242 \varnothing$.
243 \end{definition}
244
245 \begin{definition}
246 An element $x$ is a \emph{periodic point} for $f$ of period $n\in \mathds{N}^*$
247 if $f^{n}(x)=x$.% The set of periodic points of $f$ is denoted $Per(f).$
248 \end{definition}
249
250 \begin{definition}
251 $f$ is said to be \emph{regular} on $(\mathcal{X}, \tau)$ if the set of periodic
252 points for $f$ is dense in $\mathcal{X}$: for any point $x$ in $\mathcal{X}$,
253 any neighborhood of $x$ contains at least one periodic point (without
254 necessarily the same period).
255 \end{definition}
256
257
258 \begin{definition}[Devaney's formulation of chaos~\cite{Devaney}]
259 $f$ is said to be \emph{chaotic} on $(\mathcal{X},\tau)$ if $f$ is regular and
260 topologically transitive.
261 \end{definition}
262
263 The chaos property is strongly linked to the notion of ``sensitivity'', defined
264 on a metric space $(\mathcal{X},d)$ by:
265
266 \begin{definition}
267 \label{sensitivity} $f$ has \emph{sensitive dependence on initial conditions}
268 if there exists $\delta >0$ such that, for any $x\in \mathcal{X}$ and any
269 neighborhood $V$ of $x$, there exist $y\in V$ and $n > 0$ such that
270 $d\left(f^{n}(x), f^{n}(y)\right) >\delta $.
271
272 $\delta$ is called the \emph{constant of sensitivity} of $f$.
273 \end{definition}
274
275 Indeed, Banks \emph{et al.} have proven in~\cite{Banks92} that when $f$ is
276 chaotic and $(\mathcal{X}, d)$ is a metric space, then $f$ has the property of
277 sensitive dependence on initial conditions (this property was formerly an
278 element of the definition of chaos). To sum up, quoting Devaney
279 in~\cite{Devaney}, a chaotic dynamical system ``is unpredictable because of the
280 sensitive dependence on initial conditions. It cannot be broken down or
281 simplified into two subsystems which do not interact because of topological
282 transitivity. And in the midst of this random behavior, we nevertheless have an
283 element of regularity''. Fundamentally different behaviors are consequently
284 possible and occur in an unpredictable way.
285
286
287
288 \subsection{Chaotic Iterations}
289 \label{sec:chaotic iterations}
290
291
292 Let us consider  a \emph{system} with a finite  number $\mathsf{N} \in
293 \mathds{N}^*$ of elements  (or \emph{cells}), so that each  cell has a
294 Boolean  \emph{state}. Having $\mathsf{N}$ Boolean values for these
295  cells  leads to the definition of a particular \emph{state  of the
296 system}. A sequence which  elements belong to $\llbracket 1;\mathsf{N}
297 \rrbracket $ is called a \emph{strategy}. The set of all strategies is
298 denoted by $\llbracket 1, \mathsf{N} \rrbracket^\mathds{N}.$
299
300 \begin{definition}
301 \label{Def:chaotic iterations}
302 The      set       $\mathds{B}$      denoting      $\{0,1\}$,      let
303 $f:\mathds{B}^{\mathsf{N}}\longrightarrow  \mathds{B}^{\mathsf{N}}$ be
304 a  function  and  $S\in  \llbracket 1, \mathsf{N} \rrbracket^\mathds{N}$  be  a  ``strategy''.  The  so-called
305 \emph{chaotic      iterations}     are     defined      by     $x^0\in
306 \mathds{B}^{\mathsf{N}}$ and
307 \begin{equation}
308 \forall    n\in     \mathds{N}^{\ast     },    \forall     i\in
309 \llbracket1;\mathsf{N}\rrbracket ,x_i^n=\left\{
310 \begin{array}{ll}
311   x_i^{n-1} &  \text{ if  }S^n\neq i \\
312   \left(f(x^{n-1})\right)_{S^n} & \text{ if }S^n=i.
313 \end{array}\right.
314 \end{equation}
315 \end{definition}
316
317 In other words, at the $n^{th}$ iteration, only the $S^{n}-$th cell is
318 \textquotedblleft  iterated\textquotedblright .  Note  that in  a more
319 general  formulation,  $S^n$  can   be  a  subset  of  components  and
320 $\left(f(x^{n-1})\right)_{S^{n}}$      can     be      replaced     by
321 $\left(f(x^{k})\right)_{S^{n}}$, where  $k<n$, describing for example,
322 delays  transmission~\cite{Robert1986,guyeux10}.  Finally,  let us  remark that
323 the term  ``chaotic'', in  the name of  these iterations,  has \emph{a
324 priori} no link with the mathematical theory of chaos, presented above.
325
326
327 Let us now recall how to define a suitable metric space where chaotic iterations
328 are continuous. For further explanations, see, e.g., \cite{guyeux10}.
329
330 Let $\delta $ be the \emph{discrete Boolean metric}, $\delta
331 (x,y)=0\Leftrightarrow x=y.$ Given a function $f$, define the function:
332 %%RAPH : ici j'ai coupé la dernière ligne en 2, c'est moche mais bon
333 \begin{equation}
334 \begin{array}{lrll}
335 F_{f}: & \llbracket1;\mathsf{N}\rrbracket\times \mathds{B}^{\mathsf{N}} &
336 \longrightarrow & \mathds{B}^{\mathsf{N}} \\
337 & (k,E) & \longmapsto & \left( E_{j}.\delta (k,j)+ \right.\\
338 &       &              & \left. f(E)_{k}.\overline{\delta
339 (k,j)}\right) _{j\in \llbracket1;\mathsf{N}\rrbracket},%
340 \end{array}%
341 \end{equation}%
342 \noindent where + and . are the Boolean addition and product operations.
343 Consider the phase space:
344 \begin{equation}
345 \mathcal{X} = \llbracket 1 ; \mathsf{N} \rrbracket^\mathds{N} \times
346 \mathds{B}^\mathsf{N},
347 \end{equation}
348 \noindent and the map defined on $\mathcal{X}$:
349 \begin{equation}
350 G_f\left(S,E\right) = \left(\sigma(S), F_f(i(S),E)\right), \label{Gf}
351 \end{equation}
352 \noindent where $\sigma$ is the \emph{shift} function defined by $\sigma
353 (S^{n})_{n\in \mathds{N}}\in \llbracket 1, \mathsf{N} \rrbracket^\mathds{N}\longrightarrow (S^{n+1})_{n\in
354 \mathds{N}}\in \llbracket 1, \mathsf{N} \rrbracket^\mathds{N}$ and $i$ is the \emph{initial function} 
355 $i:(S^{n})_{n\in \mathds{N}} \in \llbracket 1, \mathsf{N} \rrbracket^\mathds{N}\longrightarrow S^{0}\in \llbracket
356 1;\mathsf{N}\rrbracket$. Then the chaotic iterations proposed in
357 Definition \ref{Def:chaotic iterations} can be described by the following iterations:
358 \begin{equation}
359 \left\{
360 \begin{array}{l}
361 X^0 \in \mathcal{X} \\
362 X^{k+1}=G_{f}(X^k).%
363 \end{array}%
364 \right.
365 \end{equation}%
366
367 With this formulation, a shift function appears as a component of chaotic
368 iterations. The shift function is a famous example of a chaotic
369 map~\cite{Devaney} but its presence is not sufficient enough to claim $G_f$ as
370 chaotic. 
371 To study this claim, a new distance between two points $X = (S,E), Y =
372 (\check{S},\check{E})\in
373 \mathcal{X}$ has been introduced in \cite{guyeux10} as follows:
374 \begin{equation}
375 d(X,Y)=d_{e}(E,\check{E})+d_{s}(S,\check{S}),
376 \end{equation}
377 \noindent where
378 \begin{equation}
379 \left\{
380 \begin{array}{lll}
381 \displaystyle{d_{e}(E,\check{E})} & = & \displaystyle{\sum_{k=1}^{\mathsf{N}%
382 }\delta (E_{k},\check{E}_{k})}, \\
383 \displaystyle{d_{s}(S,\check{S})} & = & \displaystyle{\dfrac{9}{\mathsf{N}}%
384 \sum_{k=1}^{\infty }\dfrac{|S^k-\check{S}^k|}{10^{k}}}.%
385 \end{array}%
386 \right.
387 \end{equation}
388
389
390 This new distance has been introduced to satisfy the following requirements.
391 \begin{itemize}
392 \item When the number of different cells between two systems is increasing, then
393 their distance should increase too.
394 \item In addition, if two systems present the same cells and their respective
395 strategies start with the same terms, then the distance between these two points
396 must be small because the evolution of the two systems will be the same for a
397 while. Indeed, both dynamical systems start with the same initial condition,
398 use the same update function, and as strategies are the same for a while, furthermore
399 updated components are the same as well.
400 \end{itemize}
401 The distance presented above follows these recommendations. Indeed, if the floor
402 value $\lfloor d(X,Y)\rfloor $ is equal to $n$, then the systems $E, \check{E}$
403 differ in $n$ cells ($d_e$ is indeed the Hamming distance). In addition, $d(X,Y) - \lfloor d(X,Y) \rfloor $ is a
404 measure of the differences between strategies $S$ and $\check{S}$. More
405 precisely, this floating part is less than $10^{-k}$ if and only if the first
406 $k$ terms of the two strategies are equal. Moreover, if the $k^{th}$ digit is
407 nonzero, then the $k^{th}$ terms of the two strategies are different.
408 The impact of this choice for a distance will be investigated at the end of the document.
409
410 Finally, it has been established in \cite{guyeux10} that,
411
412 \begin{proposition}
413 Let $f$ be a map from $\mathds{B}^\mathsf{N}$ to itself. Then $G_{f}$ is continuous in
414 the metric space $(\mathcal{X},d)$.
415 \end{proposition}
416
417 The chaotic property of $G_f$ has been firstly established for the vectorial
418 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
419 introduced the notion of asynchronous iteration graph recalled bellow.
420
421 Let $f$ be a map from $\mathds{B}^\mathsf{N}$ to itself. The
422 {\emph{asynchronous iteration graph}} associated with $f$ is the
423 directed graph $\Gamma(f)$ defined by: the set of vertices is
424 $\mathds{B}^\mathsf{N}$; for all $x\in\mathds{B}^\mathsf{N}$ and 
425 $i\in \llbracket1;\mathsf{N}\rrbracket$,
426 the graph $\Gamma(f)$ contains an arc from $x$ to $F_f(i,x)$. 
427 The relation between $\Gamma(f)$ and $G_f$ is clear: there exists a
428 path from $x$ to $x'$ in $\Gamma(f)$ if and only if there exists a
429 strategy $s$ such that the parallel iteration of $G_f$ from the
430 initial point $(s,x)$ reaches the point $x'$.
431 We have then proven in \cite{bcgr11:ip} that,
432
433
434 \begin{theorem}
435 \label{Th:Caractérisation   des   IC   chaotiques}  
436 Let $f:\mathds{B}^\mathsf{N}\to\mathds{B}^\mathsf{N}$. $G_f$ is chaotic  (according to  Devaney) 
437 if and only if $\Gamma(f)$ is strongly connected.
438 \end{theorem}
439
440 Finally, we have established in \cite{bcgr11:ip} that,
441 \begin{theorem}
442   Let $f: \mathds{B}^{n} \rightarrow \mathds{B}^{n}$, $\Gamma(f)$ its
443   iteration graph, $\check{M}$ its adjacency
444   matrix and $M$
445   a $n\times n$ matrix defined by 
446   $
447   M_{ij} = \frac{1}{n}\check{M}_{ij}$ %\textrm{ 
448   if $i \neq j$ and  
449   $M_{ii} = 1 - \frac{1}{n} \sum\limits_{j=1, j\neq i}^n \check{M}_{ij}$ otherwise.
450   
451   If $\Gamma(f)$ is strongly connected, then 
452   the output of the PRNG detailed in Algorithm~\ref{CI Algorithm} follows 
453   a law that tends to the uniform distribution 
454   if and only if $M$ is a double stochastic matrix.
455 \end{theorem} 
456
457
458 These results of chaos and uniform distribution have led us to study the possibility of building a
459 pseudorandom number generator (PRNG) based on the chaotic iterations. 
460 As $G_f$, defined on the domain   $\llbracket 1 ;  \mathsf{N} \rrbracket^{\mathds{N}} 
461 \times \mathds{B}^\mathsf{N}$, is built from Boolean networks $f : \mathds{B}^\mathsf{N}
462 \rightarrow \mathds{B}^\mathsf{N}$, we can preserve the theoretical properties on $G_f$
463 during implementations (due to the discrete nature of $f$). Indeed, it is as if
464 $\mathds{B}^\mathsf{N}$ represents the memory of the computer whereas $\llbracket 1 ;  \mathsf{N}
465 \rrbracket^{\mathds{N}}$ is its input stream (the seeds, for instance, in PRNG, or a physical noise in TRNG).
466 Let us finally remark that the vectorial negation satisfies the hypotheses of both theorems above.
467
468 \section{Application to Pseudorandomness}
469 \label{sec:pseudorandom}
470
471 \subsection{A First Pseudorandom Number Generator}
472
473 We have proposed in~\cite{bgw09:ip} a new family of generators that receives 
474 two PRNGs as inputs. These two generators are mixed with chaotic iterations, 
475 leading thus to a new PRNG that improves the statistical properties of each
476 generator taken alone. Furthermore, our generator 
477 possesses various chaos properties that none of the generators used as input
478 present.
479
480
481 \begin{algorithm}[h!]
482 \begin{small}
483 \KwIn{a function $f$, an iteration number $b$, an initial configuration $x^0$
484 ($n$ bits)}
485 \KwOut{a configuration $x$ ($n$ bits)}
486 $x\leftarrow x^0$\;
487 $k\leftarrow b + \textit{XORshift}(b)$\;
488 \For{$i=0,\dots,k$}
489 {
490 $s\leftarrow{\textit{XORshift}(n)}$\;
491 $x\leftarrow{F_f(s,x)}$\;
492 }
493 return $x$\;
494 \end{small}
495 \caption{PRNG with chaotic functions}
496 \label{CI Algorithm}
497 \end{algorithm}
498
499
500
501
502 \begin{algorithm}[h!]
503 \begin{small}
504 \KwIn{the internal configuration $z$ (a 32-bit word)}
505 \KwOut{$y$ (a 32-bit word)}
506 $z\leftarrow{z\oplus{(z\ll13)}}$\;
507 $z\leftarrow{z\oplus{(z\gg17)}}$\;
508 $z\leftarrow{z\oplus{(z\ll5)}}$\;
509 $y\leftarrow{z}$\;
510 return $y$\;
511 \end{small}
512 \caption{An arbitrary round of \textit{XORshift} algorithm}
513 \label{XORshift}
514 \end{algorithm}
515
516
517
518
519
520 This generator is synthesized in Algorithm~\ref{CI Algorithm}.
521 It takes as input: a Boolean function $f$ satisfying Theorem~\ref{Th:Caractérisation   des   IC   chaotiques};
522 an integer $b$, ensuring that the number of executed iterations is at least $b$
523 and at most $2b+1$; and an initial configuration $x^0$.
524 It returns the new generated configuration $x$.  Internally, it embeds two
525 \textit{XORshift}$(k)$ PRNGs~\cite{Marsaglia2003} that return integers
526 uniformly distributed
527 into $\llbracket 1 ; k \rrbracket$.
528 \textit{XORshift} is a category of very fast PRNGs designed by George Marsaglia,
529 which repeatedly uses the transform of exclusive or (XOR, $\oplus$) on a number
530 with a bit shifted version of it. This PRNG, which has a period of
531 $2^{32}-1=4.29\times10^9$, is summed up in Algorithm~\ref{XORshift}. It is used
532 in our PRNG to compute the strategy length and the strategy elements.
533
534 This former generator has successively passed various batteries of statistical tests, as the NIST~\cite{bcgr11:ip}, DieHARD~\cite{Marsaglia1996}, and TestU01~\cite{LEcuyerS07} ones.
535
536 \subsection{Improving the Speed of the Former Generator}
537
538 Instead of updating only one cell at each iteration, we can try to choose a
539 subset of components and to update them together. Such an attempt leads
540 to a kind of merger of the two sequences used in Algorithm 
541 \ref{CI Algorithm}. When the updating function is the vectorial negation,
542 this algorithm can be rewritten as follows:
543
544 \begin{equation}
545 \left\{
546 \begin{array}{l}
547 x^0 \in \llbracket 0, 2^\mathsf{N}-1 \rrbracket, S \in \llbracket 0, 2^\mathsf{N}-1 \rrbracket^\mathds{N} \\
548 \forall n \in \mathds{N}^*, x^n = x^{n-1} \oplus S^n,
549 \end{array}
550 \right.
551 \label{equation Oplus}
552 \end{equation}
553 where $\oplus$ is for the bitwise exclusive or between two integers. 
554 This rewriting can be understood as follows. The $n-$th term $S^n$ of the
555 sequence $S$, which is an integer of $\mathsf{N}$ binary digits, presents
556 the list of cells to update in the state $x^n$ of the system (represented
557 as an integer having $\mathsf{N}$ bits too). More precisely, the $k-$th 
558 component of this state (a binary digit) changes if and only if the $k-$th 
559 digit in the binary decomposition of $S^n$ is 1.
560
561 The single basic component presented in Eq.~\ref{equation Oplus} is of 
562 ordinary use as a good elementary brick in various PRNGs. It corresponds
563 to the following discrete dynamical system in chaotic iterations:
564
565 \begin{equation}
566 \forall    n\in     \mathds{N}^{\ast     },    \forall     i\in
567 \llbracket1;\mathsf{N}\rrbracket ,x_i^n=\left\{
568 \begin{array}{ll}
569   x_i^{n-1} &  \text{ if  } i \notin \mathcal{S}^n \\
570   \left(f(x^{n-1})\right)_{S^n} & \text{ if }i \in \mathcal{S}^n.
571 \end{array}\right.
572 \label{eq:generalIC}
573 \end{equation}
574 where $f$ is the vectorial negation and $\forall n \in \mathds{N}$, 
575 $\mathcal{S}^n \subset \llbracket 1, \mathsf{N} \rrbracket$ is such that
576 $k \in \mathcal{S}^n$ if and only if the $k-$th digit in the binary
577 decomposition of $S^n$ is 1. Such chaotic iterations are more general
578 than the ones presented in Definition \ref{Def:chaotic iterations} because, instead of updating only one term at each iteration,
579 we select a subset of components to change.
580
581
582 Obviously, replacing Algorithm~\ref{CI Algorithm} by 
583 Equation~\ref{equation Oplus}, which is possible when the iteration function is
584 the vectorial negation, leads to a speed improvement. However, proofs
585 of chaos obtained in~\cite{bg10:ij} have been established
586 only for chaotic iterations of the form presented in Definition 
587 \ref{Def:chaotic iterations}. The question is now to determine whether the
588 use of more general chaotic iterations to generate pseudorandom numbers 
589 faster, does not deflate their topological chaos properties.
590
591 \subsection{Proofs of Chaos of the General Formulation of the Chaotic Iterations}
592 \label{deuxième def}
593 Let us consider the discrete dynamical systems in chaotic iterations having 
594 the general form:
595
596 \begin{equation}
597 \forall    n\in     \mathds{N}^{\ast     },    \forall     i\in
598 \llbracket1;\mathsf{N}\rrbracket ,x_i^n=\left\{
599 \begin{array}{ll}
600   x_i^{n-1} &  \text{ if  } i \notin \mathcal{S}^n \\
601   \left(f(x^{n-1})\right)_{S^n} & \text{ if }i \in \mathcal{S}^n.
602 \end{array}\right.
603 \label{general CIs}
604 \end{equation}
605
606 In other words, at the $n^{th}$ iteration, only the cells whose id is
607 contained into the set $S^{n}$ are iterated.
608
609 Let us now rewrite these general chaotic iterations as usual discrete dynamical
610 system of the form $X^{n+1}=f(X^n)$ on an ad hoc metric space. Such a formulation
611 is required in order to study the topological behavior of the system.
612
613 Let us introduce the following function:
614 \begin{equation}
615 \begin{array}{cccc}
616  \chi: & \llbracket 1; \mathsf{N} \rrbracket \times \mathcal{P}\left(\llbracket 1; \mathsf{N} \rrbracket\right) & \longrightarrow & \mathds{B}\\
617          & (i,X) & \longmapsto  & \left\{ \begin{array}{ll} 0 & \textrm{if }i \notin X, \\ 1 & \textrm{if }i \in X,  \end{array}\right.
618 \end{array} 
619 \end{equation}
620 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$.
621
622 Given a function $f:\mathds{B}^\mathsf{N} \longrightarrow \mathds{B}^\mathsf{N} $, define the function:
623 %%RAPH : j'ai coupé la dernière ligne en 2, c'est moche
624 \begin{equation}
625 \begin{array}{lrll}
626 F_{f}: & \mathcal{P}\left(\llbracket1;\mathsf{N}\rrbracket \right) \times \mathds{B}^{\mathsf{N}} &
627 \longrightarrow & \mathds{B}^{\mathsf{N}} \\
628 & (P,E) & \longmapsto & \left( E_{j}.\chi (j,P)+\right.\\
629 &       &             &\left.f(E)_{j}.\overline{\chi(j,P)}\right) _{j\in \llbracket1;\mathsf{N}\rrbracket},%
630 \end{array}%
631 \end{equation}%
632 where + and . are the Boolean addition and product operations, and $\overline{x}$ 
633 is the negation of the Boolean $x$.
634 Consider the phase space:
635 \begin{equation}
636 \mathcal{X} = \mathcal{P}\left(\llbracket 1 ; \mathsf{N} \rrbracket\right)^\mathds{N} \times
637 \mathds{B}^\mathsf{N},
638 \end{equation}
639 \noindent and the map defined on $\mathcal{X}$:
640 \begin{equation}
641 G_f\left(S,E\right) = \left(\sigma(S), F_f(i(S),E)\right), %\label{Gf} %%RAPH, j'ai viré ce label qui existe déjà avant...
642 \end{equation}
643 \noindent where $\sigma$ is the \emph{shift} function defined by $\sigma
644 (S^{n})_{n\in \mathds{N}}\in \mathcal{P}\left(\llbracket 1 ; \mathsf{N} \rrbracket\right)^\mathds{N}\longrightarrow (S^{n+1})_{n\in
645 \mathds{N}}\in \mathcal{P}\left(\llbracket 1 ; \mathsf{N} \rrbracket\right)^\mathds{N}$ and $i$ is the \emph{initial function} 
646 $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)$. 
647 Then the general chaotic iterations defined in Equation \ref{general CIs} can 
648 be described by the following discrete dynamical system:
649 \begin{equation}
650 \left\{
651 \begin{array}{l}
652 X^0 \in \mathcal{X} \\
653 X^{k+1}=G_{f}(X^k).%
654 \end{array}%
655 \right.
656 \end{equation}%
657
658 Once more, a shift function appears as a component of these general chaotic 
659 iterations. 
660
661 To study the Devaney's chaos property, a distance between two points 
662 $X = (S,E), Y = (\check{S},\check{E})$ of $\mathcal{X}$ must be defined.
663 Let us introduce:
664 \begin{equation}
665 d(X,Y)=d_{e}(E,\check{E})+d_{s}(S,\check{S}),
666 \label{nouveau d}
667 \end{equation}
668 \noindent where $ \displaystyle{d_{e}(E,\check{E})} = \displaystyle{\sum_{k=1}^{\mathsf{N}%
669  }\delta (E_{k},\check{E}_{k})}$  is once more the Hamming distance, and
670 $  \displaystyle{d_{s}(S,\check{S})}  =  \displaystyle{\dfrac{9}{\mathsf{N}}%
671  \sum_{k=1}^{\infty }\dfrac{|S^k\Delta {S}^k|}{10^{k}}}$,
672 %%RAPH : ici, j'ai supprimé tous les sauts à la ligne
673 %% \begin{equation}
674 %% \left\{
675 %% \begin{array}{lll}
676 %% \displaystyle{d_{e}(E,\check{E})} & = & \displaystyle{\sum_{k=1}^{\mathsf{N}%
677 %% }\delta (E_{k},\check{E}_{k})} \textrm{ is once more the Hamming distance}, \\
678 %% \displaystyle{d_{s}(S,\check{S})} & = & \displaystyle{\dfrac{9}{\mathsf{N}}%
679 %% \sum_{k=1}^{\infty }\dfrac{|S^k\Delta {S}^k|}{10^{k}}}.%
680 %% \end{array}%
681 %% \right.
682 %% \end{equation}
683 where $|X|$ is the cardinality of a set $X$ and $A\Delta B$ is for the symmetric difference, defined for sets A, B as
684 $A\,\Delta\,B = (A \setminus B) \cup (B \setminus A)$.
685
686
687 \begin{proposition}
688 The function $d$ defined in Eq.~\ref{nouveau d} is a metric on $\mathcal{X}$.
689 \end{proposition}
690
691 \begin{proof}
692  $d_e$ is the Hamming distance. We will prove that $d_s$ is a distance
693 too, thus $d$, as being the sum of two distances, will also be a distance.
694  \begin{itemize}
695 \item Obviously, $d_s(S,\check{S})\geqslant 0$, and if $S=\check{S}$, then 
696 $d_s(S,\check{S})=0$. Conversely, if $d_s(S,\check{S})=0$, then 
697 $\forall k \in \mathds{N}, |S^k\Delta {S}^k|=0$, and so $\forall k, S^k=\check{S}^k$.
698  \item $d_s$ is symmetric 
699 ($d_s(S,\check{S})=d_s(\check{S},S)$) due to the commutative property
700 of the symmetric difference. 
701 \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''|$, 
702 and so for all subsets $S,S',$ and $S''$ of $\llbracket 1, \mathsf{N} \rrbracket$, 
703 we have $d_s(S,S'') \leqslant d_e(S,S')+d_s(S',S'')$, and the triangle
704 inequality is obtained.
705  \end{itemize}
706 \end{proof}
707
708
709 Before being able to study the topological behavior of the general 
710 chaotic iterations, we must first establish that:
711
712 \begin{proposition}
713  For all $f:\mathds{B}^\mathsf{N} \longrightarrow \mathds{B}^\mathsf{N} $, the function $G_f$ is continuous on 
714 $\left( \mathcal{X},d\right)$.
715 \end{proposition}
716
717
718 \begin{proof}
719 We use the sequential continuity.
720 Let $(S^n,E^n)_{n\in \mathds{N}}$ be a sequence of the phase space $%
721 \mathcal{X}$, which converges to $(S,E)$. We will prove that $\left(
722 G_{f}(S^n,E^n)\right) _{n\in \mathds{N}}$ converges to $\left(
723 G_{f}(S,E)\right) $. Let us remark that for all $n$, $S^n$ is a strategy,
724 thus, we consider a sequence of strategies (\emph{i.e.}, a sequence of
725 sequences).\newline
726 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
727 to 0. But $d_{e}(E^n,E)$ is an integer, so $\exists n_{0}\in \mathds{N},$ $%
728 d_{e}(E^n,E)=0$ for any $n\geqslant n_{0}$.\newline
729 In other words, there exists a threshold $n_{0}\in \mathds{N}$ after which no
730 cell will change its state:
731 $\exists n_{0}\in \mathds{N},n\geqslant n_{0}\Rightarrow E^n = E.$
732
733 In addition, $d_{s}(S^n,S)\longrightarrow 0,$ so $\exists n_{1}\in %
734 \mathds{N},d_{s}(S^n,S)<10^{-1}$ for all indexes greater than or equal to $%
735 n_{1}$. This means that for $n\geqslant n_{1}$, all the $S^n$ have the same
736 first term, which is $S^0$: $\forall n\geqslant n_{1},S_0^n=S_0.$
737
738 Thus, after the $max(n_{0},n_{1})^{th}$ term, states of $E^n$ and $E$ are
739 identical and strategies $S^n$ and $S$ start with the same first term.\newline
740 Consequently, states of $G_{f}(S^n,E^n)$ and $G_{f}(S,E)$ are equal,
741 so, after the $max(n_0, n_1)^{th}$ term, the distance $d$ between these two points is strictly less than 1.\newline
742 \noindent We now prove that the distance between $\left(
743 G_{f}(S^n,E^n)\right) $ and $\left( G_{f}(S,E)\right) $ is convergent to
744 0. Let $\varepsilon >0$. \medskip
745 \begin{itemize}
746 \item If $\varepsilon \geqslant 1$, we see that the distance
747 between $\left( G_{f}(S^n,E^n)\right) $ and $\left( G_{f}(S,E)\right) $ is
748 strictly less than 1 after the $max(n_{0},n_{1})^{th}$ term (same state).
749 \medskip
750 \item If $\varepsilon <1$, then $\exists k\in \mathds{N},10^{-k}\geqslant
751 \varepsilon > 10^{-(k+1)}$. But $d_{s}(S^n,S)$ converges to 0, so
752 \begin{equation*}
753 \exists n_{2}\in \mathds{N},\forall n\geqslant
754 n_{2},d_{s}(S^n,S)<10^{-(k+2)},
755 \end{equation*}%
756 thus after $n_{2}$, the $k+2$ first terms of $S^n$ and $S$ are equal.
757 \end{itemize}
758 \noindent As a consequence, the $k+1$ first entries of the strategies of $%
759 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
760 the distance between $(S^n,E^n)$ and $(S,E)$ is strictly less than $%
761 10^{-(k+1)}\leqslant \varepsilon $.\bigskip \newline
762 In conclusion,
763 %%RAPH : ici j'ai rajouté une ligne
764 \begin{flushleft}$$
765 \forall \varepsilon >0,\exists N_{0}=max(n_{0},n_{1},n_{2})\in \mathds{N}%
766 ,\forall n\geqslant N_{0},$$
767 $$ d\left( G_{f}(S^n,E^n);G_{f}(S,E)\right)
768 \leqslant \varepsilon .
769 $$
770 \end{flushleft}
771 $G_{f}$ is consequently continuous.
772 \end{proof}
773
774
775 It is now possible to study the topological behavior of the general chaotic
776 iterations. We will prove that,
777
778 \begin{theorem}
779 \label{t:chaos des general}
780  The general chaotic iterations defined on Equation~\ref{general CIs} satisfy
781 the Devaney's property of chaos.
782 \end{theorem}
783
784 Let us firstly prove the following lemma.
785
786 \begin{lemma}[Strong transitivity]
787 \label{strongTrans}
788  For all couples $X,Y \in \mathcal{X}$ and any neighborhood $V$ of $X$, we can 
789 find $n \in \mathds{N}^*$ and $X' \in V$ such that $G^n(X')=Y$.
790 \end{lemma}
791
792 \begin{proof}
793  Let $X=(S,E)$, $\varepsilon>0$, and $k_0 = \lfloor log_{10}(\varepsilon)+1 \rfloor$. 
794 Any point $X'=(S',E')$ such that $E'=E$ and $\forall k \leqslant k_0, S'^k=S^k$, 
795 are in the open ball $\mathcal{B}\left(X,\varepsilon\right)$. Let us define 
796 $\check{X} = \left(\check{S},\check{E}\right)$, where $\check{X}= G^{k_0}(X)$.
797 We denote by $s\subset \llbracket 1; \mathsf{N} \rrbracket$ the set of coordinates
798 that are different between $\check{E}$ and the state of $Y$. Thus each point $X'$ of
799 the form $(S',E')$ where $E'=E$ and $S'$ starts with 
800 $(S^0, S^1, \hdots, S^{k_0},s,\hdots)$, verifies the following properties:
801 \begin{itemize}
802  \item $X'$ is in $\mathcal{B}\left(X,\varepsilon\right)$,
803  \item the state of $G_f^{k_0+1}(X')$ is the state of $Y$.
804 \end{itemize}
805 Finally the point $\left(\left(S^0, S^1, \hdots, S^{k_0},s,s^0, s^1, \hdots\right); E\right)$, 
806 where $(s^0,s^1, \hdots)$ is the strategy of $Y$, satisfies the properties
807 claimed in the lemma.
808 \end{proof}
809
810 We can now prove Theorem~\ref{t:chaos des general}...
811
812 \begin{proof}[Theorem~\ref{t:chaos des general}]
813 Firstly, strong transitivity implies transitivity.
814
815 Let $(S,E) \in\mathcal{X}$ and $\varepsilon >0$. To
816 prove that $G_f$ is regular, it is sufficient to prove that
817 there exists a strategy $\tilde S$ such that the distance between
818 $(\tilde S,E)$ and $(S,E)$ is less than $\varepsilon$, and such that
819 $(\tilde S,E)$ is a periodic point.
820
821 Let $t_1=\lfloor-\log_{10}(\varepsilon)\rfloor$, and let $E'$ be the
822 configuration that we obtain from $(S,E)$ after $t_1$ iterations of
823 $G_f$. As $G_f$ is strongly transitive, there exists a strategy $S'$ 
824 and $t_2\in\mathds{N}$ such
825 that $E$ is reached from $(S',E')$ after $t_2$ iterations of $G_f$.
826
827 Consider the strategy $\tilde S$ that alternates the first $t_1$ terms
828 of $S$ and the first $t_2$ terms of $S'$: 
829 %%RAPH : j'ai coupé la ligne en 2
830 $$\tilde
831 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
832 is clear that $(\tilde S,E)$ is obtained from $(\tilde S,E)$ after
833 $t_1+t_2$ iterations of $G_f$. So $(\tilde S,E)$ is a periodic
834 point. Since $\tilde S_t=S_t$ for $t<t_1$, by the choice of $t_1$, we
835 have $d((S,E),(\tilde S,E))<\epsilon$.
836 \end{proof}
837
838
839
840 \section{Efficient PRNG based on Chaotic Iterations}
841 \label{sec:efficient PRNG}
842
843 Based on the proof presented in the previous section, it is now possible to 
844 improve the speed of the generator formerly presented in~\cite{bgw09:ip,guyeux10}. 
845 The first idea is to consider
846 that the provided strategy is a pseudorandom Boolean vector obtained by a
847 given PRNG.
848 An iteration of the system is simply the bitwise exclusive or between
849 the last computed state and the current strategy.
850 Topological properties of disorder exhibited by chaotic 
851 iterations can be inherited by the inputted generator, we hope by doing so to 
852 obtain some statistical improvements while preserving speed.
853
854 %%RAPH : j'ai viré tout ca
855 %% Let us give an example using 16-bits numbers, to clearly understand how the bitwise xor operations
856 %% are
857 %% done.  
858 %% Suppose  that $x$ and the  strategy $S^i$ are given as
859 %% binary vectors.
860 %% Table~\ref{TableExemple} shows the result of $x \oplus S^i$.
861
862 %% \begin{table}
863 %% \begin{scriptsize}
864 %% $$
865 %% \begin{array}{|cc|cccccccccccccccc|}
866 %% \hline
867 %% x      &=&1&0&1&1&1&0&1&0&1&0&0&1&0&0&1&0\\
868 %% \hline
869 %% S^i      &=&0&1&1&0&0&1&1&0&1&1&1&0&0&1&1&1\\
870 %% \hline
871 %% x \oplus S^i&=&1&1&0&1&1&1&0&0&0&1&1&1&0&1&0&1\\
872 %% \hline
873
874 %% \hline
875 %%  \end{array}
876 %% $$
877 %% \end{scriptsize}
878 %% \caption{Example of an arbitrary round of the proposed generator}
879 %% \label{TableExemple}
880 %% \end{table}
881
882
883
884
885 \lstset{language=C,caption={C code of the sequential PRNG based on chaotic iterations},label=algo:seqCIPRNG}
886 \begin{small}
887 \begin{lstlisting}
888
889 unsigned int CIPRNG() {
890   static unsigned int x = 123123123;
891   unsigned long t1 = xorshift();
892   unsigned long t2 = xor128();
893   unsigned long t3 = xorwow();
894   x = x^(unsigned int)t1;
895   x = x^(unsigned int)(t2>>32);
896   x = x^(unsigned int)(t3>>32);
897   x = x^(unsigned int)t2;
898   x = x^(unsigned int)(t1>>32);
899   x = x^(unsigned int)t3;
900   return x;
901 }
902 \end{lstlisting}
903 \end{small}
904
905
906
907 In Listing~\ref{algo:seqCIPRNG} a sequential  version of the proposed PRNG based
908 on  chaotic  iterations  is  presented.   The xor  operator  is  represented  by
909 \textasciicircum.  This function uses  three classical 64-bits PRNGs, namely the
910 \texttt{xorshift},         the          \texttt{xor128},         and         the
911 \texttt{xorwow}~\cite{Marsaglia2003}.  In the following, we call them ``xor-like
912 PRNGs''.   As each  xor-like PRNG  uses 64-bits  whereas our  proposed generator
913 works with 32-bits, we use the command \texttt{(unsigned int)}, that selects the
914 32 least  significant bits  of a given  integer, and the  code \texttt{(unsigned
915   int)(t$>>$32)} in order to obtain the 32 most significant bits of \texttt{t}.
916
917 Thus producing a pseudorandom number needs 6 xor operations with 6 32-bits numbers
918 that  are provided by  3 64-bits  PRNGs.  This  version successfully  passes the
919 stringent BigCrush battery of tests~\cite{LEcuyerS07}.
920
921 \section{Efficient PRNGs based on Chaotic Iterations on GPU}
922 \label{sec:efficient PRNG gpu}
923
924 In order to  take benefits from the computing power  of GPU, a program
925 needs  to have  independent blocks  of  threads that  can be  computed
926 simultaneously. In general,  the larger the number of  threads is, the
927 more local  memory is  used, and the  less branching  instructions are
928 used  (if,  while,  ...),  the  better the  performances  on  GPU  is.
929 Obviously, having these requirements in  mind, it is possible to build
930 a   program    similar   to    the   one   presented    in  Listing 
931 \ref{algo:seqCIPRNG}, which computes  pseudorandom numbers on GPU.  To
932 do  so,  we  must   firstly  recall  that  in  the  CUDA~\cite{Nvid10}
933 environment,    threads    have     a    local    identifier    called
934 \texttt{ThreadIdx},  which   is  relative  to   the  block  containing
935 them. Furthermore, in  CUDA, parts of  the code that are executed by the  GPU, are
936 called {\it kernels}.
937
938
939 \subsection{Naive Version for GPU}
940
941  
942 It is possible to deduce from the CPU version a quite similar version adapted to GPU.
943 The simple principle consists in making each thread of the GPU computing the CPU version of our PRNG.  
944 Of course,  the  three xor-like
945 PRNGs  used in these computations must have different  parameters. 
946 In a given thread, these parameters are
947 randomly picked from another PRNGs. 
948 The  initialization stage is performed by  the CPU.
949 To do it, the  ISAAC  PRNG~\cite{Jenkins96} is used to  set  all  the
950 parameters embedded into each thread.   
951
952 The implementation of  the three
953 xor-like  PRNGs  is  straightforward  when  their  parameters  have  been
954 allocated in  the GPU memory.  Each xor-like  works with  an internal
955 number  $x$  that saves  the  last  generated  pseudorandom number. Additionally,  the
956 implementation of the  xor128, the xorshift, and the  xorwow respectively require
957 4, 5, and 6 unsigned long as internal variables.
958
959
960 \begin{algorithm}
961 \begin{small}
962 \KwIn{InternalVarXorLikeArray: array with internal variables of the 3 xor-like
963 PRNGs in global memory\;
964 NumThreads: number of threads\;}
965 \KwOut{NewNb: array containing random numbers in global memory}
966 \If{threadIdx is concerned by the computation} {
967   retrieve data from InternalVarXorLikeArray[threadIdx] in local variables\;
968   \For{i=1 to n} {
969     compute a new PRNG as in Listing\ref{algo:seqCIPRNG}\;
970     store the new PRNG in NewNb[NumThreads*threadIdx+i]\;
971   }
972   store internal variables in InternalVarXorLikeArray[threadIdx]\;
973 }
974 \end{small}
975 \caption{Main kernel of the GPU ``naive'' version of the PRNG based on chaotic iterations}
976 \label{algo:gpu_kernel}
977 \end{algorithm}
978
979
980
981 Algorithm~\ref{algo:gpu_kernel}  presents a naive  implementation of the proposed  PRNG on
982 GPU.  Due to the available  memory in the  GPU and the number  of threads
983 used simultaneously,  the number  of random numbers  that a thread  can generate
984 inside   a    kernel   is   limited  (\emph{i.e.},    the    variable   \texttt{n}   in
985 algorithm~\ref{algo:gpu_kernel}). For instance, if  $100,000$ threads are used and
986 if $n=100$\footnote{in fact, we need to add the initial seed (a 32-bits number)},
987 then   the  memory   required   to  store all of the  internals   variables  of both the  xor-like
988 PRNGs\footnote{we multiply this number by $2$ in order to count 32-bits numbers}
989 and  the pseudorandom  numbers generated by  our  PRNG,  is  equal to  $100,000\times  ((4+5+6)\times
990 2+(1+100))=1,310,000$ 32-bits numbers, that is, approximately $52$Mb.
991
992 This generator is able to pass the whole BigCrush battery of tests, for all
993 the versions that have been tested depending on their number of threads 
994 (called \texttt{NumThreads} in our algorithm, tested up to $5$ million).
995
996 \begin{remark}
997 The proposed algorithm has  the  advantage of  manipulating  independent
998 PRNGs, so this version is easily adaptable on a cluster of computers too. The only thing
999 to ensure is to use a single ISAAC PRNG. To achieve this requirement, a simple solution consists in
1000 using a master node for the initialization. This master node computes the initial parameters
1001 for all the different nodes involved in the computation.
1002 \end{remark}
1003
1004 \subsection{Improved Version for GPU}
1005
1006 As GPU cards using CUDA have shared memory between threads of the same block, it
1007 is possible  to use this  feature in order  to simplify the  previous algorithm,
1008 i.e., to use less  than 3 xor-like PRNGs. The solution  consists in computing only
1009 one xor-like PRNG by thread, saving  it into the shared memory, and then to use the results
1010 of some  other threads in the  same block of  threads. In order to  define which
1011 thread uses the result of which other  one, we can use a combination array that
1012 contains  the indexes  of  all threads  and  for which  a combination has  been
1013 performed. 
1014
1015 In  Algorithm~\ref{algo:gpu_kernel2},  two  combination  arrays are  used.   The
1016 variable     \texttt{offset}    is     computed    using     the     value    of
1017 \texttt{combination\_size}.   Then we  can compute  \texttt{o1}  and \texttt{o2}
1018 representing the  indexes of  the other  threads whose results  are used  by the
1019 current one.   In this algorithm, we  consider that a 32-bits  xor-like PRNG has
1020 been chosen. In practice, we  use the xor128 proposed in~\cite{Marsaglia2003} in
1021 which  unsigned longs  (64 bits)  have been  replaced by  unsigned  integers (32
1022 bits).
1023
1024 This version  can also pass the whole {\it BigCrush} battery of tests.
1025
1026 \begin{algorithm}
1027 \begin{small}
1028 \KwIn{InternalVarXorLikeArray: array with internal variables of 1 xor-like PRNGs
1029 in global memory\;
1030 NumThreads: Number of threads\;
1031 array\_comb1, array\_comb2: Arrays containing combinations of size combination\_size\;}
1032
1033 \KwOut{NewNb: array containing random numbers in global memory}
1034 \If{threadId is concerned} {
1035   retrieve data from InternalVarXorLikeArray[threadId] in local variables including shared memory and x\;
1036   offset = threadIdx\%combination\_size\;
1037   o1 = threadIdx-offset+array\_comb1[offset]\;
1038   o2 = threadIdx-offset+array\_comb2[offset]\;
1039   \For{i=1 to n} {
1040     t=xor-like()\;
1041     t=t\textasciicircum shmem[o1]\textasciicircum shmem[o2]\;
1042     shared\_mem[threadId]=t\;
1043     x = x\textasciicircum t\;
1044
1045     store the new PRNG in NewNb[NumThreads*threadId+i]\;
1046   }
1047   store internal variables in InternalVarXorLikeArray[threadId]\;
1048 }
1049 \end{small}
1050 \caption{Main kernel for the chaotic iterations based PRNG GPU efficient
1051 version\label{IR}}
1052 \label{algo:gpu_kernel2} 
1053 \end{algorithm}
1054
1055 \subsection{Theoretical Evaluation of the Improved Version}
1056
1057 A run of Algorithm~\ref{algo:gpu_kernel2} consists in an operation ($x=x\oplus t$) having 
1058 the form of Equation~\ref{equation Oplus}, which is equivalent to the iterative
1059 system of Eq.~\ref{eq:generalIC}. That is, an iteration of the general chaotic
1060 iterations is realized between the last stored value $x$ of the thread and a strategy $t$
1061 (obtained by a bitwise exclusive or between a value provided by a xor-like() call
1062 and two values previously obtained by two other threads).
1063 To be certain that we are in the framework of Theorem~\ref{t:chaos des general},
1064 we must guarantee that this dynamical system iterates on the space 
1065 $\mathcal{X} = \mathcal{P}\left(\llbracket 1, \mathsf{N} \rrbracket\right)^\mathds{N}\times\mathds{B}^\mathsf{N}$.
1066 The left term $x$ obviously belongs to $\mathds{B}^ \mathsf{N}$.
1067 To prevent from any flaws of chaotic properties, we must check that the right 
1068 term (the last $t$), corresponding to the strategies,  can possibly be equal to any
1069 integer of $\llbracket 1, \mathsf{N} \rrbracket$. 
1070
1071 Such a result is obvious, as for the xor-like(), all the
1072 integers belonging into its interval of definition can occur at each iteration, and thus the 
1073 last $t$ respects the requirement. Furthermore, it is possible to
1074 prove by an immediate mathematical induction that, as the initial $x$
1075 is uniformly distributed (it is provided by a cryptographically secure PRNG),
1076 the two other stored values shmem[o1] and shmem[o2] are uniformly distributed too,
1077 (this is the induction hypothesis), and thus the next $x$ is finally uniformly distributed.
1078
1079 Thus Algorithm~\ref{algo:gpu_kernel2} is a concrete realization of the general
1080 chaotic iterations presented previously, and for this reason, it satisfies the 
1081 Devaney's formulation of a chaotic behavior.
1082
1083 \section{Experiments}
1084 \label{sec:experiments}
1085
1086 Different experiments  have been  performed in order  to measure  the generation
1087 speed. We have used a first computer equipped with a Tesla C1060 NVidia  GPU card
1088 and an
1089 Intel  Xeon E5530 cadenced  at 2.40  GHz,  and 
1090 a second computer  equipped with a smaller  CPU and  a GeForce GTX  280. 
1091 All the
1092 cards have 240 cores.
1093
1094 In  Figure~\ref{fig:time_xorlike_gpu} we  compare the  quantity of  pseudorandom numbers
1095 generated per second with various xor-like based PRNGs. In this figure, the optimized
1096 versions use the {\it xor64} described in~\cite{Marsaglia2003}, whereas the naive versions
1097 embed  the three  xor-like  PRNGs described  in Listing~\ref{algo:seqCIPRNG}.   In
1098 order to obtain the optimal performances, the storage of pseudorandom numbers
1099 into the GPU memory has been removed. This step is time consuming and slows down the numbers
1100 generation.  Moreover this   storage  is  completely
1101 useless, in case of applications that consume the pseudorandom
1102 numbers  directly   after generation. We can see  that when the number of  threads is greater
1103 than approximately 30,000 and lower than 5 million, the number of pseudorandom numbers generated
1104 per second  is almost constant.  With the  naive version, this value ranges from 2.5 to
1105 3GSamples/s.   With  the  optimized   version,  it  is  approximately  equal to
1106 20GSamples/s. Finally  we can remark  that both GPU  cards are quite  similar, but in
1107 practice,  the Tesla C1060  has more  memory than  the GTX  280, and  this memory
1108 should be of better quality.
1109 As a  comparison,   Listing~\ref{algo:seqCIPRNG}  leads   to the  generation of  about
1110 138MSample/s when using one core of the Xeon E5530.
1111
1112 \begin{figure}[htbp]
1113 \begin{center}
1114   \includegraphics[width=\columnwidth]{curve_time_xorlike_gpu.pdf}
1115 \end{center}
1116 \caption{Quantity of pseudorandom numbers generated per second with the xorlike-based PRNG}
1117 \label{fig:time_xorlike_gpu}
1118 \end{figure}
1119
1120
1121
1122
1123
1124 In Figure~\ref{fig:time_bbs_gpu} we highlight  the performances of the optimized
1125 BBS-based PRNG on GPU.  On  the Tesla C1060 we obtain approximately 700MSample/s
1126 and  on the  GTX 280  about  670MSample/s, which  is obviously  slower than  the
1127 xorlike-based PRNG on GPU. However, we  will show in the next sections that this
1128 new PRNG  has a strong  level of  security, which is  necessarily paid by  a speed
1129 reduction.
1130
1131 \begin{figure}[htbp]
1132 \begin{center}
1133   \includegraphics[width=\columnwidth]{curve_time_bbs_gpu.pdf}
1134 \end{center}
1135 \caption{Quantity of pseudorandom numbers generated per second using the BBS-based PRNG}
1136 \label{fig:time_bbs_gpu}
1137 \end{figure}
1138
1139 All  these  experiments allow  us  to conclude  that  it  is possible  to
1140 generate a very large quantity of pseudorandom  numbers statistically perfect with the  xor-like version.
1141 To a certain extend, it is also the case with the secure BBS-based version, the speed deflation being
1142 explained by the fact that the former  version has ``only''
1143 chaotic properties and statistical perfection, whereas the latter is also cryptographically secure,
1144 as it is shown in the next sections.
1145
1146
1147
1148
1149
1150
1151
1152 \section{Security Analysis}
1153 \label{sec:security analysis}
1154
1155
1156
1157 In this section the concatenation of two strings $u$ and $v$ is classically
1158 denoted by $uv$.
1159 In a cryptographic context, a pseudorandom generator is a deterministic
1160 algorithm $G$ transforming strings  into strings and such that, for any
1161 seed $s$ of length $m$, $G(s)$ (the output of $G$ on the input $s$) has size
1162 $\ell_G(m)$ with $\ell_G(m)>m$.
1163 The notion of {\it secure} PRNGs can now be defined as follows. 
1164
1165 \begin{definition}
1166 A cryptographic PRNG $G$ is secure if for any probabilistic polynomial time
1167 algorithm $D$, for any positive polynomial $p$, and for all sufficiently
1168 large $m$'s,
1169 $$| \mathrm{Pr}[D(G(U_m))=1]-Pr[D(U_{\ell_G(m)})=1]|< \frac{1}{p(m)},$$
1170 where $U_r$ is the uniform distribution over $\{0,1\}^r$ and the
1171 probabilities are taken over $U_m$, $U_{\ell_G(m)}$ as well as over the
1172 internal coin tosses of $D$. 
1173 \end{definition}
1174
1175 Intuitively, it means that there is no polynomial time algorithm that can
1176 distinguish a perfect uniform random generator from $G$ with a non
1177 negligible probability. The interested reader is referred
1178 to~\cite[chapter~3]{Goldreich} for more information. Note that it is
1179 quite easily possible to change the function $\ell$ into any polynomial
1180 function $\ell^\prime$ satisfying $\ell^\prime(m)>m)$~\cite[Chapter 3.3]{Goldreich}.
1181
1182 The generation schema developed in (\ref{equation Oplus}) is based on a
1183 pseudorandom generator. Let $H$ be a cryptographic PRNG. We may assume,
1184 without loss of generality, that for any string $S_0$ of size $N$, the size
1185 of $H(S_0)$ is $kN$, with $k>2$. It means that $\ell_H(N)=kN$. 
1186 Let $S_1,\ldots,S_k$ be the 
1187 strings of length $N$ such that $H(S_0)=S_1 \ldots S_k$ ($H(S_0)$ is the concatenation of
1188 the $S_i$'s). The cryptographic PRNG $X$ defined in (\ref{equation Oplus})
1189 is the algorithm mapping any string of length $2N$ $x_0S_0$ into the string
1190 $(x_0\oplus S_0 \oplus S_1)(x_0\oplus S_0 \oplus S_1\oplus S_2)\ldots
1191 (x_o\bigoplus_{i=0}^{i=k}S_i)$. One in particular has $\ell_{X}(2N)=kN=\ell_H(N)$. 
1192 We claim now that if this PRNG is secure,
1193 then the new one is secure too.
1194
1195 \begin{proposition}
1196 \label{cryptopreuve}
1197 If $H$ is a secure cryptographic PRNG, then $X$ is a secure cryptographic
1198 PRNG too.
1199 \end{proposition}
1200
1201 \begin{proof}
1202 The proposition is proved by contraposition. Assume that $X$ is not
1203 secure. By Definition, there exists a polynomial time probabilistic
1204 algorithm $D$, a positive polynomial $p$, such that for all $k_0$ there exists
1205 $N\geq \frac{k_0}{2}$ satisfying 
1206 $$| \mathrm{Pr}[D(X(U_{2N}))=1]-\mathrm{Pr}[D(U_{kN}=1]|\geq \frac{1}{p(2N)}.$$
1207 We describe a new probabilistic algorithm $D^\prime$ on an input $w$ of size
1208 $kN$:
1209 \begin{enumerate}
1210 \item Decompose $w$ into $w=w_1\ldots w_{k}$, where each $w_i$ has size $N$.
1211 \item Pick a string $y$ of size $N$ uniformly at random.
1212 \item Compute $z=(y\oplus w_1)(y\oplus w_1\oplus w_2)\ldots (y
1213   \bigoplus_{i=1}^{i=k} w_i).$
1214 \item Return $D(z)$.
1215 \end{enumerate}
1216
1217
1218 Consider  for each $y\in \mathbb{B}^{kN}$ the function $\varphi_{y}$
1219 from $\mathbb{B}^{kN}$ into $\mathbb{B}^{kN}$ mapping $w=w_1\ldots w_k$
1220 (each $w_i$ has length $N$) to 
1221 $(y\oplus w_1)(y\oplus w_1\oplus w_2)\ldots (y
1222   \bigoplus_{i=1}^{i=k_1} w_i).$ By construction, one has for every $w$,
1223 \begin{equation}\label{PCH-1}
1224 D^\prime(w)=D(\varphi_y(w)),
1225 \end{equation}
1226 where $y$ is randomly generated. 
1227 Moreover, for each $y$, $\varphi_{y}$ is injective: if 
1228 $(y\oplus w_1)(y\oplus w_1\oplus w_2)\ldots (y\bigoplus_{i=1}^{i=k_1}
1229 w_i)=(y\oplus w_1^\prime)(y\oplus w_1^\prime\oplus w_2^\prime)\ldots
1230 (y\bigoplus_{i=1}^{i=k} w_i^\prime)$, then for every $1\leq j\leq k$,
1231 $y\bigoplus_{i=1}^{i=j} w_i^\prime=y\bigoplus_{i=1}^{i=j} w_i$. It follows,
1232 by a direct induction, that $w_i=w_i^\prime$. Furthermore, since $\mathbb{B}^{kN}$
1233 is finite, each $\varphi_y$ is bijective. Therefore, and using (\ref{PCH-1}),
1234 one has
1235 \begin{equation}\label{PCH-2}
1236 \mathrm{Pr}[D^\prime(U_{kN})=1]=\mathrm{Pr}[D(\varphi_y(U_{kN}))=1]=\mathrm{Pr}[D(U_{kN})=1].
1237 \end{equation}
1238
1239 Now, using (\ref{PCH-1}) again, one has  for every $x$,
1240 \begin{equation}\label{PCH-3}
1241 D^\prime(H(x))=D(\varphi_y(H(x))),
1242 \end{equation}
1243 where $y$ is randomly generated. By construction, $\varphi_y(H(x))=X(yx)$,
1244 thus
1245 \begin{equation}%\label{PCH-3}      %%RAPH : j'ai viré ce label qui existe déjà, il est 3 ligne avant
1246 D^\prime(H(x))=D(yx),
1247 \end{equation}
1248 where $y$ is randomly generated. 
1249 It follows that 
1250
1251 \begin{equation}\label{PCH-4}
1252 \mathrm{Pr}[D^\prime(H(U_{N}))=1]=\mathrm{Pr}[D(U_{2N})=1].
1253 \end{equation}
1254  From (\ref{PCH-2}) and (\ref{PCH-4}), one can deduce that
1255 there exists a polynomial time probabilistic
1256 algorithm $D^\prime$, a positive polynomial $p$, such that for all $k_0$ there exists
1257 $N\geq \frac{k_0}{2}$ satisfying 
1258 $$| \mathrm{Pr}[D(H(U_{N}))=1]-\mathrm{Pr}[D(U_{kN}=1]|\geq \frac{1}{p(2N)},$$
1259 proving that $H$ is not secure, which is a contradiction. 
1260 \end{proof}
1261
1262
1263 \section{Cryptographical Applications}
1264
1265 \subsection{A Cryptographically Secure PRNG for GPU}
1266 \label{sec:CSGPU}
1267
1268 It is  possible to build a  cryptographically secure PRNG based  on the previous
1269 algorithm (Algorithm~\ref{algo:gpu_kernel2}).   Due to Proposition~\ref{cryptopreuve},
1270 it simply consists  in replacing
1271 the  {\it  xor-like} PRNG  by  a  cryptographically  secure one.  
1272 We have chosen the Blum Blum Shum generator~\cite{BBS} (usually denoted by BBS) having the form:
1273 $$x_{n+1}=x_n^2~ mod~ M$$  where $M$ is the product of  two prime numbers (these
1274 prime numbers  need to be congruent  to 3 modulus  4). BBS is known to be
1275 very slow and only usable for cryptographic applications. 
1276
1277   
1278 The modulus operation is the most time consuming operation for current
1279 GPU cards.  So in order to obtain quite reasonable performances, it is
1280 required to use only modulus  on 32-bits integer numbers. Consequently
1281 $x_n^2$ need  to be lesser than $2^{32}$,  and thus the number $M$ must be
1282 lesser than $2^{16}$.  So in practice we can choose prime numbers around
1283 256 that are congruent to 3 modulus 4.  With 32-bits numbers, only the
1284 4 least significant bits of $x_n$ can be chosen (the maximum number of
1285 indistinguishable    bits    is    lesser    than   or    equals    to
1286 $log_2(log_2(M))$). In other words, to generate a  32-bits number, we need to use
1287 8 times  the BBS  algorithm with possibly different  combinations of  $M$. This
1288 approach is  not sufficient to be able to pass  all the tests of TestU01,
1289 as small values of  $M$ for the BBS  lead to
1290   small periods. So, in  order to add randomness  we have proceeded with
1291 the followings  modifications. 
1292 \begin{itemize}
1293 \item
1294 Firstly, we  define 16 arrangement arrays  instead of 2  (as described in
1295 Algorithm \ref{algo:gpu_kernel2}), but only 2 of them are used at each call of
1296 the  PRNG kernels. In  practice, the  selection of   combination
1297 arrays to be used is different for all the threads. It is determined
1298 by using  the three last bits  of two internal variables  used by BBS.
1299 %This approach  adds more randomness.   
1300 In Algorithm~\ref{algo:bbs_gpu},
1301 character  \& is for the  bitwise AND. Thus using  \&7 with  a number
1302 gives the last 3 bits, thus providing a number between 0 and 7.
1303 \item
1304 Secondly, after the  generation of the 8 BBS numbers  for each thread, we
1305 have a 32-bits number whose period is possibly quite small. So
1306 to add randomness,  we generate 4 more BBS numbers   to
1307 shift  the 32-bits  numbers, and  add up to  6 new  bits.  This  improvement is
1308 described  in Algorithm~\ref{algo:bbs_gpu}.  In  practice, the last 2 bits
1309 of the first new BBS number are  used to make a left shift of at most
1310 3 bits. The  last 3 bits of the  second new BBS number are  added to the
1311 strategy whatever the value of the first left shift. The third and the
1312 fourth new BBS  numbers are used similarly to apply  a new left shift
1313 and add 3 new bits.
1314 \item
1315 Finally, as  we use 8 BBS numbers  for each thread, the  storage of these
1316 numbers at the end of the  kernel is performed using a rotation. So,
1317 internal  variable for  BBS number  1 is  stored in  place  2, internal
1318 variable  for BBS  number 2  is  stored in  place 3,  ..., and finally, internal
1319 variable for BBS number 8 is stored in place 1.
1320 \end{itemize}
1321
1322 \begin{algorithm}
1323 \begin{small}
1324 \KwIn{InternalVarBBSArray: array with internal variables of the 8 BBS
1325 in global memory\;
1326 NumThreads: Number of threads\;
1327 array\_comb: 2D Arrays containing 16 combinations (in first dimension)  of size combination\_size (in second dimension)\;
1328 array\_shift[4]=\{0,1,3,7\}\;
1329 }
1330
1331 \KwOut{NewNb: array containing random numbers in global memory}
1332 \If{threadId is concerned} {
1333   retrieve data from InternalVarBBSArray[threadId] in local variables including shared memory and x\;
1334   we consider that bbs1 ... bbs8 represent the internal states of the 8 BBS numbers\;
1335   offset = threadIdx\%combination\_size\;
1336   o1 = threadIdx-offset+array\_comb[bbs1\&7][offset]\;
1337   o2 = threadIdx-offset+array\_comb[8+bbs2\&7][offset]\;
1338   \For{i=1 to n} {
1339     t$<<$=4\;
1340     t|=BBS1(bbs1)\&15\;
1341     ...\;
1342     t$<<$=4\;
1343     t|=BBS8(bbs8)\&15\;
1344     \tcp{two new shifts}
1345     shift=BBS3(bbs3)\&3\;
1346     t$<<$=shift\;
1347     t|=BBS1(bbs1)\&array\_shift[shift]\;
1348     shift=BBS7(bbs7)\&3\;
1349     t$<<$=shift\;
1350     t|=BBS2(bbs2)\&array\_shift[shift]\;
1351     t=t\textasciicircum  shmem[o1]\textasciicircum     shmem[o2]\;
1352     shared\_mem[threadId]=t\;
1353     x = x\textasciicircum   t\;
1354
1355     store the new PRNG in NewNb[NumThreads*threadId+i]\;
1356   }
1357   store internal variables in InternalVarXorLikeArray[threadId] using a rotation\;
1358 }
1359 \end{small}
1360 \caption{main kernel for the BBS based PRNG GPU}
1361 \label{algo:bbs_gpu}
1362 \end{algorithm}
1363
1364 In Algorithm~\ref{algo:bbs_gpu}, $n$ is for  the quantity of random numbers that
1365 a thread has to  generate.  The operation t<<=4 performs a left  shift of 4 bits
1366 on the variable  $t$ and stores the result in  $t$, and $BBS1(bbs1)\&15$ selects
1367 the last  four bits  of the  result of $BBS1$.   Thus an  operation of  the form
1368 $t<<=4; t|=BBS1(bbs1)\&15\;$  realizes in $t$ a  left shift of 4  bits, and then
1369 puts the 4 last bits of $BBS1(bbs1)$  in the four last positions of $t$.  Let us
1370 remark that the initialization $t$ is not a  necessity as we fill it 4 bits by 4
1371 bits, until  having obtained 32-bits.  The  two last new shifts  are realized in
1372 order to enlarge the small periods of  the BBS used here, to introduce a kind of
1373 variability.  In these operations, we make twice a left shift of $t$ of \emph{at
1374   most}  3 bits,  represented by  \texttt{shift} in  the algorithm,  and  we put
1375 \emph{exactly} the \texttt{shift}  last bits from a BBS  into the \texttt{shift}
1376 last bits of $t$. For this, an array named \texttt{array\_shift}, containing the
1377 correspondence between the  shift and the number obtained  with \texttt{shift} 1
1378 to make the \texttt{and} operation is used. For example, with a left shift of 0,
1379 we  make an  and operation  with 0,  with  a left  shift of  3, we  make an  and
1380 operation with 7 (represented by 111 in binary mode).
1381
1382 It should  be noticed that this generator has once more the form $x^{n+1} = x^n \oplus S^n$,
1383 where $S^n$ is referred in this algorithm as $t$: each iteration of this
1384 PRNG ends with $x = x \wedge t$. This $S^n$ is only constituted
1385 by secure bits produced by the BBS generator, and thus, due to
1386 Proposition~\ref{cryptopreuve}, the resulted PRNG is cryptographically
1387 secure.
1388
1389
1390
1391 \subsection{Toward a Cryptographically Secure and Chaotic Asymmetric Cryptosystem}
1392 \label{Blum-Goldwasser}
1393 We finish this research work by giving some thoughts about the use of
1394 the proposed PRNG in an asymmetric cryptosystem.
1395 This first approach will be further investigated in a future work.
1396
1397 \subsubsection{Recalls of the Blum-Goldwasser Probabilistic Cryptosystem}
1398
1399 The Blum-Goldwasser cryptosystem is a cryptographically secure asymmetric key encryption algorithm 
1400 proposed in 1984~\cite{Blum:1985:EPP:19478.19501}.  The encryption algorithm 
1401 implements a XOR-based stream cipher using the BBS PRNG, in order to generate 
1402 the keystream. Decryption is done by obtaining the initial seed thanks to
1403 the final state of the BBS generator and the secret key, thus leading to the
1404  reconstruction of the keystream.
1405
1406 The key generation consists in generating two prime numbers $(p,q)$, 
1407 randomly and independently of each other, that are
1408  congruent to 3 mod 4, and to compute the modulus $N=pq$.
1409 The public key is $N$, whereas the secret key is the factorization $(p,q)$.
1410
1411
1412 Suppose Bob wishes to send a string $m=(m_0, \dots, m_{L-1})$ of $L$ bits to Alice:
1413 \begin{enumerate}
1414 \item Bob picks an integer $r$ randomly in the interval $\llbracket 1,N\rrbracket$ and computes $x_0 = r^2~mod~N$.
1415 \item He uses the BBS to generate the keystream of $L$ pseudorandom bits $(b_0, \dots, b_{L-1})$, as follows. For $i=0$ to $L-1$,
1416 \begin{itemize}
1417 \item $i=0$.
1418 \item While $i \leqslant L-1$:
1419 \begin{itemize}
1420 \item Set $b_i$ equal to the least-significant\footnote{As signaled previously, BBS can securely output up to $\mathsf{N} = \lfloor log(log(N)) \rfloor$ of the least-significant bits of $x_i$ during each round.} bit of $x_i$,
1421 \item $i=i+1$,
1422 \item $x_i = (x_{i-1})^2~mod~N.$
1423 \end{itemize}
1424 \end{itemize}
1425 \item The ciphertext is computed by XORing the plaintext bits $m$ with the keystream: $ c = (c_0, \dots, c_{L-1}) = m \oplus  b$. This ciphertext is $[c, y]$, where $y=x_{0}^{2^{L}}~mod~N.$
1426 \end{enumerate}
1427
1428
1429 When Alice receives $\left[(c_0, \dots, c_{L-1}), y\right]$, she can recover $m$ as follows:
1430 \begin{enumerate}
1431 \item Using the secret key $(p,q)$, she computes $r_p = y^{((p+1)/4)^{L}}~mod~p$ and $r_q = y^{((q+1)/4)^{L}}~mod~q$.
1432 \item The initial seed can be obtained using the following procedure: $x_0=q(q^{-1}~{mod}~p)r_p + p(p^{-1}~{mod}~q)r_q~{mod}~N$.
1433 \item She recomputes the bit-vector $b$ by using BBS and $x_0$.
1434 \item Alice finally computes the plaintext by XORing the keystream with the ciphertext: $ m = c \oplus  b$.
1435 \end{enumerate}
1436
1437
1438 \subsubsection{Proposal of a new Asymmetric Cryptosystem Adapted from Blum-Goldwasser}
1439
1440 We propose to adapt the Blum-Goldwasser protocol as follows. 
1441 Let $\mathsf{N} = \lfloor log(log(N)) \rfloor$ be the number of bits that can
1442 be obtained securely with the BBS generator using the public key $N$ of Alice.
1443 Alice will pick randomly $S^0$ in $\llbracket 0, 2^{\mathsf{N}-1}\rrbracket$ too, and
1444 her new public key will be $(S^0, N)$.
1445
1446 To encrypt his message, Bob will compute
1447 %%RAPH : ici, j'ai mis un simple $
1448 %\begin{equation}
1449 $c = \left(m_0 \oplus (b_0 \oplus S^0), m_1 \oplus (b_0 \oplus b_1 \oplus S^0), \hdots, \right.$
1450 $ \left. m_{L-1} \oplus (b_0 \oplus b_1 \hdots \oplus b_{L-1} \oplus S^0) \right)$
1451 %%\end{equation}
1452 instead of $\left(m_0 \oplus b_0, m_1 \oplus b_1, \hdots, m_{L-1} \oplus b_{L-1} \right)$. 
1453
1454 The same decryption stage as in Blum-Goldwasser leads to the sequence 
1455 $\left(m_0 \oplus S^0, m_1 \oplus S^0, \hdots, m_{L-1} \oplus S^0 \right)$.
1456 Thus, with a simple use of $S^0$, Alice can obtain the plaintext.
1457 By doing so, the proposed generator is used in place of BBS, leading to
1458 the inheritance of all the properties presented in this paper.
1459
1460 \section{Conclusion}
1461
1462
1463 In  this  paper, a formerly proposed PRNG based on chaotic iterations
1464 has been generalized to improve its speed. It has been proven to be
1465 chaotic according to Devaney.
1466 Efficient implementations on  GPU using xor-like  PRNGs as input generators
1467 have shown that a very large quantity of pseudorandom numbers can be generated per second (about
1468 20Gsamples/s), and that these proposed PRNGs succeed to pass the hardest battery in TestU01,
1469 namely the BigCrush.
1470 Furthermore, we have shown that when the inputted generator is cryptographically
1471 secure, then it is the case too for the PRNG we propose, thus leading to
1472 the possibility to develop fast and secure PRNGs using the GPU architecture.
1473 Thoughts about an improvement of the Blum-Goldwasser cryptosystem, using the 
1474 proposed method, has been finally proposed.
1475
1476 In future  work we plan to extend these researches, building a parallel PRNG for  clusters or
1477 grid computing. Topological properties of the various proposed generators will be investigated,
1478 and the use of other categories of PRNGs as input will be studied too. The improvement
1479 of Blum-Goldwasser will be deepened. Finally, we
1480 will try to enlarge the quantity of pseudorandom numbers generated per second either
1481 in a simulation context or in a cryptographic one.
1482
1483
1484
1485 \bibliographystyle{plain} 
1486 \bibliography{mabase}
1487 \end{document}