Documentation
¶
Index ¶
- Variables
- type DecryptFunc
- type Group
- type GroupAuth
- type IWalletLock
- type KeyBind
- type KeyMiddleware
- type KeyMixLayer
- func (o *KeyMixLayer) CheckToken(ctx context.Context) error
- func (o *KeyMixLayer) Decrypt(key *aes.EncryptedKey) (crypto.PrivateKey, error)
- func (o *KeyMixLayer) Encrypt(key crypto.PrivateKey) (*aes.EncryptedKey, error)
- func (o *KeyMixLayer) EqualRootToken(token string) error
- func (o *KeyMixLayer) Lock(ctx context.Context, password string) error
- func (o *KeyMixLayer) LockState(ctx context.Context) bool
- func (o *KeyMixLayer) Next() error
- func (o *KeyMixLayer) SetPassword(ctx context.Context, password string) error
- func (o *KeyMixLayer) Unlock(ctx context.Context, password string) error
- type KeyStore
- type KeyStrategy
- type MethodTemplate
- type MsgTypeTemplate
- type StrategyStore
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 Group ¶
type Group struct { GroupId uint Name string // NOTE: not fill data when query groups KeyBinds []*KeyBind }
Group multi KeyBind
type IWalletLock ¶
type IWalletLock interface { // SetPassword do it first after program setup SetPassword(ctx context.Context, password string) error // unlock the wallet and enable IWallet logic Unlock(ctx context.Context, password string) error // lock the wallet and disable IWallet logic Lock(ctx context.Context, password string) error // show lock state 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 ¶
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 }
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(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) Next ¶
func (o *KeyMixLayer) Next() error
func (*KeyMixLayer) SetPassword ¶
func (o *KeyMixLayer) SetPassword(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 // wallet address MetaTypes core.MsgEnum // sum MsgEnum Methods []core.MethodName // msg method array }
KeyStrategy a uint of wallet strategy
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 ¶
MsgTypeTemplate to quickly create a private key usage strategy
type StrategyStore ¶
type StrategyStore interface { //PutMsgTypeTemplate saves a msgType template PutMsgTypeTemplate(mtt *MsgTypeTemplate) error // GetMsgTypeTemplate gets a msgType template by Id GetMsgTypeTemplate(mttId uint) (*MsgTypeTemplate, error) // GetMsgTypeTemplateByName gets a mesType template by name GetMsgTypeTemplateByName(name string) (*MsgTypeTemplate, error) // ListMsgTypeTemplates gets a list of msgType templates sort by Id ListMsgTypeTemplates(fromIndex, toIndex int) ([]*MsgTypeTemplate, error) // DeleteMsgTypeTemplate removes a msgType template from strategy store DeleteMsgTypeTemplate(mttId uint) error // PutMethodTemplate saves a method template PutMethodTemplate(mt *MethodTemplate) error // GetMethodTemplate gets a method template by Id GetMethodTemplate(mtId uint) (*MethodTemplate, error) // GetMethodTemplateByName gets a method template by name GetMethodTemplateByName(name string) (*MethodTemplate, error) // ListMethodTemplates gets a list of method templates sort by Id ListMethodTemplates(fromIndex, toIndex int) ([]*MethodTemplate, error) // DeleteMethodTemplate removes a method template from strategy store DeleteMethodTemplate(mtId uint) error // UpdateKeyBindMetaTypes update the elements of MetaTypes and Methods UpdateKeyBindMetaTypes(kb *KeyBind) error // PutKeyBind saves a keyBind PutKeyBind(kb *KeyBind) error // GetKeyBinds gets a list of keyBinds which wallet is address GetKeyBinds(address string) ([]*KeyBind, error) // GetKeyBindByName gets a keyBind by name GetKeyBindByName(name string) (*KeyBind, error) // GetKeyBindByNames gets a list of keyBinds that contain names GetKeyBindByNames(names []string) ([]*KeyBind, error) // GetKeyBindById gets a keyBind by Id GetKeyBindById(kbId uint) (*KeyBind, error) // ListKeyBinds gets a list of keyBinds sort by Id ListKeyBinds(fromIndex, toIndex int) ([]*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) (*Group, error) // GetGroup gets a group by Id GetGroup(gId uint) (*Group, error) // ListGroups gets a list of groups sort by Id ListGroups(fromIndex, toIndex int) ([]*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) (*GroupAuth, error) // GetGroupKeyBind gets an element of keyBinds in group by token and wallet address GetGroupKeyBind(token string, address string) (*KeyBind, error) // DeleteGroupAuth removes a group auth token from strategy store DeleteGroupAuth(token string) error }
Click to show internal directories.
Click to hide internal directories.