← Back to Docs

Advanced E2EE Security

Mana implements a high-fidelity end-to-end encryption model inspired by the Signal Protocol. It isn't just about encrypting payloads; it's about managing a self-healing, multi-device trust environment.

1. X3DH Handshake

The Extended Triple Diffie-Hellman (X3DH) protocol is used to establish a shared secret between two users who might not be online at the same time. Mana handles the pre-key publishing and bundle fetching automatically.

2. Double Ratchet

Once a session is established, every single message is encrypted using a unique, rotating key derived from the Double Ratchet algorithm. This ensures:

3. Multi-Device Fanout

Mana's signaling hub is device-aware. When you send an encrypted message, the framework automatically fans it out to all of the recipient's linked devices, ensuring a seamless cross-platform experience.

e2ee_config.go
package main

import "github.com/Aswanidev-vs/mana/core"

func main() {
    cfg := core.DefaultConfig()
    
    // 🛡️ Enable the security suite
    cfg.EnableE2EE = true
    
    // Optional: High-security session expiry
    cfg.E2EESessionTimeout = 30 * 24 * time.Hour
    
    app := mana.New(cfg)
    
    // Mana now handles:
    // - Pre-key storage in SQL
    // - Handshake signaling
    // - Automatic decryption retries
    
    app.Start()
}

Note: Mana's E2EE implementation uses the e2ee package for state management and the storage package for persistent key bundles.