-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0834f8a
commit d4d1290
Showing
2 changed files
with
244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.