-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>ChaCha (bitgenerators.Bitgen.ChaCha)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../odoc.support/odoc.css"/><meta name="generator" content="odoc 2.4.1"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../odoc.support/highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../../index.html">bitgenerators</a> » <a href="../index.html">Bitgen</a> » ChaCha</nav><header class="odoc-preamble"><h1>Module <code><span>Bitgen.ChaCha</span></code></h1><p>ChaCha is a 64-bit PRNG that uses a counter-based design based on the ChaCha cipher. Instances using different values of the key produce sequences. ChaCha has a period of <code class="odoc-katex-math">2^{128}</code> and supports arbitrary advancing and jumping the sequence in increments of <code class="odoc-katex-math">2^{64}</code>. These features allow multiple non-overlapping sequences to be generated.</p><p>The ChaCha state vector consists of a 16-element array of uint32 that capture buffered draws from the distribution, an 8-element array of uint32s holding the seed, and a 2-element array of uint64 that holds the 128-bit counter (<code>low, high</code>). The elements of the seed are the value provided by the user. Typical values for number of rounds are 4, 8, 12, or 20 (for high security).</p><p>ChaCha is seeded using a vector of 4 64-bit unsigned integers. By default this is provided by <a href="../SeedSequence/index.html#val-generate_64bit_state"><code>SeedSequence.generate_64bit_state</code></a>.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-t"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span></code></div><div class="spec-doc"><p><code>t</code> is the state of the bitgenerator.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-next_uint64"><a href="#val-next_uint64" class="anchor"></a><code><span><span class="keyword">val</span> next_uint64 : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span class="xref-unresolved">Stdint</span>.uint64 * <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>next_uint64 t</code> Generates a random unsigned 64-bit integer and a state of the generator advanced forward by one step.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-next_uint32"><a href="#val-next_uint32" class="anchor"></a><code><span><span class="keyword">val</span> next_uint32 : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span class="xref-unresolved">Stdint</span>.uint32 * <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>next_uint32 t</code> Generates a random unsigned 32-bit integer and a state of the generator advanced forward by one step.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-next_double"><a href="#val-next_double" class="anchor"></a><code><span><span class="keyword">val</span> next_double : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> float * <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>next_double t</code> Generates a random 64 bit float and a state of the generator advanced forward by one step.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-initialize"><a href="#val-initialize" class="anchor"></a><code><span><span class="keyword">val</span> initialize : <span><span class="xref-unresolved">Bitgen__.Seed.SeedSequence.t</span> <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>initialize s</code> Returns the initial state of the generator. The random stream is determined by the initialization of the seed sequence <code>s</code> of <a href="../SeedSequence/index.html#type-t"><code>SeedSequence.t</code></a> type.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-initialize_full"><a href="#val-initialize_full" class="anchor"></a><code><span><span class="keyword">val</span> initialize_full : | ||
<span><span class="label">key</span>:<span><span class="xref-unresolved">Stdint</span>.uint64 array</span> <span class="arrow">-></span></span> | ||
<span><span class="label">counter</span>:<span>(<span class="xref-unresolved">Stdint</span>.uint64 * <span class="xref-unresolved">Stdint</span>.uint64)</span> <span class="arrow">-></span></span> | ||
<span><span class="label">rounds</span>:int <span class="arrow">-></span></span> | ||
<a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>initialize_full key counter rounds</code> initializes the state of the ChaCha bitgenerator; where <code>key</code> is a 4-element array, <code>counter</code> is a 2-tuple, and <code>rounds</code> is the number of rounds to use. <code>rounds</code> must be non-negative, even and greater than 2, else an exception is raised.</p></div></div></div></body></html> | ||
<span><span class="xref-unresolved">Bitgen__.Seed.SeedSequence.t</span> <span class="arrow">-></span></span> | ||
<span><span>(<span class="xref-unresolved">Stdint</span>.uint64 * <span class="xref-unresolved">Stdint</span>.uint64)</span> <span class="arrow">-></span></span> | ||
<span>int <span class="arrow">-></span></span> | ||
<a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>initialize_full seedseq counter rounds</code> initializes the state of the ChaCha bitgenerator; where <code>seedseq</code> is a <a href="../SeedSequence/index.html#type-t"><code>SeedSequence.t</code></a> used to initialize the PRNG's key array, <code>counter</code> is a 2-tuple used to initialize the 128-bit counter, and <code>rounds</code> is the number of rounds to use. <code>rounds</code> must be non-negative, even and greater than 2, else an <code>Invalid_argument</code> exception is raised.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-advance"><a href="#val-advance" class="anchor"></a><code><span><span class="keyword">val</span> advance : <span><span class="xref-unresolved">Stdint</span>.uint128 <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>advance n</code> Advances the generator forward as if <code>n</code> calls to <a href="#val-next_uint32"><code>ChaCha.next_uint32</code></a> have been made, and returns the new advanced state.</p></div></div></div></body></html> |