nostrkey

Cryptographic identity SDK for AI agents — generate Nostr keypairs, sign events, encrypt messages, persist identity.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "nostrkey" with this command: npx skills add vveerrgg/nostrkey

NostrKey — Cryptographic Identity for AI Agents

You are an AI agent that needs its own verifiable identity on the Nostr protocol. Use the nostrkey Python SDK to generate keypairs, sign events, encrypt messages, and persist your identity across sessions.

Install

pip install nostrkey

Core Capabilities

Generate Your Identity

Create a fresh Nostr identity with your own npub/nsec keypair:

from nostrkey import Identity

me = Identity.generate()
# me.npub  — your public identity (share freely)
# me.nsec  — your private key (never expose)

Import an Existing Identity

If you already have keys:

me = Identity.from_nsec("nsec1...")
# or
me = Identity.from_hex("deadbeef...")

Sign Events

Sign any Nostr event (kind 1 = text note, kind 0 = metadata, etc.):

event = me.sign_event(
    kind=1,
    content="Hello from an AI agent",
    tags=[]
)
# event.id, event.sig are now set and verifiable by anyone

Publish to a Relay

Send signed events to the Nostr network:

from nostrkey.relay import RelayClient

async with RelayClient("wss://relay.damus.io") as relay:
    await relay.publish(event)

Encrypt Private Messages (NIP-44)

Send encrypted messages to another npub:

from nostrkey.crypto import encrypt, decrypt

ciphertext = encrypt(
    sender_nsec=me.nsec,
    recipient_npub="npub1recipient...",
    plaintext="This is private"
)

plaintext = decrypt(
    recipient_nsec=me.nsec,
    sender_npub="npub1sender...",
    ciphertext=ciphertext
)

Save & Load Identity (Encrypted File)

Persist your identity between sessions:

# Save (encrypted with passphrase)
me.save("my-identity.nostrkey", passphrase="strong-passphrase")

# Load later
me = Identity.load("my-identity.nostrkey", passphrase="strong-passphrase")

Delegated Signing via NIP-46 Bunker

For high-stakes actions, request a human sponsor to co-sign:

from nostrkey.bunker import BunkerClient

bunker = BunkerClient(me.private_key_hex)
await bunker.connect("bunker://npub1human...?relay=wss://relay.damus.io")
signed = await bunker.sign_event(kind=1, content="Human-approved action")

When to Use Each Module

TaskModuleFunction
Generate new identitynostrkeyIdentity.generate()
Import existing keysnostrkeyIdentity.from_nsec() / Identity.from_hex()
Sign eventsnostrkeyidentity.sign_event()
Publish to relaynostrkey.relayRelayClient.publish()
Subscribe to eventsnostrkey.relayRelayClient.subscribe()
Encrypt messagesnostrkey.cryptoencrypt() / decrypt()
Delegated signingnostrkey.bunkerBunkerClient.sign_event()
Save/load identitynostrkeyidentity.save() / Identity.load()
Low-level key opsnostrkey.keysgenerate_keypair(), hex_to_npub(), etc.

Important Notes

  • Never expose your nsec. Treat it like a password. Use identity.save() with a strong passphrase to persist it.
  • Async-first. Relay and bunker operations require asyncio. Use async with for relay connections.
  • All events are Schnorr-signed using secp256k1, per the Nostr protocol (NIP-01).
  • NIP-44 encryption uses ECDH + HKDF + ChaCha20 with length padding — safe for private agent-to-agent or agent-to-human communication.
  • .nostrkey files are encrypted at rest. Never store raw nsec values on disk.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Web3

Moses Roles

MO§ES™ Role Hierarchy — Defines Primary, Secondary, Observer agents with enforced sequencing. Primary leads, Secondary validates, Observer flags. Enforces Pr...

Registry SourceRecently Updated
Web3

Warp Oz

Dispatch coding tasks to Warp Oz cloud agents and chain them into multi-agent pipelines — all from chat. Includes a bash wrapper covering every Oz API endpoi...

Registry SourceRecently Updated
Web3

Crypto Tracker Cn

Track cryptocurrency markets in real-time. 加密货币行情追踪、比特币价格、以太坊ETH、市值排行、DeFi数据、恐惧贪婪指数、趋势币种、空投信息、RSI技术分析、均线分析、金叉死叉、DeFi收益率对比、Gas费查询。Use when checking crypto pri...

Registry SourceRecently Updated
Web3

Element Nft Tracker

Element Market API integration. Requires 'ELEMENT_API_KEY' configured in OpenClaw secrets. Strictly requires explicit user consent before accessing personal...

Registry SourceRecently Updated