hd

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Secp256k1Type uses the Bitcoin secp256k1 ECDSA parameters.
	Secp256k1Type = PubKeyType("secp256k1")
	// Ed25519Type represents the Ed25519Type signature system.
	// It is currently not supported for end-user keys (wallets/ledgers).
	Ed25519Type = PubKeyType("ed25519")
	// Sr25519Type represents the Sr25519Type signature system.
	Sr25519Type = PubKeyType("sr25519")

	// Sm2Type represents the Sm2Type signature system.
	Sm2Type = PubKeyType("sm2")
)
View Source
const (
	BIP44Prefix = "44'/118'/"
	PartialPath = "0'/0/0"
	FullPath    = BIP44Prefix + PartialPath
)

Variables

View Source
var (
	// Secp256k1 uses the Bitcoin secp256k1 ECDSA parameters.
	Secp256k1 = secp256k1Algo{}
	Sm2       = sm2Algo{}
)

Functions

func ComputeMastersFromSeed

func ComputeMastersFromSeed(seed []byte) (secret [32]byte, chainCode [32]byte)

ComputeMastersFromSeed returns the master public key, master secret, and chain code in hex.

func DerivePrivateKeyForPath

func DerivePrivateKeyForPath(privKeyBytes [32]byte, chainCode [32]byte, path string) ([32]byte, error)

DerivePrivateKeyForPath derives the private key by following the BIP 32/44 path from privKeyBytes, using the given chainCode.

Types

type BIP44Params

type BIP44Params struct {
	Purpose      uint32 `json:"purpose"`
	CoinType     uint32 `json:"coinType"`
	Account      uint32 `json:"account"`
	Change       bool   `json:"change"`
	AddressIndex uint32 `json:"addressIndex"`
}

type DeriveFn

type DeriveFn func(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error)

type GenerateFn

type GenerateFn func(bz []byte) crypto.PrivKey

type PubKeyType

type PubKeyType string

PubKeyType defines an algorithm to derive key-pairs which can be used for cryptographic signing.

type SignatureAlgo

type SignatureAlgo interface {
	Name() PubKeyType
	Derive() DeriveFn
	Generate() GenerateFn
}

func NewSigningAlgoFromString

func NewSigningAlgoFromString(str string) (SignatureAlgo, error)

type WalletGenerator

type WalletGenerator interface {
	Derive(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error)
	Generate(bz []byte) crypto.PrivKey
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL