Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the book #4

Merged
merged 8 commits into from
Nov 14, 2018
Merged

Update the book #4

merged 8 commits into from
Nov 14, 2018

Conversation

dhardy
Copy link
Member

@dhardy dhardy commented Nov 8, 2018

Various changes to fill in the blanks and prepare for 0.6.

There are still a few short-comings of this doc, but at this point I feel I've written the lion's share of the book, so please consider writing a PR if you have contributions!

@vks would you like to work your xoshiro crate into this somehow? I did actually mention it in the update guide. (Or if you'd rather not mention it at this point or do something else with it, that's fine — rust-random is open to new crates.)

Copy link

@coltfred coltfred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great write-up. Couple missing links, but I think this is a great start to a book that we can grow over time.

@dhardy
Copy link
Member Author

dhardy commented Nov 10, 2018

Thanks. Some of it is just copy+paste though. Those links work for me (try mdbook build --open).

@dhardy dhardy mentioned this pull request Nov 12, 2018
28 tasks
@coltfred
Copy link

@dhardy the links do work. Sorry about that.

output values.

### Quality stars:
PRNGs with 3 stars or more should be good enough for any purpose.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement is too strong. All non-CSPRNG are imperfect by definition. Maybe "Should be good enough for most non-crypto applications"?

cycle length can be given, where the exact length depends on the seed.

On today's hardware, even a fast RNG with a cycle length of *only*
2<sup>64</sup> can be used for centuries before cycling. Yet we recommend a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parallel applications might achieve cycling in reasonable time.

Copy link
Member Author

@dhardy dhardy Nov 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you were skipping forward to get a unique stream, yes — but if I were using small fast RNGs in a parallel program I'd prefer to seed a bunch of independent ones, seeded off a strong (crypto?) master PRNG. Isn't this really about skipping/streams?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you seed them randomly, you will run into overlaps even more quickly. (This is the birthday problem and discussed elsewhere in this document.) So the limited cycle length is still a problem.

algorithm. People in the field of cryptography spend a lot of effort
analyzing existing designs, and what was once considered good may now turn
out to be weaker. Generally it is best to use algorithms well-analyzed by
experts, such as those recommended by NIST or ECRYPT.
Copy link
Contributor

@vks vks Nov 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add links?

I hesitate to defer to NIST after the Dual_EC_DRBG disaster.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hesitate to fully trust any single authority, but it's really beyond my expertise to give better advice here. Any suggestions?

# Further reading

There is quite a lot that can be said about PRNGs. The [PCG paper] is a
very approachable explaining more concepts.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence is missing a word?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or has too many? I think @pitdicker wrote that.

Non-cryptographic generators pre-date cryptographic ones and since we now have
fast cryptographic generators, some people argue that the cryptographic ones
are now obsolete. They do however still have some advantages: small state size,
fast initialisation and simplicity.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*non-cryptographic ones are now obsolete.

@@ -82,8 +71,7 @@ Any block cipher can be turned into a CSPRNG by encrypting a counter. Stream
ciphers are basically a CSPRNG and a combining operation, usually XOR. This
means that we can easily use any stream cipher as a CSPRNG.

This crate currently provides two CSPRNGs. The sub-crate `rand_isaac`
provides two CSPRNG-like PRNGs:
We provide the following "CSPRNG-like" RNGs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSPRNG-like is a weird word. What does it mean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rationale for this weird phrasing was to avoid having to throw ISAAC out, though I suppose we could do that, or just put everything in one big table.

This whole section is far from ideal; mostly it's a copy+paste since I didn't want to do a re-write.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just call ISAAC a CSPRNG. CSPRNG-like does not make sense to me without definition.

- sampling from various random number distributions

The `rand_chacha`, `rand_hc`, `rand_isaac`, `rand_pcg` and `rand_xorshift`
libraries provide additional PRNGs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add: "They are recommended over StdRng and SmallRng when reproducibility is needed."

@vks
Copy link
Contributor

vks commented Nov 12, 2018

Looks very good! I only had a few minor comments.

@dhardy

would you like to work your xoshiro crate into this somehow? I did actually mention it in the update guide. (Or if you'd rather not mention it at this point or do something else with it, that's fine — rust-random is open to new crates.)

Sure, should I do the following?

  1. Open a PR adding a rand_xoshiro crate.
  2. Add xoshiro to the PRNG table.

@dhardy
Copy link
Member Author

dhardy commented Nov 13, 2018

@vks I'd be happy to have rand_xoshiro merged here. The main advantage over a seperate rust-random/xoshiro crate would be getting the API doc in here.

Would you like to make a patch against this PR? You seem to have some idea what to say.

@vks vks mentioned this pull request Nov 14, 2018
@dhardy
Copy link
Member Author

dhardy commented Nov 14, 2018

@vks can you review 3af3188 please?

@vks
Copy link
Contributor

vks commented Nov 14, 2018

@dhardy

@vks can you review 3af3188 please?

Looks good! 👍

@dhardy dhardy merged commit 9b4ff85 into rust-random:master Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants