Skip to main content

Wire Format Reference

Draft

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:

EncodingMeaning
'0' (0x30)Nothing — value is absent
'1' (0x31) + encoded valueJust — value follows
Common Pitfall

The Maybe encoding uses ASCII '0'/'1' (0x30/0x31), NOT binary 0x00/0x01. Several early SimpleGo bugs were caused by this confusion.

Integers

TypeSizeEncoding
Word162 bytesBig-endian
Word324 bytesBig-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

CharacterHexUsage
Space0x20Between command parts
Newline0x0ARecord separator