Two-Layer Encryption: How Z-Text Protects Your Messages
Most encrypted messengers rely on a single layer of encryption. Z-Text uses two independent encryption layers, each protecting against different threat vectors.
Most encrypted messengers rely on a single layer of encryption. Z-Text uses two independent encryption layers, each protecting against different threat vectors. This article explains how they work together to provide defense-in-depth for your messages.
Layer 1: Blockchain Shielding
The first layer of encryption comes from the BitcoinZ blockchain itself. Shielded transactions use zk-SNARKs (Zero-Knowledge Succinct Non-Interactive Arguments of Knowledge) to encrypt all transaction data.
When a Z-Text message is sent as a shielded transaction, the following are hidden from all network observers:
- The sender's address
- The recipient's address
- The transaction amount
- The memo field (where the message is stored)
Only the holder of the recipient's z-address viewing key can decrypt the memo field and read the message content. This protects against passive network surveillance and blockchain analysis.
Layer 2: Contact Key Encryption
The second layer adds end-to-end encryption on top of the blockchain shielding. During the handshake process, Z-Text establishes a shared secret key between two contacts using Elliptic Curve Diffie-Hellman (ECDH) key exchange.
Before any message is placed into the transaction memo, it is encrypted with this shared key. This means that even if someone obtains the z-address viewing key (through coercion, theft, or a future vulnerability), they still cannot read messages without the separately derived contact key.
The Handshake Key Exchange
The contact key is established through a trustless handshake protocol:
- Alice sends a handshake request to Bob's z-address, containing her ephemeral public key (encrypted in the memo of a shielded transaction)
- Bob accepts by sending his ephemeral public key back to Alice (also via shielded transaction)
- Both Alice and Bob independently derive the same shared secret using ECDH
- This shared secret becomes the symmetric encryption key for all future messages
The beauty of this approach is that even the key exchange is protected by Layer 1 shielding. An observer cannot see the public keys being exchanged or even that a handshake is occurring.
Why Two Layers Matter
Each layer protects against different attack scenarios:
- Layer 1 alone protects against network observers and blockchain analysts, but is vulnerable to viewing key compromise
- Layer 2 alone protects against viewing key compromise, but would be vulnerable if messages were sent in the clear on-chain
- Both layers together require an attacker to compromise two independent cryptographic systems simultaneously
This is the principle of defense-in-depth applied to messaging encryption. No single point of failure can expose your messages.
Cryptographic Primitives
Z-Text's encryption stack uses well-established cryptographic primitives:
- zk-SNARKs (Groth16) for Layer 1 shielded transactions
- ECDH over Curve25519 for key exchange
- ChaCha20-Poly1305 for Layer 2 symmetric encryption
- BLAKE2b for key derivation
All cryptographic operations are performed in the Rust core of the application, leveraging constant-time implementations to prevent timing side-channel attacks.
Practical Implications
For the user, the two-layer encryption is completely transparent. The app handles all key exchange and encryption automatically. Messages appear in a familiar chat interface with no indication of the sophisticated cryptography happening underneath.
The result is a level of message security that exceeds what any centralized messenger can offer -- not because the cryptography is more complex, but because the trust model is fundamentally different. There is no server to subpoena, no company to coerce, and no single key that unlocks everything.
Related Articles
The Blockchain Handshake: Trustless Key Exchange
Before two Z-Text users can exchange messages, they must complete a cryptographic handshake. This article explains how it works and why it matters for security.
Z-Text vs Signal vs Telegram: A Privacy Comparison
Not all privacy claims are equal. This article compares Z-Text's architecture with two popular alternatives: Signal and Telegram.