fbpx
Wikipedia

Counter-based random number generator

A counter-based random number generation (CBRNG, also known as a counter-based pseudo-random number generator, or CBPRNG) is a kind of pseudorandom number generator that uses only an integer counter as its internal state. They are generally used for generating pseudorandom numbers for large parallel computations.

Background edit

We can think of a pseudorandom number generator (PRNG) as a function that transforms a series of bits known as the state into a new state and a random number.

That is, given a PRNG function and an initial state  , we can repeatedly use the PRNG to generate a sequence of states and random numbers.

 

In some PRNGs, such as the Mersenne Twister, the state is large, more than 2048 bytes. In other PRNGs, such as xorshift,   and   are one and the same (and so the state is small, just 4, 8, or 16 bytes, depending on the size of the numbers being generated). But in both cases, and indeed in most traditional PRNGs, the state evolves unpredictably, so if you want to calculate a particular   given an initial state  , you have to calculate  ,  , and so on, running the PRNG   times.

Such algorithms are inherently sequential and not amenable to running on parallel machines like multi-core CPUs and GPUs.

In contrast, a counter-based random number generator (CBRNG) is a PRNG where the state "evolves" in a particularly simple manner:  . This way you can generate each number independently, without knowing the result of the previous call to the PRNG.

This property make it easy to run a CBRNG on a multiple CPU threads or a GPU. For example, to generate   random numbers on a GPU, you might spawn   threads and have the  th thread calculate  .

CBRNGs based on block ciphers edit

Some CBRNGs are based on reduced-strength versions of block ciphers. Below we explain how this works.

When using a cryptographic block cipher in counter mode, you generate a series of blocks of random bits. The  th block is calculated by encrypting the number   using the encryption key  :  .

This is similar to a CBRNG, where you calculate the  th random number as  . Indeed, any block cipher can be used as a CBRNG; simply let  !

This yields a strong, cryptographically-secure source of randomness. But cryptographically-secure pseudorandom number generators tend to be slow compared to insecure PRNGs, and in practice many uses of random numbers don't require this degree of security.

In 2011, Salmon et al. at D. E. Shaw Research introduced[1] two CBRNGs based on reduced-strength versions of block ciphers.

  • Threefry uses a reduced-strength version of the Threefish block cipher. (Juvenile fish are known as "fry".)
  • ARS uses a reduced-strength version of the AES block cipher. ("ARS" is a pun on "AES"; "AES" stands for "advanced encryption standard", and "ARS" stands for "advanced randomization system"[2]).

ARS is used in recent versions of Intel's Math Kernel Library[3] and gets good performance by using instructions from the AES-NI instruction set, which specifically accelerate AES encryption.

Code implementing Threefry, ARS, and Philox (see below) is available from the authors.[4]

CBRNGs based on multiplication edit

In addition to Threefry and ARS, Salmon et al. described a third counter-based PRNG, Philox,[1] based on wide multiplies; e.g. multiplying two 32-bit numbers and producing a 64-bit number, or multiplying two 64-bit numbers and producing a 128-bit number.

As of 2020, Philox is popular on CPUs and GPUs. On GPUs, nVidia's cuRAND library[5] and TensorFlow[6] provide implementations of Philox. On CPUs, Intel's MKL provides an implementation.

A new CBRNG based on multiplication is the Squares RNG.[7] This generator passes stringent tests of randomness[8] and is considerably faster than Philox.

References edit

  1. ^ a b Salmon, John; Moraes, Mark; Dror, Ron; Shaw, David (2011). "Parallel random numbers: as easy as 1, 2, 3". Proceedings of 2011 International Conference for High Performance Computing, Networking, Storage and Analysis, Article No. 16. doi:10.1145/2063384.2063405.
  2. ^ "Random123: A Library of Counter-Based Random Number Generators". Retrieved August 8, 2020.
  3. ^ Fedorov, Gennady; Gladkov, Eugeny (2015). "New counter-based Random Number Generators in Intel® Math Kernel Library". Intel. Retrieved August 22, 2016.
  4. ^ "Random123".
  5. ^ "Device API Overview". Retrieved August 8, 2020.
  6. ^ "Random number generation | TensorFlow Core".
  7. ^ Widynski, Bernard (2020). "Squares: A Fast Counter-Based RNG". arXiv:2004.06278 [cs.DS].
  8. ^ L’Ecuyer, Pierre; Nadeau-Chamard, Oliver; Chen, Yi-Fan; Lebar, Justin (2021). "Multiple streams with recurrence-based, counter-based, and splittable random number generators". 2021 Winter Simulation Conference (WSC). IEEE, 2021.

counter, based, random, number, generator, counter, based, random, number, generation, cbrng, also, known, counter, based, pseudo, random, number, generator, cbprng, kind, pseudorandom, number, generator, that, uses, only, integer, counter, internal, state, th. A counter based random number generation CBRNG also known as a counter based pseudo random number generator or CBPRNG is a kind of pseudorandom number generator that uses only an integer counter as its internal state They are generally used for generating pseudorandom numbers for large parallel computations Contents 1 Background 2 CBRNGs based on block ciphers 3 CBRNGs based on multiplication 4 ReferencesBackground editWe can think of a pseudorandom number generator PRNG as a function that transforms a series of bits known as the state into a new state and a random number That is given a PRNG function and an initial state s t a t e 0 displaystyle mathrm state 0 nbsp we can repeatedly use the PRNG to generate a sequence of states and random numbers P R N G s t a t e 0 s t a t e 1 n u m 1 P R N G s t a t e 1 s t a t e 2 n u m 2 P R N G s t a t e 2 s t a t e 3 n u m 3 P R N G s t a t e 3 displaystyle begin aligned mathrm PRNG mathrm state 0 amp mathrm state 1 mathrm num 1 mathrm PRNG mathrm state 1 amp mathrm state 2 mathrm num 2 mathrm PRNG mathrm state 2 amp mathrm state 3 mathrm num 3 mathrm PRNG mathrm state 3 amp ldots end aligned nbsp In some PRNGs such as the Mersenne Twister the state is large more than 2048 bytes In other PRNGs such as xorshift s t a t e i displaystyle mathrm state i nbsp and n u m i displaystyle mathrm num i nbsp are one and the same and so the state is small just 4 8 or 16 bytes depending on the size of the numbers being generated But in both cases and indeed in most traditional PRNGs the state evolves unpredictably so if you want to calculate a particular s t a t e i displaystyle mathrm state i nbsp given an initial state s t a t e 0 displaystyle mathrm state 0 nbsp you have to calculate s t a t e 1 displaystyle mathrm state 1 nbsp s t a t e 2 displaystyle mathrm state 2 nbsp and so on running the PRNG i displaystyle i nbsp times Such algorithms are inherently sequential and not amenable to running on parallel machines like multi core CPUs and GPUs In contrast a counter based random number generator CBRNG is a PRNG where the state evolves in a particularly simple manner s t a t e i i displaystyle mathrm state i i nbsp This way you can generate each number independently without knowing the result of the previous call to the PRNG This property make it easy to run a CBRNG on a multiple CPU threads or a GPU For example to generate n displaystyle n nbsp random numbers on a GPU you might spawn n displaystyle n nbsp threads and have the i displaystyle i nbsp th thread calculate P R N G i displaystyle mathrm PRNG i nbsp CBRNGs based on block ciphers editSome CBRNGs are based on reduced strength versions of block ciphers Below we explain how this works When using a cryptographic block cipher in counter mode you generate a series of blocks of random bits The i displaystyle i nbsp th block is calculated by encrypting the number i displaystyle i nbsp using the encryption key k displaystyle k nbsp B l o c k i E i k displaystyle mathrm Block i E i k nbsp This is similar to a CBRNG where you calculate the i displaystyle i nbsp th random number as P R N G i displaystyle mathrm PRNG i nbsp Indeed any block cipher can be used as a CBRNG simply let P R N G i E i s e e d displaystyle mathrm PRNG i E i mathrm seed nbsp This yields a strong cryptographically secure source of randomness But cryptographically secure pseudorandom number generators tend to be slow compared to insecure PRNGs and in practice many uses of random numbers don t require this degree of security In 2011 Salmon et al at D E Shaw Research introduced 1 two CBRNGs based on reduced strength versions of block ciphers Threefry uses a reduced strength version of the Threefish block cipher Juvenile fish are known as fry ARS uses a reduced strength version of the AES block cipher ARS is a pun on AES AES stands for advanced encryption standard and ARS stands for advanced randomization system 2 ARS is used in recent versions of Intel s Math Kernel Library 3 and gets good performance by using instructions from the AES NI instruction set which specifically accelerate AES encryption Code implementing Threefry ARS and Philox see below is available from the authors 4 CBRNGs based on multiplication editIn addition to Threefry and ARS Salmon et al described a third counter based PRNG Philox 1 based on wide multiplies e g multiplying two 32 bit numbers and producing a 64 bit number or multiplying two 64 bit numbers and producing a 128 bit number As of 2020 Philox is popular on CPUs and GPUs On GPUs nVidia s cuRAND library 5 and TensorFlow 6 provide implementations of Philox On CPUs Intel s MKL provides an implementation A new CBRNG based on multiplication is the Squares RNG 7 This generator passes stringent tests of randomness 8 and is considerably faster than Philox References edit a b Salmon John Moraes Mark Dror Ron Shaw David 2011 Parallel random numbers as easy as 1 2 3 Proceedings of 2011 International Conference for High Performance Computing Networking Storage and Analysis Article No 16 doi 10 1145 2063384 2063405 Random123 A Library of Counter Based Random Number Generators Retrieved August 8 2020 Fedorov Gennady Gladkov Eugeny 2015 New counter based Random Number Generators in Intel Math Kernel Library Intel Retrieved August 22 2016 Random123 Device API Overview Retrieved August 8 2020 Random number generation TensorFlow Core Widynski Bernard 2020 Squares A Fast Counter Based RNG arXiv 2004 06278 cs DS L Ecuyer Pierre Nadeau Chamard Oliver Chen Yi Fan Lebar Justin 2021 Multiple streams with recurrence based counter based and splittable random number generators 2021 Winter Simulation Conference WSC IEEE 2021 Retrieved from https en wikipedia org w index php title Counter based random number generator amp oldid 1197047668, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.