Wire Format Reference
This section is under construction. This chapter will contain complete byte-level encoding rules verified against ESP32 test data.
Encoding Primitives
ByteString (Short)
1-byte length prefix followed by data:
┌──────────────┬───────────────────┐
│ Length (1B) │ Data (N bytes) │
└──────────────┴───────────────────┘
Maximum length: 255 bytes.
Large ByteString
2-byte BE16 length prefix followed by data:
┌──────────────┬───────────────────┐
│ Length (2B) │ Data (N bytes) │
│ BE16 │ │
└──────────────┴───────────────────┘
Maybe Type
SimpleX encodes optional values using ASCII characters:
| Encoding | Meaning |
|---|---|
'0' (0x30) | Nothing — value is absent |
'1' (0x31) + encoded value | Just — value follows |
The Maybe encoding uses ASCII '0'/'1' (0x30/0x31), NOT binary 0x00/0x01. Several early SimpleGo bugs were caused by this confusion.
Integers
| Type | Size | Encoding |
|---|---|---|
| Word16 | 2 bytes | Big-endian |
| Word32 | 4 bytes | Big-endian |
Tail
Remaining bytes in the buffer (no length prefix). Used for the last field in a structure.
Key Encodings
X25519 SPKI Format (44 bytes)
┌─────────────────────────┬────────────────────┐
│ ASN.1 Header (12 bytes) │ Raw Key (32 bytes) │
└─────────────────────────┴────────────────────┘
ASN.1 header for X25519: 30 2a 30 05 06 03 2b 65 6e 03 21 00
X448 SPKI Format (68 bytes)
┌─────────────────────────┬────────────────────┐
│ ASN.1 Header (12 bytes) │ Raw Key (56 bytes) │
└─────────────────────────┴────────────────────┘
ASN.1 header for X448: 30 42 30 05 06 03 2b 65 6f 03 39 00
Ed25519 SPKI Format (44 bytes)
ASN.1 header for Ed25519: 30 2a 30 05 06 03 2b 65 70 03 21 00
Raw Key Format
Used in rcAD (Associated Data) — 56-byte raw X448 keys with NO ASN.1 wrapper.
Separators
| Character | Hex | Usage |
|---|---|---|
| Space | 0x20 | Between command parts |
| Newline | 0x0A | Record separator |