Loading vLEI.wiki
Fetching knowledge base...
Fetching knowledge base...
This comprehensive explanation has been generated from 9 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 CESR primitive class for encoding variable-length text strings containing only Base64 URL-safe characters, providing more compact qb64 encoding than raw bytes while preserving round-trip transposability between text and binary domains.
Bexter is a specialized subclass of the Matter class within CESR (Composable Event Streaming Representation) that handles variable-length strings containing exclusively Base64 URL-safe characters. As a cryptographic primitive, Bexter represents a fundamental building block in KERI's encoding architecture, designed specifically to optimize the representation of Base64 text (referred to as 'bext') in both text and binary domains.
The primary purpose of Bexter is to achieve compact encoding of Base64 text strings while maintaining CESR's core property of round-trip transposability—the ability to convert data between text domain and binary domain without information loss. When a Bexter instance is created using the bext parameter, the resulting qb64 (qualified Base64) encoding is more compact than if the same content were treated as raw bytes and then encoded.
This efficiency gain comes from a fundamental design principle: the text is used directly to form the value part of the qb64 version, excluding only the leader bytes that contain the derivation code and length information. This direct utilization preserves the inherent compactness of Base64 encoding while adding the self-describing framing that CESR requires.
As a Matter subclass, Bexter inherits the standard structure of CESR primitives:
Implementations must either:
The recommended approach is prevention: reject or transform inputs that would trigger the ambiguity.
Strict validation of the Base64 URL-safe character set is essential:
Validation should occur at instantiation time to fail fast rather than producing invalid CESR streams.
Implementations should include comprehensive round-trip tests:
# Test text -> qb64 -> text preservation
original = "test-string_123"
bexter = Bexter(bext=original)
recovered = bexter.text
assert original == recovered, "Round-trip failed"
# Test qb64 -> qb2 -> qb64 preservation
qb64_original = bexter.qb64
qb2_form = bexter.qb2
bexter_from_binary = Bexter(qb2=qb2_form)
assert qb64_original == bexter_from_binary.qb64, "Binary round-trip failed"
When implementing CESR stream parsers:
Parsers must handle Bexter primitives atomically—either successfully parse the entire primitive or fail cleanly without partial consumption.
For high-throughput applications:
When implementing Bexter in languages other than Python:
The key architectural distinction is that Bexter treats its payload as text-domain data rather than arbitrary binary data, enabling optimizations specific to Base64-encoded content.
Bexter's structure consists of:
Bexter inherits standard Matter properties and adds text-specific functionality:
Inherited from Matter:
.pad: Number of pad characters given raw input.code: Derivation code indicating cipher suite.raw: Crypto material bytes without code.index: Count of attached crypto material by context.qb64: Fully qualified Base64 string with derivation code.qb64b: Fully qualified Base64 as bytes.qb2: Binary representation with derivation code.transferable: Boolean indicating transferable derivation codeBexter-Specific:
.text: The Base64 text value with the text code and leader removed from .qb64The encoding format follows CESR's variable-length primitive pattern. The documentation provides concrete examples showing the relationship between input text (bext) and encoded output (qb64):
bext = "" → qb64 = '4AAA'bext = "-" → qb64 = '6AABAAA-'bext = "-A" → qb64 = '5AABAA-A'bext = "-A-" → qb64 = '4AABA-A-'bext = "-A-B" → qb64 = '4AAB-A-B'These examples demonstrate how the leader portion (the characters before the actual text value) varies in length to maintain proper alignment and self-framing properties.
Character Set Constraint: Bexter is strictly limited to Base64 URL-safe characters:
Variable Length: Unlike fixed-length primitives, Bexter can represent strings of arbitrary length, with the length encoded in the leader bytes.
Critical Limitation - Leading 'A' Ambiguity: A significant constraint exists for strings beginning with the character 'A' whose length is a multiple of 3 or 4. Due to pre-padding mechanics in the encoding scheme:
Bexter(bext='ABBB').bext == 'BBB' (leading 'A' is stripped)Bexter(bext='BBB').bext == 'BBB' (no leading 'A', preserved)Bexter(bext='ABBB').qb64 == '4AABABBB' == Bexter(bext='BBB').qb64 (identical encoding)This ambiguity means that Bexter should only be used for Base64 strings that never start with 'A'. This is a documented design constraint rather than a bug, arising from the interaction between CESR's padding rules and Base64 encoding.
Bexter instances are created by providing Base64 text through the bext parameter:
bexter_instance = Bexter(bext="-A-B")
The initialization process:
.textAs with other CESR primitives, Bexter instances are typically immutable once created. The design philosophy of CESR emphasizes creating new primitives rather than modifying existing ones, which supports:
Validation operations for Bexter include:
The documentation identifies two specific use cases where Bexter is the optimal primitive choice:
Bexter is used to encode paths that navigate through nested Self-Addressing Data (SAD) structures and Self-Addressing Identifiers (SAID). In ACDC credentials and other KERI data structures, complex nested hierarchies often require path expressions to reference specific fields or sub-structures.
For example, a path like "attributes/legalEntity/LEI" can be efficiently encoded as a Bexter primitive, allowing it to be embedded in CESR streams alongside other cryptographic material. The Base64-compatible path components ensure compact representation while maintaining human readability in the text domain.
In multi-signature schemes, KERI supports fractionally weighted thresholds where different keys can have different voting weights. These threshold expressions, when represented as Base64-compatible strings, can be efficiently encoded using Bexter.
For instance, a threshold expression might specify that signatures from keys with combined weight ≥ 2/3 are required. When such expressions are encoded in a Base64-compatible format, Bexter provides the optimal primitive for including them in establishment events or other KERI messages.
Bexter integrates into the broader KERI protocol stack:
In KEL Events: Bexter primitives may appear in key event logs when events include path references or threshold expressions.
In ACDC Credentials: Authentic Chained Data Containers may use Bexter for encoding paths in selective disclosure mechanisms or for referencing nested attributes.
In CESR Streams: Bexter primitives can be freely mixed with other primitive types in CESR streams, maintaining the composability property that allows seamless concatenation and parsing.
The lifecycle of a Bexter primitive typically follows this pattern:
.text property accessed to retrieve the original Base64 string for application logicBexter exists within an ecosystem of related CESR primitives:
Matter Class: The parent class providing core primitive functionality. All Bexter instances are Matter instances, inheriting standard properties and methods.
Other Variable-Length Primitives: CESR includes other variable-length primitive types for different data categories (raw bytes, numbers, etc.). Bexter is specifically optimized for Base64 text.
Fixed-Length Primitives: In contrast to Bexter's variable length, CESR also defines fixed-length primitives for common cryptographic outputs (256-bit hashes, Ed25519 signatures, etc.).
Count Codes and Group Codes: These CESR constructs enable grouping of primitives, including Bexter instances, for efficient stream processing and pipelining.
Bexter's design prioritizes:
Implementers must be aware of:
Bexter's role in CESR ensures interoperability:
Bexter represents a specialized component in KERI's broader architecture:
Composability: By providing efficient Base64 text encoding, Bexter supports CESR's goal of composable streams where different primitive types can be seamlessly concatenated.
Self-Framing: The variable-length encoding with embedded length information enables parsers to extract Bexter primitives from streams without external context.
Dual-Domain Support: Bexter's ability to represent the same data in both text (qb64) and binary (qb2) domains supports KERI's goal of protocol flexibility across different transport mechanisms.
Cryptographic Integrity: While Bexter itself doesn't contain cryptographic material, it can be included in signed messages, with the signature covering the entire CESR stream including any Bexter primitives.
This primitive type exemplifies KERI's design philosophy of creating minimal, composable building blocks that can be combined to support complex protocols while maintaining verifiability and efficiency.
Interoperability testing should verify that Bexter primitives created in one language can be correctly parsed and decoded in all other language implementations.
Implementations should provide clear error messages for:
Since Bexter is a Matter subclass, implementations must: