Skip to content

Turbin3/enmarch

Repository files navigation

Enmarch

Private messaging with local encryption, on-chain X-Wing identity, and ZK-verified registry-root and message-root updates.

What Is Live Today

  • Wallet-authenticated web and Android chat clients
  • Invite-based encrypted conversations
  • X-Wing public key registration on Solana
  • Redis-backed realtime relay and message sync
  • Backend-generated proofs for registry-root and message-root updates
  • Configurable MagicBlock Private Ephemeral Rollup (PER) submission path with direct Solana fallback
  • Solana-settled root updates

Current Architecture

Client

  • Solana wallet auth
  • local X25519 and X-Wing messaging identity
  • invite creation and import
  • local encryption and decryption
  • on-chain X-Wing registry integration
  • React + Vite web client
  • Android Expo client with Mobile Wallet Adapter

Backend

  • challenge/verify auth flow
  • WebSocket relay
  • Redis message storage with TTL
  • offline sync
  • commitment tracking
  • native proof generation
  • automatic registry-root and message-root submission
  • configurable PER delegation, commit, and undelegation flow
  • direct Solana submission fallback

Solana

  • main Enmarch program
  • verifier program
  • registry-root and message-root state PDAs
  • append-only X-Wing registry PDA
  • PER permission and delegation instructions

ZK

  • Noir circuit for valid Merkle-tree append transitions
  • native proof generation through Sunspot
  • verifier-gated root updates

What Is Not Fully Productized Yet

  • durable conversation and message metadata database
  • backend-owned inbox and history model
  • long-term replacement for message-root and registry-root bootstrap leaves in env
  • production-ready X-Wing registry account design

Repo Layout

.
├── backend/                  # Bun relay, sync API, on-chain submit path
├── frontend/                 # React + Vite messaging app
├── mobile/                   # Android Expo client with MWA wallet auth
├── packages/
│   ├── circuit/              # Noir circuit + proving artifacts
│   ├── core/                 # Shared messaging protocol helpers
│   ├── encryption/           # X-Wing + symmetric encryption helpers
│   ├── merkle-tree/          # Poseidon tree and witness helpers
│   ├── onchain-client/       # Generated and low-level on-chain helpers
│   └── solana-client/        # App-facing Solana client helpers
├── program/
│   └── enmarch_program/      # Pinocchio Solana program
└── setup.sh                  # local dev bootstrap script

Prerequisites

  • Bun
  • Docker + Docker Compose
  • Solana CLI if you want to inspect or deploy program state
  • Go toolchain if you want to run the native prover locally

Local Development

  1. Copy the root env file.
cp .env.example .env

If you plan to use setup.sh, set a non-empty REDIS_PASSWORD in .env first because the script enforces it.

  1. Install dependencies.
bun install
cd frontend && bun install
  1. Start Redis.
docker compose up -d redis
  1. Start the backend.
bun run backend:dev
  1. Start the frontend in another terminal.
cd frontend
bun dev

Backend: http://localhost:3001
Frontend: http://localhost:5173

One-Command Startup

chmod +x ./setup.sh
./setup.sh

setup.sh installs deps, starts Redis, then runs frontend and backend together.

Important Environment Values

At the repo root:

  • SOLANA_RPC_URL
  • SOLANA_KEYPAIR_PATH
  • MESSAGE_ROOT_BOOTSTRAP_LEAVES_HEX
  • REGISTRY_ROOT_BOOTSTRAP_LEAVES_HEX
  • SUNSPOT_GO_DIR
  • REDIS_HOST
  • REDIS_PORT
  • JWT_SECRET

Optional MagicBlock PER path:

  • MAGICBLOCK_ENABLED
  • MAGICBLOCK_RPC_URL
  • MAGICBLOCK_VALIDATOR_ADDRESS
  • MAGICBLOCK_MESSAGE_*
  • MAGICBLOCK_REGISTRY_*
  • MAGICBLOCK_COMMIT_THRESHOLD
  • MAGICBLOCK_COMMIT_INTERVAL_MS

In frontend/.env.local if needed:

  • VITE_API_BASE_URL
  • VITE_SOLANA_RPC_URL

In mobile/.env if needed:

  • EXPO_PUBLIC_API_BASE_URL
  • EXPO_PUBLIC_SOLANA_RPC_URL
  • EXPO_PUBLIC_MWA_CHAIN
  • EXPO_PUBLIC_APP_NAME
  • EXPO_PUBLIC_APP_URI
  • EXPO_PUBLIC_APP_ICON_URI
  • EXPO_PUBLIC_EXPO_PROJECT_ID

Notes On State

  • Message payloads are still ephemeral and Redis-backed
  • Conversation metadata is still partly client-side
  • MESSAGE_ROOT_BOOTSTRAP_LEAVES_HEX and REGISTRY_ROOT_BOOTSTRAP_LEAVES_HEX currently bridge pre-existing on-chain tree history until the backend owns durable tree state
  • Root updates use MagicBlock PER when enabled and fully configured. The backend falls back to direct Solana submission otherwise.

Validation

bun run typecheck
bun run backend:test
cd frontend && bun run lint && bun run build

Mobile-specific build and device instructions live in mobile/README.md.

Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors