Skip to main content

random_secret_bytes

Function random_secret_bytes 

Source
pub fn random_secret_bytes() -> [u8; 32]
Expand description

Mint 32 cryptographically secure random bytes from the operating system’s entropy source.

The canonical way to generate secret material in this workspace: an ed25519 private key for Signer::from_key_bytes, or the secret half of a pc_<id>_<secret> transport bearer. Every byte is uniformly random — unlike an identifier such as a UUID, which fixes several bits to encode its own version and variant and so is not key material, however random the rest of it is.

§Panics

Panics if the OS entropy source is unavailable, which on a supported platform means the process cannot safely mint secrets at all — failing loudly beats returning predictable key material.