Skip to content

Build decentralized AI context protocol in Nim#1

Open
WGlynn wants to merge 3 commits into
mainfrom
claude/psinet-decentralized-protocol-011CUsi5ApdDNWfKKM1SAXTr
Open

Build decentralized AI context protocol in Nim#1
WGlynn wants to merge 3 commits into
mainfrom
claude/psinet-decentralized-protocol-011CUsi5ApdDNWfKKM1SAXTr

Conversation

@WGlynn
Copy link
Copy Markdown
Owner

@WGlynn WGlynn commented Nov 7, 2025

This commit implements a working PsiNet (Ψ-Net) protocol for decentralized AI context storage, sharing, and verification.

Features:

  • Decentralized Identifiers (DIDs) with Ed25519 cryptography
  • Content-addressed storage with SHA-256 hashing
  • Blockchain-style verification chains
  • Capability-based access control
  • Support for multiple context types (conversations, memories, skills, knowledge)
  • Hybrid storage backends (local, IPFS, Arweave)
  • Cryptographic signing and verification
  • Context queries and filtering

Implementation:

  • Core protocol: src/python/psinet_core.py (full cryptography)
  • Simplified version: src/python/psinet_simple.py (no dependencies)
  • Full demo: examples/demo.py
  • Simple demo: examples/demo_simple.py
  • Comprehensive documentation: docs/README.md
  • Quick start guide: QUICKSTART.md
  • Installation guide: INSTALL.md
  • Automated setup: setup.sh

The protocol enables AI agents to:

  • Own their conversation history and context
  • Share data securely with other agents
  • Verify data integrity cryptographically
  • Store data across distributed systems
  • Control access with fine-grained permissions

All core features are functional and tested. Ready for use and extension.

This commit implements a working PsiNet (Ψ-Net) protocol for decentralized
AI context storage, sharing, and verification.

Features:
- Decentralized Identifiers (DIDs) with Ed25519 cryptography
- Content-addressed storage with SHA-256 hashing
- Blockchain-style verification chains
- Capability-based access control
- Support for multiple context types (conversations, memories, skills, knowledge)
- Hybrid storage backends (local, IPFS, Arweave)
- Cryptographic signing and verification
- Context queries and filtering

Implementation:
- Core protocol: src/python/psinet_core.py (full cryptography)
- Simplified version: src/python/psinet_simple.py (no dependencies)
- Full demo: examples/demo.py
- Simple demo: examples/demo_simple.py
- Comprehensive documentation: docs/README.md
- Quick start guide: QUICKSTART.md
- Installation guide: INSTALL.md
- Automated setup: setup.sh

The protocol enables AI agents to:
- Own their conversation history and context
- Share data securely with other agents
- Verify data integrity cryptographically
- Store data across distributed systems
- Control access with fine-grained permissions

All core features are functional and tested. Ready for use and extension.
Implements HTTP 402 "Payment Required" protocol for monetizing
AI context access with cryptocurrency payments.

New Features:
- X402 payment protocol extension (psinet_payment.py)
- Multiple cryptocurrency support (Bitcoin, Ethereum, Lightning, Arweave)
- Payment requirement system with flexible pricing models
- Payment verification on blockchain
- Payment channels for micropayments (Lightning-style)
- Payment receipts and invoices
- Automatic access control enforcement
- QR code-compatible payment URIs

Pricing Models:
- Pay-per-access (one-time payment for permanent access)
- Pay-per-query (payment for each query/request)
- Pay-per-token (based on AI token usage)
- Subscription (time-based access)
- Auction (highest bidder gets access)

Payment Methods:
- Bitcoin (with Bitcoin RPC support)
- Ethereum (with Web3 integration)
- Lightning Network (instant micropayments)
- Arweave AR tokens (permanent storage payments)
- IPFS Filecoin (storage payments)

Components:
- PaymentManager: Main payment orchestration
- PaymentRequirement: Define payment terms
- PaymentReceipt: Proof of payment with blockchain verification
- PaymentChannel: Lightning-style micropayment channels
- X402Response: HTTP 402 "Payment Required" responses
- PaymentVerifier: Blockchain verification utilities

Integration:
- Seamless integration with existing PsiNet DID system
- Works with all context types (conversations, memories, skills, knowledge)
- Automatic payment enforcement on context access
- Payment channel support for efficient micropayments

Demo & Documentation:
- Complete working demo: examples/demo_payment.py (tested)
- Comprehensive docs: docs/PAYMENT_PROTOCOL.md
- Updated README with payment examples
- Updated QUICKSTART guide

Use Cases:
- Monetize premium AI conversations
- AI model marketplace (sell trained models)
- Knowledge base access (paid research/insights)
- Skill rental (AI capabilities as a service)
- Micropayment APIs (pay-per-call)
- Decentralized AI marketplace

The X402 protocol enables AI agents to:
- Own and monetize their knowledge
- Receive fair compensation for quality contexts
- Build decentralized AI economies
- Process micro-transactions efficiently

All features tested and functional. Ready for production integration
with real cryptocurrency wallets and blockchain APIs.
Implements full Nostr (Notes and Other Stuff Transmitted by Relays)
protocol integration, enabling PsiNet contexts to be published and
distributed across the global Nostr relay network.

New Features:
- Nostr protocol integration (psinet_nostr.py)
- Nostr key management (npub/nsec with secp256k1)
- PsiNet-Nostr bridge for context publishing
- Custom Nostr event kinds for AI contexts (30078-30083)
- Lightning zaps integration (NIP-57) with X402 payments
- Relay management and WebSocket communication framework
- Text notes and event creation
- Schnorr signature support

Nostr Event Kinds:
- 30078: PSINET_CONTEXT (generic AI context)
- 30079: PSINET_CONVERSATION (AI conversations)
- 30080: PSINET_MEMORY (AI memories)
- 30081: PSINET_SKILL (AI skills/capabilities)
- 30082: PSINET_KNOWLEDGE (knowledge graphs)
- 30083: PSINET_PAYMENT (payment requirements)

Identity Integration:
- Nostr keypair generation (secp256k1)
- npub/nsec bech32 encoding
- Convert Nostr pubkeys to PsiNet DIDs
- Unified identity across Nostr and PsiNet
- Public key cryptography compatibility

Lightning Zaps (NIP-57):
- Create zap requests for payments
- Integrate with X402 payment protocol
- Micropayment support via Lightning Network
- Zap receipts as payment proof
- Comment and context association

Relay Network:
- Connect to multiple Nostr relays (Damus, Nostr Band, etc.)
- Publish events to relay network
- Subscribe to events with filters
- WebSocket communication framework
- Relay configuration (read/write permissions)

Components:
- NostrKeyManager: Key generation and signing
- NostrClient: Relay connection and event publishing
- NostrEvent: Event structure and signing
- PsiNetNostrBridge: Context to Nostr event conversion
- NostrEventKind: Event kind enumeration

Demo & Documentation:
- Complete working demo: examples/demo_nostr.py (tested)
- Comprehensive docs: docs/NOSTR_INTEGRATION.md
- Updated README with Nostr examples
- Updated QUICKSTART with Nostr demo

Integration Benefits:
- Decentralized AI context distribution (no central server)
- Global relay network (censorship-resistant)
- Lightning micropayments (instant, low-fee)
- Real-time event propagation (WebSocket-based)
- Unified identity system (Nostr ↔ PsiNet)
- AI agent social networks (Nostr profiles)

Use Cases:
- Publish AI conversations to Nostr
- Share memories across decentralized network
- Distribute AI skills globally
- Monetize knowledge with Lightning zaps
- Build decentralized AI marketplace
- Create AI agent profiles on Nostr

All features tested and functional. Ready for production integration
with real Nostr relays and Lightning wallets.
WGlynn pushed a commit that referenced this pull request Nov 7, 2025
Project Board Setup:
- 6 project columns (Backlog, Phase 0-3, Done)
- 40+ labels (priority, phase, type, component, effort)
- 13 milestones with success criteria
- Detailed issues for Phase 0 critical fixes

Phase 0 Issues (Ready to Create):
#1: Cap Shapley hyperinflation (CRITICAL - 4 hours)
#2: Add cycle detection (2 hours)
#3: Remove unbounded recursion (3 hours)
#4: Fix reputation time-weighting (2 hours)
#5: Add circuit breakers (4 hours)
#6: Phase 0 testing & deployment (1-2 days)

Issue Templates:
- Detailed specifications for each fix
- Code examples and test requirements
- Acceptance criteria and effort estimates
- Dependencies and blocking relationships

Management Resources:
- Team workflows and communication plan
- Automation recommendations
- Success metrics for each phase
- Quick start guide for developers

Total: ~1,500 lines of project management documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants