[claude] Timmy Nostr identity — keypair, profile, relay presence (#856) #1325

Merged
Timmy merged 1 commits from claude/issue-856 into main 2026-03-24 02:22:39 +00:00

1 Commits

Author SHA1 Message Date
Alexander Whitestone
5d4d484f59 feat: Timmy's Nostr identity — keypair, profile, relay presence (#856)
Some checks failed
Tests / lint (pull_request) Failing after 24s
Tests / test (pull_request) Has been skipped
Implements Timmy's Nostr identity stack in `src/infrastructure/nostr/`:

- **keypair.py**: Pure-Python secp256k1 keypair generation (BIP-340),
  bech32 nsec/npub encoding (NIP-19), `generate_keypair()` / `load_keypair()`.
- **event.py**: NIP-01 event construction with BIP-340 Schnorr signing,
  `build_event()` + `schnorr_sign()` / `schnorr_verify()`.
- **relay.py**: WebSocket relay client via `websockets`, publishes NIP-01
  `["EVENT", …]` messages to one or many relays concurrently with graceful
  degradation when unavailable.
- **identity.py**: `NostrIdentityManager` — publishes Kind 0 (profile
  metadata) and Kind 31990 (NIP-89/NIP-90 capability card) to configured
  relays; reads all settings from `config.settings`.

Config additions to `src/config.py`:
  `NOSTR_PRIVKEY`, `NOSTR_PUBKEY`, `NOSTR_RELAYS`, `NOSTR_NIP05`,
  `NOSTR_PROFILE_NAME`, `NOSTR_PROFILE_ABOUT`, `NOSTR_PROFILE_PICTURE`.

All operations degrade gracefully (log WARNING, never crash) when keys or
relays are not configured — consistent with the project's error-handling
patterns.

Tests: 647 unit tests pass; new tests cover keypair, event signing/verify,
and the full identity announce lifecycle.

Fixes #856

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 22:20:03 -04:00