@blockchaincommons/components - v1.0.0-beta.4
    Preparing search index...

    Class HKDFRng

    A deterministic random number generator based on HKDF-HMAC-SHA256.

    Implements the RandomNumberGenerator interface from @blockchaincommons/rand (fillBytes, nextU32, nextU64); draw bytes with rand's randomBytes and fillRandomBytes.

    Implements

    • RandomNumberGenerator
    Index
    • Parameters

      • keyMaterial: Uint8Array

        The input key material for HKDF

      • salt: string

        The salt string; page i uses "<salt>-<i>"

      • pageLength: { pageLength?: number } = {}

        Bytes of output derived per page (32 by default). A page length of 0 is accepted, as the reference accepts it; the generator then serves only empty draws and throws InvalidData on the first request for a byte (where the reference never returns).

      Returns HKDFRng

    • get keyMaterial(): Uint8Array

      Returns Uint8Array

    • Fills the provided buffer with deterministic random bytes.

      Parameters

      • dest: Uint8Array

        The buffer to fill with random bytes

      Returns void

    • Generates a random u32 value.

      Returns number

      A deterministic random 32-bit unsigned integer

    • Generates a random u64 value.

      Note: JavaScript numbers can only safely represent integers up to 2^53 - 1, so this returns a BigInt for full 64-bit precision.

      Returns bigint

      A deterministic random 64-bit unsigned integer as BigInt