Skip to content

caarloshenriq/keyforge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KeyForge

KeyForge is a simple command-line tool written in Go for generating BIP32 master keys (xprv and xpub) from either:

  • a secure random seed (64 bytes), or
  • a BIP39 mnemonic phrase (24 words)

This project is educational and meant to help developers understand how hierarchical deterministic wallets work at the base level.


📦 Features

  • 🔐 Generate a secure 64-byte seed
  • 🧠 Generate a 24-word BIP39 mnemonic (optional)
  • 🧬 Derive BIP32 master keys (xprv and xpub)
  • 🛠️ Compatible with Bitcoin Mainnet

🛠️ Installation

Make sure you have Go installed (go1.20 or newer).

Clone the repo and install dependencies:

git clone https://github.com/caarloshenriq/keyforge.git
cd keyforge
go mod tidy

🚀 Usage

1. Default: generate using BIP39 mnemonic

go run .

This will:

  • Generate 24-word mnemonic (BIP39)
  • Derive seed from it
  • Derive BIP32 master key (xprv) and its public version (xpub)

2. Generate using only raw seed (no mnemonic)

go run . --mnemonic=false

This will:

  • Generate a 64-byte random seed
  • Derive BIP32 master key from it

📂 Project Structure

keyforge/
├── main.go          # Entry point with CLI logic
├── bip39.go         # Handles mnemonic and seed generation
├── bip32.go         # Handles xprv/xpub derivation
├── network.go       # Defines Bitcoin MainNet key prefixes
├── go.mod

📚 Standards Used

  • BIP32 – HD wallet key derivation
  • BIP39 – Mnemonic generation
  • Uses hdkeychain/v3 (Decred fork) for robust BIP32 support

✅ Example Output

🔐 Generated Mnemonic:
banana sport nominee harbor foster bulb ...

🧬 Generated Seed (hex):
54d2f1c3f7...

🔑 xprv:
xprv9s21ZrQ...

🔓 xpub:
xpub661MyMw...

⚠️ Warning

This tool is for educational and development purposes only. Do not use the generated keys to store real funds without proper auditing and secure entropy sources.


📄 License

MIT License

About

A simple CLI tool for generating BIP32 master keys.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages