[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
Collaborator

Fixes #856

Summary

Implements Timmys full Nostr identity stack in src/infrastructure/nostr/:

  • keypair.py — Pure-Python secp256k1 keypair generation (BIP-340), bech32 nsec/npub encoding (NIP-19)
  • event.py — NIP-01 event construction with BIP-340 Schnorr signing (schnorr_sign / schnorr_verify)
  • relay.py — WebSocket relay client (via websockets) that publishes NIP-01 ["EVENT", …] to one or many relays concurrently, with graceful degradation
  • identity.pyNostrIdentityManager publishes Kind 0 (profile metadata) and Kind 31990 (NIP-89/NIP-90 capability card) to configured relays

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

All operations degrade gracefully when keys/relays are not configured.

Tests

647 unit tests pass. New tests cover keypair round-trips, Schnorr sign/verify, event ID hashing, and the full identity announce lifecycle with mocked relay.

Fixes #856 ## Summary Implements Timmys full Nostr identity stack in `src/infrastructure/nostr/`: - **keypair.py** — Pure-Python secp256k1 keypair generation (BIP-340), bech32 `nsec`/`npub` encoding (NIP-19) - **event.py** — NIP-01 event construction with BIP-340 Schnorr signing (`schnorr_sign` / `schnorr_verify`) - **relay.py** — WebSocket relay client (via `websockets`) that publishes NIP-01 `["EVENT", …]` to one or many relays concurrently, with graceful degradation - **identity.py** — `NostrIdentityManager` publishes Kind 0 (profile metadata) and Kind 31990 (NIP-89/NIP-90 capability card) to configured relays **Config** additions to `config.py`: `NOSTR_PRIVKEY`, `NOSTR_PUBKEY`, `NOSTR_RELAYS`, `NOSTR_NIP05`, `NOSTR_PROFILE_NAME`, `NOSTR_PROFILE_ABOUT`, `NOSTR_PROFILE_PICTURE`. All operations degrade gracefully when keys/relays are not configured. ## Tests 647 unit tests pass. New tests cover keypair round-trips, Schnorr sign/verify, event ID hashing, and the full identity announce lifecycle with mocked relay.
claude added 1 commit 2026-03-24 02:20:39 +00:00
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
5d4d484f59
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>
Timmy merged commit c5e4657e23 into main 2026-03-24 02:22:39 +00:00
Timmy deleted branch claude/issue-856 2026-03-24 02:22:40 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1325