Wyrand Explained: 5 Facts About the One-Word Generator

Wyrand explained in plain terms means understanding the one-word generator that feeds the fastest hashes, a design from 2019 that turns a single 64-bit counter into a stream of well-mixed numbers. The central question is why one counter and a single multiply can beat generators with pages of state, and the answer is that a good mix spreads every bit of the counter across the output, so wyrand gives every seed a fair start, and that fairness is the whole point of the design.

Wyrand is a fast pseudorandom number generator created by Yi Wang, with Diego Barrios Romero, Daniel Lemire and Li Jin, producing a 64-bit value on every call. It turns a seed into a sequence by adding a fixed constant to its state and passing the result through a multiply-and-mix step, and it is built on the idea that a generator should be small enough to fit anywhere, which means the whole state is a single word, and that smallness is what makes it unlike the generators of its era.

This article gives you five facts about wyrand, explains what it is, how it works, and why it still matters.

Key takeaways

  • Wyrand is a fast generator from 2019, by Yi Wang and colleagues.
  • Its whole state is a single 64-bit word.
  • It adds the constant 0x2d358dccaa6c78a5 each step.
  • It passes BigCrush and PractRand randomness tests.
  • It is the default generator in Nim, V and Zig.

What wyrand is

The first fact is that wyrand is a counter generator, which means one number drives the whole stream. A normal generator keeps a large state, but wyrand keeps a single 64-bit word and adds a constant to it, which means the state is as small as it can be, and because the state is so small, it can be copied, saved and restored for free.

The second fact is that it is the companion to wyhash. Wyrand shares its mixing step with the wyhash hash function, which means the same multiply-and-mix core serves two jobs, and because the core is shared, a program that hashes and generates numbers needs only one piece of code.

The third fact is that it is the default in three languages. Wyrand is the default generator in Nim, V and Zig, which means it runs in millions of programs, and because it is the default, it is the generator most developers in those languages meet first.

The fourth fact is that it is fast enough to beat the C library. Wyrand runs about seven times faster than the C rand function and about four times faster than the Mersenne Twister, which means it is the front door to fast randomness, and because its mixing is strong, the speed costs nothing in quality.

The fifth fact is that it is not for security, and it never pretends otherwise. Wyrand is built for speed and for seeding, not for secrets, which means it must never guard a password or a key, and that honesty is the reason it is the first example engineers meet when they learn the line between fast randomness and secure randomness.

Our guide to SplitMix64 explains the earlier one-word generator it is measured against, and our guide to wyhash explains the hash function that shares its mixing core.

How wyrand works

Everything starts with the seed, which is the initial state. Wyrand takes any 64-bit seed and stores it as its counter, which means the starting state depends on the seed, and because any seed is allowed, the same seed always gives the same stream.

Each step begins with the constant, which is added to the state. Wyrand adds 0x2d358dccaa6c78a5 to its counter, which means the state moves by a fixed odd step, and because the constant is odd, the counter visits every value before it repeats.

The mixing is what makes the design work as a whole. The new state is mixed with a second constant through a 64-by-64-bit multiply, which means the value is scrambled thoroughly, and because the multiply produces 128 bits, the mixing spreads across the whole output.

The output spreads the effect further. Wyrand returns the mixed value directly, which means the result is a fresh 64-bit number on every call, and because the mix is strong, the outputs look random even though the counter moves in fixed steps.

The period is what turns one counter into a long stream. Wyrand cycles through all 2 to the power of 64 states before it repeats, which means the sequence is long enough for any practical use, and because the period is exact, the design needs no extra machinery to stay fresh.

The stream comes from the counter, read out one value at a time. Wyrand outputs one number per step for the full period, which means the generator is as simple as a counter plus a multiply, and that simplicity is exactly what a seeder needs for its job.

A dark office desk with a laptop showing a glowing green cipher diagram, a brass key and a notebook beside it
A dark office desk with a laptop showing a glowing green cipher diagram, a brass key and a notebook beside it, shows how wyrand works: counter values take turns passing through the mix, step after step, until random numbers emerge.

Comparing wyrand with other fast generators

Wyrand is one of several fast generators built for speed, and each was built with a different emphasis. SplitMix64 is the one-word generator built on a golden constant and a finalizer, the Mersenne Twister is the classic generator built on a huge twisted state, and wyrand is the one built on a counter and a single multiply, while each approach trades something for something else.

The table below sets out the main contrasts between the leading approaches.

Aspect wyrand SplitMix64 Mersenne Twister
Output size 64 bits 64 bits 32 bits
State One 64-bit word One 64-bit word 19,937 bits
Core step Add and multiply-mix Add, xor-shift, multiply Twist and temper
Period 2 to the power of 64 2 to the power of 64 2 to the power of 19937 minus 1
Best for Seeding and speed Seeding generators General simulation

The practical result is that wyrand is the right choice for seeding and speed, SplitMix64 suits seeding generators, and the Mersenne Twister fits general simulation instead.

Where wyrand is used

Programming languages use it as their default generator. Nim, V and Zig ship wyrand as their standard generator, because it is fast and portable, and that adoption is the reason it runs in real programs rather than only in benchmarks.

Hash libraries use it to seed their state. Fast hashes and tables fill their registers from wyrand output, because a generator needs a well-mixed start, and that seeding is the reason wyrand earns its keep in random-number code.

Games use it to drive random events. A game that rolls dice and shuffles decks needs numbers quickly, because a slow generator becomes the bottleneck, and that speed is the reason wyrand appears in game code.

Benchmarking uses it as a speed reference. Engineers still quote wyrand when they discuss how fast a generator can run, because it is the clearest example of a counter and a multiply paying off, and that number shapes how new generators are measured.

Teaching uses it as the counter-generator example. Courses introduce wyrand when they explain that a counter can be a generator, because it is the clearest case of the idea in a real design, and a student who understands wyrand understands why mixing matters in generator design.

Strengths and limits

The greatest strength of wyrand is its size. A generator with one word of state can be copied and split for free, and that strength is real, measured in the languages that adopted it and confirmed by the hashes it seeds.

It is also a strength that the design is easy to explain. A counter, a constant and a multiply is a design anyone can describe, and that simplicity is worth more than cleverness in a field where a generator nobody can audit is a generator nobody trusts.

The limits are real, though, and the biggest is that it is not cryptographic. Wyrand was never designed to resist an adversary, which means it must never guard a secret or a key, and a system that needs secure randomness must use a cryptographic generator instead.

Wyrand checklist

  • Use wyrand for seeding, never for security or passwords.
  • Remember its whole state is one 64-bit word.
  • Note the step adds a fixed constant each time.
  • Compare it with SplitMix64 to see two kinds of fast generator.
  • Study the multiply-mix, which is what spreads the bits.
  • Check the seed, since any 64-bit value is allowed.
  • Keep real secrets behind cryptographic generators.
  • Read the wyhash paper to see how the constants were chosen.
  • Choose a cryptographic generator when security matters.

Frequently asked questions

What is wyrand in simple terms?

It is a 2019 generator that turns a single counter into a stream of 64-bit numbers by adding a constant and mixing the result.

Who created wyrand?

Yi Wang, with Diego Barrios Romero, Daniel Lemire and Li Jin, who built it alongside the wyhash function.

How is wyrand different from SplitMix64?

Both are one-word generators, but wyrand mixes with a single multiply while SplitMix64 mixes with three xor-shift-multiply rounds.

Is wyrand still secure?

It is fast and well tested, but it is not a cryptographic generator, so it must never guard secrets or keys.

Where is wyrand used?

In Nim, V and Zig, in hash libraries, in games, in benchmarking, and in teaching about counter-based generators.

When should I use wyrand?

When you need a fast seeder, when you split work across cores, or when you study counter-based generator design.

The bottom line

Wyrand explained in one line is this: the one-word generator, a 2019 design of a counter, a constant and a multiply that seeds the fastest hashes and taught the field that small can seed big.

It is proof that a counter can be a generator, and the reason it still matters is that every fast generator designed since has been judged partly by the lesson wyrand taught.

This article is general information about how wyrand works, not advice about choosing encryption for a particular device or system.

Latest articles

Scroll to Top