Loading vLEI.wiki
Fetching knowledge base...
Fetching knowledge base...
This comprehensive explanation has been generated from 196 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.
CESR (Composable Event Streaming Representation) is a dual text-binary encoding protocol that provides self-framing, composable representation of cryptographic primitives and structured data, enabling lossless round-trip conversion between human-readable text and compact binary formats while maintaining separability.
CESR addresses a fundamental challenge in cryptographic protocol design: representing cryptographic primitives (digests, keys, signatures) and structured data in formats that are simultaneously:
Traditional encodings like Base64 provide only value information without type or size metadata. CESR solves this by prepending derivation codes (also called framing codes) that encode type and size information, making each primitive self-framing.
The protocol's defining innovation is text-binary concatenation composability: the ability to convert groups of concatenated primitives between text (T) and binary (B) domains en masse without loss, while maintaining the separability of individual primitives. Formally:
T(cat(b[k])) = cat(T(b[k])) and B(cat(t[k])) = cat(B(t[k])) for all k
This property is essential for streaming protocols where primitives need efficient processing in both domains.
CESR is formally specified in:
draft-ssmith-cesr (Composable Event Streaming Representation)draft-pfeairheller-cesr-proof - CESR Proof Signatures extensiondraft-ssmith-said - Self-Addressing Identifiers (uses CESR encoding)draft-ssmith-keri - KERI protocol (primary consumer of CESR)CESR evolved from the need to support KERI's cryptographic event streaming requirements:
CESR operates across three abstract domain representations:
A-Z, a-z, 0-9, -, _) per RFC 4648(text_code, raw_binary)The composability property requires strict 24-bit boundary alignment:
Every CESR primitive is self-framing - it contains all information needed to parse it without external delimiters:
Example Text Domain Primitive:
E<43 Base64 characters>
E = derivation code (Blake3-256 digest)CESR uses multiple code tables optimized for different requirements:
Small Fixed Raw Size (1-character codes):
A (random seed), B (Ed25519 public key), E (Blake3-256 digest)Large Fixed Raw Size (2-character codes):
0B (Ed25519 signature), 0D (Blake3-512 digest)Small Variable Raw Size (2-character codes):
Large Variable Raw Size (4-character codes):
Purpose: Enable grouping of primitives for pipelining
Types:
Example:
-AAB<primitive1><primitive2>
-AAB = count code indicating 2 primitives followCESR supports hierarchical composition through:
All CESR primitives follow this general structure:
[Derivation Code][Value]
Derivation Code Components:
CESR uses leading pad bytes (not trailing = characters) to achieve 24-bit alignment:
Algorithm:
ps = (3 - (N mod 3)) mod 3 where N = raw byte lengthps zero bytes to raw valueExample (1-byte value):
0x420x0000 42AABCM: MABC1-Character Codes (pad size 1):
[Code][43 Base64 chars]
Example: BDKrJxkcR9m5u1xs33F5pxRJP6T7hJEbhpHrUtlDdhh0
2-Character Codes (pad size 0):
[Code1][Code2][42 Base64 chars]
Example: 0BDKrJxkcR9m5u1xs33F5pxRJP6T7hJEbhpHrUtlDdhh0
Variable-Length Codes:
[Code][Length][Value]
Example: 4B##<value> where ## encodes length in Base64
Binary encoding follows similar principles but operates on bytes:
Structure:
[Binary Code][Raw Bytes]
Code Mapping:
E → Binary code 0x0C0B → Binary code 0x34 0x00Alignment: Binary codes ensure 3-byte alignment through lead byte padding
Seeds and Salts:
A: 128-bit random seed0A: 256-bit random saltPublic Keys:
B: Ed25519 non-transferable prefixD: Ed25519 public verification keyC: X25519 public encryption key1AAA: ECDSA secp256k1 public keyDigests:
E: Blake3-256 (32 bytes)F: Blake2b-256 (32 bytes)G: Blake2s-256 (32 bytes)H: SHA3-256 (32 bytes)I: SHA2-256 (32 bytes)0D: Blake3-512 (64 bytes)Signatures:
0B: Ed25519 signature (64 bytes)0C: ECDSA secp256k1 signatureNumbers:
M: Short number (2 bytes)N: Big number (8 bytes)0H: Long number (4 bytes)Strings:
4B##: Variable-length byte string (small)5B##: Variable-length byte string (lead size 1)7AAB####: Variable-length byte string (big)Timestamps and UUIDs:
CESR streams can interleave with other serialization formats:
Supported Formats:
Detection Mechanism:
Example Mixed Stream:
[CESR primitives][JSON object][CESR primitives][CBOR data]
CESR provides cold start stream parsing capabilities:
Problem: After reboot or error, parser needs framing information
Solution:
Re-synchronization Process:
Pipelining enables parallel processing:
Performance Benefits:
CESR defines six transformations between domains:
T(B) - Binary to Text:
B(T) - Text to Binary:
Round-Trip Property:
T(B(T(primitive))) = T(primitive)
B(T(B(primitive))) = B(primitive)
CESR supports cryptographic attachments without wrapper envelopes:
Signature Attachments:
[Message Body][Count Code][Signatures]
Receipt Attachments:
[Key Event][Count Code][Witness Receipts]
CESR-Proof Attachments (from draft-pfeairheller-cesr-proof):
[SAD][Count Code][Path-Signature Pairs]
CESR provides algorithm agility through derivation codes:
Benefits:
Security Consideration: Derivation codes must be carefully managed to prevent downgrade attacks
Self-Framing Integrity:
Composability Integrity:
Protected Against:
Not Protected Against (requires higher-level protocols):
Malformed Stream Attacks:
Resource Exhaustion:
CESR is the native encoding for KERI:
Key Event Messages:
{
"v": "KERI10JSON00011c_",
"t": "icp",
"d": "EH7Oq9oxCgYa-nnNLvwhp9sFZpALILlRYyB-6n4WDi7w",
"i": "EH7Oq9oxCgYa-nnNLvwhp9sFZpALILlRYyB-6n4WDi7w",
"s": "0",
"kt": "1",
"k": ["DSuhyBcPZEZLK-fcw5tzHn2N46wRCG_ZOoeKtWTOunRA"],
"n": ["EPYuj8mq_PYYsoBKkzX1kxSPGYBWaIya3slgCOyOtlqU"]
}
Signature Attachments (CESR-encoded):
-AABAA1o61PgMhwhi89FES_vwYeSbbWnVuELV_jv7Yv6f5zNiOLnj1ZZa4MW2c6Z_vZDt55QUnLaiaikE-d_ApsFEgCA
ACDCs use CESR for:
SAIDs (Self-Addressing Identifiers):
EAdXt3gIXOf2BBWNHdSXCJnFJL5OuQPyM5K0neuniccMCompact Disclosure:
CESR-Proof Signatures:
SAID (Self-Addressing Identifier) protocol uses CESR:
SAID Generation:
#)Verification:
OOBI (Out-Of-Band Introduction) uses CESR for:
AID Encoding: All AIDs in OOBIs are CESR-encoded URL Construction: CESR primitives embedded in URLs Discovery: CESR enables compact AID representation
Challenge: Multiple code tables with version evolution
Approach:
Text Domain:
Binary Domain:
Stream Processing:
24-Bit Alignment:
Code Table Synchronization:
Interleaved Format Detection:
Error Recovery:
Round-Trip Testing:
for each primitive:
text = T(R(primitive))
binary = B(text)
recovered = R(B(binary))
assert primitive == recovered
Composability Testing:
primitives = [p1, p2, p3]
text_concat = cat([T(p) for p in primitives])
binary_group = B(text_concat)
recovered_text = T(binary_group)
assert text_concat == recovered_text
Interoperability Testing:
Primitive Classes:
Common Interface:
.qb64() # Qualified Base64 text
.qb64b() # Qualified Base64 bytes
.qb2() # Qualified binary
.code() # Derivation code
.raw() # Raw bytes
Parser Architecture:
JavaScript/TypeScript:
Buffer for binary operationsPython:
bytes for binary domainbase64 standard libraryRust:
Go:
encoding/base64All CESR primitives MUST align on 24-bit boundaries:
ps = (3 - (N mod 3)) mod 3CESR uses leading pad bytes (not trailing = characters):
= pad charactersImplementations MUST support:
Implementations SHOULD provide:
Text Domain:
Binary Domain:
Implementations MUST validate:
T(B(T(x))) = T(x) and B(T(B(x))) = B(x)Primitive Classes: Implement typed classes for each primitive category (Diger, Verfer, Signer, etc.) with common interface:
.qb64() - Qualified Base64 text.qb2() - Qualified binary.code() - Derivation code.raw() - Raw bytesParser Components: