storage

package
v1.6.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: MIT, Apache-2.0, MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLocked          = errors.New("wallet locked")
	ErrPasswordEmpty   = errors.New("password not set")
	ErrInvalidPassword = errors.New("password mismatch")
	ErrPasswordExist   = errors.New("the password already exists")
	ErrAlreadyUnlocked = errors.New("wallet already unlocked")
	ErrAlreadyLocked   = errors.New("wallet already locked")
)
View Source
var (
	ErrKeyInfoNotFound = fmt.Errorf("key info not found")
	ErrKeyExists       = fmt.Errorf("key already exists")
)
View Source
var EmptyPassword []byte

Functions

This section is empty.

Types

type DecryptFunc

type DecryptFunc func(keyJson []byte, keyType types.KeyType) (crypto.PrivateKey, error)

type IWalletLock

type IWalletLock = api.IWalletLock

type KeyMiddleware

type KeyMiddleware interface {
	// Encrypt aes encrypt key
	Encrypt(password []byte, key crypto.PrivateKey) (*aes.EncryptedKey, error)
	// Decrypt decrypt aes key
	Decrypt(password []byte, key *aes.EncryptedKey) (crypto.PrivateKey, error)
	// Next Check the password has been set and the wallet is locked
	Next() error
	// EqualRootToken compare the root token
	EqualRootToken(token string) error
	// CheckToken check if the `strategy` token has all permissions
	CheckToken(ctx context.Context) error
	IWalletLock
}

KeyMiddleware the middleware bridging strategy and wallet

func NewKeyMiddleware

func NewKeyMiddleware(cnf *config.CryptoFactor) KeyMiddleware

type KeyMixLayer

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

func (*KeyMixLayer) CheckToken

func (o *KeyMixLayer) CheckToken(ctx context.Context) error

func (*KeyMixLayer) Decrypt

func (o *KeyMixLayer) Decrypt(password []byte, key *aes.EncryptedKey) (crypto.PrivateKey, error)

func (*KeyMixLayer) Encrypt

func (o *KeyMixLayer) Encrypt(password []byte, key crypto.PrivateKey) (*aes.EncryptedKey, error)

func (*KeyMixLayer) EqualRootToken

func (o *KeyMixLayer) EqualRootToken(token string) error

func (*KeyMixLayer) Lock

func (o *KeyMixLayer) Lock(ctx context.Context, password string) error

func (*KeyMixLayer) LockState

func (o *KeyMixLayer) LockState(ctx context.Context) bool

func (*KeyMixLayer) Next

func (o *KeyMixLayer) Next() error

Next Check the password has been set and the wallet is locked

func (*KeyMixLayer) SetPassword

func (o *KeyMixLayer) SetPassword(ctx context.Context, password string) error

func (*KeyMixLayer) Unlock

func (o *KeyMixLayer) Unlock(ctx context.Context, password string) error

func (*KeyMixLayer) VerifyPassword added in v1.2.1

func (o *KeyMixLayer) VerifyPassword(_ context.Context, password string) error

type KeyStore

type KeyStore interface {
	// Put saves a key info
	Put(key *aes.EncryptedKey) error
	// Get gets a key out of keystore and returns PrivateKey corresponding to key address
	Get(addr core.Address) (*aes.EncryptedKey, error)
	// Has check the PrivateKey exist in the KeyStore
	Has(addr core.Address) (bool, error)
	// List lists all the keys stored in the KeyStore
	List() ([]core.Address, error)
	// Delete removes a key from keystore
	Delete(addr core.Address) error
}

Constraint database implementation has: sqlite

type StrategyStore

type StrategyStore interface {
	//PutMsgTypeTemplate saves a msgType template
	PutMsgTypeTemplate(mtt *types.MsgTypeTemplate) error
	// GetMsgTypeTemplate gets a msgType template by Id
	GetMsgTypeTemplate(mttId uint) (*types.MsgTypeTemplate, error)
	// GetMsgTypeTemplateByName gets a mesType template by name
	GetMsgTypeTemplateByName(name string) (*types.MsgTypeTemplate, error)
	// ListMsgTypeTemplates gets a list of msgType templates sort by Id
	ListMsgTypeTemplates(fromIndex, toIndex int) ([]*types.MsgTypeTemplate, error)
	// DeleteMsgTypeTemplate  removes a msgType template from strategy store
	DeleteMsgTypeTemplate(mttId uint) error

	// PutMethodTemplate saves a method template
	PutMethodTemplate(mt *types.MethodTemplate) error
	// GetMethodTemplate gets a method template by Id
	GetMethodTemplate(mtId uint) (*types.MethodTemplate, error)
	// GetMethodTemplateByName gets a method template by name
	GetMethodTemplateByName(name string) (*types.MethodTemplate, error)
	// ListMethodTemplates gets a list of method templates sort by Id
	ListMethodTemplates(fromIndex, toIndex int) ([]*types.MethodTemplate, error)
	// DeleteMethodTemplate  removes a method template from strategy store
	DeleteMethodTemplate(mtId uint) error

	// UpdateKeyBindMetaTypes update the elements of MetaTypes and Methods
	UpdateKeyBindMetaTypes(kb *types.KeyBind) error
	// PutKeyBind saves a keyBind
	PutKeyBind(kb *types.KeyBind) error
	// GetKeyBinds gets a list of keyBinds which wallet is address
	GetKeyBinds(address string) ([]*types.KeyBind, error)
	// GetKeyBindByName gets a keyBind by name
	GetKeyBindByName(name string) (*types.KeyBind, error)
	// GetKeyBindByNames gets a list of keyBinds that contain names
	GetKeyBindByNames(names []string) ([]*types.KeyBind, error)
	// GetKeyBindById gets a keyBind by Id
	GetKeyBindById(kbId uint) (*types.KeyBind, error)
	// ListKeyBinds gets a list of keyBinds sort by Id
	ListKeyBinds(fromIndex, toIndex int) ([]*types.KeyBind, error)
	// DeleteKeyBind removes a keyBinds from strategy store
	DeleteKeyBind(kbId uint) error
	// DeleteKeyBindsByAddress  removes a keyBind from strategy store
	DeleteKeyBindsByAddress(address string) (int64, error)

	// PutGroup saves a group
	PutGroup(name string, keyBindIDs []uint) error
	// GetGroupByName gets a group by name
	GetGroupByName(name string) (*types.Group, error)
	// GetGroup gets a group by Id
	GetGroup(gId uint) (*types.Group, error)
	// ListGroups gets a list of groups sort by Id
	ListGroups(fromIndex, toIndex int) ([]*types.Group, error)
	// DeleteGroup  removes a group from strategy store
	DeleteGroup(gId uint) error

	// PutGroup saves a strategy token
	PutGroupAuth(token string, groupId uint) error
	// GetTokensByGroupId gets a strategy token by groupId
	GetTokensByGroupId(groupId uint) ([]string, error)
	// GetGroupAuth gets a group by strategy token
	GetGroupAuth(token string) (*types.GroupAuth, error)
	// GetGroupKeyBind gets an element of keyBinds in group by token and wallet address
	GetGroupKeyBind(token string, address string) (*types.KeyBind, error)
	// DeleteGroupAuth  removes a group auth token from strategy store
	DeleteGroupAuth(token string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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