Skip to content

Commit 71cbfbb

Browse files
committed
docs: sanitized public CLAUDE.md (working context moved to private bizdocs)
1 parent 977a7bc commit 71cbfbb

1 file changed

Lines changed: 20 additions & 68 deletions

File tree

CLAUDE.md

Lines changed: 20 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,26 @@
1-
# CLAUDE.md — nostrkey.app.OC-python.src
1+
# CLAUDE.md — nostrkey
22

3-
## What This Is
4-
Open-source Python SDK for OpenClaw AI entities to generate and manage their own Nostr cryptographic identities. The Python equivalent of the NostrKey browser extension — but for bots.
3+
## What this is
4+
Nostr identity SDK for OpenClaw AI agents — generate keys, sign events, encrypt data, run a NIP-46 bunker. Part of the open-source OpenClaw Nostr toolkit. MIT licensed.
55

6-
## Ecosystem Position
7-
NostrKey (browser extension) is for humans. This SDK is for AI entities (OpenClaw bots) that need their own npub/nsec keypairs, event signing, encryption, and optionally NIP-46 bunker delegation to a human sponsor.
6+
## Install
7+
```
8+
pip install nostrkey
9+
```
810

9-
## Package Name
10-
`nostrkey` on PyPI — `pip install nostrkey`
11+
## Develop
12+
```
13+
python -m venv .venv && . .venv/bin/activate
14+
pip install -e ".[dev]"
15+
python -m pytest -q # tests
16+
python -m build # sdist + wheel
17+
```
1118

12-
## Current Version
13-
v0.3.4 — **staged, pending PyPI/ClawHub publish.** Kernel of the coordinated 2026-07 correctness release: NIP-46 bunker `connect()` correctness + timeouts, canonical NIP-44 v2 unpad, resolved-DNS SSRF guard, and official NIP-06 known-answer test vectors. Zero C dependencies. Ships the shared KAT vector spine (NIP-44 v2 / NIP-49 / NIP-19 TLV / BIP-340) the rest of the family verifies against.
14-
15-
(Prior: v0.2.0 published on PyPI and ClawHub 2026-03-17, red-team audited, 49 tests.)
16-
17-
## Module Structure
18-
- `nostrkey.identity` — high-level OpenClaw identity management (generate, store, load)
19-
- `nostrkey.keys` — keypair generation, bech32 encoding (npub/nsec), hex conversion, private key validation
20-
- `nostrkey.events` — create, serialize, hash, and sign Nostr events (BIP-340 Schnorr)
21-
- `nostrkey.crypto` — NIP-44 encryption/decryption (ECDH + HKDF + ChaCha20, spec-compliant padding)
22-
- `nostrkey.bunker` — NIP-46 bunker client for delegated signing to a human's NostrKey
23-
- `nostrkey.relay` — WebSocket relay client (publish events, subscribe to filters, SSRF protection)
24-
- `nostrkey._secp256k1` — BIP-340 Schnorr + ECDH via `cryptography` package (internal)
25-
- `nostrkey._chacha20` — Pure-Python ChaCha20 for NIP-44 (internal)
26-
27-
## Key Design Decisions
28-
- Zero C dependencies — uses `cryptography` package (ships binary wheels for all platforms)
29-
- Replaced `secp256k1` C binding with `_secp256k1.py` using `cryptography`'s EC primitives + pure-Python BIP-340 Schnorr (2026-03-17)
30-
- Identity files use ChaCha20-Poly1305 AEAD (v3 format), backward-compatible with v2 (XOR + HMAC)
31-
- v1 identity files no longer supported (unauthenticated)
32-
- Async-first API (asyncio) for relay and bunker operations
33-
- Type hints throughout
34-
- MIT licensed, open source
35-
36-
## Dependencies
37-
- `cryptography>=42.0,<45.0` — ECDH, ChaCha20-Poly1305, key generation (OpenSSL-backed, binary wheels)
38-
- `websockets>=12.0,<15.0` — relay and bunker WebSocket connections
39-
- `bech32>=1.2.0,<2.0` — npub/nsec encoding
40-
41-
## Security (v0.2.0 red team, 2026-03-17)
42-
15 findings fixed from Tavin's red team + independent audit:
43-
- ChaCha20-Poly1305 AEAD for identity files (PBKDF2 600K iterations)
44-
- NIP-44 spec-compliant ECDH (raw x-coordinate) and padding
45-
- Private key range validation (reject zero, >= N)
46-
- Relay SSRF protection (blocks localhost, private IPs, reserved addresses)
47-
- Path traversal protection on identity save/load
48-
- Bunker response pubkey verification
49-
- secrets.token_bytes() for all randomness
50-
- Log scrubbing (no key material in logs)
51-
- Best-effort key zeroing (Identity.wipe())
52-
- Dataclass fields repr=False
19+
## Layout
20+
- `src/nostrkey/` — package source
21+
- `tests/` — pytest suite
22+
- `clawhub/` — ClawHub skill metadata (SKILL.md, metadata.json)
5323

5424
## Conventions
55-
- kebab-case for file names in docs/config, snake_case for Python modules
56-
- Tests in `tests/` using pytest (49 tests across 5 files)
57-
- Examples in `examples/`
58-
- ClawHub skill definition in `clawhub/` (SKILL.md + metadata.json)
59-
- No cryptocurrency/token functionality — identity only
60-
- After code changes: run `python3 -m pytest tests/ -v` before committing
61-
62-
## ClawHub Skill
63-
The `clawhub/` directory contains the OpenClaw skill bundle for publishing to ClawHub. Keep `metadata.json` version in sync with `pyproject.toml` version on each release. The `SKILL.md` is the agent-facing instruction set — it should reflect the current public API.
64-
65-
**Published:** `nostrkey@0.2.0` on ClawHub (2026-03-17). Install via `clawhub install nostrkey`.
66-
**Publish command:** `npx clawhub publish ./clawhub --slug nostrkey --name "NostrKey" --version X.Y.Z --tags latest --changelog "..."`
67-
**Important:** The CLI is `npx clawhub` (npm package), NOT the Python `clawhub` package. Must `npx clawhub login` first (GitHub auth). ClawHub rejects re-publishing existing versions — always bump.
68-
**Examples:** `clawhub/examples/` — generate_and_post.py, encrypt_dm.py, delegated_signing.py
69-
70-
## Related Repos
71-
- `nostrkey.browser.plugin.src` — NostrKey browser extension (JS, the human equivalent)
72-
- `nostr-crypto-utils` — TypeScript crypto library (reference implementation for crypto operations)
73-
- `loginwithnostr.web.landingpage.src` — Landing page, `/openclaw` route references this SDK
74-
- Docs page: `nostrkey.com/python` (in `nostrkey.browser.plugin.src/docs/python.html`)
25+
- Python + pyproject (hatchling). Pure-Python crypto (`cryptography`), zero native build deps.
26+
- Public, MIT-licensed, open source.

0 commit comments

Comments
 (0)