keystore

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2021 License: LGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// StandardScryptN is the N parameter of Scrypt encryption algorithm, using 256MB
	// memory and taking approximately 1s CPU time on a modern processor.
	StandardScryptN = 1 << 18

	// StandardScryptP is the P parameter of Scrypt encryption algorithm, using 256MB
	// memory and taking approximately 1s CPU time on a modern processor.
	StandardScryptP = 1

	// LightScryptN is the N parameter of Scrypt encryption algorithm, using 4MB
	// memory and taking approximately 100ms CPU time on a modern processor.
	LightScryptN = 1 << 12

	// LightScryptP is the P parameter of Scrypt encryption algorithm, using 4MB
	// memory and taking approximately 100ms CPU time on a modern processor.
	LightScryptP = 6
)

Variables

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

Functions

func EncryptKey

func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error)

EncryptKey encrypts a key using the specified scrypt parameters into a json blob that can be decrypted later on.

func ZeroKey

func ZeroKey(k *ecdsa.PrivateKey)

ZeroKey zeroes a private key in memory.

Types

type Key

type Key struct {
	Id      uuid.UUID // Version 4 "random" for unique id not derived from key data
	Address common.Address
	// we only store privkey as pubkey/address can be derived from it
	// privkey in this struct is always in plaintext
	PrivateKey *ecdsa.PrivateKey
	// for validator, also store the bls key in case of enable bls signature
	BlsKey []byte
}

func DecryptKey

func DecryptKey(keyjson []byte, auth string) (*Key, error)

DecryptKey decrypts a key from a json blob, returning the private key itself.

func (*Key) Clone

func (k *Key) Clone() *Key

func (*Key) IsValKey

func (k *Key) IsValKey() bool

type PassphraseKeyStore

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

func NewPassphraseKeyStore

func NewPassphraseKeyStore(keydir string, scryptN, scryptP int) (*PassphraseKeyStore, error)

func (*PassphraseKeyStore) GetKey

func (ks *PassphraseKeyStore) GetKey(addr common.Address, filename string, passphrase string) (*Key, error)

func (*PassphraseKeyStore) GetPath

func (ks *PassphraseKeyStore) GetPath(addr common.Address) string

func (*PassphraseKeyStore) ImportKey

func (ks *PassphraseKeyStore) ImportKey(key *Key, passphrase string) (string, error)

func (*PassphraseKeyStore) JoinPath

func (ks *PassphraseKeyStore) JoinPath(filename string) string

func (*PassphraseKeyStore) ScryptN

func (p *PassphraseKeyStore) ScryptN() int

func (*PassphraseKeyStore) ScryptP

func (p *PassphraseKeyStore) ScryptP() int

func (*PassphraseKeyStore) StoreKey

func (ks *PassphraseKeyStore) StoreKey(filename string, key *Key, passphrase string) error

type PlainKeyJSON

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

type PlaintextKeyStore

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

func NewPlaintextKeyStore

func NewPlaintextKeyStore(keydir string, scryptN, scryptP int) (*PlaintextKeyStore, error)

func (*PlaintextKeyStore) GetKey

func (ks *PlaintextKeyStore) GetKey(addr common.Address, filename string, passphrase string) (*Key, error)

func (*PlaintextKeyStore) GetPath

func (ks *PlaintextKeyStore) GetPath(addr common.Address) string

func (*PlaintextKeyStore) ImportKey

func (ks *PlaintextKeyStore) ImportKey(key *Key, passphrase string) (string, error)

func (*PlaintextKeyStore) JoinPath

func (ks *PlaintextKeyStore) JoinPath(filename string) string

func (*PlaintextKeyStore) StoreKey

func (ks *PlaintextKeyStore) StoreKey(filename string, key *Key, passphrase string) error

Jump to

Keyboard shortcuts

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