Loading vLEI.wiki
Fetching knowledge base...
Fetching knowledge base...
This comprehensive explanation has been generated from 38 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.
Variable-length in the KERI/CESR context refers to encoding primitives whose size is not predetermined but instead dynamically specified through count codes or framing codes. Unlike fixed-length primitives that always occupy the same number of characters or bytes, variable-length primitives include metadata that tells parsers exactly how many units to extract from a stream.
Key characteristics:
Variable-length encoding is fundamental to CESR's ability to handle diverse cryptographic primitives and data structures efficiently:
CESR uses count codes (also called group codes) to specify the length of variable-size elements. These codes appear as prefixes that indicate:
For example, the bexter class handles variable-length Base64 text strings using codes like:
4B##: Small byte string with lead size 0 (supports up to 4,095 quadlets)5B##: Small byte string with lead size 16B##: Small byte string with lead size 27AAB####: Large byte string with lead size 0 (supports up to 16,777,215 quadlets)When implementing CESR parsers, variable-length primitives require:
All variable-length primitives MUST align on 24-bit boundaries:
When using variable-length Base64 text (bexter), avoid strings that:
These may not round-trip correctly due to pre-padding mechanics.
Variable-length encoding trades fixed-size simplicity for flexibility:
Variable-length primitives are measured in:
This alignment ensures CESR's composability property—the ability to convert concatenated primitives between text and binary domains without loss.
Verifiable Identifiers (VIDs): Open-mode TSP implementations encode VIDs (URNs or DIDs) as variable-length UTF-8 byte strings, allowing identifiers of arbitrary length while maintaining CESR compatibility.
ACDC Credentials: Variable-length encoding enables compact representation of credential fields, nested SADs (Self-Addressing Data), and SAID paths without fixed size constraints.
Collective Signatures: Multi-party signatures have variable length as a function of the number of signers, requiring variable-length encoding to accommodate different participant counts.
Nested Paths: The SAD Path Language uses variable-length encoding for paths to nested credential attributes, enabling compact Base64-compatible path expressions.
To maintain 24-bit alignment, variable-length primitives use pre-padding with leading zero bytes before Base64 conversion. The pad size ps is computed as:
ps = (3 - (rs % 3)) % 3
where rs is the raw size in bytes. This ensures the encoded primitive aligns on 24-bit boundaries, preserving CESR's composability.