GhostlineGhostline

Messaging Architecture

Messaging Architecture

Ghostline's messaging system is built on Signal protocol with MLS (Messaging Layer Security) for advanced group messaging capabilities.

Protocol Stack

Signal Protocol

Ghostline uses the Signal protocol for one-on-one and small group messaging:

  • Double Ratchet: Automatic key rotation
  • Perfect Forward Secrecy: Past messages remain secure
  • Deniable Authentication: Cryptographic deniability
  • Asynchronous: Works with offline recipients

MLS Protocol

Messaging Layer Security for scalable group messaging:

  • Group Key Management: Efficient key distribution
  • Scalability: Support for large groups
  • Forward Secrecy: Group message security
  • Membership Changes: Efficient member management

Architecture Components

Client Components

Message Client:

  • Signal protocol implementation
  • MLS group management
  • Local message storage (encrypted)
  • Key management integration

Key Management:

  • Key generation and storage
  • Key exchange protocols
  • Key rotation handling
  • Recovery key management

Storage:

  • Encrypted local database
  • Message caching
  • Media storage
  • Contact management

Server Components

Message Relay:

  • Encrypted message routing
  • Offline message queuing
  • Delivery status tracking
  • No message content access

Key Server:

  • Pre-key distribution
  • Identity key management
  • Key exchange facilitation
  • No key material access

Group Management:

  • MLS group state management
  • Membership tracking
  • Group policy enforcement
  • No group message access

Message Flow

One-on-One Messaging

Sender                    Server                    Recipient
  │                         │                          │
  │── Encrypted Message ────>│                          │
  │                         │── Encrypted Message ────>│
  │                         │                          │
  │<── Delivery Receipt ────│<── Read Receipt ────────│

Group Messaging

Sender                    Server                    Group Members
  │                         │                          │
  │── Encrypted Message ────>│                          │
  │   (Group Key)            │                          │
  │                         │── Encrypted Message ────>│
  │                         │── Encrypted Message ────>│
  │                         │── Encrypted Message ────>│

Encryption Details

Signal Protocol Encryption

Double Ratchet Algorithm:

  1. Initial key exchange (X3DH)
  2. Sender key generation
  3. Message encryption (AES-256)
  4. Key rotation after each message
  5. Perfect forward secrecy

Message Structure:

┌─────────────────────────────────┐
│ Header (encrypted with ratchet) │
├─────────────────────────────────┤
│ Payload (encrypted with AES-256)│
├─────────────────────────────────┤
│ Authentication tag (HMAC)        │
└─────────────────────────────────┘

MLS Group Encryption

Group Key Derivation:

  1. Initial group key establishment
  2. Tree-based key structure
  3. Efficient key updates
  4. Forward secrecy maintenance

Group Message Structure:

┌─────────────────────────────────┐
│ Group ID                        │
├─────────────────────────────────┤
│ Sender ID                       │
├─────────────────────────────────┤
│ Encrypted Message (group key)   │
├─────────────────────────────────┤
│ Authentication                  │
└─────────────────────────────────┘

Metadata Protection

Minimized Metadata

Ghostline minimizes metadata collection:

  • No Message Content: Servers never see message content
  • Limited Timestamps: Reduced timestamp precision
  • Anonymous Routing: Optional Tor routing
  • No Contact Discovery: No phone number lookup

Metadata Encryption

Where metadata is necessary:

  • Encrypted metadata fields
  • Zero-knowledge proofs
  • Differential privacy
  • Aggregated statistics only

Key Management

Key Generation

  • Cryptographically secure random number generation
  • Hardware security module support
  • Key derivation from master key
  • Regular key rotation

Key Storage

  • Encrypted local storage
  • Hardware key support
  • Secure key backup
  • Recovery key management

Key Exchange

  • X3DH key exchange protocol
  • Pre-key distribution
  • Identity key verification
  • Secure key transport

Group Management

MLS Group Operations

Creating Groups:

  1. Initialize MLS group
  2. Add initial members
  3. Establish group key
  4. Distribute group state

Adding Members:

  1. Invite new member
  2. Update group key
  3. Distribute new group state
  4. Member joins group

Removing Members:

  1. Remove member from group
  2. Update group key
  3. Distribute new group state
  4. Member removed

Group Policy:

  • Membership approval
  • Message permissions
  • Admin roles
  • Group settings

File Sharing

File Encryption

  1. Generate file encryption key
  2. Encrypt file with AES-256
  3. Upload encrypted file
  4. Share encryption key via Signal
  5. Recipient decrypts file

Media Optimization

  • Image compression
  • Video transcoding
  • Thumbnail generation
  • Progressive loading

Voice & Video Calls

Call Setup

  1. Establish signaling channel (encrypted)
  2. Exchange ICE candidates
  3. Establish WebRTC connection
  4. Encrypted media stream
  5. End-to-end encryption

Call Encryption

  • DTLS-SRTP for media encryption
  • Signal protocol for signaling
  • Perfect forward secrecy
  • No server access to call content

Performance Optimization

Message Delivery

  • Priority queuing
  • Batch delivery
  • Offline message handling
  • Delivery status tracking

Storage Optimization

  • Message compression
  • Media caching
  • Database optimization
  • Cleanup policies

Network Optimization

  • Connection pooling
  • Message batching
  • Efficient protocols
  • Bandwidth management

Security Considerations

Threat Model

  • Server compromise: No message access
  • Network interception: Encrypted traffic
  • Device compromise: Local encryption
  • Key compromise: Perfect forward secrecy

Security Measures

  • Regular security audits
  • Bug bounty program
  • Security updates
  • Incident response

Next Steps