SOURCE_URL: https://majikah.solutions/products/majik-message/docs/wiki-hybrid-encryption --- title: "Hybrid Encryption" id: "wiki-hybrid-encryption" group: "majik-message" type: "products" version: "1.1.0" lastUpdated: "2026-02-19T00:00:00.000Z" difficulty: "Beginner" time: "4-5 minutes" tags: [hybrid-encryption, ml-kem, x25519, aes-256-gcm, post-quantum, defense-in-depth, cryptography, key-encapsulation] --- # Hybrid Encryption > How Majik Message layers ML-KEM-768, X25519, and AES-256-GCM together for defense-in-depth security against both classical and quantum threats ## Overview Majik Message does not rely on a single cryptographic algorithm. Instead, it uses a hybrid approach that layers multiple algorithms — each defending against a different class of threat. This design means that even if one algorithm were somehow weakened in the future, the others continue to protect your messages. ### What is Hybrid Encryption? Hybrid encryption combines asymmetric (public-key) and symmetric encryption. Asymmetric encryption is powerful but slow, so it is used only to securely deliver a symmetric key. Symmetric encryption is fast and efficient, so it is used to encrypt the actual message content. In Majik Message's case, the hybrid stack adds a third layer: a classical asymmetric algorithm (X25519) runs alongside the post-quantum asymmetric algorithm (ML-KEM-768), so the system is secure against both present-day classical computers and future quantum computers simultaneously. ### The Three Layers of Majik Message Encryption Layer 1 — ML-KEM-768 (Post-Quantum Key Encapsulation): Uses the recipient's 1,184-byte ML-KEM public key to generate a shared secret. Produces a 1,088-byte ciphertext that only the recipient's private key can open. Resistant to quantum computers. Layer 2 — X25519 (Classical Identity): The Curve25519 elliptic curve algorithm provides classical security and is used for identity (fingerprinting) and account derivation. It acts as a defense-in-depth fallback and has been the gold standard for key agreement in modern secure messaging for over a decade. Layer 3 — AES-256-GCM (Symmetric Message Encryption): The actual message content is encrypted with a 256-bit AES key derived from the ML-KEM shared secret, using GCM mode for authenticated encryption. This is the fastest and most widely vetted symmetric cipher in existence. ### How It All Works Together: The Encryption Flow When you send a message, Majik Message executes this sequence: (1) ML-KEM-768 encapsulation runs against the recipient's public key, producing a 32-byte shared secret and a 1,088-byte ciphertext. (2) The 32-byte shared secret becomes the AES-256-GCM key. (3) A random 12-byte IV is generated. (4) AES-256-GCM encrypts your message using the shared secret as the key and the random IV, producing an encrypted ciphertext and a 16-byte authentication tag. (5) The ML-KEM ciphertext, the AES IV, and the AES ciphertext are all packaged together into an MJKB binary envelope. (6) That envelope is what gets stored in Redis, Supabase, or serialized into a scanner string — the relay never sees any of the underlying keys or plaintext. ### Group Messages: One Message, Many Recipients For group messages (2 or more recipients), Majik Message is efficient: the message is only AES-encrypted once. A random 32-byte AES key encrypts the message. Then for each recipient, ML-KEM-768 encapsulation produces a unique shared secret. The group AES key is XOR'd with each recipient's unique shared secret, creating an individually encrypted key slot. Each recipient's slot is included in the MJKB envelope. To decrypt, a recipient uses their private key to recover their ML-KEM shared secret, un-XORs it to retrieve the group AES key, then decrypts the message. Recipients cannot recover each other's key slots or shared secrets. > **NOTE:** Defense-in-Depth: By combining ML-KEM-768 and X25519, Majik Message is secure under two independent mathematical assumptions. If a major breakthrough somehow weakened ML-KEM lattice problems (which has never happened and is not currently anticipated), X25519 would still provide classical security. If quantum computers eventually break X25519 (the known future threat), ML-KEM-768 continues to protect the message. Both would need to fail simultaneously for the encryption to be compromised.