storage

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MIT, Apache-2.0, MIT Imports: 13 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")
)

Functions

This section is empty.

Types

type DecryptFunc

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

type Group

type Group struct {
	GroupId uint
	Name    string
	// NOTE: not fill data when query groups
	KeyBinds []*KeyBind
}

Group multi KeyBind

type GroupAuth

type GroupAuth struct {
	Token    string
	GroupId  uint
	Name     string
	KeyBinds []*KeyBind
}

GroupAuth relation with Group and generate a token for external invocation

type IWalletLock

type IWalletLock interface {
	SetPassword(ctx context.Context, password string) error
	Unlock(ctx context.Context, password string) error
	Lock(ctx context.Context, password string) error
	LockState(ctx context.Context) bool
}

type KeyBind

type KeyBind struct {
	BindId  uint
	Name    string
	Address string
	// source from MsgTypeTemplate or temporary create
	MetaTypes core.MsgEnum
	// source from MethodTemplate
	Methods []core.MethodName
}

KeyBind bind wallet usage strategy allow designated rule to pass

func (*KeyBind) ContainMethod

func (kb *KeyBind) ContainMethod(m string) bool

func (*KeyBind) ContainMsgType

func (kb *KeyBind) ContainMsgType(mt core.MsgType) bool

type KeyMiddleware

type KeyMiddleware interface {
	Encrypt(key crypto.PrivateKey) (*aes.EncryptedKey, error)
	Decrypt(key *aes.EncryptedKey) (crypto.PrivateKey, error)
	Next() error
	EqualRootToken(token string) error
	CheckToken(ctx context.Context) error
	IWalletLock
}

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(key *aes.EncryptedKey) (crypto.PrivateKey, error)

func (*KeyMixLayer) Encrypt

func (o *KeyMixLayer) Encrypt(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

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

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 KeyStrategy

type KeyStrategy struct {
	Address   core.Address
	MetaTypes core.MsgEnum
	Methods   []core.MethodName
}

type MethodTemplate

type MethodTemplate struct {
	MTId uint
	Name string
	// method name join with ','
	Methods []core.MethodName
}

MethodTemplate to quickly create a private key usage strategy msg actor and methodNum agg to method name NOTE: routeType 4

type MsgTypeTemplate

type MsgTypeTemplate struct {
	MTTId     uint
	Name      string
	MetaTypes core.MsgEnum
}

MsgTypeTemplate to quickly create a private key usage strategy

type StrategyStore

type StrategyStore interface {
	PutMsgTypeTemplate(mtt *MsgTypeTemplate) error
	GetMsgTypeTemplate(mttId uint) (*MsgTypeTemplate, error)
	GetMsgTypeTemplateByName(name string) (*MsgTypeTemplate, error)
	ListMsgTypeTemplates(fromIndex, toIndex int) ([]*MsgTypeTemplate, error)
	DeleteMsgTypeTemplate(mttId uint) error

	PutMethodTemplate(mt *MethodTemplate) error
	GetMethodTemplate(mtId uint) (*MethodTemplate, error)
	GetMethodTemplateByName(name string) (*MethodTemplate, error)
	ListMethodTemplates(fromIndex, toIndex int) ([]*MethodTemplate, error)
	DeleteMethodTemplate(mtId uint) error

	UpdateKeyBindMetaTypes(kb *KeyBind) error
	PutKeyBind(kb *KeyBind) error
	GetKeyBinds(address string) ([]*KeyBind, error)
	GetKeyBindByName(name string) (*KeyBind, error)
	GetKeyBindByNames(names []string) ([]*KeyBind, error)
	GetKeyBindById(kbId uint) (*KeyBind, error)
	ListKeyBinds(fromIndex, toIndex int) ([]*KeyBind, error)
	DeleteKeyBind(kbId uint) error
	DeleteKeyBindsByAddress(address string) (int64, error)

	PutGroup(name string, keyBindIds []uint) error
	GetGroupByName(name string) (*Group, error)
	GetGroup(gId uint) (*Group, error)
	ListGroups(fromIndex, toIndex int) ([]*Group, error)
	DeleteGroup(gId uint) error

	PutGroupAuth(token string, groupId uint) error
	GetTokensByGroupId(groupId uint) ([]string, error)
	GetGroupAuth(token string) (*GroupAuth, error)
	GetGroupKeyBind(token string, address string) (*KeyBind, error)
	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