baml.random.ChaCha20
A seedable, deterministic CSPRNG (ChaCha20). Given the same seed it always reproduces the same stream. It is cryptographically secure *only* when seeded with high-entropy input — e.g. 32 bytes drawn from `SystemRandom` (the default when no seed is given). A low-entropy or attacker-known seed makes its output predictable.
Signature
class baml.random.ChaCha20A seedable, deterministic CSPRNG (ChaCha20). Given the same seed it always
reproduces the same stream. It is cryptographically secure only when seeded
with high-entropy input — e.g. 32 bytes drawn from SystemRandom (the
default when no seed is given). A low-entropy or attacker-known seed makes
its output predictable.
Source:<builtin>/baml/ns_random/random.bamlbytes 4464–5750
Fields
_state
$rust_typeOpaque, mutex-guarded generator state owned by the Rust runtime.
Static methods
_new
(seed: uint8array) -> baml.random.ChaCha20 throws nevernew
(seed: uint8array = …) -> baml.random.ChaCha20 throws neverCreates a new ChaCha20 pseudo-random number generator.
Parameters
seed: The seed for the random number generator. If no seed is provided, a random seed is generated using the system random number generator. The seed must be at least 32 bytes long.
Panics
If seed is shorter than 32 bytes.
Implementations
baml.Concrete for T
Source:<builtin>/baml/core.bamlbytes 763–795
baml.random.Rng for baml.random.ChaCha20
Instance methods
random
(self, bytes: int) -> uint8array throws neverrandom_int
(self) -> int throws neverSource:<builtin>/baml/ns_random/random.bamlbytes 5465–5748