Skip to main content

SimpleGo Architecture

This document describes the software architecture of SimpleGo, a multi-platform implementation of the SimpleX Messaging Protocol for dedicated secure communication devices.


Table of Contents​

  1. Design Philosophy
  2. System Overview
  3. Layer Architecture
  4. Hardware Abstraction Layer
  5. Protocol Implementation
  6. Cryptographic Architecture
  7. User Interface Layer
  8. Device Implementations
  9. Memory Architecture
  10. Build System
  11. Security Architecture

Design Philosophy​

SimpleGo is built on three core principles:

Single Codebase, Multiple Devices​

The protocol implementation and user interface are written once and shared across all supported hardware platforms. Only the hardware-specific code differs between devices. This approach ensures:

  • Protocol bugs are fixed once for all devices
  • Security updates propagate automatically
  • New features benefit all platforms simultaneously
  • Development effort is maximized

Minimal Trusted Computing Base​

Security increases as code size decreases. SimpleGo targets approximately 50,000 lines of code compared to approximately 50,000,000 in a typical smartphone operating system. Every line of code is a potential vulnerability. By minimizing the codebase, we minimize the attack surface.

Hardware-Enforced Security​

Software security alone is insufficient against physical attacks. SimpleGo leverages hardware security features including:

  • Secure Elements for key storage
  • Hardware cryptographic acceleration
  • Tamper detection circuits
  • Secure boot chains
  • Flash encryption

System Overview​

+===========================================================================+
| SIMPLEGO SYSTEM |
+===========================================================================+
| |
| +---------------------------------------------------------------------+ |
| | APPLICATION LAYER | |
| | | |
| | +-------------------+ +-------------------+ +-----------------+ | |
| | | Screen Manager | | Event Handler | | State Manager | | |
| | +-------------------+ +-------------------+ +-----------------+ | |
| | | |
| +---------------------------------------------------------------------+ |
| | |
| +---------------------------------------------------------------------+ |
| | USER INTERFACE LAYER | |
| | | |
| | +-------------+ +-------------+ +-------------+ +------------+ | |
| | | Screens | | Widgets | | Themes | | Fonts | | |
| | +-------------+ +-------------+ +-------------+ +------------+ | |
| | | |
| +---------------------------------------------------------------------+ |
| | |
| +---------------------------------------------------------------------+ |
| | PROTOCOL LAYER | |
| | | |
| | +---------------+ +---------------+ +---------------+ | |
| | | SMP Client | | Agent Protocol| | Queues | | |
| | +---------------+ +---------------+ +---------------+ | |
| | | |
| | +---------------+ +---------------+ +---------------+ | |
| | | Double Ratchet| | X3DH | | Contacts | | |
| | +---------------+ +---------------+ +---------------+ | |
| | | |
| +---------------------------------------------------------------------+ |
| | |
| +---------------------------------------------------------------------+ |
| | CRYPTOGRAPHIC LAYER | |
| | | |
| | +----------+ +----------+ +----------+ +----------+ +-------+ | |
| | | X448 | | X25519 | | Ed25519 | | AES-GCM | | HKDF | | |
| | +----------+ +----------+ +----------+ +----------+ +-------+ | |
| | | |
| +---------------------------------------------------------------------+ |
| | |
| +---------------------------------------------------------------------+ |
| | HARDWARE ABSTRACTION LAYER (HAL) | |
| | | |
| | +---------+ +---------+ +---------+ +---------+ +---------+ | |
| | | Display | | Input | | Network | | Storage | | Audio | | |
| | +---------+ +---------+ +---------+ +---------+ +---------+ | |
| | | |
| | +---------+ +---------+ | |
| | | System | | Secure | | |
| | | | | Element | | |
| | +---------+ +---------+ | |
| | | |
| +---------------------------------------------------------------------+ |
| | |
| +=====================================================================+ |
| | DEVICE IMPLEMENTATION LAYER | |
| +=====================================================================+ |
| | | | | | |
| | +-----------+--+ +----------+---+ +---------+----+ +----------+ | |
| | | T-Deck Plus | | T-Deck Pro | | SimpleGo | | Desktop | | |
| | | ESP32-S3 | | ESP32-S3 | | Secure | | Linux | | |
| | | 320x240 LCD | | 320x240 LCD | | STM32 + SE | | SDL2 | | |
| | | Keyboard | | Keyboard | | Dual SE | | Testing | | |
| | +--------------+ +--------------+ +--------------+ +----------+ | |
| | | |
| +---------------------------------------------------------------------+ |
| |
+===========================================================================+

Layer Architecture​

Layer Independence​

Each layer communicates only with adjacent layers through defined interfaces:

LayerDepends OnProvides To
ApplicationUI, ProtocolUser interaction
User InterfaceHAL (display, input)Application
ProtocolCrypto, HAL (network, storage)Application
CryptographicHAL (secure element)Protocol
HALDevice ImplementationAll upper layers
Device ImplementationHardwareHAL

Code Sharing​

LayerShared Across DevicesDevice-Specific
Application100%0%
User Interface100%0%
Protocol100%0%
Cryptographic100%0%
HAL Interfaces100% (headers)0%
HAL Implementation0%100%

This separation ensures that adding a new device requires only implementing the HAL layer without modifying any other code.


Hardware Abstraction Layer​

The HAL defines seven interfaces that abstract hardware functionality:

hal_common.h​

Common types, error codes, and utilities used across all HAL interfaces.

// Error codes
typedef enum {
HAL_OK = 0,
HAL_ERR_INVALID_ARG,
HAL_ERR_NO_MEM,
HAL_ERR_NOT_FOUND,
HAL_ERR_TIMEOUT,
HAL_ERR_NOT_SUPPORTED,
HAL_ERR_IO,
HAL_ERR_BUSY,
HAL_ERR_INVALID_STATE
} hal_err_t;

// Common geometric types
typedef struct { int16_t x; int16_t y; } hal_point_t;
typedef struct { uint16_t width; uint16_t height; } hal_size_t;
typedef struct { int16_t x; int16_t y; uint16_t w; uint16_t h; } hal_rect_t;

hal_display.h​

Display initialization, configuration, and rendering.

FunctionPurpose
hal_display_init()Initialize display hardware
hal_display_get_info()Query display capabilities
hal_display_set_orientation()Set rotation (0, 90, 180, 270)
hal_display_set_backlight()Adjust brightness (0-100)
hal_display_flush()Send pixel data to display
hal_display_flush_wait()Wait for DMA transfer completion

Capability flags indicate available features:

FlagDescription
HAL_DISPLAY_CAP_TOUCHTouch overlay available
HAL_DISPLAY_CAP_BACKLIGHTAdjustable backlight
HAL_DISPLAY_CAP_ROTATIONHardware rotation support
HAL_DISPLAY_CAP_DMADMA transfers supported
HAL_DISPLAY_CAP_DOUBLE_BUFDouble buffering available

hal_input.h​

Unified input handling for keyboards, touch, encoders, and buttons.

FunctionPurpose
hal_input_init()Initialize input subsystem
hal_input_get_capabilities()Query available input methods
hal_input_register_key_cb()Register keyboard callback
hal_input_register_pointer_cb()Register touch/trackball callback
hal_input_register_encoder_cb()Register rotary encoder callback

Input capabilities by device:

DeviceKeyboardTouchTrackballEncoderButtons
T-Deck PlusPhysical QWERTYCapacitiveYesNoNo
T-Deck ProPhysical QWERTYCapacitiveYesNoNo
T-Lora PagerNoneNoNoYesYes
SimpleGo SecurePhysicalCapacitiveOptionalNoNo
DesktopUSBNoNoNoNo

hal_storage.h​

Persistent storage for settings, keys, and messages.

FunctionPurpose
hal_nvs_open()Open NVS namespace
hal_nvs_set_*()Store values (int, string, blob)
hal_nvs_get_*()Retrieve values
hal_nvs_erase_key()Delete single key
hal_nvs_erase_all()Factory reset
hal_file_open()Open file on filesystem
hal_file_read()Read from file
hal_file_write()Write to file
hal_sd_mount()Mount SD card

Storage is divided into namespaces:

NamespacePurposeEncryption
settingsUser preferencesOptional
networkWiFi credentialsYes
identityDevice identity keysYes
contactsContact listYes
messagesMessage historyYes

hal_network.h​

Network connectivity including WiFi and Ethernet.

FunctionPurpose
hal_net_init()Initialize network stack
hal_net_wifi_connect()Connect to WiFi network
hal_net_wifi_disconnect()Disconnect from WiFi
hal_net_wifi_scan()Scan for available networks
hal_net_get_ip()Get current IP address
hal_net_is_connected()Check connection status

Network events are delivered through callbacks:

EventDescription
HAL_NET_EVENT_CONNECTEDNetwork connection established
HAL_NET_EVENT_DISCONNECTEDNetwork connection lost
HAL_NET_EVENT_GOT_IPIP address obtained
HAL_NET_EVENT_LOST_IPIP address lost

hal_audio.h​

Audio output for notifications and feedback.

FunctionPurpose
hal_audio_init()Initialize audio subsystem
hal_audio_play_tone()Play single frequency tone
hal_audio_play_sequence()Play tone sequence
hal_audio_play_sound()Play predefined sound
hal_audio_set_volume()Set output volume
hal_audio_stop()Stop current playback

Predefined sounds:

SoundUse Case
HAL_SOUND_MESSAGENew message received
HAL_SOUND_CONNECTConnection established
HAL_SOUND_DISCONNECTConnection lost
HAL_SOUND_ERRORError occurred
HAL_SOUND_KEYPRESSKey pressed (optional)

hal_system.h​

System-level functions including power management.

FunctionPurpose
hal_system_get_info()Get system information
hal_system_restart()Reboot device
hal_system_get_reset_reason()Query last reset cause
hal_power_get_battery_level()Get battery percentage
hal_power_is_charging()Check charging status
hal_power_enter_light_sleep()Enter low-power mode
hal_power_enter_deep_sleep()Enter minimal-power mode
hal_watchdog_init()Initialize watchdog timer
hal_watchdog_feed()Reset watchdog timer

Protocol Implementation​

SimpleX Messaging Protocol (SMP)​

SimpleGo implements the complete SMP client protocol:

+-----------------------------------------------------------------------+
| SMP PROTOCOL STACK |
+-----------------------------------------------------------------------+
| |
| +---------------------------+ +-----------------------------+ |
| | Agent Protocol | | Connection Manager | |
| | | | | |
| | - Message routing | | - Server connections | |
| | - Delivery confirmation | | - Reconnection logic | |
| | - Error handling | | - Multi-server support | |
| +---------------------------+ +-----------------------------+ |
| | | |
| +---------------------------+ +-----------------------------+ |
| | Queue Manager | | Message Encoder | |
| | | | | |
| | - Queue creation | | - Wire format encoding | |
| | - Subscription | | - Length prefixes | |
| | - Message retrieval | | - Padding | |
| +---------------------------+ +-----------------------------+ |
| | | |
| +---------------------------------------------------------------+ |
| | SMP Commands | |
| | | |
| | NEW - Create new queue | |
| | KEY - Provide sender key | |
| | SUB - Subscribe to queue | |
| | SEND - Send message to queue | |
| | ACK - Acknowledge message receipt | |
| | OFF - Suspend queue | |
| | DEL - Delete queue | |
| +---------------------------------------------------------------+ |
| | | |
| +---------------------------------------------------------------+ |
| | TLS 1.3 Transport | |
| | | |
| | - ALPN: "smp/1" | |
| | - Server certificate verification | |
| | - Session resumption | |
| +---------------------------------------------------------------+ |
| |
+-----------------------------------------------------------------------+

Message Flow​

Sending a message:

1. Application creates message
|
v
2. Double Ratchet encrypts message body
|
v
3. Message header encrypted with header key
|
v
4. Agent protocol wraps encrypted message
|
v
5. SMP SEND command with encrypted payload
|
v
6. TLS 1.3 encrypts entire transmission
|
v
7. TCP to SMP server

Receiving a message:

1. TCP from SMP server
|
v
2. TLS 1.3 decrypts transmission
|
v
3. SMP response parsed
|
v
4. Agent protocol unwraps message
|
v
5. Message header decrypted
|
v
6. Double Ratchet decrypts message body
|
v
7. Application receives plaintext

Cryptographic Architecture​

Algorithm Selection​

PurposeAlgorithmKey SizeLibrary
Ratchet Key AgreementX448448 bitswolfSSL
Initial Key AgreementX25519256 bitslibsodium
SigningEd25519256 bitslibsodium
Symmetric EncryptionAES-256-GCM256 bitsmbedTLS
Key DerivationHKDF-SHA512512 bitsmbedTLS
HashingSHA-512512 bitsmbedTLS

Key Hierarchy​

+-----------------------------------------------------------------------+
| KEY HIERARCHY |
+-----------------------------------------------------------------------+
| |
| IDENTITY LAYER (Long-term, stored in Secure Element) |
| +-------------------------------------------------------------------+|
| | +-------------------+ +-------------------+ ||
| | | Identity Key | | Identity Key | ||
| | | (Ed25519) | | (Ed25519) | ||
| | | Signing | | Verification | ||
| | +-------------------+ +-------------------+ ||
| +-------------------------------------------------------------------+|
| | |
| X3DH KEY AGREEMENT |
| +-------------------------------------------------------------------+|
| | +-------------------+ +-------------------+ ||
| | | Signed Pre-Key | | One-Time Pre-Key | ||
| | | (X25519) | | (X25519) | ||
| | +-------------------+ +-------------------+ ||
| | | ||
| | v ||
| | +-----------------------------------------------------------+ ||
| | | Shared Secret (from X3DH) | ||
| | +-----------------------------------------------------------+ ||
| +-------------------------------------------------------------------+|
| | |
| DOUBLE RATCHET (Per-message keys, ephemeral) |
| +-------------------------------------------------------------------+|
| | v ||
| | +-------------------+ +-------------------+ ||
| | | Root Key |--->| Chain Key | ||
| | | (256 bits) | | (256 bits) | ||
| | +-------------------+ +-------------------+ ||
| | | ||
| | +--------------------+--------------------+ ||
| | | | | ||
| | v v v ||
| | +-------------+ +-------------+ +-------------+ ||
| | | Message Key | | Message Key | | Message Key | ||
| | | (Msg 1) | | (Msg 2) | | (Msg N) | ||
| | +-------------+ +-------------+ +-------------+ ||
| +-------------------------------------------------------------------+|
| |
+-----------------------------------------------------------------------+

Forward Secrecy​

The Double Ratchet protocol provides forward secrecy through two mechanisms:

  1. Diffie-Hellman Ratchet: New X448 key pair generated periodically. Compromise of current keys does not reveal past session keys.

  2. Symmetric Ratchet: Chain key advanced with each message using HKDF. Previous message keys cannot be derived from current state.

Post-Compromise Security​

If an attacker compromises the current session state, security is restored after the next Diffie-Hellman ratchet step. The attacker cannot decrypt future messages once new key material is exchanged.


User Interface Layer​

LVGL Integration​

SimpleGo uses LVGL (Light and Versatile Graphics Library) for the user interface:

ComponentPurpose
ScreensFull-screen views (chat, contacts, settings)
WidgetsReusable UI components (message bubbles, status bar)
ThemesVisual styling (colors, fonts, spacing)
Input DriversHAL integration for touch, keyboard, encoder

Screen Architecture​

+-----------------------------------------------------------------------+
| SCREEN MANAGER |
+-----------------------------------------------------------------------+
| |
| +-------------+ +-------------+ +-------------+ +-------------+ |
| | Splash | | Main | | Chat | | Contacts | |
| | Screen | | Screen | | Screen | | Screen | |
| +-------------+ +-------------+ +-------------+ +-------------+ |
| |
| +-------------+ +-------------+ +-------------+ +-------------+ |
| | Settings | | Connect | | QR Code | | About | |
| | Screen | | Screen | | Screen | | Screen | |
| +-------------+ +-------------+ +-------------+ +-------------+ |
| |
+-----------------------------------------------------------------------+

Adaptive Layout​

The UI adapts to device capabilities:

CapabilityAdaptation
Small display (< 200px width)Compact layout, smaller fonts
No touchKeyboard/encoder navigation highlighted
No keyboardOn-screen keyboard activated
Low memoryReduced animation, simpler themes

Device Implementations​

Directory Structure​

devices/
|
+-- t_deck_plus/
| +-- config/
| | +-- device_config.h # Hardware constants and pin mappings
| +-- hal_impl/
| +-- hal_display.c # ST7789V display driver
| +-- hal_input.c # Keyboard, trackball, touch
| +-- hal_audio.c # MAX98357A I2S audio
| +-- hal_storage.c # NVS and SD card
| +-- hal_network.c # ESP32 WiFi
| +-- hal_system.c # AXP2101 power management
|
+-- t_deck_pro/
| +-- config/
| | +-- device_config.h
| +-- hal_impl/
| +-- hal_display.c # ST7789V display driver
| +-- hal_input.c # Keyboard, trackball, touch
| +-- hal_audio.c # I2S audio
| +-- hal_storage.c # NVS and SD card
| +-- hal_network.c # ESP32 WiFi
| +-- hal_system.c # Power management
|
+-- t_lora_pager/
| +-- config/
| | +-- device_config.h
| +-- hal_impl/
| +-- hal_display.c # OLED display driver
| +-- hal_input.c # Encoder and buttons
| +-- hal_audio.c # Buzzer
| +-- hal_storage.c # NVS
| +-- hal_network.c # ESP32 WiFi + LoRa
| +-- hal_system.c # Battery management
|
+-- simplego_secure/
| +-- config/
| | +-- device_config.h
| +-- hal_impl/
| +-- hal_secure_element.c # ATECC608B + OPTIGA integration
| +-- hal_display.c # Display driver
| +-- hal_input.c # Input handling
| +-- hal_network.c # WiFi + LTE
| +-- ...
|
+-- template/
+-- config/
| +-- device_config.h.template
+-- hal_impl/
+-- hal_template.c # Implementation template

Device Comparison​

FeatureT-Deck PlusT-Deck ProT-Lora PagerSimpleGo Secure
MCUESP32-S3ESP32-S3ESP32-S3STM32U585
Display320x240 IPS320x240 IPS128x64 OLED320x240 IPS
InputKB + Trackball + TouchKB + Trackball + TouchEncoder + ButtonsKB + Touch
AudioI2S SpeakerI2S SpeakerBuzzerI2S Speaker
Secure ElementNoneNoneNoneDual (ATECC + OPTIGA)
RadioWiFi + LoRa (opt)WiFi + LoRa (opt)WiFi + LoRaWiFi + LTE + LoRa
PowerAXP2101 PMUAXP2101 PMUBattery ADCFull PMU
TargetTier 1 DevTier 1 DevTier 1 CompactTier 2 Production

Memory Architecture​

ESP32-S3 Memory Map​

+-----------------------------------------------------------------------+
| FLASH MEMORY (16 MB) |
+-----------------------------------------------------------------------+
| Offset | Size | Partition | Contents |
|-------------|---------|----------------|------------------------------|
| 0x000000 | 64 KB | Bootloader | Second-stage bootloader |
| 0x010000 | 8 KB | Partition Table| Partition definitions |
| 0x012000 | 24 KB | NVS | Settings, credentials |
| 0x018000 | 8 KB | PHY Init | WiFi calibration data |
| 0x01A000 | 4 MB | Application | Firmware |
| 0x41A000 | 4 MB | OTA | Update partition |
| 0x81A000 | ~7.5 MB | Storage | Messages, contacts |
+-----------------------------------------------------------------------+

+-----------------------------------------------------------------------+
| INTERNAL SRAM (512 KB) |
+-----------------------------------------------------------------------+
| Region | Size | Usage |
|-------------|---------|-----------------------------------------------|
| IRAM | 128 KB | Instruction cache, interrupt handlers |
| DRAM | 320 KB | Heap, stack, static data |
| RTC SRAM | 16 KB | Deep sleep persistence |
+-----------------------------------------------------------------------+

+-----------------------------------------------------------------------+
| PSRAM (8 MB) |
+-----------------------------------------------------------------------+
| Usage | Typical Allocation |
|---------------------------------|-------------------------------------|
| LVGL Display Buffers | 150 KB (320x240x2 double buffer) |
| LVGL Object Pool | 256 KB |
| Message Cache | 512 KB |
| Cryptographic Buffers | 64 KB |
| Network Buffers | 128 KB |
| Application Heap | Remaining |
+-----------------------------------------------------------------------+

Memory Allocation Strategy​

TypeAllocationReason
Display buffersPSRAMLarge, performance not critical
Crypto operationsInternal SRAMSecurity, speed
Network buffersPSRAMLarge, DMA capable
UI objectsPSRAMNumerous small allocations
StackInternal SRAMSpeed, reliability

Memory Safety​

// All sensitive memory is cleared after use
void secure_clear(void *ptr, size_t len) {
volatile uint8_t *p = (volatile uint8_t *)ptr;
while (len--) {
*p++ = 0;
}
}

// Buffer operations always bounds-checked
hal_err_t safe_copy(void *dst, size_t dst_size,
const void *src, size_t src_size) {
if (src_size > dst_size) {
return HAL_ERR_INVALID_ARG;
}
memcpy(dst, src, src_size);
return HAL_OK;
}

Build System​

ESP-IDF Integration​

SimpleGo uses the standard ESP-IDF build system:

simplex_client/
|
+-- CMakeLists.txt # Project definition (minimal)
+-- Kconfig # Configuration options
+-- sdkconfig.defaults # Default configuration
|
+-- main/
| +-- CMakeLists.txt # Component registration
| +-- Kconfig # Component-specific options
| +-- core/ # Protocol implementation
| +-- hal/ # HAL interface headers
| +-- ui/ # User interface
| +-- include/ # Public headers
|
+-- devices/
| +-- t_deck_plus/
| +-- t_embed_cc1101/
|
+-- components/ # External libraries
+-- wolfssl/
+-- lvgl/

Device Selection​

Device selection is managed through Kconfig:

# Interactive configuration
idf.py menuconfig
# Navigate to: SimpleGo Configuration -> Target Device

# Or via sdkconfig
echo "CONFIG_SIMPLEGO_DEVICE_T_DECK_PLUS=y" >> sdkconfig

Build Process​

# Full build
idf.py build

# Build and flash
idf.py flash -p /dev/ttyUSB0

# Build, flash, and monitor
idf.py flash monitor -p /dev/ttyUSB0

# Clean build
idf.py fullclean
idf.py build

For detailed build system documentation, see BUILD_SYSTEM.md.


Security Architecture​

Secure Boot​

+-----------------------------------------------------------------------+
| SECURE BOOT CHAIN |
+-----------------------------------------------------------------------+
| |
| +------------------+ |
| | ROM Bootloader | Immutable, in silicon |
| | (First Stage) | |
| +--------+---------+ |
| | |
| | Verify signature (RSA-3072 / ECDSA) |
| v |
| +------------------+ |
| | Second Stage | Public key hash in eFuse |
| | Bootloader | |
| +--------+---------+ |
| | |
| | Verify signature |
| v |
| +------------------+ |
| | Application | Signed firmware image |
| | Firmware | |
| +--------+---------+ |
| | |
| | Runtime integrity checks |
| v |
| +------------------+ |
| | Secure Element | Verify device identity (Tier 2+) |
| | Verification | |
| +------------------+ |
| |
+-----------------------------------------------------------------------+

Flash Encryption​

All flash contents are encrypted with AES-256-XTS:

RegionEncryptionKey Storage
BootloaderYeseFuse (read-protected)
ApplicationYeseFuse (read-protected)
NVSYeseFuse (read-protected)
OTA PartitionYeseFuse (read-protected)

Key Storage​

Key TypeStorage LocationProtection
Device IdentitySecure ElementHardware isolation
TLS Client KeySecure ElementHardware isolation
Ratchet KeysEncrypted NVSFlash encryption
Session KeysRAM onlyCleared after use

Tamper Response (Tier 2+)​

Tamper Event Detected
|
v
+------------------+
| Zeroization | < 1 microsecond
| - Clear SRAM |
| - Clear SE keys |
| - Clear NVS |
+------------------+
|
v
+------------------+
| Device Brick | Optional, configurable
+------------------+

References​


Document History​

VersionDateChanges
0.1.16January 2026Complete rewrite for HAL architecture
0.1.0December 2025Initial protocol-focused documentation