hd

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MultiType implies that a pubkey is a multisignature
	MultiType = PubKeyType("multi")
	// Secp256k1Type uses the Bitcoin secp256k1 ECDSA parameters.
	Secp256k1Type    = PubKeyType("secp256k1")
	EthSecp256k1Type = PubKeyType("eth_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")
)
View Source
const (
	BIP44Prefix = "m/44'/60'/"
	PartialPath = "0'/0/0"
	FullPath    = BIP44Prefix + PartialPath
)

Variables

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

Functions

func ComputeMastersFromSeed

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

ComputeMastersFromSeed returns the master secret key's, and chain code.

func DerivePrivateKeyForPath

func DerivePrivateKeyForPath(privKeyBytes, chainCode [32]byte, path string) ([]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"`
}

BIP44Params wraps BIP 44 params (5 level BIP 32 path). To receive a canonical string representation ala m / purpose' / coinType' / account' / change / addressIndex call String() on a BIP44Params instance.

func CreateHDPath

func CreateHDPath(coinType, account, index uint32) *BIP44Params

CreateHDPath returns BIP 44 object from account and index parameters.

func NewFundraiserParams

func NewFundraiserParams(account, coinType, addressIdx uint32) *BIP44Params

NewFundraiserParams creates a BIP 44 parameter object from the params: m / 44' / coinType' / account' / 0 / address_index The fixed parameters (purpose', coin_type', and change) are determined by what was used in the fundraiser.

func NewParams

func NewParams(purpose, coinType, account uint32, change bool, addressIdx uint32) *BIP44Params

NewParams creates a BIP 44 parameter object from the params: m / purpose' / coinType' / account' / change / addressIndex

func NewParamsFromPath

func NewParamsFromPath(path string) (*BIP44Params, error)

Parse the BIP44 path and unmarshal into the struct.

func (BIP44Params) DerivationPath

func (p BIP44Params) DerivationPath() []uint32

DerivationPath returns the BIP44 fields as an array.

func (BIP44Params) String

func (p BIP44Params) String() string

type DeriveFn

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

type GenerateFn

type GenerateFn func(bz []byte) types.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) tmcrypto.PrivKey
}

Jump to

Keyboard shortcuts

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