Loading vLEI.wiki
Fetching knowledge base...
Fetching knowledge base...
This comprehensive explanation has been generated from 49 GitHub source documents. All source documents are searchable here.
Last updated: October 7, 2025
This content is meant to be consumed by AI agents via MCP. Click here to get the MCP configuration.
Note: In rare cases it may contain LLM hallucinations.
For authoritative documentation, please consult the official GLEIF vLEI trainings and the ToIP Glossary.
A Cryptographically Secure Pseudorandom Number Generator (CSPRNG) is a deterministic algorithm that produces a sequence of numbers from an unknown internal state, where the output is computationally indistinguishable from true randomness even when the algorithm is known, providing the cryptographic strength necessary for secure key generation, seed creation, and nonce generation in KERI systems.
A Cryptographically Secure Pseudorandom Number Generator (CSPRNG) is a deterministic computational algorithm that generates sequences of numbers (bits, bytes, or other units) from an internal state that remains unknown to observers. The defining characteristic that distinguishes a CSPRNG from a basic PRNG is its cryptographic security property: the output sequence is computationally indistinguishable from true randomness to any observer who does not know the internal state, even when the PRNG algorithm itself is perfectly known.
In the KERI protocol and ACDC credential systems, CSPRNGs serve as the foundational entropy source for generating the seeds (also called bran) that derive the private keys controlling Autonomic Identifiers (AIDs). The cryptographic strength of these identifiers depends entirely on the unpredictability of the CSPRNG output.
According to Document 1, a PRNG achieves cryptographic security when:
MUST use operating system CSPRNGs for all cryptographic operations:
/dev/urandom or getrandom() system callCryptGenRandom() or BCryptGenRandom()SecRandomCopyBytes()SecureRandom classMUST NOT use non-cryptographic PRNGs (Mersenne Twister, Linear Congruential Generators, Math.random()) for any security-critical operations.
Per GLEIF vLEI Ecosystem Governance Framework:
Encryption: All stored seeds MUST be encrypted using:
Access Control:
BIP-39 Mnemonics: For user-facing seed backup:
Secret Sharing: For enterprise deployments:
Statistical Testing: Validate CSPRNG output quality:
ent or This contrasts sharply with non-cryptographic PRNGs, which may pass basic statistical randomness tests but can be distinguished from true randomness by an intelligent attacker with knowledge of the algorithm.
Within the KERI ecosystem, CSPRNGs fulfill several critical security functions:
The apparent paradox of CSPRNGs is that they are simultaneously deterministic and unpredictable:
Deterministic: Given the same internal state (seed), a CSPRNG will always produce the same output sequence. This reproducibility is actually a feature, not a bug—it enables key recovery mechanisms where a user can regenerate their entire key hierarchy from a single backed-up seed phrase.
Unpredictable: Without knowledge of the internal state, the next output value cannot be predicted better than random guessing, even with complete knowledge of all previous outputs and the algorithm itself.
This property is formalized in Document 23 from NIST terminology: "A cryptographic PRNG is a PRNG that is unpredictable when the seed is unknown."
The GLEIF vLEI Ecosystem Governance Framework (Document 28) establishes that all AID generation must use CSPRNGs or true random number generators with at least 128 bits of cryptographic strength. This entropy threshold provides:
While the KERI specifications do not mandate specific CSPRNG algorithms, common implementations include:
Operating System CSPRNGs:
/dev/urandom (Linux/Unix)CryptGenRandom (Windows)SecRandomCopyBytes (macOS/iOS)Algorithmic CSPRNGs:
The critical requirement is that the chosen CSPRNG must be cryptographically analyzed and widely accepted by the security community, not merely statistically random.
CSPRNGs provide several essential security properties:
CSPRNG output used for seed generation is typically represented in multiple formats:
Raw Binary: The native output format, typically 128, 256, or 512 bits of entropy
Hexadecimal: Common for technical display and debugging
3a7f8c2e9b1d4f6a8e3c5b7d9f1a4c6e
Base64: Compact representation for storage and transmission
On+MLpsdT2qOPFt9nxpMbg==
BIP-39 Mnemonic: Human-readable word sequences for backup and recovery (Document 4):
broken toddler farm argue elder behind sea ramp
cake rabbit renew option combine guilt inflict sentence
what desert manage angry manual grit copy hundred
The BIP-39 standard maps entropy to word sequences from a standardized 2048-word dictionary, where each word represents 11 bits of entropy. A 24-word phrase encodes 264 bits (256 bits of entropy + 8-bit checksum).
When CSPRNG-derived values appear in CESR streams (such as in key event logs), they are encoded with appropriate derivation codes:
Private Key Encoding: CESR does not typically transmit private keys, but when stored locally, they use qualified encoding:
Public Key Encoding: Derived from CSPRNG-generated private keys:
DDSxKwKSZZq672OtzOlokik6L0rr3TtWrZDiHfnATU9j
Where the leading character(s) encode the derivation algorithm.
Seed Encoding: When seeds are stored in KERI keystores, they are encrypted and qualified with codes indicating:
The most critical use of CSPRNGs in KERI occurs during inception events when establishing a new AID. The process follows this sequence:
As specified in Document 28, the GLEIF Root AID generation requires:
"An AID must be created from two sets of asymmetric signing key pairs. The key pairs must be generated from either a cryptographically-secure pseudo-random number generator (CSPRNG) or a true random number generator with at least 128 bits of cryptographic strength."
KERI's revolutionary pre-rotation mechanism depends on CSPRNG security. When creating an inception or rotation event, the controller:
n (next) fieldThis scheme provides post-quantum security because an attacker who compromises current keys cannot forge a rotation event—they would need to break the one-way hash function to discover the pre-committed next key.
In ACDC credentials, CSPRNGs generate the high-entropy UUID field (u) that serves as a "salty nonce" for private ACDCs. As described in Document 11:
"The UUID, u, field value provides a universally unique identifier that may be used to index or search for the ACDC in a database. When the UUID, u, field is present, the ACDC may be considered a private ACDC."
The UUID must have sufficient entropy (≥128 bits) to prevent rainbow table attacks that could reveal ACDC contents by brute-force enumeration.
The KERI Request Authentication Method (KRAM) uses CSPRNG-generated nonces for replay attack protection. As detailed in Document 26, each authenticated request includes:
The nonce ensures that even identical requests at the same timestamp produce different signatures, preventing replay attacks.
A PRNG is the broader category of which CSPRNG is a specialized subset. While all CSPRNGs are PRNGs, not all PRNGs are cryptographically secure. Non-cryptographic PRNGs like Mersenne Twister or Linear Congruential Generators may pass statistical randomness tests but are predictable to attackers who understand the algorithm.
Key Distinction: PRNGs are suitable for simulations, games, and non-security applications. CSPRNGs are mandatory for cryptographic operations where unpredictability is a security requirement.
TRNGs (also called Hardware Random Number Generators) derive entropy from physical processes:
As noted in Document 5:
"Despite the availability of hardware RNGs, pseudorandom number generators (PRNGs) remain important in practice due to: Speed in number generation, Reproducibility of sequences"
In KERI implementations, TRNGs are often used to seed CSPRNGs, combining the true randomness of physical entropy with the speed and reproducibility of algorithmic generation.
CSPRNGs work in conjunction with Key Derivation Functions like:
The typical flow: CSPRNG → Seed → KDF → Key Material → Key Pairs
KDFs stretch and transform CSPRNG output into cryptographic key material with specific properties required by signing algorithms.
CSPRNG-generated seeds enable hierarchical deterministic (HD) key derivation as specified in BIP-32. From a single CSPRNG seed, an entire tree of key pairs can be deterministically derived:
CSPRNG Seed
|
v
Master Key
|
+-- Child Key 0
| |
| +-- Grandchild Key 0/0
| +-- Grandchild Key 0/1
|
+-- Child Key 1
|
+-- Grandchild Key 1/0
This enables key reproduction from a single backed-up seed, a critical feature for key recovery in KERI systems.
CSPRNG-generated seeds represent the ultimate root of trust in KERI systems. Their protection requires:
Encryption at Rest: Seeds stored in keystores must be encrypted using:
Access Control:
Backup Procedures:
Implementations must ensure CSPRNG entropy quality:
Seeding: CSPRNGs must be seeded from high-quality entropy sources:
/dev/random, getrandom())Reseeding: Long-running processes should periodically reseed CSPRNGs to maintain forward secrecy and recover from potential state compromise.
Testing: Implementations should validate CSPRNG output using statistical test suites:
Browser Environments: Use window.crypto.getRandomValues() (Web Crypto API)
Node.js: Use crypto.randomBytes() from the built-in crypto module
Python: Use secrets module (not random module) for cryptographic operations
Rust: Use rand crate with OsRng or ThreadRng for cryptographic randomness
Mobile Platforms:
SecRandomCopyBytes()SecureRandom classWhile CSPRNGs are slower than non-cryptographic PRNGs, the performance impact is negligible for KERI operations:
The security benefits vastly outweigh any performance costs. Never use non-cryptographic PRNGs for security-critical operations.
Insufficient Entropy: Using predictable seeds (timestamps, process IDs) undermines CSPRNG security. Always use OS-provided entropy sources.
Improper Seeding: Seeding with low-entropy values (user passwords without key derivation) provides false security.
State Exposure: Logging or transmitting CSPRNG internal state compromises all future outputs.
Weak Algorithms: Using deprecated or non-cryptographic PRNGs (Mersenne Twister, LCG) in security contexts.
Inadequate Reseeding: Long-running processes that never reseed may become vulnerable to state compromise attacks.
CSPRNGs form the bedrock of cryptographic security in KERI and ACDC systems. Their role in generating unpredictable, high-entropy seeds for key derivation directly determines the security of all downstream operations—from AID control authority to credential issuance and verification. Understanding the distinction between cryptographic and non-cryptographic randomness, implementing proper entropy management, and following security best practices for seed storage are essential for building secure KERI-based identity systems.
rngtestFunctional Testing:
Web Browsers:
// CORRECT
const array = new Uint8Array(32);
window.crypto.getRandomValues(array);
// WRONG - NOT cryptographically secure
Math.random();
Node.js:
// CORRECT
const crypto = require('crypto');
const seed = crypto.randomBytes(32);
// WRONG
const random = require('random');
Python:
# CORRECT
import secrets
seed = secrets.token_bytes(32)
# WRONG
import random
random.randbytes(32) # Not cryptographically secure
Rust:
// CORRECT
use rand::rngs::OsRng;
use rand::RngCore;
let mut seed = [0u8; 32];
OsRng.fill_bytes(&mut seed);
// WRONG
use rand::thread_rng; // May not be cryptographically secure