Loading vLEI.wiki
Fetching knowledge base...
Fetching knowledge base...
This comprehensive explanation has been generated from 27 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.
Hierarchical composition is an encoding protocol property enabling [CESR](/concept/cesr) streams to be organized in nested, tree-like structures through count codes and [group framing codes](/concept/[group-framing-code](/concept/group-framing-code "A group-framing-code also called count-code or group-code is a special CESR fram...")), facilitating [pipelining](/concept/pipelining) operations ([multiplexing](/concept/multiplexing) and de-multiplexing) of complex data streams in both text and compact binary formats for scalable management of high-bandwidth applications.
Hierarchical composition is a fundamental architectural property of CESR (Composable Event Streaming Representation) that enables primitives to be organized in nested, multi-level structures rather than flat sequences. This capability allows groups of primitives to themselves be treated as higher-level primitives, creating tree-like data structures within CESR streams.
The core principle is that group framing codes function as independently composable primitives, meaning a group of primitives can be framed with a count code and then that entire framed group can participate in higher-level compositions. This recursive composability enables arbitrarily deep nesting of data structures while maintaining the fundamental CESR properties of self-framing and text-binary composability.
Key properties of hierarchical composition include:
The concept of hierarchical data composition has deep roots in computer science, appearing in various forms:
Implementing hierarchical composition requires parsers that:
Count codes must:
When converting hierarchical structures between text and binary domains:
For high-bandwidth applications:
For abstract concept understanding:
Traditional Approaches:
These traditional approaches typically require one of two strategies:
{} in JSON) that require scanning to find boundariesBoth approaches create challenges for stream processing where data arrives incrementally and must be processed without buffering entire structures. Additionally, traditional formats typically optimize for either text readability (XML/JSON) or binary compactness (Protocol Buffers), but not both simultaneously.
Multiplexing in Telecommunications:
The term "multiplexing" originates from telecommunications, where multiple signals are combined over a shared medium. Traditional multiplexing techniques include:
CESR's hierarchical composition applies multiplexing concepts to cryptographic data streams, enabling multiple logical streams to be interleaved and nested within a single physical stream.
CESR achieves hierarchical composition through a novel combination of count codes, 24-bit alignment, and self-framing primitives that enables efficient stream processing of nested structures in both text and binary domains.
As documented in Document 8, CESR uses count codes (also called group codes) as special framing codes that specify the number of primitives in a group. A count code is itself a primitive that:
This last property is crucial: because count codes are themselves primitives, they can be included in higher-level groups, enabling recursive nesting.
Example structure (conceptual):
[Count Code: 3 primitives]
[Primitive 1]
[Primitive 2]
[Count Code: 2 primitives] ← Nested group
[Primitive 3]
[Primitive 4]
The outer count code indicates 3 primitives follow, but one of those "primitives" is itself a count code introducing a nested group. This recursive structure enables arbitrary hierarchy depth.
As explained in Document 3 and Document 4, hierarchical composition enables pipelining operations consisting of:
These operations are efficient because:
Hierarchical composition maintains CESR's fundamental composability property across domains. As documented in Document 6, this means:
T(cat(b[k])) = cat(T(b[k])) for all k
B(cat(t[k])) = cat(B(t[k])) for all k
Where T(B) converts binary to text, B(T) converts text to binary, and cat() concatenates primitives. This property holds at every level of the hierarchy:
This is achieved through 24-bit boundary alignment - every primitive (including count codes) aligns on 24-bit boundaries, which is the least common multiple of 6 bits (Base64 character width) and 8 bits (byte width). This alignment ensures that domain conversions never create bit-level dependencies between adjacent primitives, even in nested structures.
As defined in Document 18, self-framing means each element contains its own type, size, and value information. Hierarchical composition preserves this property at every nesting level:
This recursive self-framing enables cold start stream parsing - a parser can begin processing at any point in a hierarchical stream and correctly identify primitive boundaries without external schema information.
Hierarchical composition is essential for KERI event structures, which contain nested components:
Key Event Structure (from Document 24):
This hierarchical structure is encoded using CESR count codes:
ACDC Structures (from Document 9):
ACDCs (Authentic Chained Data Containers) use hierarchical composition for:
The specification mandates insertion-ordered field maps that preserve canonical ordering through hierarchical nesting, enabling deterministic SAID computation across nested structures.
As noted in Document 1 and Document 5, hierarchical composition enables management at scale for high-bandwidth applications through:
Efficient Stream Processing:
Flexible Data Organization:
1. Multi-Signature Events:
A rotation event with multiple signature groups:
[Event Header]
[Event Configuration]
[Count Code: 2 signature groups]
[Count Code: 3 signatures - current keys]
[Signature 1]
[Signature 2]
[Signature 3]
[Count Code: 2 signatures - witnesses]
[Witness Signature 1]
[Witness Signature 2]
Hierarchical composition allows the event to contain nested signature groups, each with its own count code, enabling efficient verification of different signature types.
2. ACDC Presentation Chains:
A presentation exchange disclosing multiple chained credentials:
[Presentation Message]
[Count Code: 3 ACDCs]
[ACDC 1 - Root Credential]
[Attribute Section]
[Edge Section]
[Count Code: 2 edges]
[Edge to ACDC 2]
[Edge to ACDC 3]
[ACDC 2 - Delegated Credential]
[ACDC 3 - Role Credential]
The hierarchical structure represents the directed acyclic graph (DAG) of credential relationships while maintaining efficient stream encoding.
3. Witness Pool Configurations:
A KEL (Key Event Log) with hierarchical witness structure:
[Inception Event]
[Witness Configuration]
[Count Code: 2 witness pools]
[Count Code: 5 witnesses - primary pool]
[Witness 1 AID]
[Witness 2 AID]
[Witness 3 AID]
[Witness 4 AID]
[Witness 5 AID]
[Count Code: 3 witnesses - backup pool]
[Witness 6 AID]
[Witness 7 AID]
[Witness 8 AID]
Hierarchical composition enables complex witness topologies with primary and backup pools, each independently managed.
Efficiency:
Flexibility:
Interoperability:
Complexity:
Overhead:
Constraints:
However, these trade-offs are justified by the significant benefits in scalability, efficiency, and interoperability that hierarchical composition provides for complex cryptographic event streams in decentralized identity systems.