Blockchain Commons Components TypeScript Library - v1.0.0-alpha.13
    Preparing search index...

    Class HKDFRng

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

    Implements the RandomNumberGenerator interface from @bcts/rand.

    Implements

    • RandomNumberGenerator
    Index

    Methods

    • Creates a new HKDFRng with a custom page length.

      Parameters

      • keyMaterial: Uint8Array

        The seed material to derive random numbers from

      • salt: string

        A salt value to mix with the key material

      • pageLength: number

        The number of bytes to generate in each HKDF call

      Returns HKDFRng

      A new HKDFRng instance configured with the specified parameters

    • Creates a new HKDFRng with the default page length of 32 bytes.

      Parameters

      • keyMaterial: Uint8Array

        The seed material to derive random numbers from

      • salt: string

        A salt value to mix with the key material

      Returns HKDFRng

      A new HKDFRng instance configured with the specified key material and salt

    • Generates deterministic random bytes.

      Parameters

      • length: number

        The number of bytes to generate

      Returns Uint8Array

      A Uint8Array of random bytes

    • 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

    • Attempts to fill the provided buffer with random bytes. This implementation never fails.

      Parameters

      • dest: Uint8Array

        The buffer to fill with random bytes

      Returns void

    • Fills the provided buffer with deterministic random bytes. Alias for fillBytes for interface compatibility.

      Parameters

      • data: Uint8Array

        The buffer to fill with random bytes

      Returns void