Rust Patcher
Secure Decentralized Software Updates - Working work in progress
Implementation Flow
1. Add Dependency (Crates.io)
# Cargo.toml
[]
= "0.1"
2. Initialize Patcher
// main.rs
use Patcher;
async
3. Initialize Cryptographic Identity
Output:
New keys generated:
Trusted-Key = mw6iuq1iu7qd5gcz59qpjnu6tw9yn7pn4gxxkdbqwwwxfzyziuro
Shared-Secret = 8656fg8j6s43a4jndkzdysjuof588zezsn6s8sd6wwcpwf6b3r9y
4. Extend main with keys
// main.rs
use Patcher;
async
5. Publish Updates (Master Node)
# Increment version in Cargo.toml first
Creates signed package with:
- SHA-256 executable hash
- Version metadata (major.minor.patch)
- Ed25519 publisher signature
- PKARR DHT record
Network Architecture
Master Node Flow
sequenceDiagram
Master->>+PKARR: Publish signed package
Master->>+Iroh: Announce version topic
Master-->>Network: Propagate via DHT
Client Node Flow
sequenceDiagram
Client->>+PKARR: Check version records
PKARR-->>-Client: Return latest signed package
Client->>+Iroh: Discover peers via topic
Iroh-->>-Client: Return node list
Client->>Peer: Establish P2P connection
Peer-->>Client: Stream verified update
Client->>Self: Safe replace via self_replace
Key Processes
-
Version Propagation
- Master nodes sign packages with secret key
- PKARR DHT stores version records with TTL
- Iroh topic tracker maintains peer list per version
-
Update Verification
// Verification chain if pub_key.verify.is_ok && compute_hash == stored_hash && version > current_version
-
Self-Update Mechanism
- Hash and Signature verification after data download
- Temp file write with atomic replacement
- Execv syscall for instant reload
CLI Reference
Command | Function |
---|---|
init |
Generate cryptographic identity |
publish |
Create/distribute signed package |
Zero configuration needed for peer discovery - automatic via Iroh Topic Tracker