# Messaging Layer

If the Identity Layer establishes who you are, the Messaging Layer defines how you communicate. Traditional email is a patchwork: plaintext origins, later bolted-on TLS, clunky MIME attachments, and endless spam countermeasures. It is interoperable, but brittle, surveilled, and inherently insecure. SolMail rethinks messaging as a wallet-native, end-to-end encrypted (E2EE), censorship-resistant protocol that integrates financial primitives, not ads or intermediaries.

#### Design Principles

1. Wallet as Inbox: Every Solana wallet can receive messages without requiring extra setup. Users may later opt into a full SolMail mailbox for enhanced UX, but the baseline is universal addressability.
2. E2EE by Default: Encryption is non-optional. Messages are encrypted client-side using ElGamal, attachments with AES-256, and signed with Ed25519. This prevents providers, relayers, or infrastructure nodes from inspecting contents.
3. On-Chain Metadata: Unlike Web2 email headers (easily forged), SolMail enforces cryptographic provenance. Sender, timestamp, and integrity checks are immutably anchored on-chain.
4. Programmability: A message isn’t just text. It may carry tokens, NFTs, invoices, or signed approvals — all verifiable and executable without leaving the inbox

<figure><img src="https://2152941121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYW47dyWBcpoC1VKQqOt3%2Fuploads%2FOpwPf433uWf9rltR8mvO%2Fmessaging_component_architecture_vertical.png?alt=media&#x26;token=a8e5f61c-9f18-44cf-aed1-46e2c8870769" alt=""><figcaption></figcaption></figure>

#### Message Format

Solmail uses a format inspired by RFC 5322/2045, with a modified structure for decentralized and encrypted messaging. The message layout is divided as follows, where all fields except the version are encrypted, stored in a decentralized network as hashes, and referenced in the Mail’s account buffer.

**Header**

Header Includes

* Version
* Encrypted recipient wallet info
* Identity proof (handle/domain, tagged as origin)

**Body**

* Encrypted payload (can be plain text, structured JSON, or command instructions).

**Attachments:**

* Contains hash mappings for attachments.
* Each hash points to a file stored in a chosen decentralized storage provider.

**Plugins:**

* Each plugin defines its own identifier keys.
* Plugin data is structured in JSON and consumed by compatible client-side plugins for rendering.

**Audit Trail:**

Every message is anchored on the Solana ledger, providing an immutable log while keeping message content private.

**Versioning Paradigm:**

Unlike semantic versioning, Solmail uses client-based mapping for the major version

* 1 = Web client
* 2 = Mobile client
* 3 = DApp client
* Minor and patch versions indicate iterations.

#### Inbox = Wallet (Email-as-a-Wallet)

The central innovation of SolMail is EaaW (Email-as-a-Wallet). In practice:

* A DAO treasurer sends a payroll message → attached token transfers execute with one tap inside the inbox.
* A freelancer receives an invoice → the recipient pays instantly via Solana Pay, directly from the message thread.
* A DAO circulates a governance proposal → members sign approvals or multi-sig requests within the same thread.

The inbox ceases to be a passive communication channel and becomes an active financial and organizational command center.

#### Attachments and Storage

Attachments are often the weakest link in email security. SolMail addresses this by:

* Distributed Storage: Files are uploaded to decentralized storage (e.g., Irys).
* Client-Side Encryption: Only recipients hold keys, ensuring no relay or node can leak sensitive files.
* Verifiable Integrity: Every attachment is hashed, signed, and logged on-chain, preventing tampering or “man-in-the-middle” substitution.

Thus, an attached contract or invoice is as tamper-proof as the blockchain itself.

#### Notifications and Real-Time Sync

Modern users expect more than just inbox refreshes. SolMail integrates:

* Wallet-Native Alerts: Notifications flow directly to Phantom, Solflare, or any Solana wallet.
* Push Infrastructure: Mobile apps receive encrypted push notifications without exposing message content.
* Battery-Aware Sync: Background updates minimize device resource usage — essential for Solana Mobile and future Seeker integrations.

\\
