Skip to main content

SimpleGo Protocol Documentation

Complete documentation of the SimpleX SMP protocol implementation.


Overview

SimpleGo implements the SimpleX Messaging Protocol (SMP) for secure, decentralized messaging.


Protocol Stack

LayerProtocolDescription
5ApplicationUser messages, contacts
4Agent ProtocolE2E encryption, connections
3SMPQueue-based message delivery
2TLS 1.3Transport security
1TCPNetwork transport

SMP Protocol

Key Concepts

ConceptDescription
QueueUnidirectional message channel
SenderParty that sends to queue
RecipientParty that receives from queue
RelayServer that hosts queues

SMP Commands

CommandDirectionDescription
NEWClient to ServerCreate new queue
SUBClient to ServerSubscribe to queue
SENDClient to ServerSend message
ACKClient to ServerAcknowledge receipt
OFFClient to ServerSuspend queue
DELClient to ServerDelete queue

SMP Responses

ResponseDescription
OKCommand succeeded
ERRCommand failed
MSGMessage delivered
NMSGNew message notification

Agent Protocol

Connection States

StateDescription
NEWCreated, not confirmed
PENDINGWaiting for confirmation
CONFIRMEDReady for messaging
ESTABLISHEDFully established
DELETEDConnection deleted

Agent Messages

MessageDescription
CONFConnection confirmation
INFOConnection information
HELLOInitial greeting
MSGUser message
ACKMessage acknowledgment

E2E Encryption Protocol

Key Exchange (X3DH)

StepOperation
1Sender generates ephemeral X448 key
2Sender performs 3 DH operations
3Sender derives keys via HKDF
4Sender sends public keys to recipient
5Recipient performs same DH
6Both have same shared secrets

Double Ratchet

RatchetTriggerDerives
RootDH ratchet stepRoot key, chain key, header key
ChainEach messageMessage key, chain key, IVs

Message Encryption

LayerKeyContent
Headerheader_keyMsgHeader
Bodymessage_keyMessage content

Connection Establishment

Step 1: Create Invitation

Recipient:

  1. Generate X448 key pairs
  2. Create queue on SMP server
  3. Build invitation with server and keys
  4. Share invitation

Step 2: Accept Invitation

Sender:

  1. Parse invitation
  2. Connect to SMP server
  3. Create sender queue
  4. Perform X3DH
  5. Send AgentConfirmation

Step 3: Confirm Connection

Recipient:

  1. Receive AgentConfirmation
  2. Decrypt connection info
  3. Perform X3DH
  4. Initialize ratchet
  5. Connection ready

Message Format

EncRatchetMessage

FieldSizeDescription
emHeaderLen1 byte123
emHeader123 bytesEncrypted header
emAuthTag16 bytesBody auth tag
emBodyVariableEncrypted body (Tail)

EncMessageHeader (123 bytes)

FieldSizeDescription
ehVersion2 bytesVersion (2)
ehIV16 bytesHeader IV
ehAuthTag16 bytesHeader auth tag
ehBodyLen1 byte88
ehBody88 bytesEncrypted MsgHeader

MsgHeader (88 bytes)

FieldSizeDescription
msgMaxVersion2 bytesVersion (2)
dhKeyLen1 byte68
msgDHRs68 bytesX448 SPKI key
msgPN4 bytesPrevious chain count
msgNs4 bytesMessage number
padding9 bytesZero padding

Error Handling

SMP Errors

ErrorDescription
AUTHAuthentication failed
NO_QUEUEQueue does not exist
QUOTAQueue quota exceeded
NO_MSGNo message available
LARGE_MSGMessage too large

Agent Errors

ErrorDescription
A_DUPLICATEDuplicate connection
A_PROHIBITEDOperation not allowed
A_MESSAGEMessage parsing error
A_CRYPTOCryptographic error

Security Properties

Confidentiality

  • AES-256-GCM encryption
  • Keys from DH shared secrets
  • Forward secrecy via Double Ratchet

Integrity

  • GCM authentication tags
  • Message counters prevent replay
  • Hash chains link messages

Authentication

  • X3DH mutual authentication
  • Ed25519 signatures
  • TLS server authentication

Privacy

  • No user identifiers
  • Random queue IDs
  • Servers cannot read content

References


License

AGPL-3.0 - See LICENSE