derivation

package
v0.0.0-...-4dd0036 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Zero         uint32 = 0
	ZeroQuote    uint32 = 0x80000000
	PurposeBIP44 uint32 = 0x8000002C // 44' BIP44
	PurposeBIP49 uint32 = 0x80000031 // 49' BIP49
	PurposeBIP84 uint32 = 0x80000054 // 84' BIP84
	Apostrophe   uint32 = 0x80000000
	CoinType     uint32 = 98055361
)
View Source
const PublicKeyCompressedLength = 33

Variables

This section is empty.

Functions

func CreateMnemonic

func CreateMnemonic(bitSize int) (string, error)

func PublicKeyForPrivateKey

func PublicKeyForPrivateKey(key []byte) []byte

PublicKeyForPrivateKey 私钥转公钥

Types

type BipKey

type BipKey struct {
	Bip32Key *bip32.Key
	// contains filtered or unexported fields
}

func (*BipKey) CreateAddr

func (k *BipKey) CreateAddr(AddrPre string) (crypto.AddressCoin, ed25519.PublicKey, ed25519.PrivateKey)

CreateAddr 通过助记词推导出私钥,再通过私钥生成地址

type KeyManager

type KeyManager struct {
	// contains filtered or unexported fields
}

func GeneratePrivate

func GeneratePrivate(Seeds []byte, pwd []byte, Salt []byte, MnemonicLang []string) (*KeyManager, error)

GeneratePrivate 根据原始seed推导私钥 123 1234

func NewKeyManager

func NewKeyManager(mnemonic string, passphrase string) (*KeyManager, error)

func (*KeyManager) GetAccountKey

func (km *KeyManager) GetAccountKey(purpose, coinType, account uint32) (*bip32.Key, error)

GetAccountKey 根据account获取key

func (*KeyManager) GetChangeKey

func (km *KeyManager) GetChangeKey(purpose, coinType, account, change uint32) (*bip32.Key, error)

GetChangeKey 获取指定路径的bip32.key

func (*KeyManager) GetCoinTypeKey

func (km *KeyManager) GetCoinTypeKey(purpose, coinType uint32) (*bip32.Key, error)

GetCoinTypeKey 根据不同币种获取key

func (*KeyManager) GetKey

func (km *KeyManager) GetKey(purpose, coinType, account, change, index uint32) (*BipKey, error)

GetKey KeyManager 兼容一下批量创建的时候

func (*KeyManager) GetMasterKey

func (km *KeyManager) GetMasterKey() (*bip32.Key, error)

GetMasterKey 找根key

func (*KeyManager) GetMnemonic

func (km *KeyManager) GetMnemonic() string

GetMnemonic 构造助记词返回

func (*KeyManager) GetPassphrase

func (km *KeyManager) GetPassphrase() string

GetPassphrase 构造助记词密码返回

func (*KeyManager) GetPurposeKey

func (km *KeyManager) GetPurposeKey(purpose uint32) (*bip32.Key, error)

GetPurposeKey 根据协议获取key

func (*KeyManager) GetSeed

func (km *KeyManager) GetSeed() []byte

GetSeed 获取助记词的seed

Jump to

Keyboard shortcuts

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