xoshiro / xoroshiro
Fast linear generators from Blackman and Vigna for simulation, not for secrets
Overview
The xoshiro and xoroshiro generators are small, very fast pseudorandom number generators based on xor, shift and rotate operations on a linear state, followed by a nonlinear scrambler. They are popular defaults for simulations and games but must never be used for keys, nonces or tokens.
Each generator updates a 64- to 512-bit state with a linear transformation over GF(2), which guarantees a long, well-understood period, and then applies a scrambler to produce output. The scrambler name is part of the variant: + adds two state words, ++ adds, rotates and adds again, * multiplies by a constant and ** multiplies, rotates and multiplies. The + variants have weak low-order bits and are intended for generating floating-point numbers, where those bits are discarded.
xoroshiro uses two state words (64 or 128 bits of state), while xoshiro uses four or eight (128, 256 or 512 bits). The authors recommend xoshiro256** or xoshiro256++ for general-purpose use. These generators are the defaults in several language runtimes, including .NET and Lua. Fourteen variants are present: xoroshiro64* and xoroshiro64**, xoroshiro128 with +, ++ and **, and xoshiro128, xoshiro256 and xoshiro512, each with +, ++ and **.
History
2018–2018xoshiro / xoroshiro published by David Blackman, Sebastiano Vigna
How it works
- Seed the state with nonzero values, typically from SplitMix64.
- Compute the output by applying the scrambler (+, ++, * or **) to one or more state words.
- Advance the state with a fixed sequence of xors, shifts and rotations.
- Use jump functions to split one stream into non-overlapping subsequences for parallel work.
Security notes
Not cryptographically secure: the state is linear and can be recovered from a small number of outputs, after which all future and past outputs are predictable. Use the OS RNG or a DRBG for anything security-related. The + variants also have statistically weak low bits.
Typical uses
Variants in NextSSL
14| Algorithm | Tier | Sizes (bytes) | Standards | API |
|---|---|---|---|---|
| Xoroshiro128+ xoroshiro128-plus |
unverified | out 1–268435456 · seed 16 | xoroshiro128+ (Blackman, Vigna 2016), low bits are weak… | root |
| Xoroshiro128-Plusplus xoroshiro128-plusplus |
unverified | out 1–268435456 · seed 16 | xoroshiro128++ (Blackman, Vigna 2018), NOT cryptographi… | root |
| Xoroshiro128-Starstar xoroshiro128-starstar |
unverified | out 1–268435456 · seed 16 | xoroshiro128** (Blackman, Vigna 2018), NOT cryptographi… | root |
| Xoroshiro64-Star xoroshiro64-star |
unverified | out 1–268435456 · seed 8 | xoroshiro64* (Blackman, Vigna 2018), NOT cryptographica… | root |
| Xoroshiro64-Starstar xoroshiro64-starstar |
unverified | out 1–268435456 · seed 8 | xoroshiro64** (Blackman, Vigna 2018), NOT cryptographic… | root |
| Xoshiro128+ xoshiro128-plus |
unverified | out 1–268435456 · seed 16 | xoshiro128+ (Blackman, Vigna 2018), low bits are weak, … | root |
| Xoshiro128-Plusplus xoshiro128-plusplus |
unverified | out 1–268435456 · seed 16 | xoshiro128++ (Blackman, Vigna 2018), NOT cryptographica… | root |
| Xoshiro128-Starstar xoshiro128-starstar |
unverified | out 1–268435456 · seed 16 | xoshiro128** (Blackman, Vigna 2018), NOT cryptographica… | root |
| Xoshiro256+ xoshiro256-plus |
unverified | out 1–268435456 · seed 32 | xoshiro256+ (Blackman, Vigna 2018), low bits are weak, … | root |
| Xoshiro256-Plusplus xoshiro256-plusplus |
unverified | out 1–268435456 · seed 32 | xoshiro256++ (Blackman, Vigna 2018), NOT cryptographica… | root |
| Xoshiro256-Starstar xoshiro256-starstar |
unverified | out 1–268435456 · seed 32 | xoshiro256** (Blackman, Vigna 2018), NOT cryptographica… | root |
| Xoshiro512+ xoshiro512-plus |
unverified | out 1–268435456 · seed 64 | xoshiro512+ (Blackman, Vigna 2018), low bits are weak, … | root |
| Xoshiro512-Plusplus xoshiro512-plusplus |
unverified | out 1–268435456 · seed 64 | xoshiro512++ (Blackman, Vigna 2018), NOT cryptographica… | root |
| Xoshiro512-Starstar xoshiro512-starstar |
unverified | out 1–268435456 · seed 64 | xoshiro512** (Blackman, Vigna 2018), NOT cryptographica… | root |
Frequently asked questions
Which xoshiro / xoroshiro variants does NextSSL include?
NextSSL registers 14 xoshiro / xoroshiro variants: xoroshiro128-plus, xoroshiro128-plusplus, xoroshiro128-starstar, xoroshiro64-star, xoroshiro64-starstar, xoshiro128-plus, xoshiro128-plusplus, xoshiro128-starstar, xoshiro256-plus, xoshiro256-plusplus and more.
Other non-cryptographic prngs
All 26Related
Permuted congruential generators: LCG state with a permutation on output
SplitMix64Counter-based 64-bit generator, widely used to seed other generators
Xorshift128Marsaglia's minimal xor-and-shift generator, ancestor of xoshiro
Operating system RNGThe kernel's cryptographically secure random number generator, the right default