HTP Protocol
The HookProbe Transport Protocol (HTP) is a lightweight, secure transport layer designed specifically for mesh communication with neural weight binding.
Overview
Property Value Port UDP 8144 Encryption ChaCha20-Poly1305 Key Binding Weight fingerprint NAT Traversal Heartbeat-based Message Types 9 core + 9 file ops
Why HTP?
vs QUIC
Feature QUIC HTP Message types 100+ 9 Complexity High Simple Auditability Difficult Easy Weight binding No Native HookProbe optimized No Yes
Design Goals
Simplicity - Easy to audit and implement
Security - Weight-bound session keys
NAT-friendly - Works behind CGNAT
Lightweight - Minimal overhead
Message Types
Core Messages
HELLO = 0x 01 # Edge → Validator: Initiate
CHALLENGE = 0x 02 # Validator → Edge: Challenge
ATTEST = 0x 03 # Edge → Validator: Attestation
ACCEPT = 0x 04 # Validator → Edge: Session accepted
REJECT = 0x 05 # Validator → Edge: Session rejected
DATA = 0x 10 # Bidirectional: Encrypted payload
HEARTBEAT = 0x 20 # Bidirectional: NAT keep-alive
ACK = 0x 21 # Response to DATA/HEARTBEAT
CLOSE = 0x FF # Bidirectional: Close session
File Operations
class FileOperation ( IntEnum ):
CREATE = 0x 30 # Create new file
READ = 0x 31 # Retrieve file
UPDATE = 0x 32 # Update file
DELETE = 0x 33 # Delete file
STAT = 0x 34 # Get metadata
LIST = 0x 35 # List directory
CHUNK = 0x 36 # File data chunk
COMPLETE = 0x 37 # Transfer complete
ERROR = 0x 38 # Operation error
Connection Flow
Edge (behind NAT/CGNAT) Validator (Cloud)
│─── (1) HELLO ─────────────────────────►│
│ [node_id, W_fingerprint] │ Check device registry
│◄── (2) CHALLENGE ──────────────────────│
│ Sign: Ed25519(nonce + W_fingerprint) │
│─── (3) ATTEST ─────────────────────────►│
│ [signature (64 bytes)] │ Verify signature
│ │ Generate session_secret
│◄── (4) ACCEPT ──────────────────────────│
│ [session_secret (32 bytes)] │
│ Derive ChaCha20 key: │ Derive same key:
│ k = SHA256(secret + W_fingerprint) │ k = SHA256(secret + W_fingerprint)
│◄══ (5) DATA (encrypted) ══════════════►│
│ [TER logs, PoSF signatures] │
│─── (6) HEARTBEAT (every 30s) ─────────►│
│◄── (7) ACK ────────────────────────────│
Packet Structure
┌─────────────────────────────────────────────────────────────┐
│ HTP HEADER (32 bytes) │
├─────────────────────────────────────────────────────────────┤
│ version (2 bytes): Protocol version (1.0 = 0x0100) │
│ type (2 bytes): Message type enum │
│ sequence (4 bytes): Packet sequence number │
│ timestamp (4 bytes): Unix timestamp │
│ flow_token (8 bytes): Session identifier │
│ nonce (8 bytes): Random nonce for encryption │
│ flags (4 bytes): Message flags │
└─────────────────────────────────────────────────────────────┘
Resonance Layer (64 bytes)
┌─────────────────────────────────────────────────────────────┐
│ RESONANCE LAYER (64 bytes) │
├─────────────────────────────────────────────────────────────┤
│ RDV (32 bytes): Resonance Derived Value │
│ PoSF (32 bytes): Proof-of-Sensor-Fusion signature │
└─────────────────────────────────────────────────────────────┘
Payload
┌─────────────────────────────────────────────────────────────┐
├─────────────────────────────────────────────────────────────┤
│ payload_length (4 bytes): Length of encrypted data │
│ payload (variable): ChaCha20-Poly1305 encrypted │
└─────────────────────────────────────────────────────────────┘
Key Derivation
Session Key
def derive_session_key ( session_secret : bytes , w_fingerprint : bytes ) -> bytes :
Derive ChaCha20 key from session secret and weight fingerprint.
The weight fingerprint binds the key to the device's neural state.
return SHA256 ( session_secret + w_fingerprint )
Weight Fingerprint
def compute_weight_fingerprint ( weights : NeuralWeights ) -> bytes :
SHA-512 hash of current neural network weights.
- System is compromised (integrity change)
- Time passes (TER-driven evolution)
serialized = weights. serialize_deterministic ()
return SHA512 ( serialized )
NAT Traversal
Heartbeat Mechanism
# Edge sends heartbeat every 30 seconds
await session. send ( MessageType.HEARTBEAT )
NAT Binding
NAT Type Binding Timeout Heartbeat Interval Full Cone 5+ minutes 60s Restricted 2 minutes 30s Symmetric 30 seconds 15s CGNAT Variable 30s (default)
File Transfer
CRUD Operations
from htp_file import HTPFileTransfer
async with HTPFileTransfer ( session ) as ft:
await ft. create ( ' /path/file.txt ' , b ' content ' )
data = await ft. read ( ' /path/file.txt ' )
await ft. update ( ' /path/file.txt ' , b ' new content ' )
await ft. delete ( ' /path/file.txt ' )
stat = await ft. stat ( ' /path/file.txt ' )
entries = await ft. list ( ' /path/ ' )
file_op (1 byte): Operation enum
flags (1 byte): Compression, atomic write
chunk_index (2 bytes): Current chunk (0-65535)
file_id (4 bytes): Transfer ID
total_chunks(4 bytes): Total chunks
file_hash (4 bytes): First 4 bytes of SHA256
Security Features
Feature Description Chunk size 8KB default (tunable) Integrity SHA256 verification Compression Optional zlib Path safety Traversal prevention Extension filter Whitelist-based Atomic write Temp file + rename Max size 1GB default Concurrency 16 transfers max
Security Properties
Key Binding
Session keys are bound to:
Session secret - Generated by validator
Weight fingerprint - Device’s neural state
Timestamp - Prevents replay
Compromise Detection
If a device is compromised:
Integrity hash changes
Weight evolution diverges
Weight fingerprint changes
Session key derivation differs
Connection fails or is rejected
Forward Secrecy
Each session uses a new:
Session secret (from validator)
Nonce (per packet)
Derived key (from fingerprint)
Implementation
Client Usage
from htp import HTPClient
validator = " validator.hookprobe.mesh:8144 " ,
async with client. connect () as session:
await session. send_data ( ter_logs )
updates = await session. receive ()
Error Handling
class HTPError ( Exception ): pass
class AuthenticationError ( HTPError ): pass
class ResonanceError ( HTPError ): pass
class SessionExpired ( HTPError ): pass
2026 Roadmap
Enhancement Purpose Status Neural Trust Scoring Continuous trust (0.0-1.0) Planned Q1 Adaptive Polymorphism BURST/SWARM/GHOST modes Planned Q1 Jitter Injection Anti-surveillance timing Planned Q1 Energy-Aware Routing Battery management Planned Q1 Witness Verification Anti-hallucination BLS Planned Q2
Configuration
encryption : chacha20-poly1305
compression : zlib # optional
Next Steps