Loading vLEI.wiki
Fetching knowledge base...
Fetching knowledge base...
This comprehensive explanation has been generated from 183 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.
Composability in CESR is the property that enables any set of self-framing concatenated primitives expressed in either the Text domain or Binary domain to be converted as a group to the other domain and back again without loss, while maintaining the separability of individual primitives.
Composability, formally termed text-binary concatenation composability, is a foundational property of CESR (Composable Event Streaming Representation) that ensures bidirectional, lossless conversion of concatenated cryptographic primitives between text and binary encoding domains. This property guarantees that:
The mathematical formulation establishes that for transformation functions T(B) (Binary to Text) and B(T) (Text to Binary), and concatenation function cat(), the property holds when:
T(cat(b[k])) = cat(T(b[k])) for all k
B(cat(t[k])) = cat(B(t[k])) for all k
This means transforming a concatenated group produces the same result as concatenating individually transformed primitives.
Traditional encoding schemes face a fundamental trade-off between human readability and computational efficiency:
Binary Protocols (UDP, TCP, DNS) provide compact, performant representations but are difficult to develop, debug, and version. Custom tooling is required, and over-the-wire debugging is nearly impossible.
Text Protocols (HTTP, SMTP) offer easy development and debugging but suffer from verbosity and inefficiency in production environments.
Hybrid Formats (XML/JSON for text, CBOR/MessagePack for binary) enable zero-cost switching between representations but still require complete re-serialization and don't preserve primitive boundaries during conversion.
Implementations MUST ensure all primitives align on 24-bit boundaries:
ps = (3 - (N mod 3)) mod 3The first characters of a CESR primitive encode the derivation code, which:
CESR parsers must:
Implementations should:
For high-performance implementations:
Implementations MUST verify:
The critical limitation of naive Base64 encoding is that it cannot preserve primitive boundaries when converting concatenated binary strings. Standard Base64 uses trailing = pad characters that create ambiguity at concatenation points, making it impossible to reliably parse individual primitives after group conversion.
CESR achieves composability through strict 24-bit boundary alignment - the least common multiple of:
This constraint ensures that:
Unlike naive Base64 that uses trailing = pad characters, CESR employs leading pad bytes ("lead bytes") prepended to raw binary values before Base64 conversion. The pad size calculation is:
ps = (3 - (N mod 3)) mod 3
where ps is pad size and N is raw binary length in bytes.
For a one-byte value requiring 2 lead bytes, the pre-padded binary converts to 4 Base64 characters where the first 2 characters encode the lead bytes. These characters can be replaced with a derivation code without affecting the value encoding, creating qualified primitives that are both self-describing and composable.
CESR operates across three interconnected domains:
(code, raw) tuples[A-Z, a-z, 0-9, -, _]The composability property enables complete transformation circuits:
R→T(R)→T→B(T)→B→R(B)→R
R→B(R)→B→T(B)→T→R(T)→R
Composability depends critically on CESR's self-framing property. Each primitive includes:
This enables parsers to extract primitives from concatenated streams without external delimiters or schemas.
Composability provides distinct advantages across the software lifecycle:
Development Phase:
Production Phase:
Composability enables sophisticated stream processing patterns:
Multiplexing: Combining multiple self-framing primitives into complex streams using count codes
Demultiplexing: Unraveling primitives from composite streams while preserving individual boundaries
Hierarchical Composition: Group framing codes function as independently composable primitives, enabling nested structures
Pipelining: Processing streams across multiple cores at network speeds (40 GHz) rather than processor speeds (5 GHz)
Composability ensures cryptographic operations remain valid across domain transformations:
The composability property provides strong interoperability guarantees:
The CESR specification uses an effective analogy to illustrate composability:
Google Translate is not composable - repeatedly translating text from English to Dutch and back degrades the message until reaching a stable but altered state. Each translation loses information.
CESR is composable - like having two "languages" (text and binary) where:
While composability provides significant benefits, it imposes constraints:
Alignment Overhead: The 24-bit boundary requirement may introduce padding that slightly increases size for some primitives
Encoding Complexity: Implementations must correctly handle pre-padding and derivation codes, which is more complex than naive Base64
Format Restrictions: Only Base64 URL-safe characters are permitted in text domain, excluding the = pad character entirely
Parsing Requirements: Parsers must understand CESR framing codes and version strings to correctly process streams
However, these constraints are carefully designed to be minimal while ensuring the composability property holds universally across all CESR primitives and compositions.
Composability is not merely a convenience feature but a foundational architectural requirement for KERI:
The composability property ensures that KERI's cryptographic guarantees hold universally, regardless of which encoding domain is used at any point in the protocol flow. This enables the flexible, interoperable, and scalable identity infrastructure that KERI provides.