Skip to main content

Nostr Secure Enclave — server-side key management for AI entities, bots, and backend services

Project description

nostr-secure-enclave

Python package for Nostr Secure Enclave. Server-side key management for AI entities, bots, and backend services.

Package: nostr-secure-enclave (PyPI)

Implementation

Pure Python using cryptography for AES-256-GCM + secp256k1 for Schnorr signing (BIP-340).

Use Cases

  • OpenClaw / AI entity identity
  • Bot process keypairs
  • Backend service identity
  • MCP tool server signing

API

import os
from nse import NSE, NostrEvent
from nse.storage import FileStorage

# Initialize with master key + persistent storage
nse = NSE(
    master_key=os.environ['NSE_MASTER_KEY'],
    storage=FileStorage('.nse'),
)

# Generate on first run
if not nse.exists():
    info = nse.generate()
    print(f"Identity: {info.npub}")

# Sign events
signed = nse.sign(NostrEvent(
    kind=1,
    content="Hello Nostr",
    tags=[],
    created_at=int(time.time()),
))

# Read identity (no unlock needed)
pubkey = nse.get_public_key()
npub = nse.get_npub()

# Wipe everything
nse.destroy()

Storage Backends

  • MemoryStorage — testing / ephemeral processes
  • FileStorage(directory) — persistent file storage

Security Notes

  • AES-256-GCM encryption with unique IV per operation
  • Best-effort memory zeroing after signing (bytearray.fill(0))
  • Python's GC may retain copies of key material — this is a documented limitation
  • hardware_backed is always False for Python keys (honest)

Status: Implemented (Phase 6) — 27 tests passing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nostr_secure_enclave-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nostr_secure_enclave-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file nostr_secure_enclave-0.1.0.tar.gz.

File metadata

  • Download URL: nostr_secure_enclave-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for nostr_secure_enclave-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8e05dfd746f88905443ee76e6cc16e44ffbdc657e7cc42ca4dc3a16f61f632bb
MD5 5d140cf73b6de8cb30946cabf9b0bd90
BLAKE2b-256 5da0ebd2f3f920d16c38abe68719db4a2cac5f9ca46837b7b67039d5e898499c

See more details on using hashes here.

File details

Details for the file nostr_secure_enclave-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nostr_secure_enclave-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1918c8b55052d118d118f6bdbd7d384e44bee5961e1e5a2ca19adfe7c717e7e5
MD5 0f5dee628b6708408212b606414f0d6d
BLAKE2b-256 8a046893940b56d27924d9a06b793d2c1ae8d50619e80469602129dfb781e8c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page