eyecatch # Nosnos 🔐 High-performance Nostr cryptographic operations library for Elixir ![Last commit](https://img.shields.io/github/last-commit/Comamoca/nosnos?style=flat-square) ![Issues](https://img.shields.io/github/issues/Comamoca/nosnos?style=flat-square) ![License](https://img.shields.io/github/license/Comamoca/nosnos?style=flat-square) ![Stars](https://img.shields.io/github/stars/Comamoca/nosnos?style=flat-square)

🔥 Features

Nosnos is a Elixir library implementing BIP-340 Schnorr signatures and Nostr protocol (NIP-01) cryptographic operations using Zig NIFs for performance.

🚀 How to use

Basic Signing and Verification

# Generate a random secret key (32 bytes)
secret_key = :crypto.strong_rand_bytes(32)

# Derive the public key
public_key = Nosnos.get_public_key(secret_key)

# Sign a message
message = "Hello Nostr!"
message_hash = :crypto.hash(:sha256, message)
signature = Nosnos.sign(secret_key, message_hash)

# Verify the signature
is_valid = Nosnos.verify(public_key, message_hash, signature)

Nostr Event Operations

# Sign a Nostr event
secret_key = :crypto.strong_rand_bytes(32)
timestamp = :os.system_time(:second)
content = "Hello from Elixir!"
tags = "[]"  # JSON string

event = Nosnos.sign_event(secret_key, timestamp, 1, tags, content)
# => %{
#   id: "356faddb...",
#   pubkey: "132fc0db...",
#   created_at: 1700000000,
#   kind: 1,
#   tags: "[]",
#   content: "Hello from Elixir!",
#   sig: "fb8f88a9..."
# }

# Verify a Nostr event
is_valid = Nosnos.verify_event(event)

⬇️ Install

Prerequisites

Add to your project

Add nosnos to your list of dependencies in mix.exs:

def deps do
  [
    {:nosnos, "~> 0.1.0"}
  ]
end

Then run:

mix deps.get
mix compile

From source

git clone https://github.com/Comamoca/nosnos.git
cd nosnos
mix deps.get
mix test

⛏️ Development

Using Nix (Recommended)

This project uses Nix flakes for reproducible development environments:

# Enter the development shell
nix develop

# Or use direnv (if .envrc is configured)
direnv allow

The Nix environment includes:

Manual Setup

# Install dependencies
mix deps.get

# Run tests
mix test

# Format code
mix format

📜 License

MIT License

💕 Special Thanks