Vector Messenger

repository·master·Indexed 42 days ago

https://github.com/vectorprivacy/vector

A free, open-source, and highly private messenger using decentralized protocols like Nostr and Concord for end-to-end encrypted messaging and communities. It provides a low-level headless engine via vector-core (v0.1) for custom clients and a high-level vector-sdk (v0.3) for building bots with features like slash commands, community moderation, and Tor routing.

Tokens
65.3K
Snippets
217
Records
313
Agent score
53%

What's inside Vector

  1. Vector Core feature overview

    master

    vector-core is the headless engine for Vector, providing the following protocol logic:

    • NIP-17 gift-wrapped DMs: Support for sending, replying, editing, deleting, reactions (including NIP-30 custom emojis), typing indicators, and read states.
    • Communities (Concord): An end-to-end-encrypted Discord-style protocol over Nostr featuring epoch-keyed channels, roles, capabilities, invites, and bans/kicks with read-cut rekeys.
    • Encrypted files: NIP-96 / Blossom uploads with progress tracking, retries, and server failover. Uses AES-GCM at rest and hash-based deduplication. Also supports unencrypted public-image uploads for avatars/banners.
    • Profiles: Fetching, updating, status management, blocking, local nicknames, and a prioritized background sync queue.
    • Storage & Crypto: Per-account SQLite storage with atomic migrations, a GuardedKey vault for secrets, Argon2id, AES-GCM, ChaCha20, and SIMD-accelerated hex operations.
    • Resilience: NIP-77 negentropy sync and an event-driven relay health monitor for automatic reconnection and data recovery.
  2. License information for Vector

    master
    Vector is released under the MIT License. You are free to use, copy, modify, merge, publish, distribute, sublicense, and build upon the project for any purpose, commercial or personal, provided that the original license notice is included. The project is provided 'as-is', without warranty of any kind.
  3. Developer features in Vector

    master

    Vector provides several interfaces for developers to extend its functionality:

    • Vector SDK: A Rust-based SDK for building bots with minimal protocol knowledge.
    • Slash Commands: Support for shipping real commands with typed parameters via a Discord-style picker.
    • Mini Apps: Ability to run interactive multiplayer apps and games directly inside encrypted chats.
    • AI Agent Support: An MCP (Model Context Protocol) server that provides 21 tools for programmatic interaction with Vector.
  4. What is a Mini App and how is it structured?

    master

    Mini Apps are small, isolated web applications that run within Vector chats based on the WebXDC specification. A Mini App is distributed as a .xdc file, which is a ZIP archive containing your web assets.

    Required and Optional Files

    • index.html: The main entry point (Required).
    • manifest.toml: Metadata about the app (Optional).
    • icon.png: App icon (Optional).
    • style.css: Styles (Optional).
    • app.js: JavaScript logic (Optional).
    my-app.xdc/
    ├── index.html      # Required: Main entry point
    ├── manifest.toml   # Optional: App metadata
    ├── icon.png        # Optional: App icon
    ├── style.css       # Optional: Styles
    └── app.js          # Optional: JavaScript
  5. What is the Concord protocol?

    master

    Concord is the end-to-end encrypted protocol powering Vector's Communities. It provides a Discord-style group chat experience without a central server. Instead of a company-controlled database, Concord uses a decentralized model where authority and membership are managed through cryptography.

    Key characteristics:

    • No Central Server: There is no single computer or company that holds your messages or controls access.
    • Key-Based Membership: Being a member of a community or channel is defined by possessing the corresponding cryptographic key. If you can decrypt the room, you are in it.
    • Decentralized Authority: Moderation (owners, admins, kicks, bans) is managed via a signed roster that members can independently verify using math, rather than relying on a central authority's permission.
    • End-to-End Encryption: Messages are encrypted such that the relays passing them cannot read them.
  6. How WebXDC Realtime Peer Channels work

    master

    WebXDC Realtime Peer Channels enable P2P communication between WebXDC (Mini App) instances using the Iroh gossip protocol. Peer discovery is coordinated via Nostr events.

    When a WebXDC app calls joinRealtimeChannel(), the client follows these steps:

    1. Generates or retrieves the Iroh topic ID for that app instance.
    2. Broadcasts a peer advertisement event to chat participants.
    3. Connects to other peers via Iroh P2P.

    This implementation is designed for compatibility with DeltaChat's WebXDC realtime channels, sharing the same Iroh gossip protocol, message format (Uint8Array with sequence number and public key suffix), and 128KB message size limit.

  7. Manage identities and sessions in Vector Core

    master

    vector-core uses process-global state, meaning only one account is active per process at a time.

    To manage multiple identities, you can either:

    1. Run multiple processes.
    2. Use core.swap_session() to switch the active account in place.

    Warning: Since swaps can happen at any await point, any account-scoped work must be protected using a SessionGuard to ensure the identity does not change mid-operation.

  8. Managing Communities and Members

    master

    When a message originates from a community, you can access the sender as a member to perform moderation tasks.

    Member Moderation

    If msg.member() returns Some(member), you can use:

    • member.kick().await? / member.ban().await? / member.unban().await?
    • member.grant_admin().await? / member.revoke_admin().await?
    • member.is_admin() to check status.

    Community Management

    You can manage communities directly via the bot or an incoming message:

    • bot.community(community_id) or msg.community()
    • community.invite("npub1...").await?
    • community.create_invite().await? (returns an invite link)
    • community.members().await (iterates through members)

    Joining Communities (Auto-accept)

    Configure how your bot handles community invites during the build process:

    • Accept from anyone: .public()
    • Whitelist only: .whitelist(["npub1owner..."])
    if let Some(member) = msg.member() {
        member.kick().await?;
        member.grant_admin().await?;
        if member.is_admin() { /* ... */ }
    }
    
    // Or manage a community directly:
    let community = bot.community(community_id);
    community.invite("npub1...").await?;
    let link = community.create_invite().await?;
    for m in community.members().await { /* ... */ }
  9. How the Vector memory-hardened vault works

    master

    Vector uses a specialized vault architecture to protect private keys from automated extraction, forensic imaging, and reverse engineering. Instead of storing keys as contiguous values, the vault employs several layers of obfuscation:

    1. Secret Splitting: Each key is XOR-split into 4 random shares.
    2. Scattered Storage: These shares are stored as individual usize values across 128 static arrays.
    3. Decoy Arrays: Only a few arrays contain real data; the remaining arrays are indistinguishable decoys filled with identical random values.
    4. ASLR-Derived Positioning: Share positions are derived from ASLR (Address Space Layout Randomization) addresses that change every launch, ensuring no two positions collide.
    5. Dynamic Derivation: All derivation logic uses zero compile-time constants; multipliers and iteration counts are computed from runtime ASLR addresses.

    Key Properties

    • Zero heap allocations: No pointers or allocation metadata are used, preventing structural fingerprints.
    • Zero searchable constants: No magic numbers exist in the binary for reverse engineers to find.
    • Indistinguishable arrays: All 128 arrays share identical size, content distribution, initialization timing, and modification patterns.
    • Snapshot-diff resistance: During storage, all 128 arrays receive random writes to make real writes invisible to memory diffing tools.
    • Multi-key isolation: Multiple keys (e.g., signing vs. encryption) share the same vault arrays without corrupting each other, as decoy writes exclude positions belonging to other active keys.
    • Zero side-channel: Key retrieval uses only atomic reads (no memory writes).
    • Computational hardening: Thousands of mixing iterations are used per derivation to make brute-force attacks expensive.
  10. How Concord communities and channels are structured

    master

    A Concord Community is a top-level space (similar to a Discord server) composed of several Channels (similar to #general or #announcements).

    The Core Components

    • People: Identified by their personal keypairs (Nostr npub). This identity is used to sign all actions for verification.
    • Community: Anchored by a master community key and an owner. The owner is proven via an owner attestation (a signed certificate).
    • Channels: Individual rooms within a community. Each channel has its own unique channel key, ensuring that conversations in one room are cryptographically separate from others.
    • Relays: Public, interchangeable Nostr relays that act as "dumb mailboxes." They store and forward encrypted blobs but cannot read the content or identify specific users within a community.
    • Roster: A signed list that records the roles (Owner, Admin, Member) of participants, allowing members to verify authority locally.
  11. Version format and Semver requirements

    master

    Vector uses a specific Semver-based versioning scheme to manage transitions from preview to official releases. The version is defined in src-tauri/Cargo.toml and must be synchronized across other configuration files.

    Versioning Rules

    • Official Release: Uses standard Semver (e.g., 0.4.2).
    • Preview Releases: Uses a hyphen followed by a plain number between 1 and 98 (e.g., 0.4.2-1, 0.4.2-2).

    CRITICAL: The preview identifier must be a plain number (1-98). Do not use rc1, beta.1, or any other non-numeric strings. Using non-numeric identifiers will cause the Tauri MSI bundler to fail the Windows build and cause the Android build script to fail.

    # src-tauri/Cargo.toml
    version = "0.4.2-1"   # first public preview
    version = "0.4.2-2"   # second preview
    version = "0.4.2"     # official release
  12. Understanding Update Channels (Stable vs Preview)

    master

    Vector uses two primary update channels. The preview channel acts as a permanent pointer to the newest build of either channel, ensuring preview users are automatically offered the official release when it becomes available.

    | Feature | Stable Build | Preview Build | | :--- | :--- | :| | Version Example | 0.4.2 | 0.4.2-1 | | Updater Endpoint | releases/latest/download/latest.json | releases/download/preview/latest.json | | Beta Opt-in | Available via Settings > Updates | Always active | | Stable Updates | Yes | Yes (via pointer) |

    Note: Once a preview user installs an official stable release, they transition to the stable endpoint automatically without needing a manual reinstall.