Add "Home"
parent
27c54b03d2
commit
8cc43eb6b6
1 changed files with 67 additions and 0 deletions
67
Home.md
Normal file
67
Home.md
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# go-p2p
|
||||
|
||||
> P2P node identity and message protocol for multi-node mining and compute orchestration.
|
||||
|
||||
**Module**: `forge.lthn.ai/core/go-p2p`
|
||||
**Go**: 1.25.5
|
||||
**Licence**: EUPL-1.2
|
||||
|
||||
## Overview
|
||||
|
||||
go-p2p provides the networking layer for Lethean's distributed compute mesh. It handles node identity (X25519 keypair-derived), WebSocket-based messaging, challenge-response authentication, and peer discovery with latency/geo scoring via Poindexter.
|
||||
|
||||
## Package Structure
|
||||
|
||||
| Package | Purpose |
|
||||
|---------|---------|
|
||||
| `node/` | Core types — peers, messages, identity, protocol handlers |
|
||||
| `logging/` | Structured logging with configurable levels |
|
||||
| `ueps/` | UEPS protocol packet encoding and stream reader |
|
||||
|
||||
## Quick Start
|
||||
|
||||
```go
|
||||
import "forge.lthn.ai/core/go-p2p/node"
|
||||
|
||||
// Create a controller identity
|
||||
identity := node.NewNodeIdentity("my-node", node.RoleController)
|
||||
|
||||
// Generate a challenge for peer authentication
|
||||
challenge := node.GenerateChallenge()
|
||||
response := node.SignChallenge(challenge, sharedSecret)
|
||||
ok := node.VerifyChallenge(challenge, response, sharedSecret)
|
||||
```
|
||||
|
||||
## Protocol
|
||||
|
||||
- **Version**: `1.0`
|
||||
- **Key Exchange**: X25519 ECDH
|
||||
- **Authentication**: HMAC-SHA256 challenge-response
|
||||
- **Transport**: WebSocket (gorilla/websocket)
|
||||
|
||||
## API Overview
|
||||
|
||||
| Type | Description |
|
||||
|------|-------------|
|
||||
| `NodeIdentity` | Node identity derived from X25519 public key |
|
||||
| `Peer` | Remote peer with address, role, latency, and scoring |
|
||||
| `Message` | Protocol message with typed payload (JSON) |
|
||||
| `MessageType` | Enumeration of all protocol message types |
|
||||
| `ProtocolError` | Structured error with code and message |
|
||||
| `ResponseHandler` | Helpers for validating and parsing responses |
|
||||
|
||||
## Dependencies
|
||||
|
||||
| Module | Purpose |
|
||||
|--------|---------|
|
||||
| `github.com/Snider/Borg` | Secure blob and pointer storage (stmf) |
|
||||
| `github.com/Snider/Poindexter` | Latency, hops, geo-distance, reliability metrics |
|
||||
| `github.com/google/uuid` | Message ID generation |
|
||||
| `github.com/gorilla/websocket` | WebSocket transport |
|
||||
| `github.com/adrg/xdg` | XDG base directory paths |
|
||||
|
||||
## Pages
|
||||
|
||||
- [[Node-Identity]] — Identity creation, roles, and authentication
|
||||
- [[Protocol-Messages]] — Message types, format, and payload handling
|
||||
- [[Peer-Discovery]] — Peer management, scoring, and Poindexter integration
|
||||
Loading…
Add table
Reference in a new issue