crypto

package
v0.0.0-...-581f9f3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BIP44Prefix = "44'/118'/"
	PartialPath = "0'/0/0"
	FullPath    = BIP44Prefix + PartialPath
)

Variables

This section is empty.

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 CipherParams

type CipherParams struct {
	IV string `json:"iv"`
}

type Crypto

type Crypto struct {
	CipherText   string       `json:"ciphertext"`
	CipherParams CipherParams `json:"cipherparams"`
	Cipher       string       `json:"cipher"`
	Kdf          string       `json:"kdf"`
	KdfParams    KdfParams    `json:"kdfparams"`
	Mac          string       `json:"mac"`
}

type KdfParams

type KdfParams struct {
	DkLen int    `json:"dklen"`
	Salt  string `json:"salt"`
	C     int    `json:"c"`
	Prf   string `json:"prf"`
}

type KeyManager

type KeyManager interface {
	Sign(data []byte) ([]byte, error)
	GetPrivKey() crypto.PrivKey
	ExportAsMnemonic() (string, error)
	ExportAsPrivateKey() (string, error)
	ExportAsKeystore(password string) (Keystore, error)
}

func NewKeyManager

func NewKeyManager() (KeyManager, error)

func NewKeyStoreKeyManager

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

func NewMnemonicKeyManager

func NewMnemonicKeyManager(mnemonic string) (KeyManager, error)

func NewPrivateKeyManager

func NewPrivateKeyManager(priKey string) (KeyManager, error)

type Keystore

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

Jump to

Keyboard shortcuts

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