Skip to content

Commit

Permalink
generate agent
Browse files Browse the repository at this point in the history
  • Loading branch information
melvincarvalho committed Dec 7, 2024
1 parent 0834f8a commit d4d1290
Show file tree
Hide file tree
Showing 2 changed files with 244 additions and 0 deletions.
26 changes: 26 additions & 0 deletions bin/create-agent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node

// Use nostr-tools to generate secure keypair
import { generateSecretKey, getPublicKey } from 'nostr-tools/pure';

// Generate cryptographically secure private key (32 bytes)
const privkey = generateSecretKey();

// Convert Uint8Array to hex string
const privkeyHex = Array.from(privkey)
.map(b => b.toString(16).padStart(2, '0'))
.join('');

// Derive public key using Schnorr signatures (32 bytes, hex encoded)
const pubkey = getPublicKey(privkey);

// Cool console message
console.error('\x1b[36m%s\x1b[0m', '🤖 Creating new agent...');
console.error('\x1b[33m%s\x1b[0m', '⚠️ Keep your private key secret!');
console.error('');

// Output JSON with both keys
console.log(JSON.stringify({
privkey: privkeyHex,
pubkey: pubkey
}, null, 2));
218 changes: 218 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d4d1290

Please sign in to comment.