Creates a ChaCha12-backed RandomGenerator keyed by key, with
counter starting at 0 and an all-zero nonce.
The returned ChaCha12Generator exposes both the pure-rand v8
RandomGenerator interface (next / clone / getState) and the
pre-existing byte-fill fillRandomBytes method that conforms to
@endo/random's RandomSource and crypto.getRandomValues-style
ergonomics. Callers can pick whichever entry point matches the
downstream consumer.
After 2 ** 32 blocks (256 GiB of keystream) the counter would
wrap; the generator throws RangeError instead.
makeChaCha12 reads the key bytes once, into a private state
vector, and does not retain the supplied Uint8Array reference.
Callers do not need to defensively copy the key; passing a frozen
or shared key array is safe.
Creates a ChaCha12-backed
RandomGeneratorkeyed bykey, with counter starting at 0 and an all-zero nonce.The returned
ChaCha12Generatorexposes both thepure-randv8RandomGeneratorinterface (next/clone/getState) and the pre-existing byte-fillfillRandomBytesmethod that conforms to@endo/random'sRandomSourceandcrypto.getRandomValues-style ergonomics. Callers can pick whichever entry point matches the downstream consumer.After
2 ** 32blocks (256 GiB of keystream) the counter would wrap; the generator throwsRangeErrorinstead.makeChaCha12reads the key bytes once, into a private state vector, and does not retain the suppliedUint8Arrayreference. Callers do not need to defensively copy the key; passing a frozen or shared key array is safe.