A comprehensive IPFS (InterPlanetary File System) Identity-based Ring Signatures sandbox environment with private network support, featuring a secure gateway architecture and cross-platform mobile application.
This project implements a complete IPFS private network with the following components:
- Express.js Gateway: Secure API gateway with exclusive IPFS access
- Private IPFS Network: 3-node storage network with shared swarm key
- Database: Prisma ORM with SQLite for users, files, and signatures
- Cryptography: Ring signatures implementation using node-forge
- Docker Orchestration: Containerized infrastructure with health monitoring
- React Native: Cross-platform mobile app (iOS/Android)
- Direct Gateway Mode: Real-time integration with the secured backend
- File Management: Document picker, image picker, and comprehensive file operations
- IPFS Integration: Complete CRUD operations with private IPFS network
- Modern UI: TypeScript-based with theme support and real-time status monitoring
- Docker Desktop installed and running
- Node.js 20+ (for development)
- Git
- React Native Environment (for mobile development)
- iOS: Xcode, CocoaPods
- Android: Android Studio, Android SDK
git clone <repository-url>
cd ipfs-sandbox
# Start entire IPFS system (backend + storage nodes)
./start-system.sh# In a new terminal
cd adjudicator
npm install # requires local Node.js 20+
npm run dev # serves on http://localhost:4000
# (Optional) generate fresh keypair
npm run generate:keysπ Export the printed keys to
adjudicator/.envvΓ cαΊ₯u hΓ¬nhADJUDICATOR_PUBLIC_KEY,ADJUDICATOR_SERVICE_URL,ADMIN_HMAC_SECRETtrongbackend/.env.
node scripts/seed-investigation-demo.jsStep 1: Get Your Machine's IP Address
# macOS/Linux
ifconfig | grep "inet " | grep -v "127.0.0.1"
# Output example: inet 192.168.1.69 netmask 0xffffff00
# Windows
ipconfig
# Look for IPv4 Address under your active network adapterStep 2: Update Mobile App Configuration
cd mobile/src/config/api.tsEdit line 17 and replace with your IP:
const HOST_MACHINE_IP = '192.168.1.69'; // π CHANGE THIS TO YOUR IPStep 3: Install Dependencies
cd mobile/
npm install
# For iOS (macOS only)
cd ios && pod install && cd ..Step 4: Run Mobile App
# Start Metro bundler (keep running)
npm start
# In another terminal - Run Android app
npm run android
# Or run iOS app (macOS only)
npm run ios# Check backend services
docker compose ps
# Test backend health
curl http://localhost:3000/health
# Test from your IP (replace with your IP)
curl http://192.168.1.69:3000/health# Test file upload
curl -X POST -F "[email protected]" http://localhost:3000/api/files/upload
# Test file download (replace HASH with returned hash)
curl http://localhost:3000/api/files/YOUR_HASHGET /health- System health check β WORKINGGET /api/users- User management endpoint β WORKINGPOST /api/files/upload- Upload files to IPFS (legacy) β WORKINGPOST /api/files/client-chunked-upload- Client-side chunked upload with zero-trust β NEWGET /api/files/:hash- Download files from IPFS β WORKINGGET /api/files/test-ipfs- Test IPFS connectivity β WORKINGGET /api/signatures- Ring signature operations β WORKING
New Endpoint Details:
POST /api/files/client-chunked-upload- Receives manifest with chunk CIDs and hashes
- Validates Schnorr + LSAG ownership proofs
- Stores metadata without accessing raw file data
- Backend never receives decryption keys
- See
TASK_B_C_IMPLEMENTATION_SUMMARY.mdfor payload schema
POST /api/validate-uploadβ Issues ValidationToken after policy checks (rate limit, ban list)POST /api/decrypt-escrowβ Decrypts escrowed identity + returns investigation reportGET /healthβ Service heartbeat (for docker/monitoring)
GET /admin/index.htmlβ Lightweight dashboard to trigger investigations and manage banned keysPOST /api/admin/investigateβ Backend proxy to adjudicator with optionalX-Admin-KeyPOST /api/admin/ban/DELETE /api/admin/ban/:publicKeyβ Manage entries inBannedUserPOST /api/admin/files/:fileId/flagβ Record admin flag events inAnonymousAuditLog
π See docs/adjudicator_runbook.md for full operations guide.
- IPFS API:
http://localhost:5001β WORKING (Gateway exclusive access) - IPFS Gateway:
http://localhost:8080β WORKING (Public gateway interface) - Storage Nodes: Internal-only (no external ports) β HEALTHY
- Gateway Exclusivity: Only the gateway container can access IPFS API
- Storage Node Isolation: Storage nodes operate without external API exposure
- Swarm Key Protection: All nodes use shared private network key (
c1df9ee7cb3c82fb83c6935ec7009ad7) - Network Segmentation: Docker internal network for inter-node communication
- Ring signature-based identity verification
- Private network access controls
- API endpoint protection
- File encryption at rest
- Pseudonymous registry that stores only display labels and public keys while private keys stay on-device
Architecture Overview: This system implements a true zero-trust architecture where the backend never has access to plaintext file data or decryption keys.
Upload Flow:
Mobile β Read File β Chunk (2MB) β Encrypt (AES-256-GCM) β Upload to IPFS β Send Manifest to Backend
-
Client-Side Processing (
ChunkEncryptionService.ts)- Files are read, chunked, and encrypted entirely on the mobile device
- Each chunk encrypted with unique AES-256-GCM key
- Master key and chunk keys generated on-device
- Direct upload to IPFS via gateway HTTP API (
/api/v0/add)
-
Backend Coordination (
/api/files/client-chunked-upload)- Receives only manifest (CIDs, hashes, encrypted keys)
- Verifies Schnorr ownership proofs
- Verifies LSAG ring signatures
- Stores metadata without accessing raw data
- Cannot decrypt files even if compromised
-
Key Management
- Master key and chunk keys stored locally in
KeyPackageStorage - Keys encrypted before storage
- Fingerprint verification prevents tampering
- Out-of-band key sharing for authorized users
- Master key and chunk keys stored locally in
Download Flow:
Mobile β Request Manifest β Load Keys β Download from IPFS β Decrypt β Verify β Reassemble
-
Chunk Download (
chunkDownloadManager.ts)- Downloads encrypted chunks from IPFS by CID
- Decrypts using keys from local storage
- Verifies SHA-256 integrity per chunk
- Reassembles file in memory
-
Integrity Verification
- Each chunk validated with SHA-256 hash
- Fail-fast on integrity mismatch
- Audit logging for anomalies
Security Benefits:
- β Backend never sees plaintext data
- β Backend never has decryption keys
- β End-to-end encryption from client to IPFS
- β Anonymous access via public key hashing
- β Cryptographic ownership proofs (Schnorr + LSAG)
- β Tamper-evident with hash verification
Implementation Status:
- β Task A: Client-side chunking & encryption (COMPLETED)
- β Task B: Backend manifest endpoint (COMPLETED)
- β Task C: Real IPFS download & reassembly (COMPLETED)
- β³ Task D: Integration tests & documentation (IN PROGRESS)
See TASK_A_IMPLEMENTATION_SUMMARY.md and TASK_B_C_IMPLEMENTATION_SUMMARY.md for technical details.
- One-time initialization screen prompts the user for a display name and generates a Schnorr key pair locally
- Registration sends only the display name and public key to the gateway; the private key never leaves the device
- Identity metadata is cached securely with support for restoring server-issued identifiers on subsequent launches
- Home screen file listings automatically filter by the active identity's public key so each user sees only their content
- Real IPFS Operations: Direct connection to the gateway at
localhost:3000 - Network Configurations:
- iOS Simulator:
localhost:3000 - Android Emulator:
10.0.2.2:3000 - Physical Device: Actual host IP (e.g.,
192.168.1.100:3000)
- iOS Simulator:
- Health Monitoring: Real-time connection status and error handling
- Progress Tracking: Live upload/download progress indicators
- π€ Upload: Single and multiple files with progress tracking
- π₯ Download: Retrieve files by IPFS hash with blob handling
- π List: Display all uploaded files with metadata
- ποΈ Delete: Remove files from IPFS storage
- π Metadata: File size, type, upload time, and IPFS hash management
- Access Manager modal cho phΓ©p chα»§ sα» hα»―u grant/revoke nhanh chΓ³ng; UI hiα»n thα» banner "BαΊ‘n vα»«a Δược cαΊ₯p quyα»n" / "Quyα»n truy cαΊp ΔΓ£ bα» thu hα»i" ngay sau khi backend xΓ‘c nhαΊn.
- Revocation manifest hai pha: Backend phΓ‘t
/api/files/revocation/prepare, mobile tα»± xoay key bαΊ±ng key package cα»₯c bα», upload CID mα»i lΓͺn IPFS rα»i gα»i/api/files/revocation/finalize(khΓ΄ng cΓ²n re-encrypt trΓͺn server). - Recipient sync thΓ΄ng minh: danh sΓ‘ch
anonymous-listdΓΉngETag+Last-Modified, cache theosha256(publicKey), 304 β bαΊt chαΊΏ Δα» offline, tα»± Δα»ng αΊ©nstatus='revoked', xoΓ‘ key package vΓ ghi auditdelete_cache. - QA tooling: chαΊ‘y
node scripts/reset-anonymous-grants.js --yesΔα» reset AnonymousFileAccess + audit log cho demo/testing. - Schnorr + LSAG hardening: Backend kiα»m tra
sΒ·G == R + eΒ·Q, bΔm thΓ΄ng Δiα»p cΓ³ timestamp/nonce vΓ tα»« chα»i reuse proof β replay khΓ΄ng cΓ²n tΓ‘c dα»₯ng. - Quick revoke bα» khΓ³a mαΊ·c Δα»nh: API
revokeAccessByPublicKeyHashchα» hoαΊ‘t Δα»ng khi bαΊtENABLE_QUICK_REVOKE=truehoαΊ·c truyα»nadminOverride=true. MαΊ·c Δα»nh ngΖ°α»i dΓΉng phαΊ£i Δi qua luα»ng partial re-encryption mα»i.
- Create Signatures: Generate ring signatures for files
- Verify Signatures: Validate signature authenticity
- List Signatures: Display all signatures with verification status
cd backend/
# Install dependencies
npm install
# Development mode with auto-reload
npm run dev
# Database operations
npm run prisma:generate # Generate Prisma client
npm run prisma:migrate # Run migrations
npm run prisma:studio # Database GUIcd mobile/
# Install dependencies
npm install
cd ios && pod install && cd .. # iOS only
# Launch iOS app
npm run ios- Start Gateway:
docker compose up -d(from the repository root) - Launch App:
npm run ios/npm run android - Verify Connection: Check the connection status widget in the app
- Exercise Flows: Upload, download, and revoke through the live gateway
# Rebuild containers
docker compose build --no-cache
# View container status
docker compose ps
# View logs
docker compose logs -f
# Clean system
docker compose down
docker system prune -a- Node.js β₯ 20.19 required for Jest tests
@noble/hashesuses ESM-only modules- On Node 18, tests will fail with
Cannot find module '@noble/hashes/sha2' - Solution: Upgrade Node or add manual mocks
cd mobile/
# Run all tests
npm test
# Run specific test suites
npm test ChunkEncryptionService.test.ts # Client-side chunking tests
npm test chunkDownloadManager.test.ts # Download manager testsTest Coverage:
- β
ChunkEncryptionService.test.ts- 15+ test cases- Key generation, encryption/decryption, chunking
- Edge cases, security validation
- β
chunkDownloadManager.test.ts- Download flow tests- Real IPFS download with mocks
- Decryption, integrity verification, reassembly
- β³ Integration tests (Task D - pending)
# Create test file
echo "Hello IPFS Private Network!" > test.txt
# Upload to IPFS
curl -X POST -F "[email protected]" http://localhost:3000/api/files/upload
# Expected response:
{
"success": true,
"hash": "Qmek5MHc59XAf8JjCXiDwKNBx81QGnzxJ9k6jsTVEAC4te",
"name": "test.txt",
"size": 28,
"ipfsUrl": "http://localhost:8080/ipfs/Qmek5MHc59XAf8JjCXiDwKNBx81QGnzxJ9k6jsTVEAC4te",
"apiUrl": "http://localhost:5001/api/v0/cat?arg=Qmek5MHc59XAf8JjCXiDwKNBx81QGnzxJ9k6jsTVEAC4te"
}
# Download file
curl http://localhost:3000/api/files/Qmek5MHc59XAf8JjCXiDwKNBx81QGnzxJ9k6jsTVEAC4te
# Output: Hello IPFS Private Network!- Start Gateway:
docker compose up -d - Launch App:
npm run ios/npm run android - Upload Real Files: Provide metadata + Schnorr proofs to hit
/api/files/aot-upload - Download Files: Retrieve via in-app viewer or
downloadaction - Monitor Connection: Use the connection widget for health checks and diagnostics
# Check all containers
docker compose ps
# Expected: 4 containers running (gateway + 3 storage nodes)
# Test IPFS connectivity
curl http://localhost:3000/api/files/test-ipfs
# Expected: {"success":true,"ipfsVersion":{"Version":"0.24.0",...}}
# Check IPFS peers
docker exec ipfs-sandbox-gateway-1 ipfs swarm peers
# Expected: 0 (private network, no external peers)
# Verify private network
docker exec ipfs-sandbox-gateway-1 ipfs id
# Expected: Node ID and addresses listedipfs-sandbox/
βββ backend/ # Express.js gateway
β βββ src/
β β βββ routes/ # API endpoints
β β βββ services/ # IPFS service
β β βββ config/ # Database config
β βββ prisma/ # Database schema
β βββ start.sh # IPFS initialization
βββ mobile/ # React Native app
β βββ src/
β β βββ components/
β β β βββ common/ # Reusable UI components
β β β βββ file-manager/ # File management
β β β βββ ipfs/ # IPFS-specific components
β β βββ services/
β β β βββ GatewayApiService.ts # Real API communication
β β β βββ IPFSService.ts # Unified wrapper
β β βββ hooks/
β β β βββ useIPFS.ts # Main IPFS hook
β β βββ types/ # TypeScript definitions
β βββ AppWithIPFS.tsx # Main IPFS demo app
β βββ ios/ # iOS configuration
β βββ android/ # Android configuration
β βββ TEST_IPFS_CONNECTIVITY.md # Testing guide
βββ docker-compose.yml # Container orchestration
βββ swarm.key # Private network key
βββ CLAUDE.md # Development instructions
βββ README.md # This file
# Backend (.env or docker-compose.yml)
NODE_ENV=development
DATABASE_URL=file:/app/data/database.db
IPFS_PATH=/data/ipfs
LIBP2P_FORCE_PNET=1- Private Network: Enabled with swarm key fingerprint
c1df9ee7cb3c82fb83c6935ec7009ad7 - API Access: Gateway exclusive (localhost:5001)
- Storage Nodes: 3 internal nodes for redundancy
- Bootstrap: Disabled (private network only)
// Online mode configuration
const onlineConfig = {
gatewayUrl: 'http://localhost:3000',
timeout: 30000
};"IPFS Gateway: Disconnected" in Android App:
-
Get Your Machine's IP Address:
# macOS/Linux ifconfig | grep "inet " | grep -v "127.0.0.1" # Example output: inet 192.168.1.69 netmask 0xffffff00 # Windows ipconfig # Look for IPv4 Address under your active WiFi/Ethernet adapter
-
Update Mobile App Configuration:
# Edit this file: mobile/src/config/api.ts # Update line 17 with your IP: const HOST_MACHINE_IP = '192.168.1.69'; // π CHANGE THIS
-
Reload Mobile App:
- Android: Press
Rtwice in Metro console, orCtrl+M-> Reload - iOS:
Cmd+Rin simulator
- Android: Press
-
Verify Backend is Accessible:
# Test from your IP (replace with your actual IP) curl http://192.168.1.69:3000/health # Should return: {"status":"OK",...}
Common IP Configuration Issues:
- WiFi Changes: Your IP changes when switching networks
- VPN Active: VPN may change your network configuration
- Firewall: Ensure port 3000 is not blocked
- Network Type: Ensure both host and emulator are on same network
Get Your IP for Mobile Setup:
# macOS/Linux - Copy the IP from this command
ifconfig | grep "inet " | grep -v "127.0.0.1" | awk '{print $2}'
# Windows - Look for IPv4 Address
ipconfig | findstr "IPv4"Development Workflow:
# 1. Start backend
./start-system.sh
# 2. Get your IP and update mobile/src/config/api.ts
ifconfig | grep "inet " | grep -v "127.0.0.1"
# 3. Start mobile app
cd mobile && npm start
cd mobile && npm run android # In another terminalIPFS API not responding:
# Check container logs
docker logs ipfs-sandbox-gateway-1
# Restart gateway
docker compose restart gatewayFile upload fails:
# Verify IPFS connectivity
curl http://localhost:3000/api/files/test-ipfs
# Should return: {"success":true,"ipfsVersion":{"Version":"0.24.0",...}}Storage nodes disconnected:
# Check swarm peers (should be 0 for private network)
docker exec ipfs-sandbox-gateway-1 ipfs swarm peers
# Restart entire system
docker compose down && docker compose up -dConnection failures (Online Mode):
# iOS Simulator
curl http://localhost:3000/health
# Android Emulator
curl http://10.0.2.2:3000/health
# Physical Device (replace with actual IP)
curl http://192.168.1.100:3000/healthReact Native build issues:
# Reset Metro cache
npx react-native start --reset-cache
# Clean builds
cd ios && pod deintegrate && pod install && cd .. # iOS
cd android && ./gradlew clean && cd .. # Android
# Verify environment
npx react-native doctor# All containers
docker compose logs -f
# Specific service
docker logs ipfs-sandbox-gateway-1 -f
# Mobile app debugging
# Use React Native Debugger or browser dev tools- β 4/4 Docker containers running healthy
- β IPFS gateway operational (Kubo v0.24.0)
- β Private network established with swarm key
- β API endpoints responding correctly
- β File upload/download working
- β Database operations functional
- β Direct gateway integration (online mode)
- β Complete CRUD functionality
- β Real-time connection monitoring
- β File upload with progress tracking
- β Error handling and recovery
- β TypeScript type safety
- β Modern UI with theme support
- β Mobile-to-Gateway communication
- β File operations across platforms
- β Network error handling
- β Mode switching functionality
- β Progress indicators and status updates
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Test in both online and offline modes
- Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- CLAUDE.md - Claude Code development instructions
- Mobile README - Comprehensive mobile app documentation
- Mobile Testing Guide - Mobile connectivity testing
- QA Checklist β Anonymous Access - HΖ°α»ng dαΊ«n kiα»m thα» grant/revoke & cache
- Access Manager Demo Script - Kα»ch bαΊ£n trΓ¬nh diα» n vΓ²ng Δα»i cαΊ₯p quyα»n
- TASK_A_IMPLEMENTATION_SUMMARY.md - Client-side chunking & encryption
- TASK_B_C_IMPLEMENTATION_SUMMARY.md - Backend endpoint & download flow
- issue_plan.md - Implementation roadmap and progress tracking
- STATUS.md - Current system status and recent changes
- implement_next.md - Task D priorities and next steps
- IPFS Documentation - Official IPFS docs
- React Native Docs - React Native development
- Docker Compose - Container orchestration
- @noble/hashes - Cryptographic hashing library
- @noble/secp256k1 - Elliptic curve cryptography
Status: β Fully Functional - Complete system with CRUD operations, private IPFS network, zero-trust client-side chunking, and dual-mode mobile application ready for production use.
- β
Zero-Trust Client-Side Chunking implemented (Tasks A, B, C)
- Client-side file chunking and AES-256-GCM encryption
- Direct IPFS upload from mobile without backend intermediary
- Backend manifest endpoint with ownership proof verification
- Real IPFS download with decryption and file reassembly
- Backend never sees plaintext data or decryption keys
- β Complete mobile app integration with gateway
- β Dual-mode operation (Online/Offline) implemented
- β Mock layer for offline development
- β Real-time connection monitoring
- β Comprehensive error handling
- β Progress tracking and status indicators
- β Full CRUD operations tested and verified
- β Schnorr + LSAG ring signature verification
- β Anonymous access via public key hashing
- β³ Integration tests for upload β download flow
- β³ Update architecture diagrams
- β³ End-to-end smoke tests
- β³ Performance telemetry and optimization