Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crypto HDWallet

Small utility for Go crypto projects.

Historically, ECDSA key derivation for secp256k has been available through btcd, but the ecosystem has been lacking good support for ed25519 key derivation.

This library adds support for both, which should allow Go projects to support key derivation for most blockchain protocols out there.

Usage example

EVM

package main

import (
	"crypto/ed25519"
	"encoding/hex"
	"log"

	"github.com/martinbechtle/hdwallet"
)

func main() {
	mnemonic := "elder sign digital common crumble else express festival menu surge price lawsuit"
	wallet, err := hdwallet.NewWalletFromMnemonic(mnemonic, "")
	if err != nil {
		log.Fatal(err)
	}
	derivedKey, err := wallet.DeriveECDSA(hdwallet.EvmDefaultDerivationPath)
	if err != nil {
		log.Fatal(err)
	}
	log.Println(hex.EncodeToString(derivedKey.D.Bytes()))
}

You can then get the public portion of the key and use ethereum-specific libraries to infer the address and produce signatures.

Solana

derivedKey, err := wallet.DeriveEd25519(hdwallet.SolanaDefaultDerivationPath)
if err != nil {
    log.Fatal(err)
}
log.Println(hex.EncodeToString(derivedKey))

About

hdwallet implementation for several crypto protocols

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages