feat: implement Nostr NIP-01 WebSocket relay publishing #189

Merged
jmiller merged 2 commits from feature/129-nostr-implementation into dev 2026-06-27 20:33:37 +00:00
Owner

Summary\n\nImplements full Nostr protocol support (#129), replacing the stub with a working NIP-01 WebSocket relay publisher.\n\n- BIP-340 Schnorr signatures over secp256k1 using pure PHP + ext-gmp (no external dependencies)\n- Kind-1 text note events with SHA-256 event ID and BIP-340 tagged hashes for domain separation\n- Raw WebSocket client via stream_socket_client with TLS support for wss:// relays\n- Multi-relay failover: tries each configured relay until one accepts the event\n- Public key derivation from private key hex for account display in admin\n- Credential validation: 64-char hex private key format, wss:// relay URL scheme\n\n### Architecture\n\nUnlike all other service plugins (which use curl + REST APIs), Nostr is a cryptographic protocol:\n1. Private key stays on the server -- no API tokens sent to third parties\n2. Event is constructed, hashed (SHA-256), and signed (Schnorr) locally\n3. Signed event is pushed to relay(s) over WebSocket\n4. Relay responds with [\"OK\", event_id, true/false, message]\n\n### Requirements\n\n- PHP ext-gmp (for arbitrary-precision integer arithmetic in EC math)\n- Graceful error if ext-gmp is not installed\n\nCloses #129\n\n## Test plan\n\n- [ ] Verify PHP syntax check passes\n- [ ] Verify ext-gmp check returns clear error when extension is missing\n- [ ] Test credential validation with valid/invalid hex keys and relay URLs\n- [ ] Test publishing to a public Nostr relay (e.g., wss://relay.damus.io)\n- [ ] Verify event appears on a Nostr client (e.g., primal.net) under the derived pubkey\n- [ ] Test multi-relay failover with one invalid + one valid relay

## Summary\n\nImplements full Nostr protocol support (#129), replacing the stub with a working NIP-01 WebSocket relay publisher.\n\n- **BIP-340 Schnorr signatures** over secp256k1 using pure PHP + ext-gmp (no external dependencies)\n- **Kind-1 text note events** with SHA-256 event ID and BIP-340 tagged hashes for domain separation\n- **Raw WebSocket client** via `stream_socket_client` with TLS support for `wss://` relays\n- **Multi-relay failover**: tries each configured relay until one accepts the event\n- **Public key derivation** from private key hex for account display in admin\n- **Credential validation**: 64-char hex private key format, wss:// relay URL scheme\n\n### Architecture\n\nUnlike all other service plugins (which use curl + REST APIs), Nostr is a cryptographic protocol:\n1. Private key stays on the server -- no API tokens sent to third parties\n2. Event is constructed, hashed (SHA-256), and signed (Schnorr) locally\n3. Signed event is pushed to relay(s) over WebSocket\n4. Relay responds with `[\"OK\", event_id, true/false, message]`\n\n### Requirements\n\n- PHP ext-gmp (for arbitrary-precision integer arithmetic in EC math)\n- Graceful error if ext-gmp is not installed\n\nCloses #129\n\n## Test plan\n\n- [ ] Verify PHP syntax check passes\n- [ ] Verify ext-gmp check returns clear error when extension is missing\n- [ ] Test credential validation with valid/invalid hex keys and relay URLs\n- [ ] Test publishing to a public Nostr relay (e.g., wss://relay.damus.io)\n- [ ] Verify event appears on a Nostr client (e.g., primal.net) under the derived pubkey\n- [ ] Test multi-relay failover with one invalid + one valid relay
jmiller added 2 commits 2026-06-27 20:22:24 +00:00
feat: implement Nostr NIP-01 WebSocket relay publishing (#129)
Universal: Auto Version Bump / Version Bump (push) Successful in 9s
e183b62aba
- BIP-340 Schnorr signatures over secp256k1 (pure PHP, requires ext-gmp)
- Kind-1 text note events with SHA-256 event ID and tagged hashes
- Raw WebSocket client via stream_socket_client (zero external deps)
- Multi-relay failover: tries each relay until one accepts
- Public key derivation from private key for account display
- Validates 64-char hex private key format and wss:// relay URLs

Authored-by: Moko Consulting
chore(version): auto-bump patch 01.08.11-dev [skip ci]
RC Revert / Rename rc/ back to dev/ (pull_request) Has been skipped
Branch Cleanup / Delete merged branch (pull_request) Failing after 3s
13683adfba
jmiller merged commit d3bc62f810 into dev 2026-06-27 20:33:37 +00:00
jmiller deleted branch feature/129-nostr-implementation 2026-06-27 20:33:38 +00:00
Sign in to join this conversation.
No Reviewers
No labels
Priority -
Type -
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoSuiteCross#189