Skip to main content

SimpleGo Wire Format Specification

Complete wire format documentation for the SimpleX SMP protocol.


Overview

This document describes the binary encoding format used by SimpleGo.


Length Encoding Strategies

StrategyUsageFormat
StandardFields <= 254 bytes1 byte containing length
LargeFields > 254 bytes0xFF + Word16 BE
TailLast field in structureNo prefix

Important: Adding a length prefix to a Tail field causes parsing errors.


Numeric Encodings

Word16 (Big Endian)

2 bytes, most significant byte first.

ValueEncoding
00x00 0x00
10x00 0x01
2560x01 0x00

Word32 (Big Endian)

4 bytes, most significant byte first.


AgentConfirmation Message

OffsetSizeFieldEncodingValue
02agentVersionWord16 BE7
21typeASCIIC (0x43)
31maybeE2EASCII1 (0x31)
42e2eVersionWord16 BE2
61key1Len1 byte68 (0x44)
768key1X448 SPKIOur ratchet key
751key2Len1 byte68 (0x44)
7668key2X448 SPKIOur ephemeral key
144RESTencConnInfoTailEncrypted info

Total header: 144 bytes Padding target: 14832 bytes


EncRatchetMessage

OffsetSizeFieldEncoding
01emHeaderLen1 byte (123)
1123emHeaderEncMessageHeader
12416emAuthTagRaw bytes
140RESTemBodyTail

EncMessageHeader (123 bytes)

OffsetSizeFieldEncoding
02ehVersionWord16 BE (2)
216ehIVRaw bytes
1816ehAuthTagRaw bytes
341ehBodyLen1 byte (88)
3588ehBodyEncrypted MsgHeader

Total: 2 + 16 + 16 + 1 + 88 = 123 bytes


MsgHeader (88 bytes)

OffsetSizeFieldEncoding
02msgMaxVersionWord16 BE (2)
21dhKeyLen1 byte (68)
368msgDHRsX448 SPKI
714msgPNWord32 BE
754msgNsWord32 BE
799paddingZero bytes

Total: 2 + 1 + 68 + 4 + 4 + 9 = 88 bytes


SMPQueueInfo

FieldEncoding
clientVersionWord16 BE (8)
hostCount1 byte (1)
hostLength-prefixed string
portLength-prefixed string
keyHash1-byte length + 32 bytes
senderId1-byte length + N bytes
dhPublicKey1-byte length (44) + X25519 SPKI
queueModeOptional

queueMode Encoding

ValueEncoding
NothingEmpty (0 bytes!)
Just QMMessagingM (1 byte)
Just QMSubscriptionS (1 byte)

SPKI Key Formats

X448 SPKI (68 bytes)

Header: 30 42 30 05 06 03 2b 65 6f 03 39 00 (12 bytes)

  • Raw key (56 bytes)

X25519 SPKI (44 bytes)

Header: 30 2a 30 05 06 03 2b 65 6e 03 21 00 (12 bytes)

  • Raw key (32 bytes)

Padding Format

Format: [2 bytes: length Word16 BE][content][# padding]

Message TypePadded Size
AgentConfirmation14832 bytes
HELLO15840 bytes

Common Encoding Mistakes

MistakeIncorrectCorrect
E2E key lengthWord16 BE1 byte
MsgHeader DH keyWord16 BE1 byte
ehBody lengthWord16 BE1 byte
emHeader size124 bytes123 bytes
prevMsgHash length1 byteWord16 BE
Port encodingSpace charLength byte
smpQueues count1 byteWord16 BE
queueMode Nothing0 byteEmpty
Tail fieldWith prefixNo prefix
rcAD keysSPKI (68B)Raw (56B)
Payload AAD236 bytes235 bytes

References


License

AGPL-3.0 - See LICENSE