keystore

package
v0.0.0-...-84d53aa Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToReadKeystoreFile      = errors.New("failed to read keystore file")
	ErrInvalidKeystoreVersion        = errors.New("cannot parse old version")
	ErrFailedToUnmarshalKeystoreJSON = errors.New("failed unmarshal keystore json")
	ErrWrongPassphrase               = errors.New("wrong passphrase for keystore")
	ErrFailedToDecrypt               = errors.New("failed to decrypt keystore by passphrase")
)
View Source
var (
	// ErrNoMatch address key doesn't match error.
	ErrNoMatch = errors.New("no key for given address")
)

Functions

func DecryptDataV3

func DecryptDataV3(CipherJSON CipherJSON, auth string) ([]byte, error)

DecryptDataV3 decrypts CipherJSON file with auth string

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

func MakeKeystoreV3

func MakeKeystoreV3(privKeyHex, passphrase string, fn string) error

MakeKeystoreV3 makes keystore file by version 3.

Types

type CipherJSON

type CipherJSON 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"`
}

CipherJSON json format for crypto field in keystore file

func EncryptDataV3

func EncryptDataV3(data, auth []byte, scryptN, scryptP int) (CipherJSON, error)

EncryptDataV3 encrypts the data given as 'data' with the password 'auth'.

type EncryptedKeyJSONV3

type EncryptedKeyJSONV3 struct {
	Address string     `json:"address"`
	Crypto  CipherJSON `json:"crypto"`
	ID      string     `json:"id"`
	Version int        `json:"version"`
}

EncryptedKeyJSONV3 is a struct for encrypted key

type Key

type Key struct {
	ID uuid.UUID // Version 4 "random" for unique id not derived from key data
	// to simplify lookups we also store the address
	Address common.Address
	// we only store privkey as pubkey/address can be derived from it
	// privkey in this struct is always in plaintext
	PrivateKey signature.PrivateKey
}

Key key struct for encryption key argument

func DecryptKey

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

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

type KeyStore

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

KeyStore manages private keys.

func NewKeyStore

func NewKeyStore() *KeyStore

NewKeyStore creates a keystore for the given directory.

func (*KeyStore) Accounts

func (ks *KeyStore) Accounts() []common.Address

Accounts returns all key files present in the directory.

func (*KeyStore) Delete

func (ks *KeyStore) Delete(a common.Address) error

Delete deletes key.

func (*KeyStore) GetKey

func (ks *KeyStore) GetKey(a common.Address) (signature.PrivateKey, error)

GetKey gets key.

func (*KeyStore) HasAddress

func (ks *KeyStore) HasAddress(addr common.Address) bool

HasAddress reports whether a key with the given address is present.

func (*KeyStore) SetKey

func (ks *KeyStore) SetKey(key signature.PrivateKey) (common.Address, error)

SetKey set key.

Jump to

Keyboard shortcuts

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