Skip to content

About

Zero-knowledge hybrid P2P messenger with E2E encryption, Noise Protocol, and P2P signaling

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

πŸ” Messenger Secure

Zero-knowledge hybrid P2P messenger with end-to-end encryption.

Repository: Viktor592/messenger-secure
Status: 🚧 Active Development
Latest Build: βœ… TypeScript 2150 LOC, 13 files


πŸ“‹ Project Overview

Messenger Secure is a cryptographically secure messaging application that prioritizes user privacy and data protection. It uses a hybrid architecture:

  • P2P Direct: When both users are online, messages are encrypted end-to-end via WebRTC
  • Relay: When users are offline, messages are stored encrypted on the server (7-day TTL)
  • Zero-Knowledge: Server never has access to plaintext messages or encryption keys

πŸ›‘οΈ Security Stack

Layer Technology
Transport TLS 1.3
E2E Encryption Noise Protocol (Curve25519, ChaCha20-Poly1305)
Key Exchange X3DH + Double Ratchet
Signing Ed25519
Hashing SHA256

πŸ—οΈ Project Status

βœ… Completed Phases

Phase Description Status Files
Round 1 Backend scaffolding βœ… Complete +21
Round 2 Mobile app scaffold βœ… Complete +23
Round 3 API integration βœ… Complete +12
Round 4 Backend implementation βœ… Complete TS fixes
Round 5 Local dev setup βœ… Complete +3

Total Backend Code: 2,150 lines of TypeScript across 13 files


πŸ“ Architecture

Backend Stack

  • Runtime: Node.js 20+
  • Framework: Express.js + TypeScript
  • Database: PostgreSQL 16
  • Cache: Redis 7
  • Crypto: tweetnacl + Node.js crypto
  • Real-time: Socket.io

Mobile Stack

  • Framework: React Native + Expo
  • Language: TypeScript
  • State: Zustand
  • Storage: SQLite + SecureStore
  • Networking: Socket.io client

Web Stack

  • Framework: React 18
  • Build: Vite
  • Styling: TailwindCSS
  • State: Zustand

πŸš€ Quick Start

Prerequisites

node --version  # v20+

Install & Build

git clone https://github.com/Viktor592/messenger-secure.git
cd messenger-secure

# Verify compilation
bash test-build.sh

Local Development

# Start databases (Docker)
docker-compose -f docker-compose.dev.yml up -d

# Initialize backend
cd backend
npm install
npm run build
npx prisma db push

# Start server
npm run dev
# Opens on http://localhost:3001

See LOCAL_SETUP.md for detailed instructions.


πŸ“‘ API

Authentication

POST /api/auth/register      β†’ SMS code sent
POST /api/auth/verify        β†’ JWT tokens
POST /api/auth/refresh       β†’ New access token
POST /api/auth/logout        β†’ Session terminated

Contacts

GET  /api/contacts/search        β†’ Find user
POST /api/contacts/add           β†’ Add contact
GET  /api/contacts/verify/:fp    β†’ Verify fingerprint
GET  /api/contacts/list          β†’ List contacts

Messages

GET  /api/messages/pending       β†’ Offline messages
POST /api/messages/relay         β†’ Store encrypted message
DELETE /api/messages/:id         β†’ Delete message
POST /api/messages/batch-delete  β†’ Bulk delete
GET  /api/messages/stats         β†’ Message statistics

Groups

POST /api/groups/create              β†’ Create group
GET  /api/groups/list                β†’ List groups
GET  /api/groups/:id                 β†’ Get group details
POST /api/groups/:id/add-member      β†’ Add member
POST /api/groups/:id/leave           β†’ Leave group
DELETE /api/groups/:id               β†’ Delete group

Full API docs: API.md


πŸ” Database Schema

User
β”œβ”€β”€ id (UUID)
β”œβ”€β”€ phoneHash (SHA256, unique)
β”œβ”€β”€ publicKey (Curve25519)
β”œβ”€β”€ identityKeyFingerprint (Ed25519)
└── displayName

Message (7-day TTL)
β”œβ”€β”€ id
β”œβ”€β”€ fromPhoneHash
β”œβ”€β”€ toPhoneHash
└── encryptedBlob (Noise Protocol)

Group
β”œβ”€β”€ id
β”œβ”€β”€ name
β”œβ”€β”€ creatorPhoneHash
└── GroupMember[]

Session, SmsCode, Prekey, Device, AuditLog

πŸ§ͺ Testing

Build Verification

bash test-build.sh
# βœ… TypeScript compiles
# βœ… 2150 LOC backend
# βœ… 13 source files

API Testing

# Health check
curl http://localhost:3001/health

# Register phone
curl -X POST http://localhost:3001/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{"phone": "+79991234567"}'

E2E Testing

See E2E_TESTING.md for full integration tests with two clients.


πŸ“š Documentation


🚒 Deployment

Docker (Recommended)

# Development
docker-compose -f docker-compose.dev.yml up

# Production
docker-compose -f docker-compose.prod.yml up -d

VPS Setup

See SETUP.md for:

  • Server provisioning (Ubuntu 22.04+)
  • SSL/TLS certificates (Let's Encrypt)
  • PostgreSQL backup strategy
  • Monitoring & alerting
  • Log aggregation

πŸ—ΊοΈ Roadmap

βœ… MVP (In Progress)

  • Backend API with encryption
  • Mobile client scaffold
  • Docker compose setup
  • E2E testing

🚧 Phase 2

  • WebRTC P2P implementation
  • Group messaging encryption
  • File sharing
  • Voice/video calls

⏳ Phase 3

  • Performance optimization
  • Offline message queue
  • End-to-end search
  • Device management

🀝 Contributing

  1. Fork: git clone https://github.com/Viktor592/messenger-secure.git
  2. Branch: git checkout -b feature/description
  3. Commit: git commit -m "feat: description"
  4. Push: git push origin feature/description
  5. PR: Submit pull request

Standards:

  • TypeScript strict mode
  • No untyped any
  • Meaningful commits
  • Updated docs

πŸ“ž Contact

Author: Viktor592
Email: viktor@motor-app.ru
GitHub: @Viktor592


πŸ“„ License

[Your License Here]


Status: βœ… Build Successful (2026-09-25)
Next Steps: Mobile integration + local E2E testing

About

Zero-knowledge hybrid P2P messenger with E2E encryption, Noise Protocol, and P2P signaling

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages