Skip to content

CodaCrew-Code-Labs/MetaMesh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MetaMesh

Rust License Build Status

A high-performance, cross-platform cryptographic identity management system with post-quantum security using Dilithium signatures, deterministic key generation, and mesh networking capabilities.

Features

  • Post-Quantum Cryptography - Dilithium2 signatures for quantum-resistant security
  • Hardware Entropy Collection - Physical sensors (accelerometer, microphone, timing jitter) for true randomness
  • Deterministic Key Generation - Reproducible keys from mnemonic phrases
  • Cross-Platform Daemon - gRPC service for all platforms including microcontrollers
  • Mesh Transport Layer - BLE, WiFi Direct, and LoRa support with automatic failover
  • Multi-Target Support - CLI, mobile, embedded, and node implementations
  • Human-Readable Mnemonics - Natural language seed phrases for key recovery

Architecture

metamesh/
β”œβ”€β”€ common/
β”‚   β”œβ”€β”€ crypto/          # Post-quantum cryptographic primitives
β”‚   β”œβ”€β”€ identity/        # Identity generation and recovery with hardware entropy
β”‚   β”œβ”€β”€ transport/       # Mesh networking (BLE, WiFi Direct, LoRa)
β”‚   β”œβ”€β”€ entropy/         # Hardware entropy collection
β”‚   └── utils/           # Shared utilities
β”œβ”€β”€ daemon/              # gRPC background service with transport listeners
β”œβ”€β”€ cli/                 # Command-line interface
β”œβ”€β”€ mobile/              # Mobile library (iOS/Android)
β”œβ”€β”€ embedded/            # Embedded systems library
β”œβ”€β”€ node/                # Network node implementation
└── scripts/             # Installation and deployment scripts

Quick Start

Prerequisites

  • Rust 1.70+ (Install Rust)
  • Protocol Buffers compiler (protoc)
# macOS
brew install protobuf

# Ubuntu/Debian
sudo apt install protobuf-compiler

# Windows
choco install protoc

Build from Source

git clone https://github.com/your-org/metamesh.git
cd metamesh
cargo build --release

Platform-Specific Setup

πŸ“± Android

# Install Android NDK and add targets
rustup target add aarch64-linux-android armv7-linux-androideabi

# Build for Android
cargo build --release --target aarch64-linux-android

# Run daemon (requires root or ADB)
adb push target/aarch64-linux-android/release/metamesh-daemon /data/local/tmp/
adb shell "/data/local/tmp/metamesh-daemon --port 50051 &"

# Run client
adb shell "/data/local/tmp/metamesh-client health"

🍎 iOS

# Add iOS targets
rustup target add aarch64-apple-ios x86_64-apple-ios

# Build for iOS (library only - no daemon)
cargo build --release --target aarch64-apple-ios -p metamesh-mobile

# Integration via Xcode project with FFI bindings
# See mobile/ directory for Swift integration examples

🐧 Linux

# Install dependencies
sudo apt update
sudo apt install build-essential protobuf-compiler libbluetooth-dev

# Build and run
cargo build --release
./target/release/metamesh-daemon --port 50051 &
./target/release/metamesh-client health

# Install as systemd service
sudo ./scripts/install-daemon.sh
sudo systemctl start metamesh-daemon

🍎 macOS

# Install dependencies
brew install protobuf

# Build and run
cargo build --release
./target/release/metamesh-daemon --port 50051 &
./target/release/metamesh-client health

# Install as LaunchAgent
./scripts/install-daemon-macos.sh
launchctl list | grep metamesh

πŸͺŸ Windows

# Install dependencies (PowerShell as Administrator)
choco install protoc rust-ms

# Build and run
cargo build --release
Start-Process "target\release\metamesh-daemon.exe" -ArgumentList "--port 50051"
.\target\release\metamesh-client.exe health

# Install as Windows Service
PowerShell -ExecutionPolicy Bypass -File scripts\install-daemon-windows.ps1
Get-Service -Name MetaMeshDaemon

πŸ₯§ Raspberry Pi

# Install Rust and dependencies
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
sudo apt install build-essential protobuf-compiler libbluetooth-dev

# Build (may take 30+ minutes)
cargo build --release

# Run with BLE permissions
sudo ./target/release/metamesh-daemon --port 50051 &
./target/release/metamesh-client health

# Auto-start on boot
sudo systemctl enable metamesh-daemon

πŸ”§ Arduino (ESP32/ESP8266)

# Install ESP toolchain
rustup target add xtensa-esp32-espidf

# Build embedded version (no_std)
cargo build --release --target xtensa-esp32-espidf -p metamesh-embedded

# Flash to ESP32 (requires esptool)
esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash 0x1000 target/xtensa-esp32-espidf/release/metamesh-embedded

# Monitor serial output
screen /dev/ttyUSB0 115200

πŸ€– ESP32 (Standalone)

# Install ESP-IDF and Rust ESP toolchain
rustup target add xtensa-esp32-espidf

# Configure for ESP32
export ESP_IDF_PATH=/path/to/esp-idf
export PATH="$PATH:$ESP_IDF_PATH/tools"

# Build and flash
cargo build --release --target xtensa-esp32-espidf -p metamesh-embedded
cargo espflash --target xtensa-esp32-espidf --port /dev/ttyUSB0

# Connect via serial for configuration
minicom -D /dev/ttyUSB0 -b 115200

πŸ”Œ Generic Embedded (ARM Cortex-M)

# Add ARM targets
rustup target add thumbv7em-none-eabihf thumbv6m-none-eabi

# Build for ARM Cortex-M4
cargo build --release --target thumbv7em-none-eabihf -p metamesh-embedded

# Flash using OpenOCD or similar
openocd -f interface/stlink.cfg -f target/stm32f4x.cfg -c "program target/thumbv7em-none-eabihf/release/metamesh-embedded verify reset exit"

Transport Layer

MetaMesh automatically detects and uses available transport mediums:

  • BLE (Bluetooth Low Energy) - Cross-platform mesh networking
  • WiFi Direct - High-bandwidth peer-to-peer (planned)
  • LoRa - Long-range, low-power communication (planned)

The daemon monitors transport availability and automatically switches between mediums:

πŸš€ MetaMesh Daemon Starting...
πŸ”΅ Checking BLE availability...
βœ… BLE: Listening on UUID 6ba7b810-9dad-11d1-80b4-00c04fd430c8
πŸ“‘ BLE: Starting advertising...
πŸ” BLE: Starting scanning for MetaMesh devices...
βœ… 1 transport medium available (BLE)
🌐 gRPC daemon listening on 0.0.0.0:50051
✨ MetaMesh daemon ready!

Usage

CLI Client

# Health check
./target/release/metamesh-client health

# Generate new identity
./target/release/metamesh-client create-address

# Recover from mnemonic
./target/release/metamesh-client recover-keys "The person named Alice lives in Boston, Mr Smith works at TechCorp, Bob walks down Main street"

# List all APIs
./target/release/metamesh-client list-apis

# Shutdown daemon
./target/release/metamesh-client shutdown

gRPC API

The daemon exposes the following gRPC services on port 50051:

Health Check

rpc Health(HealthRequest) returns (HealthResponse);

Create Address

rpc CreateAddress(CreateAddressRequest) returns (CreateAddressResponse);

Returns: seed_id, public_key, mnemonic

Recover Keys

rpc RecoverKeys(RecoverKeysRequest) returns (RecoverKeysResponse);

Input: mnemonic
Returns: seed_id, public_key, private_key

Address Management

rpc ListAddresses(ListAddressesRequest) returns (ListAddressesResponse);
rpc DeleteAddress(DeleteAddressRequest) returns (DeleteAddressResponse);
rpc DeleteAllAddresses(DeleteAllAddressesRequest) returns (DeleteAllAddressesResponse);

Transport

rpc PingCheck(PingCheckRequest) returns (PingCheckResponse);
rpc Deserialize(DeserializeRequest) returns (DeserializeResponse);
rpc PendingPackets(PendingPacketsRequest) returns (PendingPacketsResponse);

Shutdown

rpc Shutdown(ShutdownRequest) returns (ShutdownResponse);

Installation

System Service Installation

Linux (systemd)

chmod +x scripts/install-daemon.sh
sudo ./scripts/install-daemon.sh

# Control service
sudo systemctl start metamesh-daemon
sudo systemctl status metamesh-daemon
sudo systemctl stop metamesh-daemon

macOS (LaunchAgent)

chmod +x scripts/install-daemon-macos.sh
./scripts/install-daemon-macos.sh

# Control service
launchctl list | grep metamesh
launchctl unload ~/Library/LaunchAgents/com.metamesh.daemon.plist

Windows (Service)

# Run as Administrator
PowerShell -ExecutionPolicy Bypass -File scripts/install-daemon-windows.ps1

# Control service
Get-Service -Name MetaMeshDaemon
Stop-Service -Name MetaMeshDaemon
Start-Service -Name MetaMeshDaemon

Development

Project Structure

  • common/crypto - Core cryptographic operations using Dilithium2
  • common/identity - Identity generation with hardware entropy and human-readable mnemonics
  • common/transport - Mesh networking transport layer (BLE, WiFi Direct, LoRa)
  • common/entropy - Hardware entropy collection from physical sensors
  • common/utils - Base64 encoding, hashing, and utilities
  • daemon - gRPC server with Protocol Buffers and transport listeners
  • cli - Command-line interface for testing
  • mobile - FFI bindings for mobile platforms
  • embedded - Lightweight library for microcontrollers
  • node - Network node for distributed operations

Build Targets

# All components
cargo build --release

# Specific component
cargo build --release -p metamesh-daemon
cargo build --release -p metamesh-cli

# Mobile library
cargo build --release --target aarch64-apple-ios
cargo build --release --target armv7-linux-androideabi

# Embedded (no_std)
cargo build --release --target thumbv7em-none-eabihf

Testing

# Run all tests
cargo test

# Test specific component
cargo test -p metamesh-crypto
cargo test -p metamesh-identity

# Integration tests
cargo test --test integration

# Test coverage with tarpaulin
cargo tarpaulin -p metamesh-daemon --out Html --output-dir coverage

Protocol Buffer Development

# Regenerate protobuf code
cd daemon
cargo build

# View generated code
ls target/debug/build/metamesh-daemon-*/out/

Security

  • Post-Quantum Resistant - Uses NIST-standardized Dilithium2 signatures
  • Hardware Entropy - True randomness from physical sensors (accelerometer, microphone, timing jitter)
  • Deterministic Generation - Keys derived from BLAKE3 hash chains
  • No Key Storage - Keys regenerated from mnemonic phrases
  • Memory Safety - Written in Rust with zero-copy operations

Performance

  • Binary Protocol - gRPC with Protocol Buffers (50% faster than JSON)
  • Zero Allocations - Optimized for embedded systems
  • Concurrent Operations - Async/await with Tokio runtime
  • Cross-Platform - Single binary for all platforms
  • Hardware Entropy - Platform-specific sensor integration

Platform Support

Platform BLE WiFi Direct LoRa Hardware Entropy
Android βœ… πŸ”„ πŸ”„ βœ… (Accel, Mic, Light)
iOS βœ… ❌ πŸ”„ βœ… (Accel, Mic, Light)
macOS βœ… ❌ πŸ”„ βœ… (Timing, CPU temp)
Linux βœ… βœ… βœ… βœ… (Timing, CPU temp)
Windows βœ… βœ… πŸ”„ βœ… (Timing, CPU temp)
Pi βœ… βœ… βœ… βœ… (Timing, CPU temp)
ESP32 πŸ”„ ❌ βœ… βœ… (ADC, Timing, Temp)
Arduino πŸ”„ ❌ βœ… βœ… (ADC, Timing, Temp)

βœ… Implemented | πŸ”„ Planned | ❌ Not Supported

Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

Development Setup

# Install development dependencies
rustup component add rustfmt clippy

# Format code
cargo fmt

# Lint code
cargo clippy

# Check all targets
cargo check --all-targets

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support


Remaining Actions

Core Modules

common/crypto

  • Implement signature verification functions
  • Add key serialization/deserialization
  • Performance benchmarks for Dilithium operations
  • Memory-safe key handling

common/identity

  • Add identity validation functions
  • Implement identity backup/restore
  • Add identity metadata support
  • Mnemonic phrase validation

common/entropy

  • Complete platform-specific implementations:
    • Android JNI integration for sensors
    • iOS Core Motion framework integration
    • ESP32 ADC and temperature sensor APIs
    • Arduino hardware register access
  • Add entropy quality assessment
  • Implement entropy pooling and mixing
  • Add fallback entropy sources

common/transport

  • Complete BLE implementation:
    • GATT service and characteristic definitions
    • Packet fragmentation for large messages
    • Connection management and reconnection
    • Device discovery and pairing
  • Implement WiFi Direct transport
  • Implement LoRa transport
  • Add transport layer encryption
  • Implement mesh routing protocols
  • Add transport quality metrics

common/utils

  • Add configuration management
  • Implement logging framework
  • Add error handling utilities
  • Performance monitoring tools

Applications

daemon

  • Add transport packet handling
  • Implement mesh routing
  • Add peer discovery and management
  • Configuration file support
  • Metrics and monitoring endpoints
  • Add authentication for gRPC APIs

cli

  • Add mesh network commands
  • Implement peer management
  • Add transport status commands
  • Configuration management CLI
  • Add interactive mode

mobile

  • Complete iOS bindings
  • Complete Android bindings
  • Add mobile-specific transport optimizations
  • Background operation support
  • Push notification integration

embedded

  • Complete no_std implementation
  • Add embedded-specific transport drivers
  • Power management optimizations
  • Memory usage optimizations
  • Hardware abstraction layer

node

  • Implement distributed consensus
  • Add blockchain/ledger functionality
  • Implement smart contracts
  • Add token/payment systems
  • Network governance mechanisms

Infrastructure

Testing

  • Integration tests for transport layer
  • End-to-end mesh networking tests
  • Performance benchmarks
  • Security audit and penetration testing
  • Cross-platform compatibility tests

Documentation

  • API documentation
  • Architecture documentation
  • Deployment guides
  • Security best practices
  • Developer tutorials

Deployment

  • Docker containers
  • Kubernetes manifests
  • CI/CD pipelines
  • Release automation
  • Package managers (Homebrew, apt, etc.)

MetaMesh - Quantum-resistant identity management for the decentralized future.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published