Loading vLEI.wiki
Fetching knowledge base...
Fetching knowledge base...
This comprehensive explanation has been generated from 25 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.
Lead bytes are bytes with zero values that are prepended (added to the beginning) of raw binary cryptographic material before Base64 conversion in CESR (Composable Event Streaming Representation) encoding. These bytes serve to align the data on 24-bit boundaries, which is essential for CESR's composability property. The term "lead bytes" is used specifically to avoid confusion with "pad characters" (the = character in traditional Base64), which are added after conversion.
0x00CESR requires all primitives to align on because:
Implementations must correctly calculate lead bytes using the formula ps = (3 - (N mod 3)) mod 3 where N is the raw binary size in bytes. This ensures:
When encoding CESR primitives:
When parsing CESR streams:
Implementations should validate:
For high-performance implementations:
The terminology distinction is critical:
Traditional Base64 (post-padding):
= characters to reach 4-character boundaries= padCESR Approach (pre-padding with lead bytes):
= characters neededThe number of lead bytes (ps) required is calculated as:
ps = (3 - (N mod 3)) mod 3
Where N is the size of the raw binary value in bytes.
N mod 3 = 0: No lead bytes needed (ps = 0)N mod 3 = 1: Two lead bytes needed (ps = 2)N mod 3 = 2: One lead byte needed (ps = 1)In CESR, the Base64 characters that result from encoding the lead bytes are replaced with derivation codes that indicate the primitive type and size. This replacement is possible because:
For example, a 1-byte value requires 2 lead bytes, producing 4 Base64 characters total. The first 2-3 characters (from lead bytes) can be replaced with type codes, while the remaining characters encode the actual value.
Lead bytes enable CESR's self-framing property: