{"id":19060294,"url":"https://github.com/sgiath/nostr-lib","last_synced_at":"2026-01-24T00:31:57.792Z","repository":{"id":65314847,"uuid":"589516658","full_name":"Sgiath/nostr-lib","owner":"Sgiath","description":"Library implementing Nostr specs","archived":false,"fork":false,"pushed_at":"2025-01-12T16:13:18.000Z","size":84,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-24T06:49:41.006Z","etag":null,"topics":["elixir","nostr"],"latest_commit_sha":null,"homepage":"https://sgiath.dev/nostr","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sgiath.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-16T10:00:08.000Z","updated_at":"2025-01-12T16:13:22.000Z","dependencies_parsed_at":"2024-01-08T15:04:09.725Z","dependency_job_id":"52dc3b0d-752b-45aa-a9fd-1def3e5dbacc","html_url":"https://github.com/Sgiath/nostr-lib","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"dcc86e542afffc73d85af909058200a5afad19ef"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sgiath%2Fnostr-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sgiath%2Fnostr-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sgiath%2Fnostr-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sgiath%2Fnostr-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sgiath","download_url":"https://codeload.github.com/Sgiath/nostr-lib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250580713,"owners_count":21453531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","nostr"],"created_at":"2024-11-09T00:14:23.032Z","updated_at":"2026-01-24T00:31:57.787Z","avatar_url":"https://github.com/Sgiath.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nostr\n\n[![Hex.pm](https://img.shields.io/hexpm/v/nostr_lib.svg)](https://hex.pm/packages/nostr_lib)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-blue.svg)](https://hexdocs.pm/nostr_lib)\n[![License](https://img.shields.io/hexpm/l/nostr_lib.svg)](https://github.com/sgiath/nostr-lib/blob/master/LICENSE)\n\nA comprehensive low-level Elixir library implementing the [Nostr protocol](https://nostr.com/).\nProvides structures, parsing, serialization, and cryptographic functions for building Nostr\napplications.\n\n## Features\n\n- Full event lifecycle: creation, signing, validation, serialization\n- Schnorr signature support (secp256k1)\n- NIP-44 encryption (versioned encrypted payloads)\n- NIP-19 bech32 encoding (npub, nsec, note, nprofile, nevent, naddr)\n- NIP-59 gift wrap protocol for private messaging\n- WebSocket message protocol handling\n- Subscription filter building\n\n## Installation\n\nAdd `nostr_lib` to your dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:nostr_lib, \"~\u003e 0.2.0\"}\n  ]\nend\n```\n\n## Quick Start\n\n### Create and Sign an Event\n\n```elixir\n# Generate or use existing private key (32 bytes hex)\nprivate_key = \"your_private_key_hex\"\n\n# Create a text note (kind 1)\n{:ok, event} = Nostr.Event.Note.create(\"Hello Nostr!\", private_key)\n\n# Serialize for sending to relay\njson = Nostr.Event.serialize(event)\n```\n\n### Parse Incoming Events\n\n```elixir\n# Parse JSON from relay\n{:ok, event} = Nostr.Event.parse(json_string)\n\n# Validate event signature\ncase Nostr.Event.Validator.validate(event) do\n  {:ok, event} -\u003e # Valid event\n  {:error, reason, event} -\u003e # Invalid\nend\n```\n\n### Build Subscription Filters\n\n```elixir\n# Create a filter for text notes from specific authors\nfilter = %Nostr.Filter{\n  kinds: [1],\n  authors: [\"pubkey1\", \"pubkey2\"],\n  limit: 100\n}\n```\n\n### Bech32 Encoding\n\n```elixir\n# Encode public key as npub\n{:ok, npub} = Nostr.Bech32.encode(:npub, pubkey_hex)\n# =\u003e \"npub1...\"\n\n# Decode back\n{:ok, {:npub, pubkey}} = Nostr.Bech32.decode(npub)\n```\n\n## Implemented NIPs\n\n| NIP | Status | Description | Event Kinds |\n|-----|--------|-------------|-------------|\n| [NIP-01](https://github.com/nostr-protocol/nips/blob/master/01.md) | Full | Basic protocol | 0, 1 |\n| [NIP-02](https://github.com/nostr-protocol/nips/blob/master/02.md) | Full | Follow list | 3 |\n| [NIP-03](https://github.com/nostr-protocol/nips/blob/master/03.md) | Full | OpenTimestamps | 1040 |\n| [NIP-04](https://github.com/nostr-protocol/nips/blob/master/04.md) | Deprecated | Encrypted DMs (use NIP-17) | 4 |\n| [NIP-05](https://github.com/nostr-protocol/nips/blob/master/05.md) | Full | DNS-based identifiers | - |\n| [NIP-09](https://github.com/nostr-protocol/nips/blob/master/09.md) | Full | Event deletion | 5 |\n| [NIP-16](https://github.com/nostr-protocol/nips/blob/master/16.md) | Full | Event kind ranges | 1000-39999 |\n| [NIP-17](https://github.com/nostr-protocol/nips/blob/master/17.md) | Full | Private direct messages | 14, 15, 10050 |\n| [NIP-18](https://github.com/nostr-protocol/nips/blob/master/18.md) | Deprecated | Reposts | 6 |\n| [NIP-19](https://github.com/nostr-protocol/nips/blob/master/19.md) | Full | Bech32 encoding | - |\n| [NIP-21](https://github.com/nostr-protocol/nips/blob/master/21.md) | Full | nostr: URI scheme | - |\n| [NIP-22](https://github.com/nostr-protocol/nips/blob/master/22.md) | Full | Comments | 1111 |\n| [NIP-23](https://github.com/nostr-protocol/nips/blob/master/23.md) | Full | Long-form content | 30023, 30024 |\n| [NIP-25](https://github.com/nostr-protocol/nips/blob/master/25.md) | Full | Reactions | 7, 17 |\n| [NIP-28](https://github.com/nostr-protocol/nips/blob/master/28.md) | Full | Public chat channels | 40-44 |\n| [NIP-30](https://github.com/nostr-protocol/nips/blob/master/30.md) | Full | Custom emoji | - |\n| [NIP-32](https://github.com/nostr-protocol/nips/blob/master/32.md) | Full | Labeling | 1985 |\n| [NIP-36](https://github.com/nostr-protocol/nips/blob/master/36.md) | Full | Sensitive content | - |\n| [NIP-37](https://github.com/nostr-protocol/nips/blob/master/37.md) | Full | Draft events | 31234 |\n| [NIP-38](https://github.com/nostr-protocol/nips/blob/master/38.md) | Full | User statuses | 30315 |\n| [NIP-39](https://github.com/nostr-protocol/nips/blob/master/39.md) | Full | External identities | - |\n| [NIP-42](https://github.com/nostr-protocol/nips/blob/master/42.md) | Full | Relay authentication | 22242 |\n| [NIP-44](https://github.com/nostr-protocol/nips/blob/master/44.md) | Full | Versioned encryption | - |\n| [NIP-45](https://github.com/nostr-protocol/nips/blob/master/45.md) | Partial | Event counting | - |\n| [NIP-49](https://github.com/nostr-protocol/nips/blob/master/49.md) | Full | Private key encryption | - |\n| [NIP-51](https://github.com/nostr-protocol/nips/blob/master/51.md) | Full | Lists | 10001-10030, 30000-30030 |\n| [NIP-52](https://github.com/nostr-protocol/nips/blob/master/52.md) | Full | Calendar | 31924 |\n| [NIP-56](https://github.com/nostr-protocol/nips/blob/master/56.md) | Full | Reporting | 1984 |\n| [NIP-57](https://github.com/nostr-protocol/nips/blob/master/57.md) | Full | Lightning zaps | 9734, 9735 |\n| [NIP-58](https://github.com/nostr-protocol/nips/blob/master/58.md) | Full | Badges | 8 |\n| [NIP-59](https://github.com/nostr-protocol/nips/blob/master/59.md) | Full | Gift wrap | 13, 1059 |\n| [NIP-65](https://github.com/nostr-protocol/nips/blob/master/65.md) | Full | Relay list metadata | 10002 |\n| [NIP-94](https://github.com/nostr-protocol/nips/blob/master/94.md) | Full | File metadata | 1063 |\n\n## Core Modules\n\n| Module | Description |\n|--------|-------------|\n| `Nostr.Event` | Core event struct with create, parse, serialize, sign, validate |\n| `Nostr.Crypto` | Cryptographic operations (keys, signing, encryption) |\n| `Nostr.Message` | WebSocket protocol messages (EVENT, REQ, CLOSE, etc.) |\n| `Nostr.Filter` | Subscription filter building |\n| `Nostr.Bech32` | NIP-19 bech32 encoding/decoding |\n| `Nostr.NIP44` | Versioned encrypted payloads |\n| `Nostr.NIP17` | Private message convenience functions |\n| `Nostr.NIP05` | DNS-based identifier verification |\n\n## Event Types\n\nEach event kind has a dedicated module in `Nostr.Event.*`:\n\n| Kind | Module | Description |\n|------|--------|-------------|\n| 0 | `Metadata` | User profile metadata |\n| 1 | `Note` | Text notes/posts |\n| 3 | `Contacts` | Follow list |\n| 4 | `DirectMessage` | Encrypted DMs (deprecated) |\n| 5 | `Deletion` | Event deletion requests |\n| 6 | `Repost` | Reposts (deprecated) |\n| 7 | `Reaction` | Reactions to events |\n| 8 | `BadgeAward` | Badge awards |\n| 13 | `Seal` | Sealed/encrypted events |\n| 14 | `PrivateMessage` | Private chat messages |\n| 15 | `FileMessage` | Encrypted file messages |\n| 17 | `ExternalReaction` | Reactions to external content |\n| 40-44 | `Channel*` | Public chat channels |\n| 1040 | `OpenTimestamps` | Timestamp attestations |\n| 1059 | `GiftWrap` | Gift wrapped events |\n| 1063 | `FileMetadata` | File metadata |\n| 1111 | `Comment` | Threaded comments |\n| 1984 | `Report` | Content reports |\n| 1985 | `Label` | Content labels |\n| 9734 | `ZapRequest` | Lightning zap requests |\n| 9735 | `ZapReceipt` | Lightning zap receipts |\n| 10002 | `RelayList` | Relay list metadata |\n| 10050 | `DMRelayList` | DM relay preferences |\n| 22242 | `ClientAuth` | Client authentication |\n| 30023 | `Article` | Long-form content |\n| 30315 | `UserStatus` | User status updates |\n\n## Related Packages\n\nThis library is part of a larger Nostr ecosystem for Elixir:\n\n- **nostr_lib** (this package) - Low-level protocol implementation\n- **nostr_client** - WebSocket client for connecting to relays\n- **nostr_server** - WebSocket server for building relays\n- **nostr_relay** - Full relay implementation\n\n## Documentation\n\nFull documentation is available on [HexDocs](https://hexdocs.pm/nostr_lib).\n\n## Contributing\n\nContributions are welcome! Please feel free to submit issues and pull requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgiath%2Fnostr-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgiath%2Fnostr-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgiath%2Fnostr-lib/lists"}