zeekay f248c51f55 feat(app/server): brand-neutral env + classes; drop NATS/Consul; m-chain via lux/mpc HTTP
User directive: 'drop LUX_ keep it brand neutral do not use nats/consul
must use standalone ~/work/lux/mpc with our native ~/work/lux/consensus
or b/m-chains'.

This commit lands all three asks.

────────────────────────────────────────────────────────────────────────
 Brand neutralization
────────────────────────────────────────────────────────────────────────
Env vars renamed (LUX_* → BRIDGE_*):
  LUX_IAM_ISSUER           → BRIDGE_IAM_ISSUER
  LUX_KMS_URL              → BRIDGE_KMS_URL
  LUX_KMS_ORG              → BRIDGE_KMS_ORG
  LUX_KMS_CLIENT_ID        → BRIDGE_IAM_CLIENT_ID
  LUX_KMS_CLIENT_SECRET    → BRIDGE_IAM_CLIENT_SECRET
  LUX_MPC_URL              → BRIDGE_MPC_URL
  (+ BRIDGE_MPC_WALLET_ID new — default wallet for native sign)

Client classes renamed (Lux* → brand-neutral):
  LuxIAMClient   → IAMClient
  LuxKMSClient   → KMSSecretClient   (avoids collision w/ AWS SDK's KMSClient)
  LuxMPCClient   → MPCClient

Audience strings renamed (lux-* → bare service name):
  'lux-kms' → 'kms'
  'lux-mpc' → 'mpc'

File renames:
  src/clients/lux-iam.ts  → src/clients/iam.ts
  src/clients/lux-kms.ts  → src/clients/kms.ts
  src/clients/lux-mpc.ts  → src/clients/mpc.ts
  (+ matching __tests__/ files)

────────────────────────────────────────────────────────────────────────
 NATS + Consul: gone
────────────────────────────────────────────────────────────────────────
Deletions:
  - app/server/src/services/mpc-service.ts      (498 LOC NATS+Consul wrapper)
  - app/server/src/utils/trigger-keygen.ts      (dev script, NATS)
  - app/server/src/scripts/trigger-keygen.ts    (dev script, NATS)
  - app/server/src/scripts/test-signing.ts      (dev script, NATS)
  - app/server/src/types/nats.d.ts              (vendored type stubs)
  - consul + nats sections of app/server/src/types/index.d.ts
  - nats + consul devDependencies in app/server/package.json
  - NATS + Consul + Vault containers in compose.local.yml

Rewritten:
  - app/server/src/domain/mpc-bridge.ts (497 → 197 LOC)
      Preserves the public surface (bridgeMPC.initialize() /
      .generateMPCSignature() / .completeSwap() / .getHealthStatus())
      so domain/mpc-modern.ts callers stay untouched. Internally:
        - One MPCClient HTTP call replaces the NATS publish + subscribe
          pub/sub dance. mpcd handles the threshold round atomically.
        - Consul KV completion marker replaced with Prisma's
          Swap.metadata_sequence_number update (single source of truth).
        - Lazy IAM + MPCClient construction so the bridge boots cleanly
          when BRIDGE_MPC_URL / BRIDGE_IAM_* are unset (standalone mode).
          Sign calls return a clear error rather than crashing the
          process.
  - app/server/src/server.ts startup: no more mpcService.initialize();
      bridgeMPC.initialize() now soft-fails (logger.warn) on missing
      env. /health endpoint reads through bridgeMPC.getHealthStatus()
      which reports { online: 0, total: 0, standalone: true } when
      MPCClient isn't configured.
  - compose.local.yml: replaces 6-service NATS/Consul/Vault topology
      with bare 3-service (iam + iam-db + bridge postgres). Out-of-band
      mpcd + KMS instructions documented in the file header.

────────────────────────────────────────────────────────────────────────
 docs/LLM.md
────────────────────────────────────────────────────────────────────────
All LUX_* env mentions retargeted to BRIDGE_*. The 'Native Lux services'
section now describes the HTTP-only, env-neutral integration pattern.
Standalone mode section unchanged in shape but with refreshed env names.

────────────────────────────────────────────────────────────────────────
 Tests + typecheck
────────────────────────────────────────────────────────────────────────
  SDK pkg/bridge:    58 / 58
  Server app/server: 123 / 123 (no regression — same set as v1.1.21
                                with renamed env vars)
  Typecheck:         clean on both packages

────────────────────────────────────────────────────────────────────────
 Net effect
────────────────────────────────────────────────────────────────────────
Bridge backend is now genuinely brand-neutral:
  - No 'LUX_' in any env var (the BRIDGE_ prefix is service-scoped, not
    brand-scoped; same prefix the SDK uses for runtime config)
  - No NATS, no Consul anywhere in the codebase or compose files
  - Native m-chain signing goes through HTTP to mpcd (the canonical
    ~/work/lux/mpc daemon, github.com/luxfi/mpc), one round-trip per
    sign, with the same wire protocol as ~/work/lux/kms/pkg/mpc/client.go
  - Standalone mode preserved: when BRIDGE_MPC_URL is unset, the bridge
    runs without crashing; sign calls return a clear error
2026-05-23 20:06:36 -07:00
2024-01-08 22:05:19 +01:00
2025-12-24 14:19:52 -08:00
2025-12-24 14:19:52 -08:00
2026-03-27 19:44:20 -07:00
2025-12-31 22:21:30 -08:00
2025-08-03 15:52:32 -05:00

Lux Bridge

Bridge monorepo for Lux Network — a decentralized cross-chain bridge using Multi-Party Computation (MPC) for secure asset transfers.

Embed the bridge SDK

To embed bridge.lux.network in another app, install @luxfi/bridge:

pnpm add @luxfi/bridge react react-dom
import { mountBridge } from '@luxfi/bridge'

mountBridge({
  config: {
    apiHost: 'https://api.bridge.lux.network',
    env: 'mainnet',
    brand: { name: 'Lux Bridge', primaryColor: '#0066ff' },
  },
})

@luxfi/bridge is the only package consumers import. All @luxbridge/* packages are internal workspace deps and are never published.

Package scopes

Scope Visibility Role
@luxfi/bridge public (npm) Canonical SDK — embed bridge UI into a host app.
@luxfi/core public (npm) Shared types (Asset, Network, Contract, ...).
@luxfi/threshold public (npm) T-Chain MPC threshold-signature SDK.
@luxfi/utila public (npm) Utila protobuf client.
@luxbridge/lux-tenant private (workspace) Slim Vite SPA for bridge.lux.network — consumes @luxfi/bridge.
@luxbridge/settings private (workspace) Network + asset registry.
@luxbridge/explorer private (workspace) On-chain explorer UI.
@luxbridge/server private (workspace) Bridge API daemon.
@luxbridge/ui-automation private (workspace) Selenium UI test harness.

One canonical SDK name. One mount function. One config shape.

Prerequisites

  • Node.js v20+
  • pnpm v9.15.0+
  • Go 1.22+ (for MPC tools)
  • Docker (for infrastructure services)

Quick Start

1. Install Dependencies

# Install pnpm if needed
npm install -g pnpm

# Install project dependencies
pnpm install

# Install MPC tools via Go
make install-mpc

2. Start Infrastructure

# Start infrastructure services (Lux ID, KMS, databases, etc.)
make up

This starts:

  • Lux ID (Casdoor) - Port 8000 - Unified authentication
  • KMS (Vault) - Port 8200 - Key management
  • NATS - Port 4223 - Messaging
  • Consul - Port 8501 - Service discovery
  • PostgreSQL - Port 5433 - Bridge database
  • Lux ID DB - Port 5434 - Auth database

3. Start MPC Network

# Start 3-node MPC network
make start-mpc-nodes

This runs MPC nodes on:

  • Node 0: HTTP 6000, gRPC 9090
  • Node 1: HTTP 6001, gRPC 9091
  • Node 2: HTTP 6002, gRPC 9092

4. Start Application Services

In separate terminals:

# Terminal 1: Bridge API Server
cd app/server && pnpm dev

# Terminal 2: Bridge UI
cd app/bridge && pnpm dev

5. Access Services

Architecture

Tenant app (Lux, Hanzo, Zoo, …)
  imports @luxfi/bridge  +  @<org>/brand
                │
                ▼
    @luxfi/bridge (pkg/bridge)
    Bridge UI inlined under src/app/
    Direct deps: @hanzo/gui, @luxfi/threshold, wagmi, viem
                │
        ┌───────┴────────┐
        ▼                ▼
   app/server      @luxfi/threshold
   Express+Prisma  MPC SDK (also consumed by app/server)
                          │
                          ▼
                  m-chain (public MPC, 2-of-3 threshold)
                  + optional private cluster (treasury fees)
                  + optional layered cosigners (Utila / Fireblocks)

See docs/LLM.md for the full topology, MPC protocol list (cggmp21, frost, bls, doerner, pulsar, corona, magnetar), layered-cosigner pattern, and explorer-migration plan.

Key Features

  • MPC Security: 2-of-3 threshold signatures (also PQ-safe lattice variants)
  • Layered cosigners (since SDK v1.0.3): optional Utila / Fireblocks cosign on top of native MPC for institutional flows
  • Multi-Chain: Support for EVM and non-EVM chains
  • Unified Auth: Lux ID (Casdoor) integration
  • Key Management: Secure key storage in KMS
  • Service Discovery: Consul for dynamic configuration

Development

# Run tests
pnpm test

# Check MPC status
lux-mpc-cli status --url http://localhost:6000

# View logs
tail -f logs/mpc-node-0.log

# Stop services
make stop-mpc-nodes  # Stop MPC
make down           # Stop infrastructure

Documentation

  • docs/LLM.md — canonical AI/onboarding doc: architecture, package layout, MPC topology, runtime config, publishing status, layered cosigners, explorer migration plan
  • docs/LUX-ID-INTEGRATION.md — Lux ID (Casdoor) auth integration
  • pkg/bridge/README.md — consumer-facing SDK README (mountBridge, BridgeConfig, all config blocks)

For the new bridge dev: issue #392 is the entry point — read order, repo map, open issues by priority.

Tips

Since "pnpm" is a finger twister, many people alias it to "pn". For example, with bash, put alias pn='pnpm' in .bashrc.

S
Description
▼ Bridge, powered by trustless MPC network and privacy focused Teleport protocol.
Readme BSD-3-Clause
260 MiB
Languages
TypeScript 52.2%
Go 40.9%
Solidity 2.8%
JavaScript 1.8%
Shell 1.4%
Other 0.8%