keys

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BIPPurpose  = 44
	BIPCoinType = 714
	BIPChange   = false
	BIP44Prefix = "44'/714'/"
	PartialPath = "0'/0/0"
	FullPath    = BIP44Prefix + PartialPath
)

Variables

View Source
var (
	ErrDecrypt = errors.New("could not decrypt key with given passphrase")
)

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 {
	// contains filtered or unexported fields
}

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

func NewBinanceBIP44Params

func NewBinanceBIP44Params(account uint32, addressIdx uint32) *BIP44Params

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

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' / coin_type' / account' / change / address_index

func (BIP44Params) DerivationPath

func (p BIP44Params) DerivationPath() []uint32

Return the BIP44 fields as an array.

func (BIP44Params) String

func (p BIP44Params) String() string

type CryptoJSON

type CryptoJSON struct {
	Cipher       string                 `json:"cipher"`
	CipherText   string                 `json:"ciphertext"`
	CipherParams cipherparamsJSON       `json:"cipherparams"`
	KDF          string                 `json:"kdf"`
	KDFParams    map[string]interface{} `json:"kdfparams"`
	MAC          string                 `json:"mac"`
}

type EncryptedKeyJSON

type EncryptedKeyJSON struct {
	Address string     `json:"address"`
	Crypto  CryptoJSON `json:"crypto"`
	Id      string     `json:"id"`
	Version int        `json:"version"`
}

type KeyManager

type KeyManager interface {
	Sign(txtype.StdSignMsg) ([]byte, error)
	GetPrivKey() crypto.PrivKey
	GetAddr() ctypes.AccAddress

	ExportAsMnemonic() (string, error)
	ExportAsPrivateKey() (string, error)
	ExportAsKeyStore(password string) (*EncryptedKeyJSON, error)
}

func NewKeyManager

func NewKeyManager() (KeyManager, error)

func NewKeyStoreKeyManager

func NewKeyStoreKeyManager(file string, auth string) (KeyManager, error)

func NewMnemonicKeyManager

func NewMnemonicKeyManager(mnemonic string) (KeyManager, error)

func NewMnemonicPathKeyManager

func NewMnemonicPathKeyManager(mnemonic, keyPath string) (KeyManager, error)

The full path is "purpose' / coin_type' / account' / change / address_index". "purpose' / coin_type'" is fixed as "44'/714'/", user can customize the rest part.

func NewPrivateKeyManager

func NewPrivateKeyManager(priKey string) (KeyManager, error)

type PlainKeyJSON

type PlainKeyJSON struct {
	Address    string `json:"address"`
	PrivateKey string `json:"privatekey"`
	Id         string `json:"id"`
	Version    int    `json:"version"`
}

Jump to

Keyboard shortcuts

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