@blockchaincommons/rand - v1.0.0-beta.3
    Preparing search index...

    A deterministic generator (xoshiro256**), identical to rand_xoshiro's Xoshiro256StarStar for the same seed.

    NOT cryptographically secure. For tests and reproducible fixtures only.

    fillBytes draws one 64-bit word per byte and keeps its low byte — the reference's fill_random_data, which every seeded fixture downstream depends on. SeededRng.fillBytesPacked is the other stream, rand_core's packed fill_bytes.

    Implements

    Index
    • Parameters

      • seed: Uint8Array<ArrayBufferLike> | Seed

        four 64-bit words, or 32 little-endian bytes (the byte layout rand_xoshiro's from_seed reads, and the one SeededRng.state returns). An all-zero seed is replaced by the SplitMix64 expansion of zero, as the reference does.

      Returns SeededRng

      InvalidSeed unless seed is an array of exactly four bigints in [0, 2^64 - 1] (holes and other element types are rejected) or a Uint8Array of exactly 32 bytes. Other typed arrays, ArrayBuffers and DataViews are rejected.

    • get "[toStringTag]"(): string

      Debug label: Object.prototype.toString reports the class name.

      Returns string

    • get state(): Uint8Array<ArrayBuffer>

      The 256-bit state as 32 little-endian bytes (a copy); SeededRng.fromState resumes it exactly. (new SeededRng(state) also resumes every state a generator can reach, but substitutes an all-zero one.)

      Returns Uint8Array<ArrayBuffer>

    • The generator whose state is exactly state: the 32 little-endian bytes SeededRng.state returns, restored with no all-zero substitution. This is provenance-mark's Xoshiro256StarStar::from_data; bc-rand itself has no raw-state constructor. An all-zero state is xoshiro's fixed point and draws zeros forever, as it does there; the constructor, which is from_seed, substitutes it instead.

      Parameters

      • state: Uint8Array

      Returns SeededRng

      InvalidSeed unless state is a Uint8Array of exactly 32 bytes.

    • One 64-bit draw per byte, keeping the low byte (the reference's fill_random_data).

      Parameters

      • dest: Uint8Array

      Returns void

      InvalidArgument unless dest is a Uint8Array.

    • The reference's RngCore::fill_bytes stream (rand_core's fill_bytes_via_next over xoshiro256**): eight little-endian bytes per 64-bit step; a tail of five to seven bytes from one more step; a tail of one to four bytes from xoshiro's own next_u32, the high half of a step. This is what reference code reaching the generator through rand_core generics draws (e.g. bc-crypto's Ed25519 key generation); SeededRng.fillBytes is the other stream, fill_random_data.

      Parameters

      • dest: Uint8Array

      Returns void

      InvalidArgument unless dest is a Uint8Array.