Skip to content

X-Vlad/go-bip39

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-bip39

Go Version License Status Go Reference

A golang implementation of the BIP39 spec for mnemonic seeds.

⚠️ Important Notice

This is a modernized fork of the original go-bip39 library by tyler-smith, which has been removed from GitHub.

Changes from the original

  • Fixed typos in error messages
  • Updated dependencies

Installation

go get github.com/X-Vlad/go-bip39

Migration from tyler-smith/go-bip39

Add this to your go.mod:

replace github.com/tyler-smith/go-bip39 => github.com/X-Vlad/go-bip39 v1.0.0

Usage

package main

import (
    "fmt"
    
    "github.com/X-Vlad/go-bip39"
    "github.com/X-Vlad/go-bip32"
)

func main() {
    // Generate a mnemonic for memorization or user-friendly seeds
    entropy, _ := bip39.NewEntropy(256)
    mnemonic, _ := bip39.NewMnemonic(entropy)

    // Generate a Bip32 HD wallet for the mnemonic and a user supplied password
    seed := bip39.NewSeed(mnemonic, "Secret Passphrase")

    masterKey, _ := bip32.NewMasterKey(seed)
    publicKey := masterKey.PublicKey()

    // Display mnemonic and keys
    fmt.Println("Mnemonic: ", mnemonic)
    fmt.Println("Master private key: ", masterKey)
    fmt.Println("Master public key: ", publicKey)
}

API Reference

Functions

  • NewEntropy(bitSize int) ([]byte, error) - Generate random entropy (bitSize must be 128-256, multiple of 32)
  • NewMnemonic(entropy []byte) (string, error) - Generate mnemonic words from entropy
  • NewSeed(mnemonic string, password string) []byte - Generate seed from mnemonic and password
  • NewSeedWithErrorChecking(mnemonic string, password string) ([]byte, error) - Same as NewSeed but validates mnemonic first
  • IsMnemonicValid(mnemonic string) bool - Check if mnemonic is valid
  • EntropyFromMnemonic(mnemonic string) ([]byte, error) - Extract entropy from mnemonic
  • MnemonicToByteArray(mnemonic string, raw ...bool) ([]byte, error) - Convert mnemonic to byte array

Word Lists

  • SetWordList(list []string) - Set custom word list
  • GetWordList() []string - Get current word list
  • GetWordIndex(word string) (int, bool) - Get word index in current word list

Supported Languages

The library includes word lists for multiple languages in the wordlists package:

  • English (default)
  • Japanese
  • Korean
  • Spanish
  • Chinese (Simplified & Traditional)
  • French
  • Italian
  • Czech

Testing

go test -v ./...

License

MIT License - see LICENSE for details.

Credits

Based on the original go-bip39 by tyler-smith.

Wordlists are from the BIP39 spec.

Test vectors are from the Trezor python-mnemonic implementation.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Donate

If this project was helpful, you can support development:

Network Address
BTC bc1q3l4jcnplvcmvqh26pfh3qdkrw4flqevemsfed8
ETH, BSC, ... (EVM) 0x49999CD2B8F7Bc9309e5929a79799eA55a17e6Ce
Tron TDxyjiittx9zzkHd25wmM12mvutTKBhZKS
Solana ahiiQWz9eRLpFRpEFSPf7See7J46YBFhMgsADNmGRgt
TON UQCfsCHBWq3_kD0D_mkfetuwIgACoSJ8YsYTZPKKkMprDlLD

About

Go implementation of BIP39 mnemonic seeds. Modernized fork of tyler-smith/go-bip39 with updated dependencies.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages