key

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Bip32PubkeyVersionMainnet string = "0488b21e"
	Bip49PubkeyVersionMainnet string = "049d7cb2"
	Bip84PubkeyVersionMainnet string = "04b24746"
	Bip32PubkeyVersionTestnet string = "043587cf"
	Bip49PubkeyVersionTestnet string = "044a5262"
	Bip84PubkeyVersionTestnet string = "045f1cf6"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bip32Item added in v0.4.0

type Bip32Item func() string

func Bip32ByNum added in v0.4.0

func Bip32ByNum(value int) Bip32Item

Bip32ByNum returns Bip32Item function.

func Bip32ByString added in v0.4.0

func Bip32ByString(value string) Bip32Item

Bip32ByString returns Bip32Item function.

func Bip32Root added in v0.4.0

func Bip32Root() Bip32Item

Bip32Root returns Bip32Item function.

func HardenedBip32ByNum added in v0.4.0

func HardenedBip32ByNum(value int) Bip32Item

HardenedBip32ByNum returns Bip32Item function.

type ExtPrivkeyApi

type ExtPrivkeyApi interface {
	GetPubkey(extPrivkey *types.ExtPrivkey) (pubkey *types.Pubkey, err error)
	GetPrivkey(extPrivkey *types.ExtPrivkey) (privkey *types.Privkey, err error)
	GetExtPubkey(extPrivkey *types.ExtPrivkey) (pubkey *types.ExtPubkey, err error)
	GetExtPrivkeyByPath(extPrivkey *types.ExtPrivkey, bip32Path string) (derivedPrivkey *types.ExtPrivkey, err error)
	GetData(extPrivkey *types.ExtPrivkey) (data *types.ExtkeyData, err error)
}

type ExtPrivkeyApiImpl

type ExtPrivkeyApiImpl struct {
	cfdErrors.HasInitializeError
	// contains filtered or unexported fields
}

func NewExtPrivkeyApi

func NewExtPrivkeyApi(options ...config.CfdConfigOption) *ExtPrivkeyApiImpl

func (*ExtPrivkeyApiImpl) GetData

func (k *ExtPrivkeyApiImpl) GetData(extPrivkey *types.ExtPrivkey) (data *types.ExtkeyData, err error)

GetData ...

func (*ExtPrivkeyApiImpl) GetExtPrivkeyByPath

func (k *ExtPrivkeyApiImpl) GetExtPrivkeyByPath(extPrivkey *types.ExtPrivkey, bip32Path string) (derivedPrivkey *types.ExtPrivkey, err error)

func (*ExtPrivkeyApiImpl) GetExtPubkey

func (k *ExtPrivkeyApiImpl) GetExtPubkey(extPrivkey *types.ExtPrivkey) (pubkey *types.ExtPubkey, err error)

GetExtPubkey

func (*ExtPrivkeyApiImpl) GetPrivkey

func (k *ExtPrivkeyApiImpl) GetPrivkey(extPrivkey *types.ExtPrivkey) (privkey *types.Privkey, err error)

GetPrivkey

func (*ExtPrivkeyApiImpl) GetPubkey

func (k *ExtPrivkeyApiImpl) GetPubkey(extPrivkey *types.ExtPrivkey) (pubkey *types.Pubkey, err error)

GetPubkey ...

func (*ExtPrivkeyApiImpl) Valid added in v0.3.7

func (k *ExtPrivkeyApiImpl) Valid(extPrivkey *types.ExtPrivkey) error

Valid ...

type ExtPubkeyApi

type ExtPubkeyApi interface {
	GetPubkey(extPubkey *types.ExtPubkey) (pubkey *types.Pubkey, err error)
	// GetExtPubkeyByPath ...
	GetExtPubkeyByPath(extPubkey *types.ExtPubkey, bip32Path string) (derivedPubkey *types.ExtPubkey, err error)
	GetData(extPubkey *types.ExtPubkey) (data *types.ExtkeyData, err error)
	// ConvertToBip32 ...
	ConvertToBip32(extPubkey *types.ExtPubkey) (bip32ExtPubkey *types.ExtPubkey, err error)
}

type ExtPubkeyApiImpl

type ExtPubkeyApiImpl struct {
	cfdErrors.HasInitializeError
	// contains filtered or unexported fields
}

func NewExtPubkeyApi

func NewExtPubkeyApi(options ...config.CfdConfigOption) *ExtPubkeyApiImpl

func (*ExtPubkeyApiImpl) ConvertToBip32 added in v0.3.17

func (k *ExtPubkeyApiImpl) ConvertToBip32(extPubkey *types.ExtPubkey) (bip32ExtPubkey *types.ExtPubkey, err error)

ConvertToBip32 ...

func (*ExtPubkeyApiImpl) GetData

func (k *ExtPubkeyApiImpl) GetData(extPubkey *types.ExtPubkey) (data *types.ExtkeyData, err error)

GetData ...

func (*ExtPubkeyApiImpl) GetExtPubkeyByPath added in v0.3.7

func (k *ExtPubkeyApiImpl) GetExtPubkeyByPath(extPubkey *types.ExtPubkey, bip32Path string) (derivedPubkey *types.ExtPubkey, err error)

GetExtPubkeyByPath ...

func (*ExtPubkeyApiImpl) GetPubkey

func (k *ExtPubkeyApiImpl) GetPubkey(extPubkey *types.ExtPubkey) (pubkey *types.Pubkey, err error)

GetPubkey ...

func (*ExtPubkeyApiImpl) Valid added in v0.3.7

func (k *ExtPubkeyApiImpl) Valid(extPubkey *types.ExtPubkey) error

Valid ...

type HdWalletApi

type HdWalletApi interface {
	GetExtPrivkey(seed *types.ByteData) (privkey *types.ExtPrivkey, err error)
	GetExtPrivkeyByPath(seed *types.ByteData, bip32Path string) (derivedPrivkey *types.ExtPrivkey, err error)
	GetExtPubkeyByPath(seed *types.ByteData, bip32Path string) (derivedPubkey *types.ExtPubkey, err error)
	GetExtPrivkeyWithFormat(seed *types.ByteData, formatType types.ExtkeyFormatType) (privkey *types.ExtPrivkey, err error)
	GetExtPrivkeyByPathWithFormat(seed *types.ByteData, bip32Path string, formatType types.ExtkeyFormatType) (derivedPrivkey *types.ExtPrivkey, err error)
	GetExtPubkeyByPathWithFormat(seed *types.ByteData, bip32Path string, formatType types.ExtkeyFormatType) (derivedPubkey *types.ExtPubkey, err error)
	GetSeedFromMnemonicEng(mnemonic []string) (seed *types.ByteData, entropy *types.ByteData, err error)
	GetSeedFromMnemonicEngAndPassphrase(mnemonic []string, passphrase string) (seed *types.ByteData, entropy *types.ByteData, err error)
	GetMnemonicFromEntropyEng(entropy *types.ByteData) (mnemonic *[]string, err error)
	GetSeedFromMnemonic(mnemonic []string, language string) (seed *types.ByteData, entropy *types.ByteData, err error)
	GetSeedFromMnemonicAndPassphrase(mnemonic []string, language string, passphrase string) (seed *types.ByteData, entropy *types.ByteData, err error)
	GetMnemonicFromEntropy(entropy *types.ByteData, language string) (mnemonic *[]string, err error)
	CreateBip32Path(items ...Bip32Item) (path string, err error)
}

type HdWalletApiImpl

type HdWalletApiImpl struct {
	cfdErrors.HasInitializeError
	// contains filtered or unexported fields
}

func NewHdWalletApi added in v0.3.7

func NewHdWalletApi(options ...config.CfdConfigOption) *HdWalletApiImpl

func (*HdWalletApiImpl) CreateBip32Path added in v0.4.0

func (h *HdWalletApiImpl) CreateBip32Path(items ...Bip32Item) (path string, err error)

func (*HdWalletApiImpl) GetExtPrivkey added in v0.3.7

func (h *HdWalletApiImpl) GetExtPrivkey(seed *types.ByteData) (privkey *types.ExtPrivkey, err error)

------------------------------------- implement HdWalletApiImpl -------------------------------------

func (*HdWalletApiImpl) GetExtPrivkeyByPath added in v0.3.7

func (h *HdWalletApiImpl) GetExtPrivkeyByPath(seed *types.ByteData, bip32Path string) (derivedPrivkey *types.ExtPrivkey, err error)

func (*HdWalletApiImpl) GetExtPrivkeyByPathWithFormat added in v0.4.0

func (h *HdWalletApiImpl) GetExtPrivkeyByPathWithFormat(seed *types.ByteData, bip32Path string, formatType types.ExtkeyFormatType) (derivedPrivkey *types.ExtPrivkey, err error)

func (*HdWalletApiImpl) GetExtPrivkeyWithFormat added in v0.4.0

func (h *HdWalletApiImpl) GetExtPrivkeyWithFormat(seed *types.ByteData, formatType types.ExtkeyFormatType) (privkey *types.ExtPrivkey, err error)

func (*HdWalletApiImpl) GetExtPubkeyByPath added in v0.3.7

func (h *HdWalletApiImpl) GetExtPubkeyByPath(seed *types.ByteData, bip32Path string) (derivedPubkey *types.ExtPubkey, err error)

func (*HdWalletApiImpl) GetExtPubkeyByPathWithFormat added in v0.4.0

func (h *HdWalletApiImpl) GetExtPubkeyByPathWithFormat(seed *types.ByteData, bip32Path string, formatType types.ExtkeyFormatType) (derivedPubkey *types.ExtPubkey, err error)

func (*HdWalletApiImpl) GetMnemonicFromEntropy added in v0.3.7

func (h *HdWalletApiImpl) GetMnemonicFromEntropy(entropy *types.ByteData, language string) (mnemonic *[]string, err error)

func (*HdWalletApiImpl) GetMnemonicFromEntropyEng added in v0.3.7

func (h *HdWalletApiImpl) GetMnemonicFromEntropyEng(entropy *types.ByteData) (mnemonic *[]string, err error)

func (*HdWalletApiImpl) GetSeedFromMnemonic added in v0.3.7

func (h *HdWalletApiImpl) GetSeedFromMnemonic(mnemonic []string, language string) (seed *types.ByteData, entropy *types.ByteData, err error)

func (*HdWalletApiImpl) GetSeedFromMnemonicAndPassphrase added in v0.3.7

func (h *HdWalletApiImpl) GetSeedFromMnemonicAndPassphrase(mnemonic []string, language string, passphrase string) (seed *types.ByteData, entropy *types.ByteData, err error)

func (*HdWalletApiImpl) GetSeedFromMnemonicEng added in v0.3.7

func (h *HdWalletApiImpl) GetSeedFromMnemonicEng(mnemonic []string) (seed *types.ByteData, entropy *types.ByteData, err error)

func (*HdWalletApiImpl) GetSeedFromMnemonicEngAndPassphrase added in v0.3.7

func (h *HdWalletApiImpl) GetSeedFromMnemonicEngAndPassphrase(mnemonic []string, passphrase string) (seed *types.ByteData, entropy *types.ByteData, err error)

type PrivkeyApi

type PrivkeyApi interface {
	HasWif(wif string) bool
	GetWifFromHex(privkeyHex string) (privkey *types.Privkey, err error)
	GetWifFromHexWithCompressedPubkey(privkeyHex string, compressedPubkey bool) (privkey *types.Privkey, err error)
	GetPrivkeyFromWif(wif string) (privkey *types.Privkey, err error)
	GetPubkey(privkey *types.Privkey) (pubkey *types.Pubkey, err error)
	CreateEcSignature(privkey *types.Privkey, sighash *types.ByteData, sighashType *types.SigHashType) (signature *types.ByteData, err error)
	CreateEcSignatureGrindR(privkey *types.Privkey, sighash *types.ByteData, sighashType *types.SigHashType, grindR bool) (signature *types.ByteData, err error)
	SignMessage(privkey *types.Privkey, message, magic string, isOutputBase64 bool) (signature string, err error)
}

PrivkeyApi This interface has privkey operation API.

type PrivkeyApiImpl

type PrivkeyApiImpl struct {
	cfdErrors.HasInitializeError
	// contains filtered or unexported fields
}

func NewPrivkeyApi

func NewPrivkeyApi(options ...config.CfdConfigOption) *PrivkeyApiImpl

func (*PrivkeyApiImpl) CreateEcSignature

func (k *PrivkeyApiImpl) CreateEcSignature(privkey *types.Privkey, sighash *types.ByteData, sighashType *types.SigHashType) (signature *types.ByteData, err error)

CreateEcSignature ...

func (*PrivkeyApiImpl) CreateEcSignatureGrindR added in v0.3.11

func (k *PrivkeyApiImpl) CreateEcSignatureGrindR(privkey *types.Privkey, sighash *types.ByteData, sighashType *types.SigHashType, grindR bool) (signature *types.ByteData, err error)

CreateEcSignatureGrindR ...

func (*PrivkeyApiImpl) GetPrivkeyFromWif

func (k *PrivkeyApiImpl) GetPrivkeyFromWif(wif string) (privkey *types.Privkey, err error)

GetPrivkeyFromWif ...

func (*PrivkeyApiImpl) GetPubkey

func (k *PrivkeyApiImpl) GetPubkey(privkey *types.Privkey) (pubkey *types.Pubkey, err error)

GetPubkey ...

func (*PrivkeyApiImpl) GetWifFromHex added in v0.3.15

func (k *PrivkeyApiImpl) GetWifFromHex(privkeyHex string) (privkey *types.Privkey, err error)

GetWifFromHex ...

func (*PrivkeyApiImpl) GetWifFromHexWithCompressedPubkey added in v0.3.15

func (k *PrivkeyApiImpl) GetWifFromHexWithCompressedPubkey(privkeyHex string, compressedPubkey bool) (privkey *types.Privkey, err error)

GetWifFromHexWithCompressedPubkey ...

func (*PrivkeyApiImpl) HasWif added in v0.3.14

func (k *PrivkeyApiImpl) HasWif(wif string) bool

HasWif ...

func (*PrivkeyApiImpl) SignMessage added in v0.4.0

func (k *PrivkeyApiImpl) SignMessage(privkey *types.Privkey, message, magic string, isOutputBase64 bool) (signature string, err error)

SignMessage ...

type PubkeyApi

type PubkeyApi interface {
	// Verify ...
	Verify(pubkey *types.Pubkey) error
	// IsCompressed ...
	IsCompressed(pubkey *types.Pubkey) error
	// VerifyEcSignature ...
	VerifyEcSignature(pubkey *types.Pubkey, sighash, signature string) (isVerify bool, err error)
	// VerifyMessage ...
	VerifyMessage(pubkey *types.Pubkey, signature, message, magic string) (recoveredPubkey *types.Pubkey, isVerify bool, err error)
}

PubkeyApi This interface has pubkey operation API.

type PubkeyApiImpl

type PubkeyApiImpl struct {
}

func NewPubkeyApi

func NewPubkeyApi() *PubkeyApiImpl

func (*PubkeyApiImpl) IsCompressed added in v0.3.14

func (p *PubkeyApiImpl) IsCompressed(pubkey *types.Pubkey) error

IsCompressed ...

func (*PubkeyApiImpl) Verify added in v0.3.14

func (p *PubkeyApiImpl) Verify(pubkey *types.Pubkey) error

Verify ...

func (*PubkeyApiImpl) VerifyEcSignature

func (p *PubkeyApiImpl) VerifyEcSignature(pubkey *types.Pubkey, sighash, signature string) (isVerify bool, err error)

VerifyEcSignature ...

func (*PubkeyApiImpl) VerifyMessage added in v0.4.0

func (p *PubkeyApiImpl) VerifyMessage(pubkey *types.Pubkey, signature, message, magic string) (recoveredPubkey *types.Pubkey, isVerify bool, err error)

VerifyMessage ...

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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