keystore

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTransfer indicates the error of transfer
	ErrTransfer = errors.New("transfer error")
	// ErrVote indicates the error of vote
	ErrVote = errors.New("vote error")
)
View Source
var (
	// ErrKey indicates the error of key
	ErrKey = errors.New("key error")
	// ErrExist is the error that the key already exists in map
	ErrExist = errors.New("key already exists")
	// ErrNotExist is the error that the key does not exist in map
	ErrNotExist = errors.New("key does not exist")
)
View Source
var (
	// ErrNilAccountManager indicates that account manager is nil
	ErrNilAccountManager = errors.New("account manager is nil")
	// ErrNumAccounts indicates invalid number of accounts in keystore
	ErrNumAccounts = errors.New("number of accounts is invalid")
)

Functions

This section is empty.

Types

type AccountManager

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

AccountManager manages keystore based accounts

func NewMemAccountManager

func NewMemAccountManager() *AccountManager

NewMemAccountManager creates a new account manager based on in-memory keystore

func NewPlainAccountManager

func NewPlainAccountManager(dir string) (*AccountManager, error)

NewPlainAccountManager creates a new account manager based on plain keystore

func (*AccountManager) Contains

func (m *AccountManager) Contains(encodedAddr string) (bool, error)

Contains returns whether keystore contains the given account

func (*AccountManager) Import

func (m *AccountManager) Import(keyBytes []byte) error

Import imports key bytes and stores it as a new account

func (*AccountManager) NewAccount

func (m *AccountManager) NewAccount() (keypair.PrivateKey, error)

NewAccount creates and stores a new account

func (*AccountManager) Remove

func (m *AccountManager) Remove(encodedAddr string) error

Remove removes the given account if exists

func (*AccountManager) SignAction

func (m *AccountManager) SignAction(encodedAddr string, elp action.Envelope) (action.SealedEnvelope, error)

SignAction signs an action envelope.

func (*AccountManager) SignHash

func (m *AccountManager) SignHash(encodedAddr string, hash []byte) ([]byte, error)

SignHash signs a hash

type KeyStore

type KeyStore interface {
	Has(string) (bool, error)
	Get(string) (keypair.PrivateKey, error)
	Store(string, keypair.PrivateKey) error
	Remove(string) error
	All() ([]string, error)
}

KeyStore defines an interface that supports operations on keystore object

func NewMemKeyStore

func NewMemKeyStore() KeyStore

NewMemKeyStore creates a new instance of MemKeyStore

func NewPlainKeyStore

func NewPlainKeyStore(dir string) (KeyStore, error)

NewPlainKeyStore returns a new instance of plain keystore

type SingleAccountManager

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

SingleAccountManager is a special account manager that maintains a single account in keystore

func NewSingleAccountManager

func NewSingleAccountManager(accountManager *AccountManager) (*SingleAccountManager, error)

NewSingleAccountManager creates a new single account manager

func (*SingleAccountManager) SignAction

SignAction signs an action envelope.

func (*SingleAccountManager) SignHash

func (m *SingleAccountManager) SignHash(hash []byte) ([]byte, error)

SignHash signs a hash

Jump to

Keyboard shortcuts

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