Skip to content

PortalTechnologiesInc/nostr-key-merge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nostr Key Merge

A CLI tool for reconstructing full private keys from split-key vanity generation. This tool combines your existing private key with a partial private key generated by vanity search tools to create a functional vanity address.

Overview

This tool implements the key reconstruction algorithm used in split-key vanity address generation. It takes:

  1. Your existing private key (read securely from stdin)
  2. A vanity prefix and partial private key
  3. Reconstructs the full private key for the vanity address

Installation

From crates.io

cargo install nostr-key-merge

Building from source

cargo build --release

Using Nix

nix run github:PortalTechnologiesInc/nostr-key-merge

Usage

If you installed via crates.io or Nix:

nostr-key-merge --prefix <vanity_prefix> --partialpriv <partial_private_key>

If you built from source:

cargo run -- --prefix <vanity_prefix> --partialpriv <partial_private_key>

Arguments

  • -p, --prefix: Vanity prefix to match (e.g., "test" for npub1test...) - Required
  • -s, --partialpriv: Partial private key from vanity generation - Required

Note: Your private key is read from stdin for security (not stored in command history)

Example

# Reconstruct a vanity key for prefix "test"
nostr-key-merge \
  --prefix npub1test \
  --partialpriv L4C9a6zWJa9pD2xT3DY3qQEpuyNakevJhwxqKoZNcDSWALk6tKTh

# You'll be prompted to enter your private key:
# Enter your private key (hex, WIF, or nsec format):
# nsec1abc123def456...

Private Key Formats Supported

  • Hex: a1b2c3d4e5f6... (64 character hex string)
  • WIF: 5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hS (Bitcoin WIF format)
  • Nsec: nsec1abc123... (Nostr bech32 format)

Example Output

Enter your private key (hex, WIF, or nsec format):
nsec1abc123def456...

Successfully reconstructed key for prefix: test
Public Key (npub): npub1testxxx...
Private Key (hex): a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789a
Private Key (nsec): nsec1abc123def456789abcdef0123456789abcdef0123456789abcdef0123456
Public Key (hex): 02abc123def456789...

Security Features

  • Stdin input: Private keys are read from stdin, not command-line arguments
  • No command history: Your private key won't appear in shell history
  • Memory safety: Rust's memory management helps prevent key leakage
  • Multiple formats: Supports secure key formats (nsec, WIF, hex)

How It Works

The tool implements the same reconstruction algorithm as VanitySearch's split-key functionality:

  1. Securely read your private key from stdin
  2. Generate target prefix pattern (npub1 + your prefix)
  3. Try different combinations using elliptic curve operations:
    • No symmetry, no endomorphism
    • No symmetry, endomorphism λ
    • No symmetry, endomorphism λ²
    • Symmetry, no endomorphism
    • Symmetry, endomorphism λ
    • Symmetry, endomorphism λ²
  4. Verify reconstruction by checking if the generated public key matches the prefix pattern

Workflow with Vanity Bot

  1. Request vanity key from the bot: npub1test
  2. Bot replies publicly with:
    Public Key: npub1testxxx...
    Partial Private Key: L4C9a6zWJa9pD2xT3DY3qQEpuyNakevJhwxqKoZNcDSWALk6tKTh
    
  3. Reconstruct using this tool:
    nostr-key-merge --prefix test --partialpriv L4C9a6zWJa9pD2xT3DY3qQEpuyNakevJhwxqKoZNcDSWALk6tKTh
  4. Use the reconstructed nsec in your Nostr client

Security Notes

  • Keep your private keys secure: Never share your main private key
  • Use stdin input: Prevents keys from appearing in command history
  • Verify results: Always test reconstructed keys in a safe environment first
  • Clean up: Clear terminal history after use if needed
  • Backup important keys: Store reconstructed keys securely

Dependencies

  • secp256k1: Elliptic curve operations
  • bitcoin: Base58 and WIF key handling
  • nostr: Nostr key format support (nsec/npub encoding/decoding)
  • clap: Command-line parsing
  • anyhow: Error handling

About

Merge nostr vanity split-keys

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published