Skip to main content
Sovran implements multiple Nostr NIPs (Nostr Implementation Possibilities) for decentralized identity, encrypted messaging, and social features.

Supported NIPs

Sovran supports NIP-04, NIP-05, NIP-06, NIP-17, NIP-19, NIP-44, and NIP-59.

NIP-04: Encrypted Direct Messages (Legacy)

Legacy encrypted direct message support using NIP-04 encryption.
NIP-04 is considered deprecated in favor of NIP-17 (gift-wrapped DMs) for enhanced metadata privacy. Sovran primarily uses NIP-17 for new messages.

NIP-05: DNS-Based Verification

NIP-05 provides DNS-based verification for Nostr identities (Lightning addresses). User Interface (components/blocks/contacts/SearchResult.tsx):
  • Profile search with NIP-05 validation
  • Search by npub, NIP-05 identifier, or display name
  • Verification badge display
Search Flow:

NIP-06: Deterministic Key Derivation

NIP-06 enables deterministic key derivation from BIP-39 seed phrases. Implementation (helper/keyDerivation.ts:14-31):
Derivation Path: m/44'/1237'/<accountIndex>'/0/0 Key Types Derived:
  • npub: Bech32-encoded public key (shareable)
  • nsec: Bech32-encoded private key (secret)
  • pubkey: Hex public key (for protocol usage)
  • privateKey: Raw private key bytes (for signing)
Provider Integration (providers/NostrKeysProvider.tsx:243-365): The NostrKeysProvider manages key derivation with caching:
Benefits:
  • Single seed phrase for both Bitcoin and Nostr
  • Deterministic identity recovery
  • Multi-account support
  • Cross-platform compatibility

NIP-17: Private Direct Messages

NIP-17 provides gift-wrapped direct messages with enhanced metadata privacy. Implementation (utils/nip17.ts): NIP-17 uses a three-layer gift-wrapping protocol:
  1. Rumor (kind 14): Unsigned event containing the actual message
  2. Seal (kind 13): Encrypts the rumor with NIP-44, signed by sender
  3. Wrap (kind 1059): Encrypts the seal with a random throwaway key

Creating Gift-Wrapped Messages

Single Recipient (utils/nip17.ts:127-151):
With Self-Copy (utils/nip17.ts:162-190): For sender to retrieve their own sent messages:

Unwrapping Received Messages

Decryption (utils/nip17.ts:221-258):
Privacy Features:
  • Random timestamps (within last 2 days) for metadata obfuscation
  • Throwaway keys prevent sender correlation
  • Seal verification ensures message authenticity

Messaging Interface

UI Components (components/screens/UserMessagesScreen.tsx):
  • NIP-17 DM conversation screen
  • Send/receive encrypted messages
  • Inline Cashu token messages
  • Inline payment request messages
Message Sending (hooks/useNostrDirectMessage.ts):
  • NIP-17 DM creation with NIP-44 encryption
  • Gift wrap generation (recipient + sender copy)
  • Relay publishing

NIP-19: Bech32 Encoding

NIP-19 defines bech32-encoded entities for Nostr. Supported Entity Types:
  • npub: Public key (user identity)
  • nsec: Private key (secret)
  • note: Note ID (event reference)
  • nprofile: Profile with relay hints
  • nevent: Event with relay hints
Decoding (helper/nostrClient.ts:7-17):
Safe Parsing (helper/nostrClient.ts:19-27):
Payment String Processing (hooks/coco/useProcessPaymentString.ts:52-75): Sovran handles both npub1... and nostr:npub1... formats:
Profile Navigation (hooks/coco/useProcessPaymentString.ts:387-398): Scanning an npub navigates to the user’s profile:

NIP-44: Encrypted Payloads

NIP-44 provides versioned encryption for Nostr messages (improved NIP-04). Implementation (utils/nip17.ts:34-44):
Usage in NIP-17:
  • Encrypts rumor in seal (kind 13)
  • Encrypts seal in gift wrap (kind 1059)
  • Uses conversation keys for sender/recipient pairs
Security Properties:
  • Forward secrecy (each message uses unique keys)
  • Authentication (verifiable sender identity)
  • Confidentiality (only recipient can decrypt)

NIP-59: Gift Wrap

NIP-59 defines the gift wrap protocol structure used by NIP-17. Event Kinds:
  • Kind 13: Seal (encrypted rumor)
  • Kind 1059: Gift wrap (encrypted seal)
Rumor Creation (utils/nip17.ts:56-70):
Seal Creation (utils/nip17.ts:78-93):
Gift Wrap Creation (utils/nip17.ts:101-114):

Social Features

User Profiles

Profile Viewer (app/(user-flow)/profile.tsx):
  • Banner and avatar display
  • Follower/following counts
  • Top followers (social proof)
  • Reputation score
  • Follow/unfollow actions
Profile Fetching (hooks/useNostrProfile.ts):
  • Profile metadata (kind 0)
  • Follower/following counts
  • Top followers list
  • User ranking

Mint Recommendations

Kind 38000: Cashu mint recommendation events Validation (helper/nostrClient.ts:64-67):
Mint Discovery (hooks/coco/useNostrDiscoveredMints.ts):
  • Discovers mints from Nostr kind 38000 events
  • Filters by k tag (38172 = Cashu mint)
  • Extracts mint URLs from u tags

Dependencies

Sovran uses nostr-tools for core Nostr operations and @nostr-dev-kit/ndk-mobile for mobile-optimized Nostr features including relay pool management.

Reference Implementation

  • NIP-06 Derivation: helper/keyDerivation.ts:14-31
  • NIP-17 Gift Wrap: utils/nip17.ts
  • NIP-19 Decoding: helper/nostrClient.ts:7-27
  • NIP-44 Encryption: utils/nip17.ts:34-44
  • Nostr Keys Provider: providers/NostrKeysProvider.tsx
  • Direct Messaging: hooks/useNostrDirectMessage.ts
  • Profile Management: hooks/useNostrProfile.ts

Learn More

BIP Standards

Learn about BIP-39 seed phrase derivation

Payment Requests

NUT-18 Nostr-based payment requests

Nostr Protocol

Official Nostr NIPs repository

Security

Secure key storage with expo-secure-store