Claude ef86b02863 feat: implement NIP-17 gift wrap chat with efficient decryption
Implements comprehensive NIP-17 private direct messaging with NIP-59
gift wrapping and NIP-44 encryption for metadata protection.

## Key Features

**Gift Wrap Decryption Service** (src/services/gift-wrap.ts):
- Automatic syncing of kind 1059 gift wraps from user's DM relays
- Efficient decryption using user's private key via signer
- Tracks decryption state (pending/success/failed) in IndexedDB
- Retries failed decryptions with exponential backoff
- Stores unsealed kind 14/15 rumor events locally
- Indexes messages by conversation key for fast lookup

**Local Storage Schema** (src/services/db.ts):
- giftWrapDecryptions: Tracks decryption attempts per gift wrap
- unsealedDMs: Stores decrypted messages with full conversation context
- Indexed by sender, recipient, conversation key, and timestamps
- Supports soft deletion and conversation management

**NIP-17 Chat Adapter** (src/lib/chat/adapters/nip-17-adapter.ts):
- Parses npub/nprofile/hex identifiers for DM recipients
- Creates gift-wrapped messages with double NIP-44 encryption
- Randomizes timestamps (±2 days) per NIP-17 spec
- Sends copy to sender's DM relays for message history
- Loads messages from local unsealed storage (no relay queries)
- Supports replies, emoji tags, and blob attachments

**Integration**:
- Added NIP-17 adapter to chat parser with priority ordering
- Auto-starts gift wrap sync on account login (useAccountSync)
- Updated chat command help text with NIP-17 examples

## Implementation Details

- Double encryption: Rumor → Seal (kind 13) → Gift Wrap (kind 1059)
- Ephemeral keys for gift wraps (plausible deniability)
- Conversation key: sorted pubkeys for consistent grouping
- Supports user's kind 10050 DM relay preferences
- Falls back to general relays if DM relays not found
- All decryption happens locally - no metadata leakage

## Testing

- TypeScript compilation verified (npx tsc --noEmit)
- Database schema migration to v18
- Gift wrap manager singleton pattern
- RxJS observables for reactive message updates

References:
- NIP-17: https://github.com/nostr-protocol/nips/blob/master/17.md
- NIP-59: https://github.com/nostr-protocol/nips/blob/master/59.md
- NIP-44: https://github.com/nostr-protocol/nips/blob/master/44.md
2026-01-19 21:13:25 +00:00
2025-12-18 15:46:02 +01:00
👶
2025-12-09 16:26:31 +01:00
2025-12-19 12:49:29 +01:00
2025-12-13 15:06:05 +01:00
2025-12-22 20:40:16 +00:00
2025-12-20 14:25:40 +01:00
2026-01-14 19:24:37 +01:00
👶
2025-12-09 16:26:31 +01:00
👶
2025-12-09 16:26:31 +01:00
👶
2025-12-09 16:26:31 +01:00
2025-12-14 16:50:16 +01:00

Grimoire

A Nostr protocol explorer and developer tool with a tiling window manager interface.

Features

  • Tiling Windows - Each window is a Nostr "app" (profile viewer, event feed, NIP docs, etc.)
  • Command Palette - Unix-style commands via Cmd+K to open apps and navigate
  • Multi-workspace - Virtual desktops with independent layouts
  • Real-time - Reactive event subscriptions with automatic updates

Stack

React 19, TypeScript, Vite, TailwindCSS, Jotai, Dexie, Applesauce

Getting Started

npm install
npm run dev

Scripts

Command Description
npm run dev Start dev server
npm run build Build for production
npm test Run tests in watch mode
npm run lint Lint code
npm run format Format code

License

MIT

Description
No description provided
Readme MIT 14 MiB
Languages
TypeScript 98.9%
CSS 0.8%
JavaScript 0.3%