@signedby/sdk 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +79 -35
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # SIGNEDBYME TypeScript SDK
2
2
 
3
- Self-signing digital signatures with zero-knowledge proofs.
3
+ Human-Controlled Identity for Autonomous Agents
4
+
5
+ ## What is SIGNEDBYME?
6
+
7
+ SIGNEDBYME is the identity layer for autonomous agents. Agents prove membership in enterprise-authorized groups using Groth16 zero-knowledge proofs — without revealing which agent they are. The enterprise gets a boolean: authorized. No identity revealed.
8
+
9
+ This SDK enables agents to generate cryptographic identity, produce zero-knowledge proofs, and authenticate to enterprises via NOSTR and OIDC.
4
10
 
5
11
  ## Installation
6
12
 
@@ -13,46 +19,82 @@ yarn add @signedby/sdk
13
19
  ## Quick Start
14
20
 
15
21
  ```typescript
16
- import { SignedByAgent, SignedByClient } from '@signedby/sdk';
17
-
18
- // Initialize agent
19
- const agent = await SignedByAgent.init({
20
- storagePath: './agent_data'
21
- });
22
-
23
- // Set email mapping for enterprises
24
- agent.setEmailMapping({
25
- 'example.com': 'user@example.com'
26
- });
27
-
28
- // Connect to SIGNEDBYME relays
29
- await agent.connectRelays();
30
-
31
- // Watch for authorization requests
32
- for await (const authRequest of agent.watchForAuthorizations()) {
33
- console.log(`Authorization from ${authRequest.enterprise}`);
34
- }
35
-
36
- // Authenticate
37
- const client = new SignedByClient('https://api.signedbyme.com');
38
- const token = await client.authenticate({
39
- clientId: 'example',
40
- proof: await agent.generateProof()
41
- });
42
- console.log(`Authenticated: ${token.sub}`);
22
+ import {
23
+ AgentIdentity,
24
+ EncryptedFileStorage,
25
+ MembershipProver,
26
+ NostrClient
27
+ } from '@signedby/sdk';
28
+
29
+ // Initialize secure storage
30
+ const storage = new EncryptedFileStorage('./agent_data');
31
+
32
+ // Create agent identity (one-time setup)
33
+ const identity = new AgentIdentity(storage);
34
+ const state = await identity.initialize();
35
+
36
+ console.log(`Agent npub: ${state.agentNpub}`);
37
+ console.log(`Leaf commitment: ${state.leafCommitment}`);
38
+
39
+ // Generate Groth16 proof for authentication
40
+ const prover = MembershipProver.fromCircuitsDir('./circuits');
41
+
42
+ const leafSecret = identity.getLeafSecret();
43
+ const witness = await loadWitness(storage, 'acme');
44
+
45
+ const proof = await prover.generateProof(leafSecret, witness);
46
+ console.log(`Proof generated in ${proof.proofTimeMs}ms`);
47
+
48
+ // Publish proof to NOSTR
49
+ const client = await NostrClient.connect(identity);
50
+ await client.publishProofEvent(proofData);
43
51
  ```
44
52
 
45
53
  ## Features
46
54
 
47
- - **Agent Management**: DID generation, secure storage
48
- - **Groth16 ZK Proofs**: Native Rust core via napi-rs
49
- - **NOSTR Integration**: Automatic relay management
50
- - **OIDC Compatible**: Standard JWT id_tokens
55
+ - **DID Generation**: secp256k1 keypair in secure storage (OS keyring, Keychain, DPAPI), never extractable
56
+ - **Groth16 ZK Proofs**: BN254 curve, ~101K constraints, <3s on ARM64 via native Rust core (napi-rs)
57
+ - **Bitcoin-Backed**: Identity fused with Lightning payment at creation via NWC (NIP-47)
58
+ - **NOSTR Integration**: Publish kinds 28101 (proof), 28102 (delegation ack), 28103 (revocation ack); poll for kinds 28200/28250/28251; NIP-42 relay authentication; decentralized audit trail on public relays
59
+ - **Witness Caching**: Merkle path cached locally, auto-refresh when root rotates out of 30-root window
60
+
61
+ ## Modules
62
+
63
+ | Export | Purpose |
64
+ |--------|---------|
65
+ | `AgentIdentity` | DID generation, leaf_secret derivation |
66
+ | `EncryptedFileStorage` | Encrypted storage with OS keyring (ChaCha20-Poly1305) |
67
+ | `MembershipProver` | Groth16 proof generation via native Rust |
68
+ | `NostrClient` | NOSTR relay client with NIP-42 auth |
69
+ | `EnrollmentBootstrap` | Three-gate genesis flow |
70
+ | `DelegationValidator` | Delegation validation (kind 28250/28251) |
71
+ | `NwcWallet` | NWC wallet integration (NIP-47) |
72
+
73
+ ## SDK Lifecycle
74
+
75
+ ### One-Time Initialization
76
+ 1. Generate DID in secure storage
77
+ 2. Derive leaf_secret (5 BN254 field elements)
78
+ 3. Compute leaf_commitment = Poseidon2(leaf_secret)
79
+ 4. Load Groth16 proving key (~88MB)
80
+ 5. Initialize NWC wallet for Lightning
81
+
82
+ ### Enrollment per Enterprise
83
+ Three-gate genesis flow — runs once per enterprise:
84
+ - **Gate 1**: Email + token verification via kind 28202
85
+ - **Gate 2**: Human signs kind 28250 delegation
86
+ - **Gate 3**: Leaf appended to Merkle tree
87
+
88
+ ### Authentication
89
+ 1. Generate Groth16 proof from leaf_secret + cached witness
90
+ 2. Publish kind 28101 to NOSTR
91
+ 3. Enterprise validates and calls API
92
+ 4. Agent receives OIDC id_token
51
93
 
52
94
  ## Requirements
53
95
 
54
96
  - Node.js 18+
55
- - Platform-specific native bindings (included)
97
+ - Native libraries bundled for supported platforms
56
98
 
57
99
  ## Supported Platforms
58
100
 
@@ -64,11 +106,13 @@ console.log(`Authenticated: ${token.sub}`);
64
106
 
65
107
  ## Documentation
66
108
 
67
- Full documentation: [https://docs.signedbyme.com](https://docs.signedbyme.com)
109
+ - [SDK Quick Start](https://signedbyme.com/docs/sdk-quickstart.html)
110
+ - [API Reference](https://signedbyme.com/docs/api-reference.html)
111
+ - [Understanding Delegation](https://signedbyme.com/docs/delegation.html)
68
112
 
69
113
  ## License
70
114
 
71
- SSAL-1.0 (SignedByMe Source-Available License)
115
+ SSAL-1.0 (SIGNEDBYME Source-Available License)
72
116
 
73
117
  ## Links
74
118
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@signedby/sdk",
3
- "version": "1.0.0",
4
- "description": "SIGNEDBYME SDK - Human-controlled identity for autonomous agents",
3
+ "version": "1.0.1",
4
+ "description": "SIGNEDBYME SDK - Human-Controlled Identity for Autonomous Agents",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",