Skip to content

Commit 19b5eae

Browse files
committed
feat: implement nse-dev Python package with full test suite (27 tests)
Pure Python: cryptography lib for AES-256-GCM + secp256k1 for Schnorr signing. Bech32 npub encoding. MemoryStorage + FileStorage backends. Generate/sign/verify round-trips, kind 0 support, wrong-key rejection, blob security. pyproject.toml ready for PyPI.
1 parent 57192fe commit 19b5eae

6 files changed

Lines changed: 715 additions & 66 deletions

File tree

platforms/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
dist/
3+
*.tsbuildinfo
4+
.pytest_cache/
5+
__pycache__/
6+
*.egg-info/
7+
build/
8+
*.pyc

platforms/python/pyproject.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[build-system]
2+
requires = ["setuptools>=68.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "nse-dev"
7+
version = "0.1.0"
8+
description = "Nostr Secure Enclave — server-side key management for AI entities, bots, and backend services"
9+
readme = "README.md"
10+
license = {text = "MIT"}
11+
requires-python = ">=3.10"
12+
authors = [
13+
{name = "Humanjava Enterprises"}
14+
]
15+
keywords = ["nostr", "secure-enclave", "key-management", "cryptography", "secp256k1"]
16+
classifiers = [
17+
"Development Status :: 3 - Alpha",
18+
"Intended Audience :: Developers",
19+
"License :: OSI Approved :: MIT License",
20+
"Programming Language :: Python :: 3",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
"Topic :: Security :: Cryptography",
25+
]
26+
dependencies = [
27+
"cryptography>=42.0",
28+
"secp256k1>=0.14.0",
29+
]
30+
31+
[project.optional-dependencies]
32+
dev = [
33+
"pytest>=8.0",
34+
"pytest-asyncio>=0.24",
35+
]
36+
37+
[project.urls]
38+
Homepage = "https://nse.dev"
39+
Repository = "https://github.com/HumanjavaEnterprises/nse-dev.web.landingpage.src"
40+
41+
[tool.setuptools.packages.find]
42+
where = ["src"]
Lines changed: 15 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,20 @@
11
"""
22
nse-dev — Nostr Secure Enclave for Python
3+
34
Server-side key management for AI entities, bots, and backend services.
5+
AES-256-GCM key wrapping for secp256k1 Nostr keys.
46
"""
57

6-
from dataclasses import dataclass
7-
from typing import Optional
8-
9-
10-
@dataclass
11-
class KeyInfo:
12-
pubkey: str
13-
npub: str
14-
created_at: int
15-
hardware_backed: bool
16-
17-
18-
@dataclass
19-
class NostrEvent:
20-
kind: int
21-
content: str
22-
tags: list[list[str]]
23-
created_at: int
24-
25-
26-
@dataclass
27-
class SignedEvent:
28-
id: str
29-
pubkey: str
30-
sig: str
31-
kind: int
32-
content: str
33-
tags: list[list[str]]
34-
created_at: int
35-
36-
37-
class NSE:
38-
"""Nostr Secure Enclave — Python implementation"""
39-
40-
def __init__(self, master_key: str):
41-
"""
42-
Args:
43-
master_key: AES-256 master key (hex string) for encrypting secp256k1 key at rest
44-
"""
45-
self._master_key = master_key
46-
47-
async def generate(self) -> KeyInfo:
48-
"""Generate a new secp256k1 keypair, encrypted at rest with AES-GCM"""
49-
# TODO: Phase 6 implementation
50-
raise NotImplementedError("Not yet implemented")
51-
52-
async def sign(self, event: NostrEvent) -> SignedEvent:
53-
"""Decrypt key, Schnorr sign, zero memory"""
54-
# TODO: Phase 6 implementation
55-
raise NotImplementedError("Not yet implemented")
56-
57-
async def get_public_key(self) -> str:
58-
"""Get the hex pubkey"""
59-
raise NotImplementedError("Not yet implemented")
60-
61-
async def get_npub(self) -> str:
62-
"""Get the bech32 npub"""
63-
raise NotImplementedError("Not yet implemented")
64-
65-
async def exists(self) -> bool:
66-
"""Check if a key exists in storage"""
67-
raise NotImplementedError("Not yet implemented")
68-
69-
async def destroy(self) -> None:
70-
"""Wipe all key material"""
71-
raise NotImplementedError("Not yet implemented")
8+
from nse.core import NSE, NSEError, NSEErrorCode, KeyInfo, SignedEvent, NostrEvent
9+
from nse.storage import MemoryStorage
10+
11+
__version__ = "0.1.0"
12+
__all__ = [
13+
"NSE",
14+
"NSEError",
15+
"NSEErrorCode",
16+
"KeyInfo",
17+
"SignedEvent",
18+
"NostrEvent",
19+
"MemoryStorage",
20+
]

0 commit comments

Comments
 (0)