Metadata-Version: 2.4
Name: nostrkey
Version: 0.1.0
Summary: Nostr identity SDK for OpenClaw AI entities — generate keys, sign events, encrypt data
Project-URL: Homepage, https://loginwithnostr.com/openclaw
Project-URL: Repository, https://github.com/HumanjavaEnterprises/nostrkey.app.OC-python.src
Project-URL: Documentation, https://loginwithnostr.com/openclaw
Author-email: Humanjava Enterprises <dev@humanjava.com>
License-Expression: MIT
License-File: LICENSE
Keywords: ai,cryptography,identity,nostr,nostrkey,openclaw
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: bech32>=1.2.0
Requires-Dist: secp256k1>=0.14.0
Requires-Dist: websockets>=12.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Description-Content-Type: text/markdown

# NostrKey for OpenClaw

**Give your AI its own cryptographic identity.**

A Python SDK for OpenClaw AI entities to generate Nostr keypairs, sign events, encrypt data, and manage their own sovereign identity on the Nostr protocol.

## Install

```bash
pip install nostrkey
```

## Quick Start

```python
from nostrkey import Identity

# Create a new AI identity
bot = Identity.generate()
print(f"npub: {bot.npub}")
print(f"nsec: {bot.nsec}")

# Sign a Nostr event
event = bot.sign_event(
    kind=1,
    content="Hello from an OpenClaw bot!",
    tags=[]
)

# Publish to a relay
import asyncio
from nostrkey.relay import RelayClient

async def publish():
    async with RelayClient("wss://relay.nostrkeep.com") as relay:
        await relay.publish(event)

asyncio.run(publish())
```

## Save & Load Identity

```python
# Save identity to file (encrypted)
bot.save("my-bot.nostrkey", passphrase="strong-passphrase")

# Load it back
bot = Identity.load("my-bot.nostrkey", passphrase="strong-passphrase")
```

## NIP-44 Encryption

```python
from nostrkey.crypto import encrypt, decrypt

# Encrypt a message to another npub
ciphertext = encrypt(
    sender_nsec=bot.nsec,
    recipient_npub="npub1abc...",
    plaintext="secret message"
)

# Decrypt a message
plaintext = decrypt(
    recipient_nsec=bot.nsec,
    sender_npub="npub1abc...",
    ciphertext=ciphertext
)
```

## NIP-46 Bunker (Delegated Signing)

When your bot needs its human sponsor to co-sign:

```python
from nostrkey.bunker import BunkerClient

async def delegated_sign():
    bunker = BunkerClient(bot.nsec)
    await bunker.connect("bunker://npub1human...?relay=wss://relay.nostrkeep.com")

    # Request the human to sign an event
    signed = await bunker.sign_event(kind=1, content="Human-approved message")
```

## The OpenClaw Model

OpenClaw bots are sovereign AI entities with their own Nostr identities:

1. **Human sponsors the bot** — pays with credit card via NostrKey
2. **Bot gets its own npub** — generated with this SDK
3. **Bot signs its own events** — posts, DMs, interactions
4. **Bot stores data in NostrKeep** — encrypted, sovereign
5. **Human vouches annually** — CC renewal re-validates accountability

Learn more at [loginwithnostr.com/openclaw](https://loginwithnostr.com/openclaw)

## NIPs Implemented

| NIP | What | Status |
|-----|------|--------|
| NIP-01 | Basic protocol (events, signing) | Implemented |
| NIP-04 | Encrypted DMs (legacy) | Implemented |
| NIP-19 | bech32 encoding (npub/nsec/note) | Implemented |
| NIP-44 | Versioned encryption | Implemented |
| NIP-46 | Nostr Connect (bunker) | Implemented |

## Part of the Humanjava Ecosystem

- [NostrKey](https://nostrkey.com) — Browser extension + mobile app for humans
- [NostrKeep](https://nostrkeep.com) — Encrypted vault storage
- [npub.bio](https://npub.bio) — Human-readable identity pages
- [Login with Nostr](https://loginwithnostr.com) — Auth for any website

## License

MIT — Humanjava Enterprises Inc.
