Loading vLEI.wiki
Fetching knowledge base...
Fetching knowledge base...
This comprehensive explanation has been generated from 185 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.
ndigs (next key digests) is a list of qualified base64-encoded cryptographic digests of public rotation keys in KERI, used to implement pre-rotation by cryptographically committing to future rotation keys without exposing them, enabling post-quantum secure key management and recovery from key compromise.
ndigs represents a fundamental cryptographic primitive in the KERI protocol that implements the pre-rotation security mechanism. The term is a contraction of "next key digests" and refers to a list data structure containing cryptographic hash commitments to public keys that will be used in future rotation events.
The primary purpose of ndigs is to enable cryptographic pre-commitment to rotation keys before they need to be revealed. This serves two critical security functions:
This abstraction is central to KERI's innovative approach to key management, distinguishing it from traditional PKI systems that lack secure key rotation mechanisms. By committing only to digests rather than actual keys, the protocol maintains a separation between signing authority (current keys) and rotation authority (next keys), which is a key architectural feature of KERI's security model.
In the KERIpy implementation, ndigs is structured as an ordered list of qualified cryptographic digests. Each digest in the list:
Secure Random Generation: Use cryptographically secure random number generators (CSPRNG) for rotation key generation. The entropy source must provide at least 128 bits of cryptographic strength.
Offline Storage: Rotation keys should be generated and stored offline, separate from current signing keys. This separation is crucial for maintaining the security properties of pre-rotation.
Key Lifecycle Management: Implement secure key lifecycle procedures:
Algorithm Selection: KERI mandates approximately 128 bits of cryptographic strength. Recommended algorithms include:
CESR Encoding: Each digest must be properly CESR-encoded with the appropriate derivation code:
E for Blake3-256F for Blake2b-256G for Blake2s-256H for SHA3-256I for SHA2-256Canonicalization: Ensure public keys are in canonical form before hashing to guarantee consistent digest computation across implementations.
Dual Threshold Verification: During rotation validation, verify both:
kt) against signatures on the rotation eventnt from previous event) against revealed keysDigest Matching: When keys are revealed during rotation:
for revealed_key, committed_digest in zip(current_keys, prior_ndigs):
computed = hash_and_encode(revealed_key)
assert computed == committed_digest
The list structure is critical because:
Each element in the ndigs list consists of:
The "qualified" nature means each digest is self-describing through its derivation code, enabling cryptographic agility where different algorithms can coexist in the same system.
In KERI establishment events (inception and rotation), ndigs appears in the n field:
Inception Event Example:
{
"v": "KERI10JSON0000e6_",
"t": "icp",
"d": "ELvaU6Z-i0d8JJR2nmwyYAZAoTNZH3UfSVPzhzS6b5CM",
"i": "ELvaU6Z-i0d8JJR2nmwyYAZAoTNZH3UfSVPzhzS6b5CM",
"s": "0",
"kt": "1",
"k": ["DSuhyBcPZEZLK-fcw5tzHn2N46wRCG_ZOoeKtWTOunRA"],
"n": ["EPYuj8mq_PYYsoBKkzX1kxSPGYBWaIya3slgCOyOtlqU"],
"bt": "2",
"b": ["BJq7UABlttINuWJh1Xl2lkqZG4NTdUdqnbFJDa6ZyxCC"],
"c": [],
"a": []
}
In this example, the n field contains a single-element list with one digest. For multi-signature configurations, the list would contain multiple digests.
Multi-Signature Example:
{
"n": [
"ETNZH3ULvYawyZ-i0d8JZU6JR2nmAoAfSVPzhzS6b5CM",
"EYAfSVPzhzaU6JR2nmoTNZH3ULvwyZb6b5CMi0d8JZAS",
"EnmwyZdi0d8JZAoTNZYAfSVPzhzaU6JR2H3ULvS6b5CM"
]
}
Each digest in ndigs follows CESR encoding conventions:
Derivation Code: First character(s) indicate the algorithm
E: Blake3-256 digestF: Blake2b-256 digestG: Blake2s-256 digestH: SHA3-256 digestI: SHA2-256 digestBase64 Encoding: The digest bytes are encoded in Base64 URL-safe format
Length: Fixed length determined by the digest algorithm (e.g., 44 characters for 256-bit digests in Base64)
The CESR encoding ensures:
Minimum Cryptographic Strength: KERI mandates approximately 128 bits of cryptographic strength for all digests, ensuring adequate security against collision attacks.
List Size: The number of elements in ndigs must match:
nt) specified in the establishment eventValidation Constraints:
During Inception:
Key Generation: Controller generates rotation key pairs
# Pseudocode for key generation
rotation_keypairs = generate_keypairs(count=threshold)
Digest Computation: Compute cryptographic digests of public keys
ndigs = []
for keypair in rotation_keypairs:
public_key = keypair.public_key
digest = blake3_hash(public_key)
qualified_digest = cesr_encode(digest, derivation_code='E')
ndigs.append(qualified_digest)
Inclusion in Event: Add ndigs list to the n field of the inception event
Secure Storage: Store the rotation private keys securely, separate from current signing keys
During Rotation:
Reveal Previous Keys: The keys committed to in the previous event's ndigs are now revealed in the k field
Commit to New Keys: Generate new rotation keys and compute their digests for the new ndigs
Verification: Validators verify that revealed keys hash to the previously committed digests
ndigs is immutable once included in a signed establishment event. Updates occur through the rotation mechanism:
Pre-Rotation Cycle:
n field with digests of keys for rotation N+1k field and commits to new keys in its n fieldn field, and so onPartial Rotation:
Threshold Changes:
nt (next threshold) field specifies how many signatures from the pre-rotated keys are requiredktValidator Responsibilities:
Digest Verification: When a rotation event occurs, validators must:
# Pseudocode for verification
def verify_rotation(current_event, prior_event):
revealed_keys = current_event['k']
committed_digests = prior_event['n']
for key, digest in zip(revealed_keys, committed_digests):
computed_digest = blake3_hash(key)
if cesr_encode(computed_digest) != digest:
raise ValidationError("Key does not match committed digest")
Threshold Validation: Verify that the number of signatures satisfies both:
Structural Validation:
Security Properties Verified:
ndigs is fundamental to KERI's establishment event structure:
Inception Events (icp):
Rotation Events (rot):
Interaction Events (ixn):
Phase 1: Generation
Phase 2: Commitment
Phase 3: Revelation
Phase 4: Retirement
Current Keys (k field):
Next Threshold (nt field):
ktKey Event Log (KEL):
Witnesses:
The digest-based commitment in ndigs provides post-quantum security properties:
Quantum Resistance: Even if quantum computers can break the signature algorithm, they cannot efficiently find pre-images of the hash digests
Forward Hiding: The pre-rotated keys remain hidden until revelation, protecting against future quantum attacks on the key derivation
Recovery Capability: If current signing keys are compromised, the controller can still rotate using the unexposed pre-rotated keys
Dead Attacks (attacks on stale key state):
Live Attacks (attacks on current keys):
Duplicity Attacks:
Implementers must carefully manage the lifecycle of rotation keys:
Digest Computation:
Validation:
Invalid Digests:
Threshold Mismatches:
ndigs supports partial rotation where not all pre-committed keys are revealed:
{
"n": [
"ETNZH3ULvYawyZ-i0d8JZU6JR2nmAoAfSVPzhzS6b5CM",
"EYAfSVPzhzaU6JR2nmoTNZH3ULvwyZb6b5CMi0d8JZAS",
"EnmwyZdi0d8JZAoTNZYAfSVPzhzaU6JR2H3ULvS6b5CM",
"ETNZH3ULvS6bYAfSVPzhzaU6JR2nmwyZfi0d8JZ5s8bk",
"EJR2nmwyZ2i0dzaU6ULvS6b5CM8JZAoTNZH3YAfSVPzh"
],
"nt": "3"
}
In the next rotation, only 3 of the 5 pre-committed keys might be revealed, keeping 2 in reserve for future rotations.
ndigs enables custodial key management patterns:
This is implemented through careful threshold configuration and key distribution.
For delegated AIDs, ndigs works in conjunction with delegation:
ndigs represents a fundamental innovation in KERI's approach to key management. By using cryptographic digests to commit to future rotation keys without exposing them, KERI achieves:
The ndigs mechanism is essential to KERI's security model and distinguishes it from traditional PKI systems that lack secure key rotation capabilities. Understanding ndigs is crucial for implementing KERI-based identity systems and for appreciating the protocol's innovative approach to decentralized key management.
List Length Validation: Verify that ndigs list length is appropriate:
Caching: Cache computed digests to avoid recomputation:
Parallel Processing: For multi-signature scenarios, parallelize:
Batch Operations: When processing multiple events, batch digest operations to leverage CPU cache locality and SIMD instructions.
Malformed ndigs: Reject events with:
Threshold Mismatches: Handle cases where:
Logging and Monitoring: Implement comprehensive logging:
Key Separation: Maintain strict separation between:
Partial Rotation Support: Implement partial rotation correctly:
Duplicity Detection: Integrate with duplicity detection mechanisms:
Unit Tests: Test individual components:
Integration Tests: Test complete workflows:
Security Tests: Verify security properties:
Cross-Implementation Compatibility: Ensure ndigs format is compatible across:
Version Compatibility: Handle version differences:
Witness Coordination: Ensure ndigs handling works correctly with: